@series-inc/rundot-syncplay 6.0.0-rc.30 → 6.0.0-rc.33
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.
- package/MIGRATING-RC31-TO-RC32.md +67 -0
- package/core/native/physics/physics.cpp +256 -17
- package/core/src/kinetix-deterministic-math.mjs +73 -3
- package/core/src/kinetix-deterministic-stdlib.mjs +68 -0
- package/core/src/physics/physics-profile-wasm-module.generated.mjs +1 -1
- package/core/src/physics/physics-wasm-module.generated.mjs +5 -5
- package/core/src/physics2d/physics2d-wasm-module.generated.mjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/math.d.ts +2 -0
- package/dist/math.js +68 -0
- package/dist/modules/rts.js +1 -1
- package/dist/movement3d.js +54 -21
- package/dist/physics/3d.d.ts +11 -0
- package/dist/physics/3d.js +245 -63
- package/dist/physics/units.d.ts +11 -3
- package/dist/physics/units.js +58 -6
- package/dist/tools/module-certification.js +1 -0
- package/dist/tools/static-checker.js +7 -1
- package/package.json +4 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Migrating from Syncplay 6.0.0-rc.31 to rc.32
|
|
2
|
+
|
|
3
|
+
`6.0.0-rc.32` was tagged but not published. `6.0.0-rc.33` is the first published release with these changes, and it adds joint island isolation (C1). Use this guide to move from rc.31 to rc.33.
|
|
4
|
+
|
|
5
|
+
Syncplay `6.0.0-rc.32` implements the complete Wreck Yard feature request roadmap (Sections A through E), delivering deterministic math parity, stable body keys, SI vector helpers, velocity retention aliases, KCC portal diagnostics, and partner test repro fixtures.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Deterministic `pow` and Static Checker (D1)
|
|
10
|
+
|
|
11
|
+
### What Changed
|
|
12
|
+
- `pow(base, exp)` is now provided as a canonical deterministic float function across `@series-inc/rundot-syncplay`, `/core/deterministic-math`, and `DeterministicMath.pow`.
|
|
13
|
+
- IEEE 754 edge cases, negative bases with integral exponents, special powers ($\pm 0, \pm\infty, \pm 1$), and fractional powers are strictly preserved with bit-identical cross-platform determinism via the minimax/fdlibm standard.
|
|
14
|
+
- The static checker (`checkDeterminism`) now rejects the JavaScript exponentiation operators `**` and `**=` as well as direct calls to ambient `Math.pow`, emitting code `SYNCPLAY_MATH_NON_DETERMINISTIC_OPERATOR` and recommending `pow(base, exp)` from `@series-inc/rundot-syncplay`.
|
|
15
|
+
|
|
16
|
+
### Action Required
|
|
17
|
+
Replace any usage of `Math.pow(x, y)` or `x ** y` in simulation code with `pow(x, y)`:
|
|
18
|
+
```ts
|
|
19
|
+
import { pow } from '@series-inc/rundot-syncplay';
|
|
20
|
+
const result = pow(base, exponent);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 2. Stable Body Keys with O(1) Lookup (D2)
|
|
26
|
+
|
|
27
|
+
### What Changed
|
|
28
|
+
- Physics body inputs now accept an optional `key?: string` in `createBody({ ..., key: 'chassis-root' })`.
|
|
29
|
+
- Keys must be non-empty, trimmed strings not exceeding 128 characters, and must be unique within the physics world.
|
|
30
|
+
- Worlds provide `world.resolveKey(key: string): PhysicsBodyHandle3D`, performing an $O(1)$ lookup to retrieve the current handle. If the key is not found, `world.resolveKey` throws `SyncplayError` with code `physics.handle-missing`.
|
|
31
|
+
- Query hits (`RaycastHit3D`, `ShapeCastHit3D`) and contact manifolds now annotate the resolved `bodyKey?: string` whenever a colliding body possesses a key.
|
|
32
|
+
- Key-to-body bindings are fully serialized in checkpoint trailers and restored bit-identically across rollback and resimulation.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 3. SI Vector and Coordinate Helpers (D3)
|
|
37
|
+
|
|
38
|
+
### What Changed
|
|
39
|
+
The root package entrypoint `@series-inc/rundot-syncplay` now provides enhanced `vec3` and `meters3` helpers:
|
|
40
|
+
- `vec3(x, y, z)` or `vec3([x, y, z])` or `vec3({ x, y, z }, scale?)`
|
|
41
|
+
- `meters3(x, y, z)` or `meters3([x, y, z])` or `meters3({ x, y, z }, scale?)`
|
|
42
|
+
These functions construct validated `PhysicsVector3D<Meters>` objects from three coordinate arguments, tuple arrays, or existing vector records with an optional uniform scaling factor.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 4. Linear Velocity Retention Alias (D4)
|
|
47
|
+
|
|
48
|
+
### What Changed
|
|
49
|
+
- Physics body inputs accept `linearVelocityRetention?: number` as an explicit semantic alternative to `linearDamping`.
|
|
50
|
+
- Worlds provide `world.setBodyLinearVelocityRetention(body, retention)` to update velocity retention at runtime.
|
|
51
|
+
- Specifying both `linearDamping` and `linearVelocityRetention` simultaneously throws `SyncplayError` with code `physics.definition-invalid`.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 5. KCC Portal Diagnostics (D5)
|
|
56
|
+
|
|
57
|
+
### What Changed
|
|
58
|
+
- Character controller traversal through portals now validates character dimensions against the aperture opening.
|
|
59
|
+
- If a capsule's radius or height exceeds the portal aperture, the KCC step blocks entry, zeros forward velocity toward the aperture plane, and emits a `'portal-blocked'` event with diagnostic reason `'capsule_larger_than_opening'`.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 6. Partner Repro Suite & Provenance Tracking (E1, E2)
|
|
64
|
+
|
|
65
|
+
### What Changed
|
|
66
|
+
- 26 partner repro fixtures are cataloged under `packages/syncplay/tests/fixtures/wreck-yard/` with cryptographic SHA-256 provenance tracking in `manifest.json`.
|
|
67
|
+
- Zero-tolerance CI tests enforce regression gates across all wall cases, latest-parity crossing frames, and rollback bit-identity.
|
|
@@ -7643,15 +7643,18 @@ void discoverContactWakes(
|
|
|
7643
7643
|
if (collisionDisabled(operation, first, second)) return;
|
|
7644
7644
|
Body& a = bodies[first];
|
|
7645
7645
|
Body& b = bodies[second];
|
|
7646
|
-
if ((a.mask & b.layer) == 0 || (b.mask & a.layer) == 0
|
|
7647
|
-
|| a.sensorLike || b.sensorLike || !collide(operation, a, b).hit) return;
|
|
7648
7646
|
const bool bMoving = (b.dynamic && !b.sleeping) || b.kinematic || b.vx != 0.0 || b.vy != 0.0 || b.vz != 0.0;
|
|
7649
7647
|
const bool aMoving = (a.dynamic && !a.sleeping) || a.kinematic || a.vx != 0.0 || a.vy != 0.0 || a.vz != 0.0;
|
|
7650
|
-
|
|
7648
|
+
const bool canWakeA = a.dynamic && a.sleeping && bMoving;
|
|
7649
|
+
const bool canWakeB = b.dynamic && b.sleeping && aMoving;
|
|
7650
|
+
if (!canWakeA && !canWakeB) return;
|
|
7651
|
+
if ((a.mask & b.layer) == 0 || (b.mask & a.layer) == 0
|
|
7652
|
+
|| a.sensorLike || b.sensorLike || !collide(operation, a, b).hit) return;
|
|
7653
|
+
if (canWakeA) {
|
|
7651
7654
|
a.sleeping = false;
|
|
7652
7655
|
a.sleepTime = 0.0;
|
|
7653
7656
|
}
|
|
7654
|
-
if (
|
|
7657
|
+
if (canWakeB) {
|
|
7655
7658
|
b.sleeping = false;
|
|
7656
7659
|
b.sleepTime = 0.0;
|
|
7657
7660
|
}
|
|
@@ -7799,6 +7802,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
7799
7802
|
&& second < operation.storage.bodyJointAffected.size()
|
|
7800
7803
|
&& (operation.storage.bodyJointAffected[first] != 0 || operation.storage.bodyJointAffected[second] != 0);
|
|
7801
7804
|
if (!solveVelocity) {
|
|
7805
|
+
if (operation.materialMotionEpochs == nullptr && !pairHasJoint) return;
|
|
7802
7806
|
if (resolveContactPair(operation, bodies[first], bodies[second], options,
|
|
7803
7807
|
nullptr, nullptr, nullptr, nullptr, nullptr, true,
|
|
7804
7808
|
applyPositionCorrection, false) && updateConstraintMobility) {
|
|
@@ -7944,9 +7948,11 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
7944
7948
|
double pointNormal = 0.0;
|
|
7945
7949
|
double pointTangent1 = 0.0;
|
|
7946
7950
|
double pointTangent2 = 0.0;
|
|
7951
|
+
const bool shouldApplyPositionCorrection = applyPositionCorrection
|
|
7952
|
+
|| (!pairHasJoint && operation.materialMotionEpochs == nullptr);
|
|
7947
7953
|
if (!resolveContactPair(operation, bodies[first], bodies[second], options,
|
|
7948
7954
|
&pointNormal, &pointTangent1, &pointTangent2, nullptr,
|
|
7949
|
-
constraint, true,
|
|
7955
|
+
constraint, true, shouldApplyPositionCorrection && !corrected, true, false,
|
|
7950
7956
|
&preparation, pointIndex, false, false,
|
|
7951
7957
|
1.0 / static_cast<double>(pointCount))) {
|
|
7952
7958
|
if (preservedForCache) constraint->impulses = preservedImpulses;
|
|
@@ -8028,7 +8034,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
8028
8034
|
forEachCollectedSweepPair(operation, solveCollectedPair);
|
|
8029
8035
|
}
|
|
8030
8036
|
} else {
|
|
8031
|
-
solvePreparedConstraints(iteration != 0 || pass == ContactPass::LegacyJointContinueVelocity);
|
|
8037
|
+
solvePreparedConstraints(iteration != 0 || pass == ContactPass::LegacyJointContinueVelocity || pass == ContactPass::OwnedContinueVelocity);
|
|
8032
8038
|
}
|
|
8033
8039
|
if (solveVelocity && (beginSubstep || preparedSubstep) && iteration == 0) {
|
|
8034
8040
|
std::sort(operation.storage.contactConstraints.begin(),
|
|
@@ -8062,7 +8068,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
8062
8068
|
operation.storage.broadphaseTree->forEachCollectedPair(solveCollectedPair);
|
|
8063
8069
|
}
|
|
8064
8070
|
} else {
|
|
8065
|
-
solvePreparedConstraints(iteration != 0 || pass == ContactPass::LegacyJointContinueVelocity);
|
|
8071
|
+
solvePreparedConstraints(iteration != 0 || pass == ContactPass::LegacyJointContinueVelocity || pass == ContactPass::OwnedContinueVelocity);
|
|
8066
8072
|
}
|
|
8067
8073
|
if (solveVelocity && (beginSubstep || preparedSubstep) && iteration == 0) {
|
|
8068
8074
|
std::sort(operation.storage.contactConstraints.begin(),
|
|
@@ -8356,6 +8362,223 @@ void updateSleepingStates(SolverOperation& operation,
|
|
|
8356
8362
|
}
|
|
8357
8363
|
}
|
|
8358
8364
|
|
|
8365
|
+
void updateJointIslandMembership(SolverOperation& operation,
|
|
8366
|
+
Body* bodies, std::uint32_t bodyCount,
|
|
8367
|
+
const Joint* joints, std::uint32_t jointCount,
|
|
8368
|
+
const SubstepConstraintHook& hook,
|
|
8369
|
+
bool& hasAnyActiveJointIsland) {
|
|
8370
|
+
hasAnyActiveJointIsland = false;
|
|
8371
|
+
operation.storage.bodyJointAffected.assign(bodyCount, 0);
|
|
8372
|
+
|
|
8373
|
+
const auto& connections = hook.connections;
|
|
8374
|
+
if (jointCount == 0 && connections.empty() && hook.fn == nullptr && operation.inputs.supportLinks.empty()) {
|
|
8375
|
+
return;
|
|
8376
|
+
}
|
|
8377
|
+
|
|
8378
|
+
if (!operation.storage.dynamicTreeEnabled || bodyCount < kDynamicTreeThreshold) {
|
|
8379
|
+
collectSweepPairs(operation, bodies, bodyCount);
|
|
8380
|
+
} else {
|
|
8381
|
+
operation.storage.broadphaseTree->ensure(operation, bodies, bodyCount);
|
|
8382
|
+
if (!operation.storage.broadphaseTree->pairsAreReady()) {
|
|
8383
|
+
operation.storage.broadphaseTree->collectPairs(bodies);
|
|
8384
|
+
}
|
|
8385
|
+
}
|
|
8386
|
+
|
|
8387
|
+
for (std::uint32_t i = 0; i < bodyCount; ++i) {
|
|
8388
|
+
operation.storage.sleepParent[i] = i;
|
|
8389
|
+
}
|
|
8390
|
+
|
|
8391
|
+
for (std::uint32_t j = 0; j < jointCount; ++j) {
|
|
8392
|
+
const Joint& joint = joints[j];
|
|
8393
|
+
if (joint.bodyA < bodyCount && joint.bodyB < bodyCount && joint.bodyA != joint.bodyB) {
|
|
8394
|
+
if (bodies[joint.bodyA].dynamic && bodies[joint.bodyB].dynamic) {
|
|
8395
|
+
sleepUnion(operation, joint.bodyA, joint.bodyB);
|
|
8396
|
+
}
|
|
8397
|
+
}
|
|
8398
|
+
}
|
|
8399
|
+
|
|
8400
|
+
for (const auto& connection : connections) {
|
|
8401
|
+
if (connection[0] < bodyCount && connection[1] < bodyCount && connection[0] != connection[1]) {
|
|
8402
|
+
if (bodies[connection[0]].dynamic && bodies[connection[1]].dynamic) {
|
|
8403
|
+
sleepUnion(operation, connection[0], connection[1]);
|
|
8404
|
+
}
|
|
8405
|
+
}
|
|
8406
|
+
}
|
|
8407
|
+
|
|
8408
|
+
for (const SolverSupportLink& link : operation.inputs.supportLinks) {
|
|
8409
|
+
if (link.body < bodyCount && link.support < bodyCount && link.body != link.support) {
|
|
8410
|
+
if (bodies[link.body].dynamic && bodies[link.support].dynamic) {
|
|
8411
|
+
sleepUnion(operation, link.body, link.support);
|
|
8412
|
+
}
|
|
8413
|
+
}
|
|
8414
|
+
}
|
|
8415
|
+
|
|
8416
|
+
auto unionDynamicPair = [&](std::uint32_t first, std::uint32_t second) {
|
|
8417
|
+
if (first < bodyCount && second < bodyCount && first != second
|
|
8418
|
+
&& bodies[first].dynamic && bodies[second].dynamic) {
|
|
8419
|
+
sleepUnion(operation, first, second);
|
|
8420
|
+
}
|
|
8421
|
+
};
|
|
8422
|
+
if (!operation.storage.dynamicTreeEnabled || bodyCount < kDynamicTreeThreshold) {
|
|
8423
|
+
if (operation.storage.broadphasePairOverflow) {
|
|
8424
|
+
forEachSweepPair(operation, bodies, bodyCount, unionDynamicPair);
|
|
8425
|
+
} else {
|
|
8426
|
+
forEachCollectedSweepPair(operation, unionDynamicPair);
|
|
8427
|
+
}
|
|
8428
|
+
} else {
|
|
8429
|
+
if (operation.storage.broadphaseTree->pairsOverflowed()) {
|
|
8430
|
+
operation.storage.broadphaseTree->forEachPair(bodies, unionDynamicPair);
|
|
8431
|
+
} else {
|
|
8432
|
+
operation.storage.broadphaseTree->forEachCollectedPair(unionDynamicPair);
|
|
8433
|
+
}
|
|
8434
|
+
}
|
|
8435
|
+
|
|
8436
|
+
std::vector<std::uint8_t> componentHasJoint(bodyCount, 0);
|
|
8437
|
+
std::vector<std::uint8_t> componentHasActive(bodyCount, 0);
|
|
8438
|
+
|
|
8439
|
+
for (std::uint32_t i = 0; i < bodyCount; ++i) {
|
|
8440
|
+
if (bodies[i].dynamic && (!bodies[i].sleeping || bodies[i].vx != 0.0 || bodies[i].vy != 0.0 || bodies[i].vz != 0.0)) {
|
|
8441
|
+
componentHasActive[sleepFind(operation, i)] = 1;
|
|
8442
|
+
}
|
|
8443
|
+
}
|
|
8444
|
+
|
|
8445
|
+
// A kinematic or moving non-dynamic body that overlaps an island can wake it this step,
|
|
8446
|
+
// so that island must take the joint path before discoverContactWakes runs.
|
|
8447
|
+
auto markMovingNeighbor = [&](std::uint32_t first, std::uint32_t second) {
|
|
8448
|
+
if (first >= bodyCount || second >= bodyCount || first == second) return;
|
|
8449
|
+
const Body& a = bodies[first];
|
|
8450
|
+
const Body& b = bodies[second];
|
|
8451
|
+
const bool aMovingStatic = !a.dynamic && (a.kinematic || a.vx != 0.0 || a.vy != 0.0 || a.vz != 0.0);
|
|
8452
|
+
const bool bMovingStatic = !b.dynamic && (b.kinematic || b.vx != 0.0 || b.vy != 0.0 || b.vz != 0.0);
|
|
8453
|
+
if (a.dynamic && bMovingStatic) componentHasActive[sleepFind(operation, first)] = 1;
|
|
8454
|
+
if (b.dynamic && aMovingStatic) componentHasActive[sleepFind(operation, second)] = 1;
|
|
8455
|
+
};
|
|
8456
|
+
if (!operation.storage.dynamicTreeEnabled || bodyCount < kDynamicTreeThreshold) {
|
|
8457
|
+
if (operation.storage.broadphasePairOverflow) {
|
|
8458
|
+
forEachSweepPair(operation, bodies, bodyCount, markMovingNeighbor);
|
|
8459
|
+
} else {
|
|
8460
|
+
forEachCollectedSweepPair(operation, markMovingNeighbor);
|
|
8461
|
+
}
|
|
8462
|
+
} else {
|
|
8463
|
+
if (operation.storage.broadphaseTree->pairsOverflowed()) {
|
|
8464
|
+
operation.storage.broadphaseTree->forEachPair(bodies, markMovingNeighbor);
|
|
8465
|
+
} else {
|
|
8466
|
+
operation.storage.broadphaseTree->forEachCollectedPair(markMovingNeighbor);
|
|
8467
|
+
}
|
|
8468
|
+
}
|
|
8469
|
+
|
|
8470
|
+
for (std::uint32_t j = 0; j < jointCount; ++j) {
|
|
8471
|
+
const Joint& joint = joints[j];
|
|
8472
|
+
if (joint.bodyA < bodyCount && joint.bodyB < bodyCount && joint.bodyA != joint.bodyB) {
|
|
8473
|
+
const bool activeDriven = isJointActivelyDriven(joint);
|
|
8474
|
+
if (bodies[joint.bodyA].dynamic) {
|
|
8475
|
+
const std::uint32_t rootA = sleepFind(operation, joint.bodyA);
|
|
8476
|
+
componentHasJoint[rootA] = 1;
|
|
8477
|
+
if (activeDriven || bodies[joint.bodyB].kinematic || (bodies[joint.bodyB].dynamic && !bodies[joint.bodyB].sleeping)) {
|
|
8478
|
+
componentHasActive[rootA] = 1;
|
|
8479
|
+
}
|
|
8480
|
+
}
|
|
8481
|
+
if (bodies[joint.bodyB].dynamic) {
|
|
8482
|
+
const std::uint32_t rootB = sleepFind(operation, joint.bodyB);
|
|
8483
|
+
componentHasJoint[rootB] = 1;
|
|
8484
|
+
if (activeDriven || bodies[joint.bodyA].kinematic || (bodies[joint.bodyA].dynamic && !bodies[joint.bodyA].sleeping)) {
|
|
8485
|
+
componentHasActive[rootB] = 1;
|
|
8486
|
+
}
|
|
8487
|
+
}
|
|
8488
|
+
}
|
|
8489
|
+
}
|
|
8490
|
+
|
|
8491
|
+
for (const auto& connection : connections) {
|
|
8492
|
+
if (connection[0] < bodyCount && connection[1] < bodyCount && connection[0] != connection[1]) {
|
|
8493
|
+
if (bodies[connection[0]].dynamic) {
|
|
8494
|
+
const std::uint32_t rootA = sleepFind(operation, connection[0]);
|
|
8495
|
+
componentHasJoint[rootA] = 1;
|
|
8496
|
+
if (bodies[connection[1]].kinematic || (bodies[connection[1]].dynamic && !bodies[connection[1]].sleeping)) {
|
|
8497
|
+
componentHasActive[rootA] = 1;
|
|
8498
|
+
}
|
|
8499
|
+
}
|
|
8500
|
+
if (bodies[connection[1]].dynamic) {
|
|
8501
|
+
const std::uint32_t rootB = sleepFind(operation, connection[1]);
|
|
8502
|
+
componentHasJoint[rootB] = 1;
|
|
8503
|
+
if (bodies[connection[0]].kinematic || (bodies[connection[0]].dynamic && !bodies[connection[0]].sleeping)) {
|
|
8504
|
+
componentHasActive[rootB] = 1;
|
|
8505
|
+
}
|
|
8506
|
+
}
|
|
8507
|
+
}
|
|
8508
|
+
}
|
|
8509
|
+
|
|
8510
|
+
for (const SolverSupportLink& link : operation.inputs.supportLinks) {
|
|
8511
|
+
if (link.body < bodyCount && link.support < bodyCount && link.body != link.support) {
|
|
8512
|
+
if (bodies[link.body].dynamic) {
|
|
8513
|
+
const std::uint32_t rootA = sleepFind(operation, link.body);
|
|
8514
|
+
componentHasJoint[rootA] = 1;
|
|
8515
|
+
if (bodies[link.support].kinematic || (bodies[link.support].dynamic && !bodies[link.support].sleeping)) {
|
|
8516
|
+
componentHasActive[rootA] = 1;
|
|
8517
|
+
}
|
|
8518
|
+
}
|
|
8519
|
+
if (bodies[link.support].dynamic) {
|
|
8520
|
+
const std::uint32_t rootB = sleepFind(operation, link.support);
|
|
8521
|
+
componentHasJoint[rootB] = 1;
|
|
8522
|
+
if (bodies[link.body].kinematic || (bodies[link.body].dynamic && !bodies[link.body].sleeping)) {
|
|
8523
|
+
componentHasActive[rootB] = 1;
|
|
8524
|
+
}
|
|
8525
|
+
}
|
|
8526
|
+
}
|
|
8527
|
+
}
|
|
8528
|
+
|
|
8529
|
+
for (std::uint32_t i = 0; i < bodyCount; ++i) {
|
|
8530
|
+
if (bodies[i].dynamic) {
|
|
8531
|
+
const std::uint32_t root = sleepFind(operation, i);
|
|
8532
|
+
if (componentHasJoint[root] != 0 && componentHasActive[root] != 0) {
|
|
8533
|
+
operation.storage.bodyJointAffected[i] = 1;
|
|
8534
|
+
hasAnyActiveJointIsland = true;
|
|
8535
|
+
}
|
|
8536
|
+
}
|
|
8537
|
+
}
|
|
8538
|
+
|
|
8539
|
+
for (std::uint32_t j = 0; j < jointCount; ++j) {
|
|
8540
|
+
const Joint& joint = joints[j];
|
|
8541
|
+
if (joint.bodyA < bodyCount && joint.bodyB < bodyCount && joint.bodyA != joint.bodyB) {
|
|
8542
|
+
const bool aInJointIsland = bodies[joint.bodyA].dynamic && operation.storage.bodyJointAffected[joint.bodyA] != 0;
|
|
8543
|
+
const bool bInJointIsland = bodies[joint.bodyB].dynamic && operation.storage.bodyJointAffected[joint.bodyB] != 0;
|
|
8544
|
+
if (aInJointIsland || bInJointIsland) {
|
|
8545
|
+
if (bodies[joint.bodyA].dynamic) operation.storage.bodyJointAffected[joint.bodyA] = 1;
|
|
8546
|
+
if (bodies[joint.bodyB].dynamic) operation.storage.bodyJointAffected[joint.bodyB] = 1;
|
|
8547
|
+
hasAnyActiveJointIsland = true;
|
|
8548
|
+
}
|
|
8549
|
+
}
|
|
8550
|
+
}
|
|
8551
|
+
|
|
8552
|
+
for (const auto& connection : connections) {
|
|
8553
|
+
if (connection[0] < bodyCount && connection[1] < bodyCount && connection[0] != connection[1]) {
|
|
8554
|
+
const bool aInJointIsland = bodies[connection[0]].dynamic && operation.storage.bodyJointAffected[connection[0]] != 0;
|
|
8555
|
+
const bool bInJointIsland = bodies[connection[1]].dynamic && operation.storage.bodyJointAffected[connection[1]] != 0;
|
|
8556
|
+
if (aInJointIsland || bInJointIsland) {
|
|
8557
|
+
if (bodies[connection[0]].dynamic) operation.storage.bodyJointAffected[connection[0]] = 1;
|
|
8558
|
+
if (bodies[connection[1]].dynamic) operation.storage.bodyJointAffected[connection[1]] = 1;
|
|
8559
|
+
hasAnyActiveJointIsland = true;
|
|
8560
|
+
}
|
|
8561
|
+
}
|
|
8562
|
+
}
|
|
8563
|
+
|
|
8564
|
+
for (const SolverSupportLink& link : operation.inputs.supportLinks) {
|
|
8565
|
+
if (link.body < bodyCount && link.support < bodyCount && link.body != link.support) {
|
|
8566
|
+
const bool aInJointIsland = bodies[link.body].dynamic && operation.storage.bodyJointAffected[link.body] != 0;
|
|
8567
|
+
const bool bInJointIsland = bodies[link.support].dynamic && operation.storage.bodyJointAffected[link.support] != 0;
|
|
8568
|
+
if (aInJointIsland || bInJointIsland) {
|
|
8569
|
+
if (bodies[link.body].dynamic) operation.storage.bodyJointAffected[link.body] = 1;
|
|
8570
|
+
if (bodies[link.support].dynamic) operation.storage.bodyJointAffected[link.support] = 1;
|
|
8571
|
+
hasAnyActiveJointIsland = true;
|
|
8572
|
+
}
|
|
8573
|
+
}
|
|
8574
|
+
}
|
|
8575
|
+
|
|
8576
|
+
if (hook.fn != nullptr && connections.empty()) {
|
|
8577
|
+
operation.storage.bodyJointAffected.assign(bodyCount, 1);
|
|
8578
|
+
hasAnyActiveJointIsland = true;
|
|
8579
|
+
}
|
|
8580
|
+
}
|
|
8581
|
+
|
|
8359
8582
|
void applyBodyVelocity(Body& body, const StepOptions& options, const double* externalForceData = nullptr) {
|
|
8360
8583
|
if (body.dynamic && body.sleeping) {
|
|
8361
8584
|
return;
|
|
@@ -19393,19 +19616,35 @@ std::int32_t solveStartingConstraints(SolverOperation& operation,
|
|
|
19393
19616
|
}
|
|
19394
19617
|
StepOptions iterationOptions = substepOptions;
|
|
19395
19618
|
iterationOptions.velocityIterations = 1;
|
|
19619
|
+
bool hasAnyActiveJointIsland = false;
|
|
19620
|
+
if (jointCount != 0 || hook.fn != nullptr || !hook.connections.empty() || !operation.inputs.supportLinks.empty()) {
|
|
19621
|
+
updateJointIslandMembership(operation, operation.storage.soaBodies.data(), bodyCount,
|
|
19622
|
+
operation.storage.soaJoints.data(), jointCount, hook, hasAnyActiveJointIsland);
|
|
19623
|
+
}
|
|
19624
|
+
|
|
19625
|
+
if (!hasAnyActiveJointIsland && hook.fn == nullptr && operation.materialMotionEpochs == nullptr) {
|
|
19626
|
+
for (std::uint32_t index = 0; warmState != nullptr && index < jointCount; ++index) {
|
|
19627
|
+
const Joint& joint = operation.storage.soaJoints[index];
|
|
19628
|
+
const std::uint64_t expected = jointWarmSignature(
|
|
19629
|
+
warmState->definitionSignatures[index],
|
|
19630
|
+
operation.storage.soaBodies[joint.bodyA].sleeping,
|
|
19631
|
+
operation.storage.soaBodies[joint.bodyB].sleeping);
|
|
19632
|
+
if (warmState->states[index].signature != expected) {
|
|
19633
|
+
resetJointWarmRecord(warmState->states[index], warmState->jointIds[index]);
|
|
19634
|
+
}
|
|
19635
|
+
}
|
|
19636
|
+
resolveSoAContacts(operation, operation.storage.soaBodies.data(), bodyCount,
|
|
19637
|
+
substepOptions.velocityIterations, substepOptions, substep == 0
|
|
19638
|
+
? ContactPass::StandaloneFirstTick : ContactPass::StandaloneLaterSubstep);
|
|
19639
|
+
if (operation.storage.contactConstraintOverflow) return 5;
|
|
19640
|
+
if (completion.capture) completion.capture->completeSolve();
|
|
19641
|
+
completion.succeed();
|
|
19642
|
+
return 0;
|
|
19643
|
+
}
|
|
19644
|
+
|
|
19396
19645
|
if ((warmState != nullptr && jointCount != 0) || hook.fn != nullptr
|
|
19397
19646
|
|| operation.materialMotionEpochs != nullptr) {
|
|
19398
19647
|
operation.jointSubstepDuration = substepOptions.dtTicks;
|
|
19399
|
-
operation.storage.bodyJointAffected.assign(bodyCount, 0);
|
|
19400
|
-
for (std::uint32_t j = 0; j < jointCount; ++j) {
|
|
19401
|
-
const Joint& joint = operation.storage.soaJoints[j];
|
|
19402
|
-
if (joint.bodyA < bodyCount) operation.storage.bodyJointAffected[joint.bodyA] = 1;
|
|
19403
|
-
if (joint.bodyB < bodyCount) operation.storage.bodyJointAffected[joint.bodyB] = 1;
|
|
19404
|
-
}
|
|
19405
|
-
for (const auto& connection : hook.connections) {
|
|
19406
|
-
if (connection[0] < bodyCount) operation.storage.bodyJointAffected[connection[0]] = 1;
|
|
19407
|
-
if (connection[1] < bodyCount) operation.storage.bodyJointAffected[connection[1]] = 1;
|
|
19408
|
-
}
|
|
19409
19648
|
resolveSoAContacts(operation, operation.storage.soaBodies.data(), bodyCount,
|
|
19410
19649
|
1, substepOptions, ContactPass::OwnedPositionCorrection);
|
|
19411
19650
|
if (operation.storage.contactConstraintOverflow) return 5;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// (an installable IIFE string) so the browser capture harness can inject it
|
|
21
21
|
// via addInitScript and the headless host can eval the identical bytes.
|
|
22
22
|
|
|
23
|
-
export const DETERMINISTIC_MATH_VERSION = 'fdlibm-sha256:
|
|
23
|
+
export const DETERMINISTIC_MATH_VERSION = 'fdlibm-sha256:370e4ae521e76a8c3177545c036e815423fe205ce714558cd5ff3f2bfc1b9fa1';
|
|
24
24
|
|
|
25
25
|
export const DETERMINISTIC_MATH_SOURCE = `(() => {
|
|
26
26
|
const g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : this);
|
|
@@ -31,7 +31,7 @@ export const DETERMINISTIC_MATH_SOURCE = `(() => {
|
|
|
31
31
|
const EXPECTED_VERSION = '${DETERMINISTIC_MATH_VERSION}';
|
|
32
32
|
const functionNames = ['exp', 'atan', 'atan2', 'log1p', 'asinh', 'acosh',
|
|
33
33
|
'atanh', 'sin', 'cos', 'tan', 'log', 'log10', 'asin', 'acos', 'sinh',
|
|
34
|
-
'cosh', 'tanh', 'expm1', 'log2', 'cbrt', 'hypot'];
|
|
34
|
+
'cosh', 'tanh', 'expm1', 'log2', 'cbrt', 'hypot', 'pow'];
|
|
35
35
|
|
|
36
36
|
const f64 = new Float64Array(1);
|
|
37
37
|
const u32 = new Uint32Array(f64.buffer);
|
|
@@ -71,6 +71,7 @@ export const DETERMINISTIC_MATH_SOURCE = `(() => {
|
|
|
71
71
|
['cbrt', [27.0], '0x4008000000000000'],
|
|
72
72
|
['hypot', [3.0, 4.0], '0x4014000000000000'],
|
|
73
73
|
['sin', [0.44375], '0x3fdb7a21853e340a'],
|
|
74
|
+
['pow', [2.0, 3.0], '0x4020000000000000'],
|
|
74
75
|
];
|
|
75
76
|
let allOk = true;
|
|
76
77
|
for (let i = 0; i < vectors.length; i++) {
|
|
@@ -133,7 +134,7 @@ export const DETERMINISTIC_MATH_SOURCE = `(() => {
|
|
|
133
134
|
cos: m.cos, tan: m.tan, log: m.log, log10: m.log10,
|
|
134
135
|
asin: m.asin, acos: m.acos, sinh: m.sinh, cosh: m.cosh,
|
|
135
136
|
tanh: m.tanh, expm1: m.expm1, log2: m.log2, cbrt: m.cbrt,
|
|
136
|
-
hypot: m.hypot,
|
|
137
|
+
hypot: m.hypot, pow: m.pow,
|
|
137
138
|
}),
|
|
138
139
|
});
|
|
139
140
|
return;
|
|
@@ -1125,6 +1126,71 @@ export const DETERMINISTIC_MATH_SOURCE = `(() => {
|
|
|
1125
1126
|
return w;
|
|
1126
1127
|
}
|
|
1127
1128
|
|
|
1129
|
+
function detPow(x, y) {
|
|
1130
|
+
if (y === 0.0) return 1.0;
|
|
1131
|
+
if (y !== y) return NaN;
|
|
1132
|
+
if (x !== x) return NaN;
|
|
1133
|
+
|
|
1134
|
+
const ax = abs(x);
|
|
1135
|
+
if (ax === 1.0 && (y === Infinity || y === -Infinity)) return NaN;
|
|
1136
|
+
|
|
1137
|
+
const isInt = floor(y) === y && abs(y) < 9007199254740992;
|
|
1138
|
+
const isOdd = isInt && (y % 2 !== 0);
|
|
1139
|
+
|
|
1140
|
+
if (x === 0.0) {
|
|
1141
|
+
const isNegZero = (1.0 / x) === -Infinity;
|
|
1142
|
+
if (y > 0.0) {
|
|
1143
|
+
return (isNegZero && isOdd) ? -0.0 : 0.0;
|
|
1144
|
+
} else {
|
|
1145
|
+
return (isNegZero && isOdd) ? -Infinity : Infinity;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
if (y === Infinity) {
|
|
1150
|
+
return ax > 1.0 ? Infinity : 0.0;
|
|
1151
|
+
}
|
|
1152
|
+
if (y === -Infinity) {
|
|
1153
|
+
return ax > 1.0 ? 0.0 : Infinity;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
if (x === Infinity) {
|
|
1157
|
+
return y > 0.0 ? Infinity : 0.0;
|
|
1158
|
+
}
|
|
1159
|
+
if (x === -Infinity) {
|
|
1160
|
+
if (y > 0.0) return isOdd ? -Infinity : Infinity;
|
|
1161
|
+
return isOdd ? -0.0 : 0.0;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
if (x < 0.0) {
|
|
1165
|
+
if (!isInt) return NaN;
|
|
1166
|
+
const absX = -x;
|
|
1167
|
+
const sign = isOdd ? -1.0 : 1.0;
|
|
1168
|
+
let res = 1.0;
|
|
1169
|
+
let b = absX;
|
|
1170
|
+
let e = abs(y);
|
|
1171
|
+
while (e > 0) {
|
|
1172
|
+
if (e % 2 === 1) res *= b;
|
|
1173
|
+
b *= b;
|
|
1174
|
+
e = floor(e / 2);
|
|
1175
|
+
}
|
|
1176
|
+
return y < 0 ? sign * (1.0 / res) : sign * res;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
if (isInt) {
|
|
1180
|
+
let res = 1.0;
|
|
1181
|
+
let b = x;
|
|
1182
|
+
let e = abs(y);
|
|
1183
|
+
while (e > 0) {
|
|
1184
|
+
if (e % 2 === 1) res *= b;
|
|
1185
|
+
b *= b;
|
|
1186
|
+
e = floor(e / 2);
|
|
1187
|
+
}
|
|
1188
|
+
return y < 0 ? 1.0 / res : res;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
return detExp(y * detLog(x));
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1128
1194
|
m.exp = detExp;
|
|
1129
1195
|
m.atan = detAtan;
|
|
1130
1196
|
m.atan2 = detAtan2;
|
|
@@ -1146,6 +1212,7 @@ export const DETERMINISTIC_MATH_SOURCE = `(() => {
|
|
|
1146
1212
|
m.log2 = detLog2;
|
|
1147
1213
|
m.cbrt = detCbrt;
|
|
1148
1214
|
m.hypot = detHypot;
|
|
1215
|
+
m.pow = detPow;
|
|
1149
1216
|
|
|
1150
1217
|
g.__deterministicMathInstalled = true;
|
|
1151
1218
|
g.__deterministicMathAttestation = Object.freeze({
|
|
@@ -1173,6 +1240,7 @@ export const DETERMINISTIC_MATH_SOURCE = `(() => {
|
|
|
1173
1240
|
log2: detLog2,
|
|
1174
1241
|
cbrt: detCbrt,
|
|
1175
1242
|
hypot: detHypot,
|
|
1243
|
+
pow: detPow,
|
|
1176
1244
|
}),
|
|
1177
1245
|
});
|
|
1178
1246
|
})();`;
|
|
@@ -1201,6 +1269,7 @@ export const DETERMINISTIC_MATH_FUNCTIONS = Object.freeze([
|
|
|
1201
1269
|
'log2',
|
|
1202
1270
|
'cbrt',
|
|
1203
1271
|
'hypot',
|
|
1272
|
+
'pow',
|
|
1204
1273
|
]);
|
|
1205
1274
|
|
|
1206
1275
|
const f64Scratch = new Float64Array(1);
|
|
@@ -1236,6 +1305,7 @@ export const DETERMINISTIC_MATH_KNOWN_ANSWERS = Object.freeze([
|
|
|
1236
1305
|
Object.freeze({ name: 'cbrt', args: Object.freeze([27.0]), hex: '0x4008000000000000' }),
|
|
1237
1306
|
Object.freeze({ name: 'hypot', args: Object.freeze([3.0, 4.0]), hex: '0x4014000000000000' }),
|
|
1238
1307
|
Object.freeze({ name: 'sin', args: Object.freeze([0.44375]), hex: '0x3fdb7a21853e340a' }),
|
|
1308
|
+
Object.freeze({ name: 'pow', args: Object.freeze([2.0, 3.0]), hex: '0x4020000000000000' }),
|
|
1239
1309
|
]);
|
|
1240
1310
|
|
|
1241
1311
|
export class DeterministicMathConflictError extends Error {
|
|
@@ -259,6 +259,9 @@ export function createDeterministicMath(fixedScale = 1_000, minFixed = DEFAULT_M
|
|
|
259
259
|
const poly = mulFixed(f, c1 - mulFixed(f, c2 - mulFixed(f, c3)));
|
|
260
260
|
return e * fixedScale + poly;
|
|
261
261
|
},
|
|
262
|
+
pow(base, exp) {
|
|
263
|
+
return pow(base, exp);
|
|
264
|
+
},
|
|
262
265
|
log(value) {
|
|
263
266
|
assertFixed(value);
|
|
264
267
|
if (value <= 0) {
|
|
@@ -544,6 +547,71 @@ function saturate(value, min, max) {
|
|
|
544
547
|
function normalizeZero(value) {
|
|
545
548
|
return Object.is(value, -0) ? 0 : value;
|
|
546
549
|
}
|
|
550
|
+
export function pow(base, exp) {
|
|
551
|
+
if (exp === 0.0)
|
|
552
|
+
return 1.0;
|
|
553
|
+
if (exp !== exp)
|
|
554
|
+
return NaN;
|
|
555
|
+
if (base !== base)
|
|
556
|
+
return NaN;
|
|
557
|
+
const ax = Math.abs(base);
|
|
558
|
+
if (ax === 1.0 && (exp === Infinity || exp === -Infinity))
|
|
559
|
+
return NaN;
|
|
560
|
+
const isInt = Math.floor(exp) === exp && Math.abs(exp) < 9007199254740992;
|
|
561
|
+
const isOdd = isInt && (exp % 2 !== 0);
|
|
562
|
+
if (base === 0.0) {
|
|
563
|
+
const isNegZero = (1.0 / base) === -Infinity;
|
|
564
|
+
if (exp > 0.0) {
|
|
565
|
+
return (isNegZero && isOdd) ? -0.0 : 0.0;
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
return (isNegZero && isOdd) ? -Infinity : Infinity;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
if (exp === Infinity) {
|
|
572
|
+
return ax > 1.0 ? Infinity : 0.0;
|
|
573
|
+
}
|
|
574
|
+
if (exp === -Infinity) {
|
|
575
|
+
return ax > 1.0 ? 0.0 : Infinity;
|
|
576
|
+
}
|
|
577
|
+
if (base === Infinity) {
|
|
578
|
+
return exp > 0.0 ? Infinity : 0.0;
|
|
579
|
+
}
|
|
580
|
+
if (base === -Infinity) {
|
|
581
|
+
if (exp > 0.0)
|
|
582
|
+
return isOdd ? -Infinity : Infinity;
|
|
583
|
+
return isOdd ? -0.0 : 0.0;
|
|
584
|
+
}
|
|
585
|
+
if (base < 0.0) {
|
|
586
|
+
if (!isInt)
|
|
587
|
+
return NaN;
|
|
588
|
+
const absX = -base;
|
|
589
|
+
const sign = isOdd ? -1.0 : 1.0;
|
|
590
|
+
let res = 1.0;
|
|
591
|
+
let b = absX;
|
|
592
|
+
let e = Math.abs(exp);
|
|
593
|
+
while (e > 0) {
|
|
594
|
+
if (e % 2 === 1)
|
|
595
|
+
res *= b;
|
|
596
|
+
b *= b;
|
|
597
|
+
e = Math.floor(e / 2);
|
|
598
|
+
}
|
|
599
|
+
return exp < 0 ? sign * (1.0 / res) : sign * res;
|
|
600
|
+
}
|
|
601
|
+
if (isInt) {
|
|
602
|
+
let res = 1.0;
|
|
603
|
+
let b = base;
|
|
604
|
+
let e = Math.abs(exp);
|
|
605
|
+
while (e > 0) {
|
|
606
|
+
if (e % 2 === 1)
|
|
607
|
+
res *= b;
|
|
608
|
+
b *= b;
|
|
609
|
+
e = Math.floor(e / 2);
|
|
610
|
+
}
|
|
611
|
+
return exp < 0 ? 1.0 / res : res;
|
|
612
|
+
}
|
|
613
|
+
return Math.exp(exp * Math.log(base));
|
|
614
|
+
}
|
|
547
615
|
export class DeterministicRandom {
|
|
548
616
|
state;
|
|
549
617
|
constructor(seed) {
|
|
@@ -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.
|
|
26
|
+
"packageVersion": "6.0.0-rc.33",
|
|
27
27
|
"compilerFlags": [
|
|
28
28
|
"-std=c++20",
|
|
29
29
|
"-O3",
|