@series-inc/rundot-syncplay 6.0.0-rc.81 → 6.0.0-rc.83
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/README.md +1 -1
- package/core/native/physics/box3d_adapter.cpp +3 -3
- package/core/native/physics/box3d_adapter.hpp +3 -5
- package/core/native/physics/box3d_deformable.cpp +3 -3
- package/core/native/physics/box3d_portal.cpp +2 -2
- package/core/native/physics/box3d_portal.hpp +1 -1
- package/core/native/physics/box3d_world_backend.cpp +43 -47
- package/core/native/physics/deformable_geometry.hpp +8 -8
- package/core/native/physics/world.cpp +3 -3
- package/core/native/physics/world.hpp +7 -8
- package/core/native/physics/world_abi.cpp +2 -2
- package/core/scripts/build-box3d-adapter.mjs +2 -1
- package/core/scripts/build-box3d-host-filter-ccd.mjs +2 -1
- package/core/scripts/build-box3d-kcc-vehicle.mjs +2 -1
- package/core/scripts/build-box3d-pair-filters.mjs +2 -1
- package/core/scripts/build-box3d-portal.mjs +2 -1
- package/core/scripts/build-box3d-support-substeps.mjs +2 -1
- package/core/scripts/build-native.mjs +2 -1
- package/core/scripts/build-wasm-physics.mjs +2 -1
- package/core/src/physics/physics-profile-wasm-module.generated.mjs +3 -3
- package/core/src/physics/physics-wasm-module.generated.mjs +3 -3
- package/core/src/physics/world.mjs +1 -1
- package/core/src/physics2d/physics2d-wasm-module.generated.mjs +1 -1
- package/core/world.d.ts +9 -0
- package/dist/extractionFingerprint.d.ts +1 -0
- package/dist/extractionFingerprint.js +30 -0
- package/dist/modules/extraction.d.ts +1 -0
- package/dist/modules/extraction.js +6 -1
- package/dist/node.d.ts +1 -0
- package/dist/node.js +1 -0
- package/dist/physics/3d.js +48 -20
- package/dist/physics/native-error-code.js +1 -1
- package/package.json +16 -5
- package/third_party/box3d/LICENSE +21 -0
- package/third_party/box3d/PROVENANCE.md +192 -0
- package/third_party/box3d/UPSTREAM.json +20 -0
- package/third_party/box3d/port/c-sources.txt +54 -0
- package/third_party/box3d/port/syncplay-sources.txt +7 -0
- package/third_party/box3d/port/test-sources.txt +36 -0
- package/third_party/box3d/scripts/box3d-profile.mjs +185 -0
- package/third_party/box3d/tree/include/box3d/base.h +206 -0
- package/third_party/box3d/tree/include/box3d/box3d.h +1968 -0
- package/third_party/box3d/tree/include/box3d/collision.h +692 -0
- package/third_party/box3d/tree/include/box3d/config.h +33 -0
- package/third_party/box3d/tree/include/box3d/constants.h +146 -0
- package/third_party/box3d/tree/include/box3d/id.h +179 -0
- package/third_party/box3d/tree/include/box3d/math_functions.h +1220 -0
- package/third_party/box3d/tree/include/box3d/types.h +3251 -0
- package/third_party/box3d/tree/src/CMakeLists.txt +324 -0
- package/third_party/box3d/tree/src/aabb.c +176 -0
- package/third_party/box3d/tree/src/aabb.h +80 -0
- package/third_party/box3d/tree/src/algorithm.h +19 -0
- package/third_party/box3d/tree/src/arena_allocator.c +178 -0
- package/third_party/box3d/tree/src/arena_allocator.h +114 -0
- package/third_party/box3d/tree/src/bitset.c +66 -0
- package/third_party/box3d/tree/src/bitset.h +67 -0
- package/third_party/box3d/tree/src/block_allocator.c +95 -0
- package/third_party/box3d/tree/src/block_allocator.h +36 -0
- package/third_party/box3d/tree/src/body.c +2729 -0
- package/third_party/box3d/tree/src/body.h +303 -0
- package/third_party/box3d/tree/src/box3d.natvis +147 -0
- package/third_party/box3d/tree/src/box3d.pc.in +11 -0
- package/third_party/box3d/tree/src/broad_phase.c +823 -0
- package/third_party/box3d/tree/src/broad_phase.h +66 -0
- package/third_party/box3d/tree/src/capsule.c +385 -0
- package/third_party/box3d/tree/src/compound.c +1208 -0
- package/third_party/box3d/tree/src/compound.h +25 -0
- package/third_party/box3d/tree/src/constraint_graph.c +328 -0
- package/third_party/box3d/tree/src/constraint_graph.h +79 -0
- package/third_party/box3d/tree/src/contact.c +912 -0
- package/third_party/box3d/tree/src/contact.h +194 -0
- package/third_party/box3d/tree/src/contact_solver.c +1237 -0
- package/third_party/box3d/tree/src/contact_solver.h +122 -0
- package/third_party/box3d/tree/src/contact_solver_wide.inl +1670 -0
- package/third_party/box3d/tree/src/container.h +185 -0
- package/third_party/box3d/tree/src/convex_manifold.c +1602 -0
- package/third_party/box3d/tree/src/convex_manifold_wide.inl +825 -0
- package/third_party/box3d/tree/src/core.c +303 -0
- package/third_party/box3d/tree/src/core.h +189 -0
- package/third_party/box3d/tree/src/ctz.h +134 -0
- package/third_party/box3d/tree/src/distance.c +1954 -0
- package/third_party/box3d/tree/src/distance_joint.c +585 -0
- package/third_party/box3d/tree/src/dynamic_tree.c +2525 -0
- package/third_party/box3d/tree/src/dynamic_tree.h +113 -0
- package/third_party/box3d/tree/src/height_field.c +1629 -0
- package/third_party/box3d/tree/src/hull.c +3226 -0
- package/third_party/box3d/tree/src/hull.h +30 -0
- package/third_party/box3d/tree/src/id_pool.c +73 -0
- package/third_party/box3d/tree/src/id_pool.h +34 -0
- package/third_party/box3d/tree/src/island.c +735 -0
- package/third_party/box3d/tree/src/island.h +101 -0
- package/third_party/box3d/tree/src/joint.c +2324 -0
- package/third_party/box3d/tree/src/joint.h +661 -0
- package/third_party/box3d/tree/src/manifold.c +196 -0
- package/third_party/box3d/tree/src/manifold.h +92 -0
- package/third_party/box3d/tree/src/math_functions.c +616 -0
- package/third_party/box3d/tree/src/math_internal.h +471 -0
- package/third_party/box3d/tree/src/mesh.c +2481 -0
- package/third_party/box3d/tree/src/mesh_contact.c +1338 -0
- package/third_party/box3d/tree/src/motor_joint.c +420 -0
- package/third_party/box3d/tree/src/mover.c +70 -0
- package/third_party/box3d/tree/src/mover_joint.c +288 -0
- package/third_party/box3d/tree/src/name_cache.c +155 -0
- package/third_party/box3d/tree/src/name_cache.h +42 -0
- package/third_party/box3d/tree/src/parallel_for.c +138 -0
- package/third_party/box3d/tree/src/parallel_for.h +23 -0
- package/third_party/box3d/tree/src/parallel_joint.c +254 -0
- package/third_party/box3d/tree/src/physics_world.c +4429 -0
- package/third_party/box3d/tree/src/physics_world.h +369 -0
- package/third_party/box3d/tree/src/platform.h +165 -0
- package/third_party/box3d/tree/src/pogo_joint.c +451 -0
- package/third_party/box3d/tree/src/prismatic_joint.c +720 -0
- package/third_party/box3d/tree/src/qsort.h +186 -0
- package/third_party/box3d/tree/src/rapidhash.h +568 -0
- package/third_party/box3d/tree/src/recording.c +1250 -0
- package/third_party/box3d/tree/src/recording.h +390 -0
- package/third_party/box3d/tree/src/recording_ops.inl +254 -0
- package/third_party/box3d/tree/src/replay.c +3791 -0
- package/third_party/box3d/tree/src/replay.h +286 -0
- package/third_party/box3d/tree/src/revolute_joint.c +672 -0
- package/third_party/box3d/tree/src/scheduler.c +198 -0
- package/third_party/box3d/tree/src/scheduler.h +15 -0
- package/third_party/box3d/tree/src/sensor.c +451 -0
- package/third_party/box3d/tree/src/sensor.h +41 -0
- package/third_party/box3d/tree/src/shape.c +2448 -0
- package/third_party/box3d/tree/src/shape.h +206 -0
- package/third_party/box3d/tree/src/simd.c +310 -0
- package/third_party/box3d/tree/src/simd.h +401 -0
- package/third_party/box3d/tree/src/simd_avx2.h +208 -0
- package/third_party/box3d/tree/src/simd_neon.h +265 -0
- package/third_party/box3d/tree/src/simd_scalar.h +286 -0
- package/third_party/box3d/tree/src/simd_sse2.h +411 -0
- package/third_party/box3d/tree/src/simd_wide.h +67 -0
- package/third_party/box3d/tree/src/six_dof_joint.c +1257 -0
- package/third_party/box3d/tree/src/solver.c +2380 -0
- package/third_party/box3d/tree/src/solver.h +314 -0
- package/third_party/box3d/tree/src/solver_set.c +682 -0
- package/third_party/box3d/tree/src/solver_set.h +67 -0
- package/third_party/box3d/tree/src/sphere.c +247 -0
- package/third_party/box3d/tree/src/spherical_joint.c +738 -0
- package/third_party/box3d/tree/src/syncplay_contact.c +186 -0
- package/third_party/box3d/tree/src/syncplay_contact.h +97 -0
- package/third_party/box3d/tree/src/syncplay_digest.c +24 -0
- package/third_party/box3d/tree/src/syncplay_digest.h +31 -0
- package/third_party/box3d/tree/src/syncplay_impact.c +67 -0
- package/third_party/box3d/tree/src/syncplay_impact.h +71 -0
- package/third_party/box3d/tree/src/syncplay_six_dof.h +103 -0
- package/third_party/box3d/tree/src/syncplay_snapshot.c +937 -0
- package/third_party/box3d/tree/src/syncplay_snapshot.h +266 -0
- package/third_party/box3d/tree/src/table.c +238 -0
- package/third_party/box3d/tree/src/table.h +74 -0
- package/third_party/box3d/tree/src/timer.c +834 -0
- package/third_party/box3d/tree/src/triangle_manifold.c +1334 -0
- package/third_party/box3d/tree/src/types.c +159 -0
- package/third_party/box3d/tree/src/verstable.h +2069 -0
- package/third_party/box3d/tree/src/weld_joint.c +304 -0
- package/third_party/box3d/tree/src/wheel_joint.c +1124 -0
- package/third_party/box3d/tree/src/wide4.c +6 -0
- package/third_party/box3d/tree/src/wide8.c +23 -0
- package/third_party/box3d/tree/src/world_snapshot.c +1739 -0
- package/third_party/box3d/tree/src/world_snapshot.h +21 -0
- package/third_party/lzma/README.md +29 -0
- package/third_party/lzma/src/7zTypes.h +600 -0
- package/third_party/lzma/src/Alloc.c +774 -0
- package/third_party/lzma/src/Alloc.h +76 -0
- package/third_party/lzma/src/Compiler.h +287 -0
- package/third_party/lzma/src/CpuArch.c +970 -0
- package/third_party/lzma/src/CpuArch.h +719 -0
- package/third_party/lzma/src/LzFind.c +1746 -0
- package/third_party/lzma/src/LzFind.h +160 -0
- package/third_party/lzma/src/LzHash.h +34 -0
- package/third_party/lzma/src/LzmaDec.c +1367 -0
- package/third_party/lzma/src/LzmaDec.h +237 -0
- package/third_party/lzma/src/LzmaEnc.c +3154 -0
- package/third_party/lzma/src/LzmaEnc.h +85 -0
- package/third_party/lzma/src/LzmaLib.c +42 -0
- package/third_party/lzma/src/LzmaLib.h +138 -0
- package/third_party/lzma/src/Precomp.h +127 -0
package/README.md
CHANGED
|
@@ -566,7 +566,7 @@ layout, WASM boundary, schedule, and checkpoint representation can change when
|
|
|
566
566
|
a complete benchmark proves a faster design. Each replacement must keep the
|
|
567
567
|
public contract, deterministic results, rollback controls, and bounded memory.
|
|
568
568
|
|
|
569
|
-
Version 6.0.0-rc.81 runs 3D physics on the soft-step engine, with physics ABI 26
|
|
569
|
+
Version 6.0.0-rc.82 (the same physics as 6.0.0-rc.81) runs 3D physics on the soft-step engine, with physics ABI 26
|
|
570
570
|
and digest algorithm revision 4. A world with a mesh above 512 triangles or a
|
|
571
571
|
heightfield above 2,048 triangles still runs on the public solver.
|
|
572
572
|
`world.rigidRouteState?.()` tells which route the next step uses.
|
|
@@ -563,7 +563,7 @@ struct WorldSlot {
|
|
|
563
563
|
// The step images (syncplay_adapter_step_image_save) that a rollback can still restore. While one is held, an
|
|
564
564
|
// empty extent stays, as it does for a world that holds checkpoints, so the image can restore. Unlike
|
|
565
565
|
// checkpointsCreated it changes nothing that outlives the image: the extent size and the state that a capture
|
|
566
|
-
// writes stay as on a peer that saved no image
|
|
566
|
+
// writes stay as on a peer that saved no image.
|
|
567
567
|
std::uint32_t stepImagePins = 0;
|
|
568
568
|
const char* faultReason = nullptr;
|
|
569
569
|
const char* faultFile = nullptr;
|
|
@@ -1114,7 +1114,7 @@ void adapterFree(void* memory, std::size_t size) {
|
|
|
1114
1114
|
}
|
|
1115
1115
|
|
|
1116
1116
|
// The allocation failure handler of b3Alloc (syncplay_set_allocation_failure). Box3D writes through every pointer
|
|
1117
|
-
// that b3Alloc returns, so a failed allocation must leave the Box3D call
|
|
1117
|
+
// that b3Alloc returns, so a failed allocation must leave the Box3D call. It throws
|
|
1118
1118
|
// std::bad_alloc through the C frames (each C unit has unwind tables: -fexceptions natively, wasm exceptions in the
|
|
1119
1119
|
// module), and the adapter and backend boundaries report it as an allocation failure. A write leaves its Box3D
|
|
1120
1120
|
// world half done, so the handler marks the world (a fault that needs a restore: the backend rolls the step image
|
|
@@ -6185,7 +6185,7 @@ std::int32_t syncplay_adapter_world_step(std::uint32_t slot, double timeStep,
|
|
|
6185
6185
|
const std::int32_t reserveStatus =
|
|
6186
6186
|
reserveBytes(*world, 65536 + world->jointCount * 4096);
|
|
6187
6187
|
if (reserveStatus != kSyncplayAdapterOk) return reserveStatus;
|
|
6188
|
-
// The heap buffers of the step, before its first write
|
|
6188
|
+
// The heap buffers of the step, before its first write: an allocation failure
|
|
6189
6189
|
// here throws before the step changes the world or its step state (inStep), so the caller's image restores.
|
|
6190
6190
|
reserveFirstImpacts(*world);
|
|
6191
6191
|
// The step-total joint reaction accumulator of the fork (syncplay_snapshot.h). The fork clears the
|
|
@@ -533,8 +533,7 @@ std::int32_t syncplay_adapter_filter_policy_clear(std::uint32_t slot);
|
|
|
533
533
|
// Rolling resistance and surface velocity are published by the resolver and reach the solver
|
|
534
534
|
// through the shape surface material of each body: Box3D takes the greater rolling resistance of
|
|
535
535
|
// the two shapes, and it subtracts the two shape surface velocities. A rule value of those two
|
|
536
|
-
// channels is therefore a resolved value of the contact record, not a per-contact override.
|
|
537
|
-
// fanout/adapter-features/adapter-features-notes.md.
|
|
536
|
+
// channels is therefore a resolved value of the contact record, not a per-contact override.
|
|
538
537
|
std::uint32_t syncplay_adapter_max_materials(); // 256
|
|
539
538
|
std::uint32_t syncplay_adapter_material_stride(); // 8
|
|
540
539
|
std::uint32_t syncplay_adapter_max_contact_rules(); // 256
|
|
@@ -881,7 +880,7 @@ std::int32_t syncplay_adapter_joint_remove(std::uint32_t slot, std::uint32_t log
|
|
|
881
880
|
// keeps no limit, as the public joint record.
|
|
882
881
|
//
|
|
883
882
|
// Four mappings of the public record decide the answer of the joint kinds beyond the six that the
|
|
884
|
-
// record first served
|
|
883
|
+
// record first served:
|
|
885
884
|
// - A motor joint applies both velocity drives without an enable flag: the public encoder writes
|
|
886
885
|
// the drive into slots 26 to 29 and 30 to 33 and no flag bit, and a cap of 0 applies no force in
|
|
887
886
|
// both engines.
|
|
@@ -900,8 +899,7 @@ std::int32_t syncplay_adapter_joint_remove(std::uint32_t slot, std::uint32_t log
|
|
|
900
899
|
// (physics.cpp relativeJointAngle applies no reference), so the frame of a wheel joint stays the
|
|
901
900
|
// identity pose.
|
|
902
901
|
//
|
|
903
|
-
// Two mappings of the wheel and motor records close the last joint gaps
|
|
904
|
-
// (fanout/wheel-motor/wheel-motor-notes.md):
|
|
902
|
+
// Two mappings of the wheel and motor records close the last joint gaps:
|
|
905
903
|
// - The wheel frame. The public wheel record names one axis (slots 9 to 11) for the suspension and
|
|
906
904
|
// for the spin and steers about a perpendicular axis that physics.cpp stableJointBasis builds from
|
|
907
905
|
// that axis. The fork wheel joint suspends and spins about the x axis of its frame A and steers
|
|
@@ -1235,8 +1235,8 @@ std::int32_t deformableSdfRaycast(DeformableWorld* world, const double origin[3]
|
|
|
1235
1235
|
budget -= 1;
|
|
1236
1236
|
double value = 0.0;
|
|
1237
1237
|
bool hit = false;
|
|
1238
|
-
// The hit test value <= 0 is a decision: on a checked blend it is the sign of the exact blend
|
|
1239
|
-
//
|
|
1238
|
+
// The hit test value <= 0 is a decision: on a checked blend it is the sign of the exact blend,
|
|
1239
|
+
// not the sign of a rounded value.
|
|
1240
1240
|
const std::int32_t status = sdfSampleAt(world, point, &value, &hit);
|
|
1241
1241
|
if (status != kDeformableOk) return status;
|
|
1242
1242
|
if (hit) {
|
|
@@ -1632,7 +1632,7 @@ std::int32_t deformableFractureMesh(DeformableWorld* world, const double point[3
|
|
|
1632
1632
|
const Node& node = world->nodes[nodeIndex];
|
|
1633
1633
|
// Ordinary inputs keep the old test with the normalized direction (bit-equal; the division
|
|
1634
1634
|
// loses nothing there). Other inputs use the caller's normal through the guarded side test: the
|
|
1635
|
-
// division normal / |normal| can lose a component that decides the sign
|
|
1635
|
+
// division normal / |normal| can lose a component that decides the sign. Either way
|
|
1636
1636
|
// a failure comes before any cut.
|
|
1637
1637
|
bool side = false;
|
|
1638
1638
|
if (geometry::ordinary({normal, node.position, point})) {
|
|
@@ -1954,7 +1954,7 @@ std::int32_t portalSliceCheckpointRestore(Slice* slice, const void* buffer, std:
|
|
|
1954
1954
|
#endif // SP_PORTAL_COUNTER
|
|
1955
1955
|
|
|
1956
1956
|
// -------------------------------------------------------------------------------------------------
|
|
1957
|
-
// The public step-driven slice
|
|
1957
|
+
// The public step-driven slice. JS owns the portal
|
|
1958
1958
|
// meaning and every crossing; this block only couples the planned proxies and keeps the registry.
|
|
1959
1959
|
// -------------------------------------------------------------------------------------------------
|
|
1960
1960
|
|
|
@@ -1986,7 +1986,7 @@ struct StepRow {
|
|
|
1986
1986
|
};
|
|
1987
1987
|
|
|
1988
1988
|
// The public step-driven slice. It holds no crossing history, no chart and no plane side: those are
|
|
1989
|
-
// JS state
|
|
1989
|
+
// JS state.
|
|
1990
1990
|
struct StepSlice {
|
|
1991
1991
|
bool inUse = false;
|
|
1992
1992
|
std::uint32_t slot = 0;
|
|
@@ -113,7 +113,7 @@ struct BodyShape {
|
|
|
113
113
|
// solved on the body's ghost in the entry chart (endA of the pair), so the body behaves like a
|
|
114
114
|
// direct pendulum when the ghost is mapped back.
|
|
115
115
|
|
|
116
|
-
// The public step-driven slice
|
|
116
|
+
// The public step-driven slice.
|
|
117
117
|
//
|
|
118
118
|
// JS owns the portal meaning and every crossing. This layer only couples: it creates the planned
|
|
119
119
|
// proxy bodies, couples them in the pre-solve hook, and removes them. It never detects a crossing
|
|
@@ -92,13 +92,13 @@ struct BackendMirror {
|
|
|
92
92
|
// The mirror numbers its joints in the order of the public joint list of the state that it last built,
|
|
93
93
|
// stepped or restored. An edit changes the public list at once and the adapter joints at the next step,
|
|
94
94
|
// so a read between the two maps a joint by its id through this list and never by its current public
|
|
95
|
-
// position
|
|
95
|
+
// position. It is set wherever adapter joints get their numbers: the
|
|
96
96
|
// build, the end of a step (after the joint breaks), and the restore (adoptRestoredState).
|
|
97
97
|
std::vector<JointId> jointIds;
|
|
98
98
|
// The joints of jointIds that a topology edit replaced since the last step (the edit rule that resets the warm
|
|
99
99
|
// record, World::stagePreparedTopologyEdit), sorted by id, each with the revision of its edit. Box3D makes a
|
|
100
100
|
// replaced joint a new joint at the next step, so it has no motor force of the last step, with or without warm
|
|
101
|
-
// starting
|
|
101
|
+
// starting. A step and a build clear the list; a capture of a stale mirror carries it; a step
|
|
102
102
|
// transaction rollback drops the marks of its own edits (rebaseRevision).
|
|
103
103
|
std::vector<std::pair<JointId, std::uint64_t>> replacedJoints;
|
|
104
104
|
// Set by restoreCanonicalImage when the identity record of a stale image carried its own joint list,
|
|
@@ -151,7 +151,7 @@ struct BackendMirror {
|
|
|
151
151
|
std::vector<std::uint64_t> filterFlagShapes;
|
|
152
152
|
// The portal slices of this mirror, one per pair, in pair-ordinal order. The backend owns their
|
|
153
153
|
// whole lifecycle: it creates them before a covered step, applies the JS plan, and destroys them
|
|
154
|
-
// before the adapter world goes away
|
|
154
|
+
// before the adapter world goes away.
|
|
155
155
|
std::vector<portal::StepSlice*> portalSlices;
|
|
156
156
|
std::vector<std::uint32_t> portalPairIds;
|
|
157
157
|
// The proxies of a query world that serve no read (copyPortalSlices): a copied proxy whose source
|
|
@@ -205,7 +205,7 @@ std::int32_t openMirrorSlice(BackendMirror& mirror, std::uint32_t slot, std::uin
|
|
|
205
205
|
void dropMirror(BackendMirror& mirror) {
|
|
206
206
|
// The adapter world goes below with every proxy body of the slices, so the slices are forgotten, not destroyed: a
|
|
207
207
|
// body removal can allocate in Box3D (a freed id grows the free list), and a drop runs in cleanup paths (a step
|
|
208
|
-
// rollback, a restore commit) that cannot fail
|
|
208
|
+
// rollback, a restore commit) that cannot fail.
|
|
209
209
|
forgetPortalSlices(mirror);
|
|
210
210
|
mirror.portalPairIds.clear();
|
|
211
211
|
mirror.retiredProxies.clear();
|
|
@@ -928,8 +928,7 @@ const char* jointRouteRestriction(const double* record, std::size_t width,
|
|
|
928
928
|
const std::uint32_t kind = static_cast<std::uint32_t>(kindValue);
|
|
929
929
|
// The record path serves the joints whose Box3D expression matches the public record: distance,
|
|
930
930
|
// prismatic, revolute, spherical, weld, filter, motor, parallel, wheel, pogo and mover. A kind that
|
|
931
|
-
// still carries a measured difference keeps the public solver
|
|
932
|
-
// backend-features-notes.md section 3 and fanout/joint-record-gaps/joint-record-gaps-notes.md).
|
|
931
|
+
// still carries a measured difference keeps the public solver.
|
|
933
932
|
if (kind == 1u || kind == 5u || kind == 6u || kind == 7u || kind == 8u) {
|
|
934
933
|
const std::uint32_t flags = static_cast<std::uint32_t>(record[19]);
|
|
935
934
|
const bool spring = (flags & (64u | 256u | 512u | 16384u)) != 0;
|
|
@@ -968,8 +967,8 @@ const char* jointRouteRestriction(const double* record, std::size_t width,
|
|
|
968
967
|
// A wheel record is served: the fork wheel joint suspends and spins about the x axis of frame A
|
|
969
968
|
// and steers about its z axis (wheel_joint.c), and the adapter turns frame x onto the record axis
|
|
970
969
|
// and frame z onto the perpendicular axis that the public solver steers about (physics.cpp
|
|
971
|
-
// stableJointBasis, box3d_adapter.cpp wheelFrameRotation).
|
|
972
|
-
//
|
|
970
|
+
// stableJointBasis, box3d_adapter.cpp wheelFrameRotation). The two engines agree on
|
|
971
|
+
// this mapping (measured). Two spring shapes keep the public solver:
|
|
973
972
|
const std::uint32_t flags = static_cast<std::uint32_t>(record[19]);
|
|
974
973
|
// A suspension spring with a positive force cap (bit 131072 with slot 43) is clamped by the public
|
|
975
974
|
// row to maxSpringForce * h (physics.cpp constraintSoftness), and b3WheelJoint has no suspension
|
|
@@ -1250,7 +1249,7 @@ BackendResult installFluidRows(std::uint32_t slot, const std::vector<BackendFlui
|
|
|
1250
1249
|
return BackendResult::ok;
|
|
1251
1250
|
}
|
|
1252
1251
|
|
|
1253
|
-
// --- The public contact-material policy
|
|
1252
|
+
// --- The public contact-material policy ---------------------------------------------------------
|
|
1254
1253
|
//
|
|
1255
1254
|
// The public world carries one immutable material table and one ordered rule list. The adapter takes
|
|
1256
1255
|
// both as the public record layouts, so the backend copies the rows it already holds:
|
|
@@ -1393,7 +1392,7 @@ BackendResult installMaterialRows(std::uint32_t slot, const BackendMaterialRows&
|
|
|
1393
1392
|
return BackendResult::ok;
|
|
1394
1393
|
}
|
|
1395
1394
|
|
|
1396
|
-
// --- The public one-way rule channel
|
|
1395
|
+
// --- The public one-way rule channel ------------------------------------------------------------
|
|
1397
1396
|
//
|
|
1398
1397
|
// A body whose assignment carries kBodyFilterOneWay keeps a contact only when the contact normal,
|
|
1399
1398
|
// taken from that body toward the other body, has a dot product of at least the minimum cosine with
|
|
@@ -1426,7 +1425,7 @@ BackendResult installOneWayRows(std::uint32_t slot, const BackendMirror& mirror,
|
|
|
1426
1425
|
return BackendResult::ok;
|
|
1427
1426
|
}
|
|
1428
1427
|
|
|
1429
|
-
// --- The public pair-filter step inputs
|
|
1428
|
+
// --- The public pair-filter step inputs --------------------------------------------------------
|
|
1430
1429
|
//
|
|
1431
1430
|
// The public world holds four inputs that decide a body pair or a shape pair: the contact exclusions
|
|
1432
1431
|
// of `setContactExclusions` and `setContactRules`, the restricted bodies, allowed pairs and contact
|
|
@@ -1896,8 +1895,8 @@ bool filterFlagsServed(const std::vector<std::uint64_t>& installed,
|
|
|
1896
1895
|
// The shapes of the adapter world of `mirror` that carry the custom-filtering flag, packed as filterFlagKey and
|
|
1897
1896
|
// sorted. Box3D is the one source of the flag: it keeps the flag with the shape, and a canonical image carries it.
|
|
1898
1897
|
// So the list of a mirror is this read after every change of its shapes (a build, an edit in place, a restore), and
|
|
1899
|
-
// a restored peer holds the list of the peer that captured the image (
|
|
1900
|
-
//
|
|
1898
|
+
// a restored peer holds the list of the peer that captured the image (with an empty list, a restored mirror
|
|
1899
|
+
// rebuilds at its first step where the producer reuses its own mirror, and the runs split). A body
|
|
1901
1900
|
// that the mirror does not hold (a portal proxy) has no public index and no key. False: the read failed.
|
|
1902
1901
|
bool readFilterFlagShapes(const BackendMirror& mirror, std::vector<std::uint64_t>& out) {
|
|
1903
1902
|
std::uint32_t count = 0;
|
|
@@ -1920,7 +1919,7 @@ bool readFilterFlagShapes(const BackendMirror& mirror, std::vector<std::uint64_t
|
|
|
1920
1919
|
return true;
|
|
1921
1920
|
}
|
|
1922
1921
|
|
|
1923
|
-
// --- The public support channel
|
|
1922
|
+
// --- The public support channel -----------------------------------------------------------------
|
|
1924
1923
|
//
|
|
1925
1924
|
// The public queue of the next tick (WorldState::tickSupports) is body-local, and the adapter channel
|
|
1926
1925
|
// is world space. The backend rebuilds one world point and one world normal per row from the current
|
|
@@ -1989,7 +1988,7 @@ std::array<double, 3> backendSupportRotate(const std::array<double, 4>& q,
|
|
|
1989
1988
|
}
|
|
1990
1989
|
|
|
1991
1990
|
// True when a body of the row allows fast rotation. Box3D clamps the angular speed at 0.25 * pi per
|
|
1992
|
-
// tick
|
|
1991
|
+
// tick, and a public body with this flag has no
|
|
1993
1992
|
// clamp, so such a row stays on the public solver.
|
|
1994
1993
|
bool backendSupportFastRotation(const WorldState& source, std::size_t bodyStride, BodyId id) {
|
|
1995
1994
|
std::size_t index = 0;
|
|
@@ -2066,13 +2065,13 @@ bool decodeSupportSurfaceRows(const BackendMirror& mirror, const WorldState& sou
|
|
|
2066
2065
|
// than it holds.
|
|
2067
2066
|
// - `supports-body`: a row names a body that left the world after admission.
|
|
2068
2067
|
// - `supports-fast-rotation`: a row names a body that allows fast rotation. Box3D clamps the angular
|
|
2069
|
-
// speed at 0.25 * pi per tick
|
|
2068
|
+
// speed at 0.25 * pi per tick, and a public body
|
|
2070
2069
|
// with this flag has no clamp.
|
|
2071
2070
|
//
|
|
2072
2071
|
// The surface velocity of a row and the damping term of a multi-substep row are served and no longer
|
|
2073
2072
|
// restrict the route: the step installs the effective surface rows of the public state in the adapter
|
|
2074
2073
|
// surface channel, and it enables the per-substep sample, which the solver dispatches once per
|
|
2075
|
-
// substep
|
|
2074
|
+
// substep. See `supportStepStatus` for the codes that a
|
|
2076
2075
|
// routed step can still report.
|
|
2077
2076
|
const char* supportRouteRestriction(World& world, const WorldState& source, std::size_t bodyStride,
|
|
2078
2077
|
const StepOptions& options) {
|
|
@@ -2249,8 +2248,7 @@ BackendResult setSupportSubstepMode(std::uint32_t slot, bool perSubstep) {
|
|
|
2249
2248
|
return BackendResult::failed;
|
|
2250
2249
|
}
|
|
2251
2250
|
|
|
2252
|
-
// Maps the status of a support-channel step to the answer of this backend
|
|
2253
|
-
// notes, section 5.2).
|
|
2251
|
+
// Maps the status of a support-channel step to the answer of this backend.
|
|
2254
2252
|
//
|
|
2255
2253
|
// - `kSyncplayAdapterSupportWakeIsland` (20): the public rule wakes one body and Box3D wakes the
|
|
2256
2254
|
// solver set of the body. The adapter refused before it changed any state, so this is a route
|
|
@@ -2339,7 +2337,7 @@ BackendResult classifyRigidScene(World& world, const WorldState& source, const S
|
|
|
2339
2337
|
if (bodyCount == 0 || source.bodies.size() % bodyCount != 0) return restrictRigidRoute("body-rows");
|
|
2340
2338
|
bodyStride = source.bodies.size() / bodyCount;
|
|
2341
2339
|
if (bodyStride < kBodyStride) return restrictRigidRoute("body-stride");
|
|
2342
|
-
// The pair-filter step inputs
|
|
2340
|
+
// The pair-filter step inputs: the contact exclusions, the
|
|
2343
2341
|
// restricted bodies, allowed pairs and contact groups, and the shape exclusions. The decode serves
|
|
2344
2342
|
// every input that the adapter can express and reports its own reason for the rest.
|
|
2345
2343
|
{
|
|
@@ -2361,7 +2359,7 @@ BackendResult classifyRigidScene(World& world, const WorldState& source, const S
|
|
|
2361
2359
|
}
|
|
2362
2360
|
// A fluid scene serves every shape, including the round solids of revolution (cylinder, cone,
|
|
2363
2361
|
// tapered capsule): the adapter fluid section reads the solid of revolution itself instead of the
|
|
2364
|
-
// cooked hull
|
|
2362
|
+
// cooked hull, so the displacement is the exact round
|
|
2365
2363
|
// volume and it does not turn with the body.
|
|
2366
2364
|
}
|
|
2367
2365
|
if (!source.bodyMaterialFrames.empty()) return restrictRigidRoute("material-frame");
|
|
@@ -2389,7 +2387,7 @@ BackendResult classifyRigidScene(World& world, const WorldState& source, const S
|
|
|
2389
2387
|
}
|
|
2390
2388
|
// The contact-material policy. The adapter takes the whole public table and the whole public rule
|
|
2391
2389
|
// list in the public layouts, so a combine mode, a priority order, a partial rule, a rolling or a
|
|
2392
|
-
// surface override is served
|
|
2390
|
+
// surface override is served. What stays restricted is
|
|
2393
2391
|
// the record the adapter would refuse or cannot express:
|
|
2394
2392
|
const BackendMaterialRows materialRows = decodeMaterialRows(world);
|
|
2395
2393
|
if (!materialRows.valid) return restrictRigidRoute(materialRows.reason);
|
|
@@ -2448,7 +2446,7 @@ BackendResult classifyRigidScene(World& world, const WorldState& source, const S
|
|
|
2448
2446
|
return BackendResult::ok;
|
|
2449
2447
|
}
|
|
2450
2448
|
|
|
2451
|
-
// --- The public portal route
|
|
2449
|
+
// --- The public portal route ---------------------------------------------------------------
|
|
2452
2450
|
//
|
|
2453
2451
|
// JS owns every portal meaning. The backend only decides whether this scene can run on the slice
|
|
2454
2452
|
// route, and then it creates the planned proxies and couples them. The preflight and the step call
|
|
@@ -2467,8 +2465,8 @@ constexpr std::uint32_t kPortalImageMagic = 0x52543250u; // "P2TR"
|
|
|
2467
2465
|
// They decide whether a woken survivor may sleep in the next steps. A restore inside the wake
|
|
2468
2466
|
// window without them let the survivors sleep early, and the replay left the run that captured.
|
|
2469
2467
|
// - kBackendStateNeverStepped: the adapter world did not step since it was built. The image of
|
|
2470
|
-
// such a world does not continue it exactly
|
|
2471
|
-
//
|
|
2468
|
+
// such a world does not continue it exactly, and a
|
|
2469
|
+
// rebuild does, so the restore rebuilds. Every other image continues, with or
|
|
2472
2470
|
// without contacts.
|
|
2473
2471
|
// - kBackendStateNoImage: the world has no built mirror. The section carries no inner image, and the
|
|
2474
2472
|
// restore leaves the world without a mirror, so its next step builds one, as the next step of the
|
|
@@ -2938,11 +2936,11 @@ void bodyWorldBounds(const double* body, double out[6]);
|
|
|
2938
2936
|
// Gives a mirror that a mirror-writing call built (ensureMirror) the bookkeeping that a restore of its capture
|
|
2939
2937
|
// derives, and replaces its adapter world by the canonical image of itself.
|
|
2940
2938
|
//
|
|
2941
|
-
// The canonical image of a world that never stepped does not continue a fresh build exactly
|
|
2942
|
-
//
|
|
2939
|
+
// The canonical image of a world that never stepped does not continue a fresh build exactly.
|
|
2940
|
+
// A mirror that a mirror-writing call builds is the state
|
|
2943
2941
|
// that a game can capture before the next step (a ragdoll group made at setup, for a late joiner), so such a mirror
|
|
2944
2942
|
// becomes an installed image at once: the producer and every peer that restores its capture continue from the same
|
|
2945
|
-
// image
|
|
2943
|
+
// image. The image carries the adapter state of the calls that follow (a ragdoll
|
|
2946
2944
|
// group, applied impulses). A call builds only where the step would build (syncMirrorToState): a world without a
|
|
2947
2945
|
// mirror, or a definition that the live world cannot take in place, so the install is not paid per tick.
|
|
2948
2946
|
//
|
|
@@ -3240,7 +3238,7 @@ bool saveMirrorImage(const BackendMirror& mirror, std::vector<std::uint8_t>& out
|
|
|
3240
3238
|
return true;
|
|
3241
3239
|
}
|
|
3242
3240
|
// A portal world carries the proxy registry next to the adapter image. The registry is the only
|
|
3243
|
-
// portal state of the image
|
|
3241
|
+
// portal state of the image: no chart, side, straddle or crossing is
|
|
3244
3242
|
// stored, because JS owns them.
|
|
3245
3243
|
output.reserve(image.size() + 64 + mirror.portalSlices.size() * 256);
|
|
3246
3244
|
StateWriter writer{output};
|
|
@@ -3548,7 +3546,7 @@ void releaseStagedMirror(Box3dBackendState& state) noexcept {
|
|
|
3548
3546
|
std::uint32_t restoreCanonicalImage(World& world, std::span<const std::uint8_t> bytes) noexcept {
|
|
3549
3547
|
if (bytes.empty() || bytes.size() > kBox3dCanonicalMaxBytes) return kBox3dCanonicalFailed;
|
|
3550
3548
|
// A portal image carries the adapter image and the proxy registry trailers. Parse the whole
|
|
3551
|
-
// structure before this call writes any adapter state
|
|
3549
|
+
// structure before this call writes any adapter state.
|
|
3552
3550
|
struct PortalTrailer {
|
|
3553
3551
|
std::uint32_t pairId = 0;
|
|
3554
3552
|
std::uint32_t ordinal = 0;
|
|
@@ -3658,7 +3656,7 @@ std::uint32_t restoreCanonicalImage(World& world, std::span<const std::uint8_t>
|
|
|
3658
3656
|
if (!staged) releaseStagedMirror(state);
|
|
3659
3657
|
}
|
|
3660
3658
|
} guard{state};
|
|
3661
|
-
// A failed Box3D allocation throws out of the adapter (adapterAllocationFailure
|
|
3659
|
+
// A failed Box3D allocation throws out of the adapter (adapterAllocationFailure). The staged world
|
|
3662
3660
|
// is aside, so the restore refuses: the guard drops the staged world, and the live mirror stays as it was.
|
|
3663
3661
|
try {
|
|
3664
3662
|
if (syncplay_adapter_world_create_ex(slot, 0.0, 0.0, 0.0, 1, 1.0, 3.0, 400.0, 30.0, 10.0, 0.2,
|
|
@@ -3679,7 +3677,7 @@ std::uint32_t restoreCanonicalImage(World& world, std::span<const std::uint8_t>
|
|
|
3679
3677
|
const std::uint32_t imageBodyCount = readU32(adapterBytes, 20);
|
|
3680
3678
|
mirror.hasRestoredImage = true;
|
|
3681
3679
|
// Every image continues, also the image of a mirror that never stepped: such a mirror is itself an installed
|
|
3682
|
-
// image on the producer (ensureMirror), so the two peers continue from the same image
|
|
3680
|
+
// image on the producer (ensureMirror), so the two peers continue from the same image.
|
|
3683
3681
|
mirror.steppedSinceBuild = imageStepped;
|
|
3684
3682
|
mirror.frame = 0;
|
|
3685
3683
|
mirror.signature = 0;
|
|
@@ -3841,7 +3839,7 @@ void prepareRestoredMirror(BackendMirror& mirror, World& world, const WorldState
|
|
|
3841
3839
|
const std::size_t bodyCount = source.topology.bodyIds.size();
|
|
3842
3840
|
if (bodyCount == 0 || source.bodies.size() % bodyCount != 0
|
|
3843
3841
|
|| source.bodies.size() / bodyCount < kBodyStride) {
|
|
3844
|
-
// A state that no routed step can serve (no body
|
|
3842
|
+
// A state that no routed step can serve (no body): the mirror is an image of no
|
|
3845
3843
|
// routed state. It still takes the bookkeeping that every other path writes, so a capture after an edit writes
|
|
3846
3844
|
// the same record on every peer, and its next step builds the mirror again (signature 0).
|
|
3847
3845
|
mirror.removalSleepVeto = std::move(mirror.restoredRemovalSleepVeto);
|
|
@@ -3912,7 +3910,7 @@ void prepareRestoredMirror(BackendMirror& mirror, World& world, const WorldState
|
|
|
3912
3910
|
mirror.noJoints = source.topology.joints.empty();
|
|
3913
3911
|
mirror.noSurfaceVelocities = source.surfaceVelocities.empty();
|
|
3914
3912
|
mirror.noFluids = source.topology.fluidIds.empty();
|
|
3915
|
-
// The bookkeeping of a mirror that stepped to this state
|
|
3913
|
+
// The bookkeeping of a mirror that stepped to this state. A peer that never
|
|
3916
3914
|
// restored holds, after its step, the frame, the signature of the definition and the step options, and the
|
|
3917
3915
|
// revision of the state that it published, and no other mark. The restore writes exactly these values
|
|
3918
3916
|
// (adoptRestoredState records the revision), so a capture after the next edit (writeMirrorIdentity) writes the
|
|
@@ -5969,7 +5967,7 @@ bool publishEditEndedPairs(World& world, const WorldState& source, WorldState& u
|
|
|
5969
5967
|
return true;
|
|
5970
5968
|
}
|
|
5971
5969
|
|
|
5972
|
-
// --- The failed step
|
|
5970
|
+
// --- The failed step -------------------------------------------------------------------------------------
|
|
5973
5971
|
//
|
|
5974
5972
|
// A routed step that does not publish leaves the world exactly as it was before the call: the public state,
|
|
5975
5973
|
// the live adapter world, the mirror bookkeeping and the staged step inputs. A game can catch the error,
|
|
@@ -6189,7 +6187,7 @@ struct StepRollback {
|
|
|
6189
6187
|
StepRollback(BackendMirror& target, World& owner) : mirror(target), world(owner) {}
|
|
6190
6188
|
|
|
6191
6189
|
// The first write of the step to the live world. The test phase (box3d_step_phase.hpp) is Live from here, so a
|
|
6192
|
-
//
|
|
6190
|
+
// reader finds the label at the write and not in a mark beside it.
|
|
6193
6191
|
void touchLive() noexcept {
|
|
6194
6192
|
liveTouched = true;
|
|
6195
6193
|
SYNCPLAY_PHASE_SET(static_cast<std::uint32_t>(Box3dStepPhase::Live));
|
|
@@ -6200,7 +6198,7 @@ struct StepRollback {
|
|
|
6200
6198
|
// Saves the live world before the first write. A failed save refuses the step before any change. The save
|
|
6201
6199
|
// reserves everything that the rollback needs (the slice records and the pointer list of the reopened slices,
|
|
6202
6200
|
// portalStepSliceStateSave; the adapter rows of the image, syncplay_adapter_step_image_save), so the rollback
|
|
6203
|
-
// allocates nothing
|
|
6201
|
+
// allocates nothing.
|
|
6204
6202
|
bool saveImage() {
|
|
6205
6203
|
std::uint32_t size = 0;
|
|
6206
6204
|
if (syncplay_adapter_step_image_size(mirror.slot, &size) != kSyncplayAdapterOk) return false;
|
|
@@ -6848,7 +6846,7 @@ BackendResult syncMirrorToState(World& world, const WorldState& source, const St
|
|
|
6848
6846
|
|
|
6849
6847
|
// The body of ensureMirror. A stale mirror (an edit since its last step) is brought to the public state by the sync of
|
|
6850
6848
|
// the step (syncMirrorToState), never dropped: a ragdoll group, the touching contacts, the sleep timers, the portal
|
|
6851
|
-
// slices and the warm start of the live world stay
|
|
6849
|
+
// slices and the warm start of the live world stay. The sync
|
|
6852
6850
|
// builds only where the step would build, and then carries what the step carries; a built mirror becomes its own
|
|
6853
6851
|
// installed image (installOwnImage). The call then holds a mirror of the public state, so the next step syncs
|
|
6854
6852
|
// nothing again, and the open keys that the sync did not continue wait for that step (BackendMirror::carriedTouching).
|
|
@@ -6944,7 +6942,7 @@ std::uint32_t ensureMirrorOrThrow(World& world, std::optional<StepRollback>* win
|
|
|
6944
6942
|
//
|
|
6945
6943
|
// The classifier, the sync and the build allocate (the material rows of the classifier, the touching reads of the
|
|
6946
6944
|
// sync, the mirror records of the build), so the body runs in ensureMirrorOrThrow and this boundary turns a throw
|
|
6947
|
-
// into a failed call
|
|
6945
|
+
// into a failed call. A throw after a live write of the sync unwinds its rollback
|
|
6948
6946
|
// record first (StepRollback: the image of the live world, or a world that needs a restore), and a throw inside a
|
|
6949
6947
|
// build leaves a mirror that is not built: the boundary drops it, so the next step or call builds it again from the
|
|
6950
6948
|
// public state, as the step of a peer whose call refused does. The public state is never written here.
|
|
@@ -7517,7 +7515,7 @@ BackendResult backendStep(World& world, const StepOptions& options) {
|
|
|
7517
7515
|
double values[6] = {};
|
|
7518
7516
|
// A six-DOF joint publishes its per-axis state into the record. The three standard blocks carry
|
|
7519
7517
|
// the definition and the state, so the row is a copy of the public record with slots 100 to 149
|
|
7520
|
-
// replaced
|
|
7518
|
+
// replaced.
|
|
7521
7519
|
if (record[0] == 10.0 && jointRowStride(record) == 3 * kJointStride) {
|
|
7522
7520
|
std::array<double, 55> stateRow{};
|
|
7523
7521
|
// Every public joint is the adapter joint index + 1 (buildBackendMirror), so a failed read is a mirror that
|
|
@@ -7564,8 +7562,7 @@ BackendResult backendStep(World& world, const StepOptions& options) {
|
|
|
7564
7562
|
// six-DOF joint on its force and torque thresholds only (world.cpp), and a locked axis of that
|
|
7565
7563
|
// record must not become a phantom 1 N.s threshold: measured before this guard, a six-DOF joint
|
|
7566
7564
|
// with locked X and Z axes and a motor on Y left the public topology on the first step with the
|
|
7567
|
-
// break reason `impulse`, and the joint id then failed to resolve
|
|
7568
|
-
// (fanout/six-dof-route/repro-joint-vanishes.mts).
|
|
7565
|
+
// break reason `impulse`, and the joint id then failed to resolve.
|
|
7569
7566
|
const bool sixDofRecord = record[0] == 10.0;
|
|
7570
7567
|
const std::uint32_t jointFlags = sixDofRecord ? 0u : static_cast<std::uint32_t>(record[19]);
|
|
7571
7568
|
const double breakImpulse =
|
|
@@ -7991,7 +7988,7 @@ BackendResult backendStep(World& world, const StepOptions& options) {
|
|
|
7991
7988
|
// impact, and the contact of that pair reaches the narrow phase only in the next step. The public
|
|
7992
7989
|
// contract reads the other way: a time-of-impact hit writes the contact row of the tick that owns
|
|
7993
7990
|
// the hit, with the impact point, the query normal and a zero penetration. The adapter collects
|
|
7994
|
-
// the rows from the fork hook
|
|
7991
|
+
// the rows from the fork hook.
|
|
7995
7992
|
//
|
|
7996
7993
|
// A narrow-phase begin row of the same pair in the same tick is replaced by the impact row: that
|
|
7997
7994
|
// row carries no point of its own when the pair never separated, and its penetration is the
|
|
@@ -8205,8 +8202,7 @@ BackendResult backendStep(World& world, const StepOptions& options) {
|
|
|
8205
8202
|
// The public joint warm record of the completed step. The Box3D joint keeps the impulses of the next
|
|
8206
8203
|
// step inside its own sim, so the record of this route carries the signature of the step that wrote it
|
|
8207
8204
|
// and no impulse. A standard joint beside a six-DOF joint therefore keeps its own signature, as it does
|
|
8208
|
-
// on the public solver, and a world that reads the record accepts it back on either route
|
|
8209
|
-
// (fanout/warm-signature-fix notes, section 2).
|
|
8205
|
+
// on the public solver, and a world that reads the record accepts it back on either route.
|
|
8210
8206
|
{
|
|
8211
8207
|
const double substepDuration = options.dtTicks / static_cast<double>(options.substeps);
|
|
8212
8208
|
const WorldError warmError = world.routedJointWarmState(
|
|
@@ -8867,7 +8863,7 @@ bool mirrorHoldsSupportBodies(World& world, const BackendMirror& mirror, const W
|
|
|
8867
8863
|
|
|
8868
8864
|
// The tick-start sample of the queued public support rows, taken by the adapter's own sampler, or
|
|
8869
8865
|
// false when no step of this world has built a mirror yet (the public formula answers then), or when
|
|
8870
|
-
// the backend does not serve the scene now. The read is a read
|
|
8866
|
+
// the backend does not serve the scene now. The read is a read: it takes the live mirror
|
|
8871
8867
|
// when that mirror holds every body that the sample reads (`mirrorHoldsSupportBodies`), otherwise the
|
|
8872
8868
|
// adapter world of `querySlot` (the query world of the public state after an edit), so the rows name
|
|
8873
8869
|
// the bodies that the public state names. It passes the rows to the sampler as arguments: no row goes
|
|
@@ -9125,7 +9121,7 @@ std::uint32_t box3dBackendCharacterStep(World& world, std::span<const double> co
|
|
|
9125
9121
|
}
|
|
9126
9122
|
|
|
9127
9123
|
// A call that writes the live adapter world without an image (a ragdoll edit, a vehicle step with impulses). A failed
|
|
9128
|
-
// Box3D allocation throws out of it (adapterAllocationFailure) and leaves that world half written
|
|
9124
|
+
// Box3D allocation throws out of it (adapterAllocationFailure) and leaves that world half written,
|
|
9129
9125
|
// so the world needs a restore: the mirror goes, and the call fails with NEEDS_RESTORE. A failed status after a
|
|
9130
9126
|
// fault of the adapter world (an extent that could not be added in the middle of a group create) is the same case:
|
|
9131
9127
|
// the call stopped after some of its writes.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// for bit. Checked also carries a bound on the distance from the exact value. A decision (a comparison)
|
|
8
8
|
// that the bounds settle is the decision of exact arithmetic; one that they do not settle is a loss, or
|
|
9
9
|
// the driver takes it in exact arithmetic (namespace exact). So a decision of the checked path is the
|
|
10
|
-
// decision of exact arithmetic
|
|
10
|
+
// decision of exact arithmetic. A guarded call tries the raw frame, then frames scaled by
|
|
11
11
|
// a power of two; if all lose a value, it returns false and the caller fails with status 10. So no
|
|
12
12
|
// result is finite and wrong from a lost component, and no decision is taken on a rounding.
|
|
13
13
|
|
|
@@ -101,7 +101,7 @@ inline Frames scaleFrames(std::initializer_list<const double*> points,
|
|
|
101
101
|
|
|
102
102
|
// How a checked computation treats its decisions (comparisons of two checked values).
|
|
103
103
|
// kCertified (the default): a decision must agree with exact arithmetic on the inputs; one that the
|
|
104
|
-
// error bounds cannot settle is a loss (
|
|
104
|
+
// error bounds cannot settle is a loss (a sum can round away a small term, and a later
|
|
105
105
|
// term can cancel the rest, so the sign of the rounded value is not the sign of the exact value).
|
|
106
106
|
// kExactFallback: the same, but an unsettled decision only sets `uncertain`; the driver then takes the
|
|
107
107
|
// decision in exact arithmetic (namespace exact) and never uses the rounded one.
|
|
@@ -408,7 +408,7 @@ inline double length(const double value[3]) {
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
// length() for a value that a call stores or reports: *inexact is set when the length is below
|
|
411
|
-
// DBL_MIN and lost bits on the way back from the scaled frame
|
|
411
|
+
// DBL_MIN and lost bits on the way back from the scaled frame.
|
|
412
412
|
inline double length(const double value[3], bool* inexact) {
|
|
413
413
|
const double sum = value[0] * value[0] + value[1] * value[1] + value[2] * value[2];
|
|
414
414
|
if (sum >= 0x1p-900 && sum <= DBL_MAX) [[likely]] return std::sqrt(sum);
|
|
@@ -590,7 +590,7 @@ T sampleBlendT(const T corners[8], T tx, T ty, T tz) {
|
|
|
590
590
|
return y0v * (T(1.0) - tz) + y1v * tz;
|
|
591
591
|
}
|
|
592
592
|
|
|
593
|
-
// The way back from a scaled frame is part of the result
|
|
593
|
+
// The way back from a scaled frame is part of the result: an unscale that is not exact
|
|
594
594
|
// (a nonzero value that becomes 0, or a subnormal that loses bits) or that overflows is a loss, and
|
|
595
595
|
// the attempt fails, so the next frame is tried or the call fails with status 10. An exact 0 stays 0.
|
|
596
596
|
inline bool unscaleExact(double value, int exponent, double* out) {
|
|
@@ -622,7 +622,7 @@ bool guardedFrames(const Frames& frames, Attempt attempt) {
|
|
|
622
622
|
return frames.largest != 0 && frames.largest != frames.balanced && attempt(frames.largest);
|
|
623
623
|
}
|
|
624
624
|
|
|
625
|
-
// ---- Exact decisions
|
|
625
|
+
// ---- Exact decisions. A decision that the error bounds of the checked type cannot
|
|
626
626
|
// settle is taken here, in exact arithmetic on the inputs. Every input is a double, so a dyadic
|
|
627
627
|
// rational, and + - * of dyadic rationals are exact: the sign of a polynomial in the inputs is exact.
|
|
628
628
|
// The decisions of the formulas are polynomials of degree 4 at most (a division is moved into a sign
|
|
@@ -1125,7 +1125,7 @@ inline bool rayPoint(const double origin[3], const double translation[3], double
|
|
|
1125
1125
|
|
|
1126
1126
|
// The side of a plane: the checked formula when the bounds settle it in a frame that loses nothing,
|
|
1127
1127
|
// else exact arithmetic (which needs no frame). The sign does not depend on the length of the
|
|
1128
|
-
// direction, so the caller's normal is used as given (no division before the test
|
|
1128
|
+
// direction, so the caller's normal is used as given (no division before the test).
|
|
1129
1129
|
inline bool planeSide(const double direction[3], const double position[3], const double point[3],
|
|
1130
1130
|
bool* positive) {
|
|
1131
1131
|
if (ordinary({direction, position, point})) {
|
|
@@ -1147,14 +1147,14 @@ inline bool planeSide(const double direction[3], const double position[3], const
|
|
|
1147
1147
|
return settled || exact::planeSide(direction, position, point, positive);
|
|
1148
1148
|
}
|
|
1149
1149
|
|
|
1150
|
-
// The side of a plane with the caller's normal, not a normalized one
|
|
1150
|
+
// The side of a plane with the caller's normal, not a normalized one.
|
|
1151
1151
|
inline bool planeSideOfNormal(const double normal[3], const double position[3],
|
|
1152
1152
|
const double point[3], bool* positive) {
|
|
1153
1153
|
return planeSide(normal, position, point, positive);
|
|
1154
1154
|
}
|
|
1155
1155
|
|
|
1156
1156
|
// The blend of one cell, and (optional) the decision value <= 0 of the SDF raycast. The plain path
|
|
1157
|
-
// needs every input of the formula ordinary: the 8 corners and the 3 weights (
|
|
1157
|
+
// needs every input of the formula ordinary: the 8 corners and the 3 weights (a weight of
|
|
1158
1158
|
// 2^-900 times a corner of 2^-200 underflows to 0). On the checked path the value is the formula in an
|
|
1159
1159
|
// unbounded range (or the call fails), and the decision is the decision of exact arithmetic.
|
|
1160
1160
|
inline bool sampleBlend(const double corners[8], double tx, double ty, double tz, double* out,
|
|
@@ -3403,7 +3403,7 @@ WorldError World::beginStepTransaction(bool holdSolver) {
|
|
|
3403
3403
|
if (holdSolver) {
|
|
3404
3404
|
// The hold can throw (its error text cannot be allocated), and the boundary of the call reports that as an
|
|
3405
3405
|
// allocation failure. The transaction must not stay open after a begin that did not return Ok: a later begin
|
|
3406
|
-
// would refuse, and the world would differ from a peer whose begin succeeded
|
|
3406
|
+
// would refuse, and the world would differ from a peer whose begin succeeded.
|
|
3407
3407
|
WorldError held;
|
|
3408
3408
|
try {
|
|
3409
3409
|
held = holdStepTransaction();
|
|
@@ -8151,7 +8151,7 @@ WorldError World::stagePreparedTopologyEdit(
|
|
|
8151
8151
|
}
|
|
8152
8152
|
// The survivors that the box of a removed body touched (the publication wakes them). The publication found them
|
|
8153
8153
|
// itself and allocated a buffer for the removed boxes in a function that cannot fail, so an allocation failure
|
|
8154
|
-
// there ended the process
|
|
8154
|
+
// there ended the process. The stage holds the allocation now.
|
|
8155
8155
|
plan.removalBoundsWakeIndices.clear();
|
|
8156
8156
|
if (!plan.removedBodies.empty() && !state_.topology.bodyIds.empty() && !topologyWorkspace_.topology.bodyIds.empty()) {
|
|
8157
8157
|
const std::vector<BodyId>& oldOrder = state_.topology.bodyIds;
|
|
@@ -11513,7 +11513,7 @@ class PortalCouplingParticipant {
|
|
|
11513
11513
|
WorldError World::step(const StepOptions& options) {
|
|
11514
11514
|
if (box3d_.needsRestore) return needsRestoreError();
|
|
11515
11515
|
backendStepCounters_.reset();
|
|
11516
|
-
// A portal step input is coupling work for the Box3D slice route only
|
|
11516
|
+
// A portal step input is coupling work for the Box3D slice route only. The
|
|
11517
11517
|
// public solver owns no portal coupling, so a silent proxy-free step would publish wrong physics.
|
|
11518
11518
|
if (staged_.portalStepActive) {
|
|
11519
11519
|
return error(WorldErrorCode::InvalidState,
|
|
@@ -1119,8 +1119,8 @@ struct Box3dCanonicalBridge {
|
|
|
1119
1119
|
// Builds the bookkeeping of the staged mirror (the mirror that `restore` staged) for `candidate`, the public
|
|
1120
1120
|
// state that the restore is about to commit, before the commit. It holds every allocation of the restore that
|
|
1121
1121
|
// depends on the public state, so `adoptRestoredState`, which runs after the commit, allocates nothing. False
|
|
1122
|
-
// when an allocation failed: the world then refuses the restore and changes nothing
|
|
1123
|
-
//
|
|
1122
|
+
// when an allocation failed: the world then refuses the restore and changes nothing.
|
|
1123
|
+
// A world without a staged image ignores it.
|
|
1124
1124
|
bool (*prepareRestore)(World& world, const WorldState& candidate) noexcept = nullptr;
|
|
1125
1125
|
};
|
|
1126
1126
|
|
|
@@ -1468,7 +1468,7 @@ struct PreparedTopologyEdit {
|
|
|
1468
1468
|
TopologyPlanAccount account;
|
|
1469
1469
|
};
|
|
1470
1470
|
|
|
1471
|
-
// The public portal step input
|
|
1471
|
+
// The public portal step input. JS owns the
|
|
1472
1472
|
// portal meaning and every crossing decision; this record only carries the coupling work of one
|
|
1473
1473
|
// step. The backend consumes it once, like every other per-step input, and clears it on restore,
|
|
1474
1474
|
// import and replaceState.
|
|
@@ -2028,7 +2028,7 @@ class World {
|
|
|
2028
2028
|
WorldError setContactGroups(
|
|
2029
2029
|
std::span<const std::pair<BodyId, std::uint32_t>> groups,
|
|
2030
2030
|
std::span<const std::pair<std::uint32_t, BodyId>> members);
|
|
2031
|
-
// The portal coupling work of the next step only
|
|
2031
|
+
// The portal coupling work of the next step only. JS owns every
|
|
2032
2032
|
// portal meaning and every crossing; this input names the pair ends, the planned proxies, the
|
|
2033
2033
|
// owning end of each member, and the exclusions. It is a step input, not state: a checkpoint, a
|
|
2034
2034
|
// snapshot and a digest do not hold it, and restoreCheckpoint, importSnapshot and replaceState
|
|
@@ -2040,7 +2040,7 @@ class World {
|
|
|
2040
2040
|
std::span<const WorldPortalMember> members,
|
|
2041
2041
|
std::span<const std::array<BodyId, 2>> exclusions = {});
|
|
2042
2042
|
// Validates a portal plan against this world without storing it. The route preflight uses it, so
|
|
2043
|
-
// it reads public state only
|
|
2043
|
+
// it reads public state only.
|
|
2044
2044
|
WorldError checkPortalStep(
|
|
2045
2045
|
std::span<const WorldPortalPair> pairs,
|
|
2046
2046
|
std::span<const WorldPortalProxy> proxies,
|
|
@@ -2076,8 +2076,7 @@ class World {
|
|
|
2076
2076
|
|| !staged_.restrictedAllowedPairs.empty() || !staged_.portalCouplings.empty()
|
|
2077
2077
|
|| !staged_.contactGroups.empty() || !staged_.shapeExclusions.empty();
|
|
2078
2078
|
}
|
|
2079
|
-
// The pair-filter step inputs of the next step, in the layouts of the engine that installs them
|
|
2080
|
-
// (see fanout/pair-filters/pair-filters-notes.md):
|
|
2079
|
+
// The pair-filter step inputs of the next step, in the layouts of the engine that installs them:
|
|
2081
2080
|
// - pendingContactExclusions: the body pairs of setContactExclusions and setContactRules.
|
|
2082
2081
|
// - pendingRestrictedBodies: the restricted bodies of setContactRules.
|
|
2083
2082
|
// - pendingRestrictedAllowedPairs: the allowed pairs of setContactRules.
|
|
@@ -2693,7 +2692,7 @@ std::uint32_t box3dBackendStep(World& world, const StepOptions& options);
|
|
|
2693
2692
|
void publishBox3dStepState(World& world, WorldState&& next) noexcept;
|
|
2694
2693
|
// The public portal route of one plan. Returns 0 when the slice serves the plan, 1 when it does not
|
|
2695
2694
|
// (a named reason is in box3dBackendError), and 2 when the plan itself is invalid. It reads public
|
|
2696
|
-
// state, the plan and the options only, so the preflight and the step agree
|
|
2695
|
+
// state, the plan and the options only, so the preflight and the step agree.
|
|
2697
2696
|
std::uint32_t box3dPortalRoute(World& world,
|
|
2698
2697
|
std::span<const WorldPortalPair> pairs,
|
|
2699
2698
|
std::span<const WorldPortalProxy> proxies,
|