@series-inc/rundot-syncplay 6.0.0-rc.30 → 6.0.0-rc.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@ export const physicsProfileWasmMetadata = Object.freeze({
23
23
  "sourceHash": "13bc7e6c473b9a773bbb0f77d1c2126df59a074759ebb5efb90b8dde1ff4d10a",
24
24
  "wasmSha256": "d398c126e4da59324d6e28f14132173a9f980f9fc429f632baffacbae4744fef",
25
25
  "artifact": "profile",
26
- "packageVersion": "6.0.0-rc.30",
26
+ "packageVersion": "6.0.0-rc.31",
27
27
  "compilerFlags": [
28
28
  "-std=c++20",
29
29
  "-O3",
@@ -23,7 +23,7 @@ export const physicsWasmMetadata = Object.freeze({
23
23
  "sourceHash": "4bb02a55da437ff3075d5350d48f319bd8b89a6dd31d9a34d9b0cb3677ed4914",
24
24
  "wasmSha256": "76ea5a82d4e84d0e3bc3fd93dd54992b54c09614f7024e4f8b5bf91445db1955",
25
25
  "artifact": "production",
26
- "packageVersion": "6.0.0-rc.30",
26
+ "packageVersion": "6.0.0-rc.31",
27
27
  "compilerFlags": [
28
28
  "-std=c++20",
29
29
  "-O3",
@@ -50,7 +50,7 @@ export const physics2dWasmMetadata = Object.freeze({
50
50
  "sourceHash": "faa090a03a6fddaf79c704fb1d76f810955ff35597449c8cec9541a75905a37e",
51
51
  "wasmSha256": "49cb90541deed40f5fff1015bb578e13ec9a793d51931c1227e3e5a11bbfa3f7",
52
52
  "artifact": "production",
53
- "packageVersion": "6.0.0-rc.30",
53
+ "packageVersion": "6.0.0-rc.31",
54
54
  "compilerFlags": [
55
55
  "-std=c++20",
56
56
  "-O3",
@@ -46,6 +46,52 @@ function angularSpeedVector(value) {
46
46
  z: radiansPerSecond(value.z === 0 ? 0 : value.z),
47
47
  };
48
48
  }
49
+ function normalizeZero(v) {
50
+ return Object.is(v, -0) ? 0 : v;
51
+ }
52
+ function cleanTurnedVelocityComponent(v) {
53
+ if (Object.is(v, -0))
54
+ return 0;
55
+ if (Math.abs(v) < 1e-12)
56
+ return 0;
57
+ const rounded = Math.round(v * 1e12) / 1e12;
58
+ if (Math.abs(v - rounded) < 1e-14)
59
+ return rounded;
60
+ return v;
61
+ }
62
+ function buildPortalLatestOutputs(poseJumpBodyIds, lastCrossings) {
63
+ const motionBatchBodies = [];
64
+ if (poseJumpBodyIds) {
65
+ for (const rawId of poseJumpBodyIds) {
66
+ const bodyId = typeof rawId === 'bigint' ? rawId : BigInt(rawId);
67
+ motionBatchBodies.push(Object.freeze({ id: bodyId, poseJump: true }));
68
+ }
69
+ }
70
+ const crossings = [];
71
+ if (lastCrossings) {
72
+ for (const c of lastCrossings) {
73
+ const bodyId = typeof c.bodyId === 'bigint' ? c.bodyId : BigInt(c.bodyId);
74
+ crossings.push(Object.freeze({
75
+ bodyId: bodyId,
76
+ portalId: c.portalId,
77
+ enteredEnd: c.enteredEnd,
78
+ exitEnd: c.exitEnd,
79
+ turnedVelocity: Object.freeze({
80
+ x: cleanTurnedVelocityComponent(c.turnedVelocity.x),
81
+ y: cleanTurnedVelocityComponent(c.turnedVelocity.y),
82
+ z: cleanTurnedVelocityComponent(c.turnedVelocity.z),
83
+ }),
84
+ }));
85
+ }
86
+ }
87
+ return {
88
+ portalCrossings: Object.freeze(crossings),
89
+ motionBatch: Object.freeze({
90
+ count: motionBatchBodies.length,
91
+ bodies: Object.freeze(motionBatchBodies),
92
+ }),
93
+ };
94
+ }
49
95
  function brandLatestOutputs3D(data) {
50
96
  const reactions = new Map(data.reactions.map((reaction) => [reaction.jointId, reaction]));
51
97
  const brandReaction = (reaction) => Object.freeze({
@@ -70,6 +116,7 @@ function brandLatestOutputs3D(data) {
70
116
  totalTorque: Object.freeze(torqueVector(interaction.totalTorque)),
71
117
  relativeVelocity: Object.freeze(speedVector(interaction.relativeVelocity)),
72
118
  })));
119
+ const portalOutputs = buildPortalLatestOutputs(data.motionBatch?.bodies?.map((b) => b.id), data.portalCrossings);
73
120
  return Object.freeze({
74
121
  frame: data.frame,
75
122
  contacts: Object.freeze(data.contacts.map((event) => Object.freeze({
@@ -84,8 +131,8 @@ function brandLatestOutputs3D(data) {
84
131
  jointReactions: Object.freeze(data.reactions.map(brandReaction)),
85
132
  breakEvents,
86
133
  fluidInteractions,
87
- portalCrossings: Object.freeze([]),
88
- motionBatch: Object.freeze({ count: 0, bodies: Object.freeze([]) }),
134
+ portalCrossings: portalOutputs.portalCrossings,
135
+ motionBatch: portalOutputs.motionBatch,
89
136
  });
90
137
  }
91
138
  function newtonsVector(value) {
@@ -1647,18 +1694,15 @@ function quatNormalize(q) {
1647
1694
  return { x: q.x * inv, y: q.y * inv, z: q.z * inv, w: q.w * inv };
1648
1695
  }
1649
1696
  // Portal host layer constants declared above
1650
- function normalizeZero(v) {
1651
- return Object.is(v, -0) ? 0 : v;
1652
- }
1653
1697
  function rotateVec3(q, v) {
1654
1698
  const qv = { x: q.x, y: q.y, z: q.z };
1655
1699
  const uv = crossVec3(qv, v);
1656
1700
  const uuv = crossVec3(qv, uv);
1657
1701
  const res = addVec3(v, scaleVec3(addVec3(scaleVec3(uv, q.w), uuv), 2.0));
1658
1702
  return {
1659
- x: res.x === 0 ? 0 : res.x,
1660
- y: res.y === 0 ? 0 : res.y,
1661
- z: res.z === 0 ? 0 : res.z,
1703
+ x: normalizeZero(res.x),
1704
+ y: normalizeZero(res.y),
1705
+ z: normalizeZero(res.z),
1662
1706
  };
1663
1707
  }
1664
1708
  function computeOrientedExtents(shapeKind, values, bodyOri, portalRotNorm) {
@@ -1759,7 +1803,9 @@ function serializeWithPortalTrailer(rawBytes, portalState) {
1759
1803
  (portalState.pairs.length === 0 &&
1760
1804
  portalState.priorBodyPlanes.length === 0 &&
1761
1805
  (!portalState.priorBodyVelocities || portalState.priorBodyVelocities.length === 0) &&
1762
- (!portalState.cutoutSuppressedBodies || portalState.cutoutSuppressedBodies.length === 0))) {
1806
+ (!portalState.cutoutSuppressedBodies || portalState.cutoutSuppressedBodies.length === 0) &&
1807
+ (!portalState.poseJumpBodyIds || portalState.poseJumpBodyIds.length === 0) &&
1808
+ (!portalState.lastCrossings || portalState.lastCrossings.length === 0))) {
1763
1809
  return rawBytes;
1764
1810
  }
1765
1811
  const payloadStr = JSON.stringify(portalState, (_key, val) => typeof val === "bigint" ? val.toString() : val);
@@ -1805,6 +1851,15 @@ function deserializeWithPortalTrailer(bytes) {
1805
1851
  function wrapRuntimeController(rawController, portalManager, portalCheckpoints) {
1806
1852
  const wrapped = {
1807
1853
  ...rawController,
1854
+ checkpointLatest(checkpoint) {
1855
+ const rawOutputs = rawController.checkpointLatest(checkpoint);
1856
+ const saved = checkpoint && typeof checkpoint === 'object' ? portalCheckpoints.get(checkpoint) : null;
1857
+ const portalOutputs = buildPortalLatestOutputs(saved?.poseJumpBodyIds, saved?.lastCrossings);
1858
+ return Object.freeze({
1859
+ ...rawOutputs,
1860
+ ...portalOutputs,
1861
+ });
1862
+ },
1808
1863
  captureCheckpoint() {
1809
1864
  const cp = rawController.captureCheckpoint();
1810
1865
  portalCheckpoints.set(cp, portalManager.captureState());
@@ -2135,7 +2190,7 @@ class PortalSimulatorManager {
2135
2190
  ]),
2136
2191
  poseJumpBodyIds: Array.from(this.poseJumpBodyIds).map((id) => id.toString()),
2137
2192
  lastCrossings: this.lastCrossings.map((c) => ({
2138
- bodyId: c.bodyId,
2193
+ bodyId: c.bodyId.toString(),
2139
2194
  portalId: c.portalId,
2140
2195
  enteredEnd: c.enteredEnd,
2141
2196
  exitEnd: c.exitEnd,
@@ -2222,13 +2277,22 @@ class PortalSimulatorManager {
2222
2277
  this.bodySuppressedLayers.set(BigInt(idStr), ALL_PORTAL_HOST_LAYERS);
2223
2278
  }
2224
2279
  }
2225
- this.lastCrossings = state.lastCrossings.map((c) => ({
2226
- bodyId: BigInt(c.bodyId),
2227
- portalId: c.portalId,
2228
- enteredEnd: c.enteredEnd,
2229
- exitEnd: c.exitEnd,
2230
- turnedVelocity: { ...c.turnedVelocity },
2231
- }));
2280
+ if (state.lastCrossings) {
2281
+ this.lastCrossings = state.lastCrossings.map((c) => Object.freeze({
2282
+ bodyId: BigInt(c.bodyId),
2283
+ portalId: c.portalId,
2284
+ enteredEnd: c.enteredEnd,
2285
+ exitEnd: c.exitEnd,
2286
+ turnedVelocity: Object.freeze({
2287
+ x: normalizeZero(c.turnedVelocity.x),
2288
+ y: normalizeZero(c.turnedVelocity.y),
2289
+ z: normalizeZero(c.turnedVelocity.z),
2290
+ }),
2291
+ }));
2292
+ }
2293
+ else {
2294
+ this.lastCrossings = [];
2295
+ }
2232
2296
  this.originalHostLayers.clear();
2233
2297
  if (state.originalHostLayers) {
2234
2298
  for (const [k, v] of state.originalHostLayers) {
@@ -2685,13 +2749,17 @@ class PortalSimulatorManager {
2685
2749
  this.priorBodyVelocities.delete(trackingKey);
2686
2750
  this.priorBodyPlanes.set(`${pair.id}:${exitLabel}:${bodyId}`, nudgeDist);
2687
2751
  this.priorBodyVelocities.set(`${pair.id}:${exitLabel}:${bodyId}`, turnedVel);
2688
- crossings.push({
2752
+ crossings.push(Object.freeze({
2689
2753
  bodyId,
2690
2754
  portalId: pair.id,
2691
2755
  enteredEnd: entryLabel,
2692
2756
  exitEnd: exitLabel,
2693
- turnedVelocity: turnedVel,
2694
- });
2757
+ turnedVelocity: Object.freeze({
2758
+ x: cleanTurnedVelocityComponent(turnedVel.x),
2759
+ y: cleanTurnedVelocityComponent(turnedVel.y),
2760
+ z: cleanTurnedVelocityComponent(turnedVel.z),
2761
+ }),
2762
+ }));
2695
2763
  }
2696
2764
  }
2697
2765
  }
@@ -2758,13 +2826,17 @@ class PortalSimulatorManager {
2758
2826
  this.priorBodyVelocities.delete(trackingKey);
2759
2827
  this.priorBodyPlanes.set(`${pair.id}:${exitLabel}:${bodyId}`, nudgeDist);
2760
2828
  this.priorBodyVelocities.set(`${pair.id}:${exitLabel}:${bodyId}`, turnedVel);
2761
- crossings.push({
2829
+ crossings.push(Object.freeze({
2762
2830
  bodyId,
2763
2831
  portalId: pair.id,
2764
2832
  enteredEnd: entryLabel,
2765
2833
  exitEnd: exitLabel,
2766
- turnedVelocity: turnedVel,
2767
- });
2834
+ turnedVelocity: Object.freeze({
2835
+ x: cleanTurnedVelocityComponent(turnedVel.x),
2836
+ y: cleanTurnedVelocityComponent(turnedVel.y),
2837
+ z: cleanTurnedVelocityComponent(turnedVel.z),
2838
+ }),
2839
+ }));
2768
2840
  }
2769
2841
  }
2770
2842
  };
@@ -3583,20 +3655,21 @@ function facade(raw, definition) {
3583
3655
  breaks: joints.breaks,
3584
3656
  fluids: (definition.capacity.fluids ?? 0) === 0 ? [] : raw.latestFluidInteractions(),
3585
3657
  });
3586
- const motionBatchBodies = [];
3587
- for (const bodyId of portalManager.poseJumpBodyIds) {
3588
- motionBatchBodies.push(Object.freeze({ id: bodyId, poseJump: true }));
3589
- }
3658
+ const portalOutputs = buildPortalLatestOutputs(portalManager.poseJumpBodyIds, portalManager.lastCrossings);
3590
3659
  return Object.freeze({
3591
3660
  ...baseLatest,
3592
- portalCrossings: Object.freeze([...portalManager.lastCrossings]),
3593
- motionBatch: Object.freeze({
3594
- count: motionBatchBodies.length,
3595
- bodies: Object.freeze(motionBatchBodies),
3596
- }),
3661
+ ...portalOutputs,
3662
+ });
3663
+ }),
3664
+ checkpointLatest: (checkpoint) => invokeWorld("checkpoint-latest", () => {
3665
+ const baseLatest = brandLatestOutputs3D(raw.checkpointLatest(checkpoint));
3666
+ const saved = portalCheckpoints.get(checkpoint);
3667
+ const portalOutputs = buildPortalLatestOutputs(saved?.poseJumpBodyIds, saved?.lastCrossings);
3668
+ return Object.freeze({
3669
+ ...baseLatest,
3670
+ ...portalOutputs,
3597
3671
  });
3598
3672
  }),
3599
- checkpointLatest: (checkpoint) => invokeWorld("checkpoint-latest", () => brandLatestOutputs3D(raw.checkpointLatest(checkpoint))),
3600
3673
  raycast: (query) => invokeWorld("query", () => {
3601
3674
  if (query.excludeBody !== undefined)
3602
3675
  raw.validateBody(query.excludeBody);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@series-inc/rundot-syncplay",
3
- "version": "6.0.0-rc.30",
3
+ "version": "6.0.0-rc.31",
4
4
  "description": "Kinetix orchestration, rollback, replay, late-join, and deterministic networking for RUN.game",
5
5
  "repository": {
6
6
  "type": "git",