@series-inc/rundot-syncplay 6.0.0-rc.2 → 6.0.0-rc.21
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 +133 -0
- package/core/deterministic-math.d.ts +75 -1
- package/core/native/instance_ledger.hpp +1095 -0
- package/core/native/legacy_checkpoint_ids.hpp +107 -0
- package/core/native/physics/abi.cpp +39 -211
- package/core/native/physics/abi.hpp +2 -6
- package/core/native/physics/articulation.cpp +1434 -0
- package/core/native/physics/articulation.hpp +279 -0
- package/core/native/physics/buoyancy.cpp +1588 -0
- package/core/native/physics/buoyancy.hpp +254 -0
- package/core/native/physics/capsule_triangle.cpp +168 -0
- package/core/native/physics/capsule_triangle.hpp +40 -0
- package/core/native/physics/capsule_triangle_native.inc +291 -0
- package/core/native/physics/certified_sum.hpp +218 -0
- package/core/native/physics/character.cpp +638 -0
- package/core/native/physics/character.hpp +169 -0
- package/core/native/physics/checkpoint_schema.hpp +379 -0
- package/core/native/physics/cloth.cpp +1401 -0
- package/core/native/physics/cloth.hpp +357 -0
- package/core/native/physics/constraint_rows.cpp +363 -2
- package/core/native/physics/constraint_rows.hpp +72 -1
- package/core/native/physics/deformable_query.cpp +1630 -0
- package/core/native/physics/deformable_query.hpp +578 -0
- package/core/native/physics/distance.cpp +1166 -0
- package/core/native/physics/distance.hpp +151 -0
- package/core/native/physics/exact/exact-applied.cpp +101 -0
- package/core/native/physics/exact/exact-applied.hpp +112 -0
- package/core/native/physics/exact/exact-dyadic.cpp +691 -0
- package/core/native/physics/exact/exact-dyadic.hpp +58 -0
- package/core/native/physics/exact/exact-operation.hpp +51 -0
- package/core/native/physics/exact/word-core.hpp +262 -0
- package/core/native/physics/extended_abi.cpp +1242 -0
- package/core/native/physics/extended_abi.hpp +355 -0
- package/core/native/physics/extended_abi_characters.cpp +261 -0
- package/core/native/physics/extended_abi_characters.hpp +434 -0
- package/core/native/physics/extended_abi_core_features.cpp +713 -0
- package/core/native/physics/extended_abi_core_features.hpp +226 -0
- package/core/native/physics/extended_abi_deformables.cpp +448 -0
- package/core/native/physics/extended_abi_deformables.hpp +867 -0
- package/core/native/physics/extended_abi_vehicles.cpp +411 -0
- package/core/native/physics/extended_abi_vehicles.hpp +222 -0
- package/core/native/physics/fracture.cpp +1981 -0
- package/core/native/physics/fracture.hpp +460 -0
- package/core/native/physics/gear.cpp +563 -0
- package/core/native/physics/gear.hpp +158 -0
- package/core/native/physics/geometry_memory.hpp +476 -0
- package/core/native/physics/geometry_store.cpp +547 -0
- package/core/native/physics/geometry_store.hpp +134 -0
- package/core/native/physics/lag_compensation.cpp +1626 -0
- package/core/native/physics/lag_compensation.hpp +405 -0
- package/core/native/physics/mass_properties.cpp +449 -0
- package/core/native/physics/mass_properties.hpp +23 -0
- package/core/native/physics/material_pose.hpp +988 -0
- package/core/native/physics/particles.cpp +1065 -0
- package/core/native/physics/particles.hpp +261 -0
- package/core/native/physics/path_joint.cpp +781 -0
- package/core/native/physics/path_joint.hpp +154 -0
- package/core/native/physics/physics.cpp +13043 -1065
- package/core/native/physics/physics.hpp +184 -8
- package/core/native/physics/planar_deformable.cpp +2433 -0
- package/core/native/physics/planar_deformable.hpp +889 -0
- package/core/native/physics/platformer_2d.cpp +1353 -0
- package/core/native/physics/platformer_2d.hpp +340 -0
- package/core/native/physics/powered_ragdoll.cpp +1100 -0
- package/core/native/physics/powered_ragdoll.hpp +279 -0
- package/core/native/physics/powertrain.cpp +586 -0
- package/core/native/physics/powertrain.hpp +180 -0
- package/core/native/physics/pulley.cpp +311 -0
- package/core/native/physics/pulley.hpp +121 -0
- package/core/native/physics/ragdoll.cpp +586 -0
- package/core/native/physics/ragdoll.hpp +221 -0
- package/core/native/physics/rope.cpp +692 -0
- package/core/native/physics/rope.hpp +215 -0
- package/core/native/physics/rounded_convex.cpp +1229 -0
- package/core/native/physics/rounded_convex.hpp +287 -0
- package/core/native/physics/sdf_geometry.cpp +1821 -0
- package/core/native/physics/sdf_geometry.hpp +474 -0
- package/core/native/physics/soft_body.cpp +1449 -0
- package/core/native/physics/soft_body.hpp +328 -0
- package/core/native/physics/soft_collision.cpp +1862 -0
- package/core/native/physics/soft_collision.hpp +561 -0
- package/core/native/physics/surface_velocity.cpp +366 -0
- package/core/native/physics/surface_velocity.hpp +243 -0
- package/core/native/physics/topology.cpp +357 -39
- package/core/native/physics/topology.hpp +97 -6
- package/core/native/physics/tracks.cpp +1179 -0
- package/core/native/physics/tracks.hpp +404 -0
- package/core/native/physics/vehicle.cpp +629 -0
- package/core/native/physics/vehicle.hpp +191 -0
- package/core/native/physics/voxel_cooking.cpp +1929 -0
- package/core/native/physics/voxel_cooking.hpp +395 -0
- package/core/native/physics/world.cpp +5290 -854
- package/core/native/physics/world.hpp +796 -24
- package/core/native/physics/world_abi.cpp +3840 -306
- package/core/native/physics/world_abi.hpp +530 -10
- package/core/native/physics/world_digest_visitor.hpp +277 -0
- package/core/native/physics/world_strong_digest.hpp +557 -0
- package/core/native/physics2d/ccd.cpp +1302 -0
- package/core/native/physics2d/ccd.hpp +141 -0
- package/core/native/physics2d/checkpoint_memory.hpp +349 -0
- package/core/native/physics2d/clock_primitives.hpp +138 -0
- package/core/native/physics2d/commands.cpp +174 -28
- package/core/native/physics2d/commands.hpp +3 -1
- package/core/native/physics2d/compound.cpp +581 -0
- package/core/native/physics2d/compound.hpp +248 -0
- package/core/native/physics2d/contour.cpp +325 -0
- package/core/native/physics2d/contour.hpp +143 -0
- package/core/native/physics2d/frame_scope.hpp +124 -0
- package/core/native/physics2d/joint_phases.hpp +93 -0
- package/core/native/physics2d/joints.cpp +587 -150
- package/core/native/physics2d/joints.hpp +5 -0
- package/core/native/physics2d/memory_private.hpp +125 -0
- package/core/native/physics2d/owned_abi.cpp +1354 -879
- package/core/native/physics2d/owned_abi.hpp +190 -52
- package/core/native/physics2d/phase_test_hooks.hpp +17 -0
- package/core/native/physics2d/physics2d.cpp +2073 -120
- package/core/native/physics2d/physics2d.hpp +154 -2
- package/core/native/physics2d/queries.cpp +1055 -79
- package/core/native/physics2d/queries.hpp +71 -5
- package/core/native/physics2d/world.cpp +1313 -353
- package/core/native/physics2d/world.hpp +124 -13
- package/core/native/sha256/sha256_compress_unsigned.hpp +68 -0
- package/core/native/sha256/sha256_fips_constants.hpp +24 -0
- package/core/native/sha256/sha256_length.hpp +56 -0
- package/core/native/sha256/sha256_memo.hpp +48 -0
- package/core/native/sha256/sha256_sink.hpp +234 -0
- package/core/physics2d-owned.d.ts +466 -126
- package/core/runtime.d.ts +192 -19
- package/core/scripts/build-native.mjs +34 -0
- package/core/scripts/build-wasm-physics.mjs +272 -23
- package/core/scripts/extended-physics-profile.mjs +634 -0
- package/core/scripts/generate-physics2d-vectors.mjs +59 -0
- package/core/src/kinetix-deterministic-math.d.ts +2 -0
- package/core/src/kinetix-deterministic-math.mjs +513 -27
- package/core/src/kinetix-owned-runtime-adapter.mjs +788 -0
- package/core/src/kinetix-runtime-adapter-utils.mjs +54 -6
- package/core/src/kinetix-runtime-contract.mjs +55 -9
- package/core/src/kinetix-runtime-identity.mjs +12 -1
- package/core/src/kinetix-session-config.mjs +7 -2
- package/core/src/kinetix-state-report.mjs +36 -0
- package/core/src/physics/abi-constants.mjs +5 -4
- package/core/src/physics/articulation.d.mts +194 -0
- package/core/src/physics/articulation.mjs +1141 -0
- package/core/src/physics/buoyancy.d.mts +143 -0
- package/core/src/physics/buoyancy.mjs +268 -0
- package/core/src/physics/cloth.d.mts +314 -0
- package/core/src/physics/cloth.mjs +1156 -0
- package/core/src/physics/deformable-query.d.mts +217 -0
- package/core/src/physics/deformable-query.mjs +1412 -0
- package/core/src/physics/distance.d.mts +160 -0
- package/core/src/physics/distance.mjs +175 -0
- package/core/src/physics/extended-wasm-instance.d.mts +5 -0
- package/core/src/physics/extended-wasm-instance.mjs +48 -0
- package/core/src/physics/feature-api.d.mts +74 -0
- package/core/src/physics/feature-api.mjs +98 -0
- package/core/src/physics/fracture.d.mts +133 -0
- package/core/src/physics/fracture.mjs +1324 -0
- package/core/src/physics/gear.d.mts +585 -0
- package/core/src/physics/gear.mjs +955 -0
- package/core/src/physics/lag-compensation.d.mts +101 -0
- package/core/src/physics/lag-compensation.mjs +1100 -0
- package/core/src/physics/mass-properties.d.mts +114 -0
- package/core/src/physics/mass-properties.mjs +137 -468
- package/core/src/physics/particles.d.mts +177 -0
- package/core/src/physics/particles.mjs +758 -0
- package/core/src/physics/path-joint.d.mts +171 -0
- package/core/src/physics/path-joint.mjs +1231 -0
- package/core/src/physics/physics-extended-wasm-module.generated.mjs +13 -0
- package/core/src/physics/physics-profile-wasm-module.generated.mjs +48 -0
- package/core/src/physics/physics-wasm-module.generated.mjs +34 -5
- package/core/src/physics/powered-ragdoll.d.mts +188 -0
- package/core/src/physics/powered-ragdoll.mjs +1043 -0
- package/core/src/physics/powertrain.d.mts +260 -0
- package/core/src/physics/powertrain.mjs +621 -0
- package/core/src/physics/pulley.d.mts +98 -0
- package/core/src/physics/pulley.mjs +686 -0
- package/core/src/physics/ragdoll.d.mts +289 -0
- package/core/src/physics/ragdoll.mjs +1323 -0
- package/core/src/physics/rope.d.mts +241 -0
- package/core/src/physics/rope.mjs +319 -0
- package/core/src/physics/rounded-convex.d.mts +328 -0
- package/core/src/physics/rounded-convex.mjs +1404 -0
- package/core/src/physics/sdf-geometry.d.mts +117 -0
- package/core/src/physics/sdf-geometry.mjs +1204 -0
- package/core/src/physics/soft-body.d.mts +144 -0
- package/core/src/physics/soft-body.mjs +1285 -0
- package/core/src/physics/soft-collision.d.mts +651 -0
- package/core/src/physics/soft-collision.mjs +1883 -0
- package/core/src/physics/surface-velocity.d.mts +156 -0
- package/core/src/physics/surface-velocity.mjs +722 -0
- package/core/src/physics/tracks.d.mts +411 -0
- package/core/src/physics/tracks.mjs +1074 -0
- package/core/src/physics/vehicle.d.mts +3 -0
- package/core/src/physics/vehicle.mjs +172 -0
- package/core/src/physics/voxel-cooking.d.mts +219 -0
- package/core/src/physics/voxel-cooking.mjs +1499 -0
- package/core/src/physics/voxel-swept-quad.mjs +110 -0
- package/core/src/physics/wasm-instance.mjs +160 -23
- package/core/src/physics/world.d.mts +62 -0
- package/core/src/physics/world.mjs +1947 -152
- package/core/src/physics2d/body-state.mjs +218 -15
- package/core/src/physics2d/collision.d.mts +52 -0
- package/core/src/physics2d/collision.mjs +234 -0
- package/core/src/physics2d/compound.mjs +454 -0
- package/core/src/physics2d/contour-state.mjs +771 -0
- package/core/src/physics2d/feature-api.d.mts +211 -0
- package/core/src/physics2d/feature-api.mjs +3 -0
- package/core/src/physics2d/fluid-state.mjs +145 -0
- package/core/src/physics2d/joint-state.mjs +1 -1
- package/core/src/physics2d/owned-queries.mjs +3 -1
- package/core/src/physics2d/owned-transport.mjs +268 -122
- package/core/src/physics2d/owned-world.mjs +353 -230
- package/core/src/physics2d/particle-fluid.d.mts +152 -0
- package/core/src/physics2d/particle-fluid.mjs +233 -0
- package/core/src/physics2d/physics2d-wasm-module.generated.mjs +27 -10
- package/core/src/physics2d/query-codec.mjs +61 -13
- package/core/src/physics2d/submerged-geometry.d.mts +51 -0
- package/core/src/physics2d/submerged-geometry.mjs +186 -0
- package/core/src/runtime.mjs +23 -0
- package/core/src/shared/bytes.d.mts +2 -0
- package/core/src/shared/bytes.mjs +33 -0
- package/core/src/shared/sha256.d.mts +3 -0
- package/core/src/shared/sha256.mjs +72 -22
- package/core/units.d.ts +50 -0
- package/core/world.d.ts +253 -5
- package/dist/authority-room.d.ts +9 -0
- package/dist/authority-room.js +45 -16
- package/dist/browser.d.ts +6 -5
- package/dist/browser.js +4 -3
- package/dist/cadence.d.ts +7 -0
- package/dist/cadence.js +19 -0
- package/dist/canonical.d.ts +1 -0
- package/dist/canonical.js +3 -0
- package/dist/checksum-policy.d.ts +10 -0
- package/dist/checksum-policy.js +14 -0
- package/dist/collider-cooking-hull.d.ts +18 -0
- package/dist/collider-cooking-hull.js +248 -0
- package/dist/collider-cooking.d.ts +140 -0
- package/dist/collider-cooking.js +794 -0
- package/dist/compat/v5.d.ts +121 -0
- package/dist/compat/v5.js +479 -0
- package/dist/creator.d.ts +7 -6
- package/dist/creator.js +4 -3
- package/dist/game-byte-section.d.ts +36 -0
- package/dist/game-byte-section.js +350 -0
- package/dist/index.d.ts +13 -6
- package/dist/index.js +9 -4
- package/dist/instant-replay.d.ts +27 -2
- package/dist/instant-replay.js +91 -16
- package/dist/lag-compensation3d.js +11 -10
- package/dist/match-log.d.ts +21 -4
- package/dist/match-log.js +92 -9
- package/dist/math.d.ts +2 -0
- package/dist/math.js +1 -0
- package/dist/modules/character-3d.d.ts +16 -1
- package/dist/modules/character-3d.js +42 -5
- package/dist/modules/combat.js +6 -5
- package/dist/movement3d-revision1.d.ts +2 -0
- package/dist/movement3d-revision1.js +973 -0
- package/dist/movement3d.d.ts +53 -3
- package/dist/movement3d.js +917 -247
- package/dist/networked-client.d.ts +15 -0
- package/dist/networked-client.js +378 -105
- package/dist/node.d.ts +3 -2
- package/dist/node.js +2 -1
- package/dist/physics/2d.d.ts +38 -4
- package/dist/physics/2d.js +57 -36
- package/dist/physics/3d.d.ts +755 -111
- package/dist/physics/3d.js +2355 -158
- package/dist/physics/edit-result-graph.d.ts +36 -0
- package/dist/physics/edit-result-graph.js +141 -0
- package/dist/physics/game-codec3d.d.ts +41 -0
- package/dist/physics/game-codec3d.js +544 -0
- package/dist/physics/installed-checkpoint3d.d.ts +13 -0
- package/dist/physics/installed-checkpoint3d.js +120 -0
- package/dist/physics/installed-runtime3d.d.ts +51 -0
- package/dist/physics/installed-runtime3d.js +372 -0
- package/dist/physics/installed-state-commitment3d.d.ts +2 -0
- package/dist/physics/installed-state-commitment3d.js +24 -0
- package/dist/physics/units.d.ts +38 -0
- package/dist/physics/units.js +56 -0
- package/dist/physics/vehicle-state3d.d.ts +93 -0
- package/dist/physics/vehicle-state3d.js +1191 -0
- package/dist/physics/voxel-body-state.d.ts +61 -0
- package/dist/physics/voxel-body-state.js +410 -0
- package/dist/r3f-render-adapter.d.ts +59 -1
- package/dist/r3f-render-adapter.js +137 -2
- package/dist/replay.d.ts +13 -0
- package/dist/replay.js +95 -70
- package/dist/run-room-transport.js +5 -1
- package/dist/runner.d.ts +17 -2
- package/dist/runner.js +472 -84
- package/dist/runtime-cleanup.d.ts +54 -0
- package/dist/runtime-cleanup.js +266 -0
- package/dist/runtime-lease.d.ts +11 -1
- package/dist/runtime-lease.js +23 -10
- package/dist/runtime-room-metadata.d.ts +2 -8
- package/dist/runtime-room-metadata.js +11 -14
- package/dist/runtime-session.d.ts +8 -0
- package/dist/runtime-session.js +222 -58
- package/dist/schema-codegen.js +3 -0
- package/dist/schema-dsl-binary.d.ts +10 -4
- package/dist/schema-dsl-binary.js +375 -76
- package/dist/scratch-pool.d.ts +32 -0
- package/dist/scratch-pool.js +60 -0
- package/dist/sdk-session.d.ts +1 -0
- package/dist/sdk-session.js +4 -0
- package/dist/secret-config.js +2 -60
- package/dist/secret-crypto.js +70 -36
- package/dist/session-snapshot.d.ts +15 -4
- package/dist/session-snapshot.js +35 -33
- package/dist/session-wire.js +14 -22
- package/dist/sparse-set.d.ts +1 -0
- package/dist/sparse-set.js +22 -0
- package/dist/spatial/spatial-grid-3d.d.ts +41 -0
- package/dist/spatial/spatial-grid-3d.js +115 -0
- package/dist/synctest.d.ts +9 -0
- package/dist/synctest.js +106 -17
- package/dist/testing-network.d.ts +2 -0
- package/dist/testing-network.js +122 -18
- package/dist/testing.d.ts +27 -6
- package/dist/testing.js +297 -56
- package/dist/tools/index.d.ts +3 -2
- package/dist/tools/index.js +3 -2
- package/dist/tools/module-certification.d.ts +6 -0
- package/dist/tools/module-certification.js +26 -2
- package/package.json +18 -5
- package/core/scripts/run-box3d-benchmark.mjs +0 -350
- package/core/src/physics/index.mjs +0 -3169
|
@@ -2,26 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
#include "physics.hpp"
|
|
4
4
|
#include "topology.hpp"
|
|
5
|
+
#include "geometry_store.hpp"
|
|
6
|
+
#include "material_pose.hpp"
|
|
5
7
|
|
|
6
8
|
#include <array>
|
|
9
|
+
#include <atomic>
|
|
7
10
|
#include <cstdint>
|
|
8
11
|
#include <limits>
|
|
12
|
+
#include <memory>
|
|
9
13
|
#include <span>
|
|
14
|
+
#include <stdexcept>
|
|
10
15
|
#include <string>
|
|
11
16
|
#include <vector>
|
|
12
17
|
|
|
13
18
|
namespace rundot::kinetix::physics {
|
|
14
19
|
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
20
|
+
// Numeric profile 1 uses encoded SoA positions as canonical solver state.
|
|
21
|
+
// Version 14 keeps legacy geometry and NativeWorldPose.
|
|
22
|
+
// Version 15 keeps record geometry and NativeWorldPose.
|
|
23
|
+
// Version 16 adds the canonical material Root. Its geometry-form tag
|
|
24
|
+
// exists only on version 16: 0 keeps the legacy values, 1 reads records.
|
|
25
|
+
constexpr std::uint32_t kWorldSnapshotVersion = 14;
|
|
26
|
+
constexpr std::uint32_t kWorldRecordSnapshotVersion = 15;
|
|
27
|
+
constexpr std::uint32_t kWorldRecordPoseSnapshotVersion = 16;
|
|
28
|
+
constexpr std::uint32_t kWorldSnapshotLegacyGeometryForm = 0;
|
|
29
|
+
constexpr std::uint32_t kWorldSnapshotRecordGeometryForm = 1;
|
|
30
|
+
constexpr std::uint32_t kWorldNumericProfile = 1;
|
|
31
|
+
constexpr std::uint32_t kSurfaceVelocityStride = 4;
|
|
18
32
|
constexpr std::uint32_t kWorldMaxBodies = 100000;
|
|
19
33
|
constexpr std::uint32_t kWorldMaxJoints = 10000;
|
|
20
|
-
constexpr std::
|
|
34
|
+
constexpr std::uint32_t kWorldMaxSupportRecords = 100000;
|
|
35
|
+
constexpr std::uint32_t kWorldMaxFluids = 64;
|
|
36
|
+
constexpr std::uint64_t kWorldMaxGeometryValues = kGeometryMaxValues;
|
|
21
37
|
constexpr std::uint64_t kWorldMaxContactCacheValues = 8388608;
|
|
22
38
|
constexpr std::uint64_t kWorldMaxForceValues = static_cast<std::uint64_t>(kWorldMaxBodies) * kForceStride;
|
|
23
39
|
constexpr std::uint32_t kWorldMaxProfileIdBytes = 256;
|
|
24
|
-
constexpr std::uint32_t kWorldMaxCompoundDepth =
|
|
40
|
+
constexpr std::uint32_t kWorldMaxCompoundDepth = kGeometryMaxCompoundDepth;
|
|
25
41
|
// Keep the owned-world contract aligned with the bounded 2D solver limits.
|
|
26
42
|
// The 3D kernel accepts uint32 values internally, but an owned world must
|
|
27
43
|
// reject work that can exceed its supported deterministic budget.
|
|
@@ -29,10 +45,18 @@ constexpr std::uint32_t kWorldMaxSubsteps = 64;
|
|
|
29
45
|
constexpr std::uint32_t kWorldMaxVelocityIterations = 32;
|
|
30
46
|
constexpr bool kWorldDynamicTreeEnabled = true;
|
|
31
47
|
constexpr std::uint32_t kBodyStrideWide = 47;
|
|
48
|
+
constexpr std::uint32_t kMotionPoseStride = 7;
|
|
49
|
+
constexpr std::uint32_t kMotionVelocityStride = 6;
|
|
50
|
+
constexpr std::uint32_t kMotionStatusVersion = 1;
|
|
51
|
+
constexpr std::uint32_t kMotionHeaderWords = 6;
|
|
52
|
+
constexpr std::uint32_t kMotionPoseValueLimit = kWorldMaxBodies * kMotionPoseStride;
|
|
53
|
+
constexpr std::uint32_t kMotionVelocityValueLimit = kWorldMaxBodies * kMotionVelocityStride;
|
|
54
|
+
constexpr std::uint32_t kMotionIdWordLimit = kWorldMaxBodies * 2;
|
|
55
|
+
constexpr std::uint32_t kMotionStatusByteLimit = kWorldMaxBodies;
|
|
32
56
|
|
|
33
57
|
struct WorldProfile {
|
|
34
58
|
std::uint32_t abiVersion = kAbiVersion;
|
|
35
|
-
std::uint32_t numericProfile =
|
|
59
|
+
std::uint32_t numericProfile = kWorldNumericProfile;
|
|
36
60
|
std::string id = "kinetix-native-v1";
|
|
37
61
|
std::array<std::uint8_t, 32> geometryDigest{};
|
|
38
62
|
|
|
@@ -58,26 +82,148 @@ struct WorldContactEvent {
|
|
|
58
82
|
std::array<double, 3> point{};
|
|
59
83
|
std::array<double, 3> normal{};
|
|
60
84
|
double penetration = 0.0;
|
|
85
|
+
double closingSpeed = 0.0;
|
|
61
86
|
|
|
62
87
|
auto operator<=>(const WorldContactEvent&) const = default;
|
|
63
88
|
};
|
|
64
89
|
|
|
65
|
-
|
|
66
|
-
|
|
90
|
+
enum class WorldJointBreakReason : std::uint32_t {
|
|
91
|
+
Impulse = 1,
|
|
92
|
+
Force = 2,
|
|
93
|
+
Torque = 4,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
struct WorldJointReaction {
|
|
97
|
+
JointId joint;
|
|
98
|
+
BodyId bodyA;
|
|
99
|
+
BodyId bodyB;
|
|
100
|
+
std::array<double, 3> force{};
|
|
101
|
+
std::array<double, 3> torque{};
|
|
102
|
+
|
|
103
|
+
auto operator<=>(const WorldJointReaction&) const = default;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
struct WorldJointBreakEvent {
|
|
107
|
+
JointId joint;
|
|
108
|
+
std::uint32_t reasonBits = 0;
|
|
109
|
+
|
|
110
|
+
auto operator<=>(const WorldJointBreakEvent&) const = default;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
struct WorldFluidInteraction {
|
|
114
|
+
BodyId body;
|
|
115
|
+
FluidId fluid;
|
|
116
|
+
double submergedVolume = 0.0;
|
|
117
|
+
std::array<double, 3> centerOfBuoyancy{};
|
|
118
|
+
std::array<double, 3> totalForce{};
|
|
119
|
+
std::array<double, 3> totalTorque{};
|
|
120
|
+
std::array<double, 3> relativeVelocity{};
|
|
121
|
+
bool shouldWake = false;
|
|
122
|
+
|
|
123
|
+
auto operator<=>(const WorldFluidInteraction&) const = default;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// World-space input. applySupport stores the body-local form.
|
|
127
|
+
struct WorldSupportSpringInput {
|
|
128
|
+
BodyId body;
|
|
129
|
+
BodyId support;
|
|
130
|
+
std::array<double, 3> point{};
|
|
131
|
+
std::array<double, 3> normal{};
|
|
132
|
+
double compression = 0.0;
|
|
133
|
+
double travel = 0.0;
|
|
134
|
+
double stiffness = 0.0;
|
|
135
|
+
double damping = 0.0;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
struct WorldSupportForceInput {
|
|
139
|
+
BodyId body;
|
|
140
|
+
BodyId support;
|
|
141
|
+
std::array<double, 3> force{};
|
|
142
|
+
std::array<double, 3> point{};
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
struct WorldSupportSpring {
|
|
146
|
+
BodyId body;
|
|
147
|
+
BodyId support;
|
|
148
|
+
std::array<double, 3> bodyLocalPoint{};
|
|
149
|
+
std::array<double, 3> supportLocalPoint{};
|
|
150
|
+
std::array<double, 3> supportLocalNormal{};
|
|
151
|
+
double compression = 0.0;
|
|
152
|
+
double travel = 0.0;
|
|
153
|
+
double stiffness = 0.0;
|
|
154
|
+
double damping = 0.0;
|
|
155
|
+
|
|
156
|
+
auto operator<=>(const WorldSupportSpring&) const = default;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
struct WorldSupportForce {
|
|
160
|
+
BodyId body;
|
|
161
|
+
BodyId support;
|
|
162
|
+
std::array<double, 3> force{};
|
|
163
|
+
std::array<double, 3> bodyLocalPoint{};
|
|
164
|
+
std::array<double, 3> supportLocalPoint{};
|
|
165
|
+
std::uint8_t supportReceivesReaction = 0;
|
|
166
|
+
|
|
167
|
+
auto operator<=>(const WorldSupportForce&) const = default;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
struct WorldTickSupports {
|
|
171
|
+
std::vector<WorldSupportSpring> springs;
|
|
172
|
+
std::vector<WorldSupportForce> forces;
|
|
173
|
+
|
|
174
|
+
bool empty() const { return springs.empty() && forces.empty(); }
|
|
175
|
+
auto operator<=>(const WorldTickSupports&) const = default;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
struct WorldBodyMobility {
|
|
179
|
+
std::array<double, 3> inverseLinear{};
|
|
180
|
+
std::array<double, 6> inverseAngular{};
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
struct WorldSupportImpulse {
|
|
184
|
+
std::array<double, 3> linear{};
|
|
185
|
+
std::array<double, 3> angular{};
|
|
186
|
+
std::uint32_t belowBound = 0;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
using WorldGeometry = std::variant<std::vector<double>, geometry_private::GeometryRootOwner>;
|
|
190
|
+
|
|
191
|
+
struct WorldGeometryView {
|
|
192
|
+
geometry_private::GeometryDescriptor descriptor{};
|
|
193
|
+
std::span<const double> values;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
struct WorldStatePayload {
|
|
67
197
|
std::vector<double> joints;
|
|
68
|
-
std::vector<double>
|
|
198
|
+
WorldGeometry geometry = std::vector<double>{};
|
|
69
199
|
std::vector<double> contactCache;
|
|
70
200
|
std::vector<double> forces;
|
|
201
|
+
std::vector<double> tickForces;
|
|
202
|
+
WorldTickSupports tickSupports;
|
|
203
|
+
std::vector<double> fluids;
|
|
71
204
|
std::vector<JointWarmState3D> jointWarmState;
|
|
72
205
|
TopologyState topology;
|
|
73
206
|
std::uint64_t frame = 0;
|
|
74
207
|
std::vector<double> surfaceVelocities;
|
|
75
208
|
std::vector<WorldContactEvent> contactEvents;
|
|
209
|
+
std::vector<WorldJointReaction> jointReactions;
|
|
210
|
+
std::vector<WorldJointBreakEvent> jointBreakEvents;
|
|
211
|
+
std::vector<WorldFluidInteraction> fluidInteractions;
|
|
212
|
+
WorldPose pose = NativeWorldPose{};
|
|
213
|
+
|
|
214
|
+
bool operator==(const WorldStatePayload& other) const;
|
|
215
|
+
bool operator!=(const WorldStatePayload& other) const { return !(*this == other); }
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
struct WorldState : WorldStatePayload {
|
|
219
|
+
std::vector<double> bodies;
|
|
76
220
|
|
|
77
221
|
bool operator==(const WorldState& other) const;
|
|
78
222
|
bool operator!=(const WorldState& other) const { return !(*this == other); }
|
|
79
223
|
};
|
|
80
224
|
|
|
225
|
+
void copyStateExceptBodies(WorldState& dest, const WorldState& src);
|
|
226
|
+
|
|
81
227
|
enum class WorldErrorCode : std::uint32_t {
|
|
82
228
|
Ok = 0,
|
|
83
229
|
InvalidProfile = 1,
|
|
@@ -100,6 +246,16 @@ enum class WorldErrorCode : std::uint32_t {
|
|
|
100
246
|
HandleStale = 18,
|
|
101
247
|
HandleMissing = 19,
|
|
102
248
|
HandleEpochOverflow = 20,
|
|
249
|
+
AllocationFailure = 21,
|
|
250
|
+
WorldAttached = 22,
|
|
251
|
+
InitialStateMismatch = 23,
|
|
252
|
+
CheckpointTokenExhausted = 24,
|
|
253
|
+
// Plan credential codes stay distinct from capacity, allocation, and handle errors.
|
|
254
|
+
// Their detail text must not contain stale, capacity, missing, or checkpoint.
|
|
255
|
+
TopologyPlanBusy = 25,
|
|
256
|
+
TopologyPlanNotFound = 26,
|
|
257
|
+
TopologyPlanRevisionMismatch = 27,
|
|
258
|
+
TopologyPlanSerialExhausted = 28,
|
|
103
259
|
};
|
|
104
260
|
|
|
105
261
|
struct WorldError {
|
|
@@ -114,9 +270,12 @@ struct WorldError {
|
|
|
114
270
|
struct WorldLimits {
|
|
115
271
|
std::uint32_t maxBodies = kWorldMaxBodies;
|
|
116
272
|
std::uint32_t maxJoints = kWorldMaxJoints;
|
|
273
|
+
std::uint32_t maxFluids = kWorldMaxFluids;
|
|
274
|
+
std::uint32_t maxFluidInteractions = 0;
|
|
117
275
|
std::uint64_t maxGeometryValues = kWorldMaxGeometryValues;
|
|
118
276
|
std::uint64_t maxContactCacheValues = kWorldMaxContactCacheValues;
|
|
119
277
|
std::uint64_t maxForceValues = kWorldMaxForceValues;
|
|
278
|
+
std::uint32_t maxSupportRecords = kWorldMaxSupportRecords;
|
|
120
279
|
};
|
|
121
280
|
|
|
122
281
|
struct WorldOwnerToken {
|
|
@@ -124,6 +283,58 @@ struct WorldOwnerToken {
|
|
|
124
283
|
auto operator<=>(const WorldOwnerToken&) const = default;
|
|
125
284
|
};
|
|
126
285
|
|
|
286
|
+
// One record owns attachment, revision, and unique capture lifetime.
|
|
287
|
+
// Copies and moves of WorldCheckpoint share this record. They do not add a capture.
|
|
288
|
+
// A 32-bit attachment-token exhaustion needs a new WASM module instance.
|
|
289
|
+
// Tokens are not recycled.
|
|
290
|
+
struct NativeWorldOwner {
|
|
291
|
+
struct ClaimedCapture {};
|
|
292
|
+
WorldOwnerToken token{};
|
|
293
|
+
std::uint64_t mutationRevision = 1;
|
|
294
|
+
bool attached = false;
|
|
295
|
+
std::uint32_t attachmentToken = 0;
|
|
296
|
+
std::uint64_t attachmentGeneration = 0;
|
|
297
|
+
std::atomic<std::uint32_t> uniqueCaptures{0};
|
|
298
|
+
|
|
299
|
+
NativeWorldOwner() = default;
|
|
300
|
+
NativeWorldOwner(const NativeWorldOwner&) = delete;
|
|
301
|
+
NativeWorldOwner& operator=(const NativeWorldOwner&) = delete;
|
|
302
|
+
|
|
303
|
+
bool acceptsCredential(std::uint32_t token) const noexcept {
|
|
304
|
+
return attached ? token != 0 && token == attachmentToken : token == 0;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
bool claimCapture() noexcept {
|
|
308
|
+
std::uint32_t current = uniqueCaptures.load(std::memory_order_relaxed);
|
|
309
|
+
while (true) {
|
|
310
|
+
if (current == std::numeric_limits<std::uint32_t>::max()) return false;
|
|
311
|
+
if (uniqueCaptures.compare_exchange_weak(
|
|
312
|
+
current, current + 1, std::memory_order_acq_rel, std::memory_order_relaxed)) {
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
void releaseCapture() noexcept {
|
|
319
|
+
std::uint32_t current = uniqueCaptures.load(std::memory_order_relaxed);
|
|
320
|
+
while (true) {
|
|
321
|
+
if (current == 0) {
|
|
322
|
+
geometry_private::InstanceMemoryLedger::instance().noteImbalance();
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (uniqueCaptures.compare_exchange_weak(
|
|
326
|
+
current, current - 1, std::memory_order_acq_rel, std::memory_order_relaxed)) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
class WorldOwnershipRefusal : public std::exception {
|
|
334
|
+
public:
|
|
335
|
+
const char* what() const noexcept override { return "world ownership operation refused"; }
|
|
336
|
+
};
|
|
337
|
+
|
|
127
338
|
struct BodyHandle {
|
|
128
339
|
WorldOwnerToken world;
|
|
129
340
|
std::uint64_t restoreEpoch = 0;
|
|
@@ -136,6 +347,12 @@ struct JointHandle {
|
|
|
136
347
|
JointId id;
|
|
137
348
|
};
|
|
138
349
|
|
|
350
|
+
struct FluidHandle {
|
|
351
|
+
WorldOwnerToken world;
|
|
352
|
+
std::uint64_t restoreEpoch = 0;
|
|
353
|
+
FluidId id;
|
|
354
|
+
};
|
|
355
|
+
|
|
139
356
|
enum class WorldQueryKind : std::uint32_t {
|
|
140
357
|
Raycast = 1,
|
|
141
358
|
Overlap = 2,
|
|
@@ -151,20 +368,307 @@ struct WorldQueryHit {
|
|
|
151
368
|
std::uint32_t childIndex = 0;
|
|
152
369
|
};
|
|
153
370
|
|
|
154
|
-
|
|
371
|
+
constexpr std::uint32_t kCheckpointBodyTileRows = 16;
|
|
372
|
+
inline constexpr std::uint8_t kStrongGeometryLegacy = 0;
|
|
373
|
+
inline constexpr std::uint8_t kStrongGeometryRecord = 1;
|
|
374
|
+
|
|
375
|
+
// Memo state is 0 empty, 1 filling, or 2 ready.
|
|
376
|
+
// logicalCount is the hashed length. physicalCount is the allocated length.
|
|
377
|
+
struct BodyTile {
|
|
378
|
+
mutable std::atomic<std::uint8_t> memoState{0};
|
|
379
|
+
std::uint32_t logicalCount = 0;
|
|
380
|
+
std::uint32_t physicalCount = 0;
|
|
381
|
+
mutable std::uint32_t memoLength = 0;
|
|
382
|
+
mutable std::array<std::uint8_t, 32> memo{};
|
|
383
|
+
std::shared_ptr<const double[]> values;
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
inline const double* bodyTileDoubles(const BodyTile& tile) noexcept {
|
|
387
|
+
return tile.values ? tile.values.get() : nullptr;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
struct CheckpointBodyTable {
|
|
391
|
+
std::uint32_t tileValues = 0;
|
|
392
|
+
std::uint64_t valueCount = 0;
|
|
393
|
+
std::vector<std::shared_ptr<const BodyTile>,
|
|
394
|
+
geometry_private::CheckpointAllocator<std::shared_ptr<const BodyTile>>> tiles;
|
|
395
|
+
std::vector<std::uint64_t, geometry_private::CheckpointAllocator<std::uint64_t>> tileAllocationBytes;
|
|
396
|
+
std::uint64_t selfAllocationBytes = 0;
|
|
397
|
+
std::uint64_t totalAllocatedBytes = 0;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
using CheckpointBodyTableOwner = std::shared_ptr<const CheckpointBodyTable>;
|
|
401
|
+
|
|
402
|
+
struct CheckpointProfile {
|
|
403
|
+
std::uint32_t abiVersion = 0;
|
|
404
|
+
std::uint32_t numericProfile = 0;
|
|
405
|
+
std::uint32_t idLength = 0;
|
|
406
|
+
std::array<char, kWorldMaxProfileIdBytes> id{};
|
|
407
|
+
std::array<std::uint8_t, 32> geometryDigest{};
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
struct CheckpointData {
|
|
155
411
|
WorldOwnerToken world;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
412
|
+
CheckpointBodyTableOwner bodies;
|
|
413
|
+
geometry_private::GeometryRootOwner geometryRoot;
|
|
414
|
+
WorldPose pose;
|
|
415
|
+
CheckpointProfile profile{};
|
|
416
|
+
|
|
417
|
+
std::size_t totalAllocatedBytes = 0;
|
|
418
|
+
std::uint64_t frame = 0;
|
|
419
|
+
BodyId nextBodyId{1};
|
|
420
|
+
JointId nextJointId{1};
|
|
421
|
+
FluidId nextFluidId{1};
|
|
422
|
+
|
|
423
|
+
std::size_t jointsOffset = 0;
|
|
424
|
+
std::size_t jointsCount = 0;
|
|
425
|
+
|
|
426
|
+
std::size_t legacyGeometryOffset = 0;
|
|
427
|
+
std::size_t legacyGeometryCount = 0;
|
|
428
|
+
|
|
429
|
+
std::size_t contactCacheOffset = 0;
|
|
430
|
+
std::size_t contactCacheCount = 0;
|
|
431
|
+
|
|
432
|
+
std::size_t forcesOffset = 0;
|
|
433
|
+
std::size_t forcesCount = 0;
|
|
434
|
+
|
|
435
|
+
std::size_t tickForcesOffset = 0;
|
|
436
|
+
std::size_t tickForcesCount = 0;
|
|
437
|
+
|
|
438
|
+
std::size_t supportSpringsOffset = 0;
|
|
439
|
+
std::size_t supportSpringsCount = 0;
|
|
440
|
+
|
|
441
|
+
std::size_t supportForcesOffset = 0;
|
|
442
|
+
std::size_t supportForcesCount = 0;
|
|
443
|
+
|
|
444
|
+
std::size_t fluidsOffset = 0;
|
|
445
|
+
std::size_t fluidsCount = 0;
|
|
446
|
+
|
|
447
|
+
std::size_t surfaceVelocitiesOffset = 0;
|
|
448
|
+
std::size_t surfaceVelocitiesCount = 0;
|
|
449
|
+
|
|
450
|
+
std::size_t jointWarmStateOffset = 0;
|
|
451
|
+
std::size_t jointWarmStateCount = 0;
|
|
452
|
+
|
|
453
|
+
std::size_t contactEventsOffset = 0;
|
|
454
|
+
std::size_t contactEventsCount = 0;
|
|
455
|
+
|
|
456
|
+
std::size_t jointReactionsOffset = 0;
|
|
457
|
+
std::size_t jointReactionsCount = 0;
|
|
458
|
+
|
|
459
|
+
std::size_t jointBreakEventsOffset = 0;
|
|
460
|
+
std::size_t jointBreakEventsCount = 0;
|
|
461
|
+
|
|
462
|
+
std::size_t fluidInteractionsOffset = 0;
|
|
463
|
+
std::size_t fluidInteractionsCount = 0;
|
|
464
|
+
|
|
465
|
+
std::size_t topologyBodyIdsOffset = 0;
|
|
466
|
+
std::size_t topologyBodyIdsCount = 0;
|
|
467
|
+
|
|
468
|
+
std::size_t topologyJointsOffset = 0;
|
|
469
|
+
std::size_t topologyJointsCount = 0;
|
|
470
|
+
|
|
471
|
+
std::size_t topologyFluidIdsOffset = 0;
|
|
472
|
+
std::size_t topologyFluidIdsCount = 0;
|
|
473
|
+
|
|
474
|
+
std::size_t bodyDefinitionSignaturesOffset = 0;
|
|
475
|
+
std::size_t bodyDefinitionSignaturesCount = 0;
|
|
476
|
+
|
|
477
|
+
std::size_t jointDefinitionSignaturesOffset = 0;
|
|
478
|
+
std::size_t jointDefinitionSignaturesCount = 0;
|
|
479
|
+
|
|
480
|
+
std::uint8_t geometryForm = kStrongGeometryLegacy;
|
|
481
|
+
mutable std::atomic<std::uint8_t> strongMemoState{0};
|
|
482
|
+
mutable WorldLimits strongMemoLimits{};
|
|
483
|
+
mutable std::array<std::uint8_t, 32> strongMemo{};
|
|
484
|
+
|
|
485
|
+
const std::byte* dataBytes() const noexcept {
|
|
486
|
+
return reinterpret_cast<const std::byte*>(this);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
std::span<const double> joints() const noexcept {
|
|
490
|
+
return {reinterpret_cast<const double*>(dataBytes() + jointsOffset), jointsCount};
|
|
491
|
+
}
|
|
492
|
+
std::span<const double> legacyGeometry() const noexcept {
|
|
493
|
+
return {reinterpret_cast<const double*>(dataBytes() + legacyGeometryOffset), legacyGeometryCount};
|
|
494
|
+
}
|
|
495
|
+
std::span<const double> contactCache() const noexcept {
|
|
496
|
+
return {reinterpret_cast<const double*>(dataBytes() + contactCacheOffset), contactCacheCount};
|
|
497
|
+
}
|
|
498
|
+
std::span<const double> forces() const noexcept {
|
|
499
|
+
return {reinterpret_cast<const double*>(dataBytes() + forcesOffset), forcesCount};
|
|
500
|
+
}
|
|
501
|
+
std::span<const double> tickForces() const noexcept {
|
|
502
|
+
return {reinterpret_cast<const double*>(dataBytes() + tickForcesOffset), tickForcesCount};
|
|
503
|
+
}
|
|
504
|
+
std::span<const WorldSupportSpring> supportSprings() const noexcept {
|
|
505
|
+
return {reinterpret_cast<const WorldSupportSpring*>(dataBytes() + supportSpringsOffset), supportSpringsCount};
|
|
506
|
+
}
|
|
507
|
+
std::span<const WorldSupportForce> supportForces() const noexcept {
|
|
508
|
+
return {reinterpret_cast<const WorldSupportForce*>(dataBytes() + supportForcesOffset), supportForcesCount};
|
|
509
|
+
}
|
|
510
|
+
std::span<const double> fluids() const noexcept {
|
|
511
|
+
return {reinterpret_cast<const double*>(dataBytes() + fluidsOffset), fluidsCount};
|
|
512
|
+
}
|
|
513
|
+
std::span<const double> surfaceVelocities() const noexcept {
|
|
514
|
+
return {reinterpret_cast<const double*>(dataBytes() + surfaceVelocitiesOffset), surfaceVelocitiesCount};
|
|
515
|
+
}
|
|
516
|
+
std::span<const JointWarmState3D> jointWarmState() const noexcept {
|
|
517
|
+
return {reinterpret_cast<const JointWarmState3D*>(dataBytes() + jointWarmStateOffset), jointWarmStateCount};
|
|
518
|
+
}
|
|
519
|
+
std::span<const WorldContactEvent> contactEvents() const noexcept {
|
|
520
|
+
return {reinterpret_cast<const WorldContactEvent*>(dataBytes() + contactEventsOffset), contactEventsCount};
|
|
521
|
+
}
|
|
522
|
+
std::span<const WorldJointReaction> jointReactions() const noexcept {
|
|
523
|
+
return {reinterpret_cast<const WorldJointReaction*>(dataBytes() + jointReactionsOffset), jointReactionsCount};
|
|
524
|
+
}
|
|
525
|
+
std::span<const WorldJointBreakEvent> jointBreakEvents() const noexcept {
|
|
526
|
+
return {reinterpret_cast<const WorldJointBreakEvent*>(dataBytes() + jointBreakEventsOffset), jointBreakEventsCount};
|
|
527
|
+
}
|
|
528
|
+
std::span<const WorldFluidInteraction> fluidInteractions() const noexcept {
|
|
529
|
+
return {reinterpret_cast<const WorldFluidInteraction*>(dataBytes() + fluidInteractionsOffset), fluidInteractionsCount};
|
|
530
|
+
}
|
|
531
|
+
std::span<const BodyId> topologyBodyIds() const noexcept {
|
|
532
|
+
return {reinterpret_cast<const BodyId*>(dataBytes() + topologyBodyIdsOffset), topologyBodyIdsCount};
|
|
533
|
+
}
|
|
534
|
+
std::span<const JointIdentity> topologyJoints() const noexcept {
|
|
535
|
+
return {reinterpret_cast<const JointIdentity*>(dataBytes() + topologyJointsOffset), topologyJointsCount};
|
|
536
|
+
}
|
|
537
|
+
std::span<const FluidId> topologyFluidIds() const noexcept {
|
|
538
|
+
return {reinterpret_cast<const FluidId*>(dataBytes() + topologyFluidIdsOffset), topologyFluidIdsCount};
|
|
539
|
+
}
|
|
540
|
+
std::span<const std::uint64_t> bodyDefinitionSignatures() const noexcept {
|
|
541
|
+
return {reinterpret_cast<const std::uint64_t*>(dataBytes() + bodyDefinitionSignaturesOffset), bodyDefinitionSignaturesCount};
|
|
542
|
+
}
|
|
543
|
+
std::span<const std::uint64_t> jointDefinitionSignatures() const noexcept {
|
|
544
|
+
return {reinterpret_cast<const std::uint64_t*>(dataBytes() + jointDefinitionSignaturesOffset), jointDefinitionSignaturesCount};
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
struct CheckpointDataDeleter {
|
|
549
|
+
void operator()(CheckpointData* ptr) const noexcept;
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
struct CaptureShare {
|
|
553
|
+
std::shared_ptr<NativeWorldOwner> owner;
|
|
554
|
+
CaptureShare(std::shared_ptr<NativeWorldOwner> owner, NativeWorldOwner::ClaimedCapture) noexcept
|
|
555
|
+
: owner(std::move(owner)) {}
|
|
556
|
+
CaptureShare(const CaptureShare&) = delete;
|
|
557
|
+
CaptureShare& operator=(const CaptureShare&) = delete;
|
|
558
|
+
~CaptureShare() {
|
|
559
|
+
if (owner) owner->releaseCapture();
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
class WorldCheckpoint {
|
|
564
|
+
public:
|
|
565
|
+
WorldCheckpoint() noexcept = default;
|
|
566
|
+
~WorldCheckpoint() = default;
|
|
567
|
+
WorldCheckpoint(const WorldCheckpoint&) noexcept = default;
|
|
568
|
+
WorldCheckpoint& operator=(const WorldCheckpoint&) noexcept = default;
|
|
569
|
+
WorldCheckpoint(WorldCheckpoint&&) noexcept = default;
|
|
570
|
+
WorldCheckpoint& operator=(WorldCheckpoint&&) noexcept = default;
|
|
571
|
+
|
|
572
|
+
CheckpointBodyTableOwner bodyTable() const noexcept {
|
|
573
|
+
return data_ ? data_->bodies : nullptr;
|
|
574
|
+
}
|
|
575
|
+
WorldOwnerToken world() const noexcept {
|
|
576
|
+
return data_ ? data_->world : WorldOwnerToken{};
|
|
577
|
+
}
|
|
578
|
+
const std::shared_ptr<const CheckpointData>& data() const noexcept {
|
|
579
|
+
return data_;
|
|
580
|
+
}
|
|
581
|
+
void clear() noexcept {
|
|
582
|
+
data_.reset();
|
|
583
|
+
share_.reset();
|
|
584
|
+
}
|
|
585
|
+
explicit operator bool() const noexcept {
|
|
586
|
+
return static_cast<bool>(data_);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
private:
|
|
590
|
+
friend class World;
|
|
591
|
+
#if defined(RUNDOT_PHYSICS_PHASE_TEST_HOOKS)
|
|
592
|
+
friend void rundot_kinetix_test_clear_checkpoint_profile_id(WorldCheckpoint& checkpoint) noexcept;
|
|
593
|
+
#endif
|
|
594
|
+
std::shared_ptr<const CheckpointData> data_;
|
|
595
|
+
std::shared_ptr<CaptureShare> share_;
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
class PreparedCheckpoint {
|
|
599
|
+
public:
|
|
600
|
+
PreparedCheckpoint() noexcept = default;
|
|
601
|
+
PreparedCheckpoint(const PreparedCheckpoint&) = delete;
|
|
602
|
+
PreparedCheckpoint& operator=(const PreparedCheckpoint&) = delete;
|
|
603
|
+
PreparedCheckpoint(PreparedCheckpoint&&) noexcept = default;
|
|
604
|
+
PreparedCheckpoint& operator=(PreparedCheckpoint&&) noexcept = default;
|
|
605
|
+
|
|
606
|
+
private:
|
|
607
|
+
friend class World;
|
|
608
|
+
WorldCheckpoint checkpoint_;
|
|
609
|
+
std::uint64_t revision_ = 0;
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
struct BodyMotionWrite {
|
|
613
|
+
std::uint32_t count = 0;
|
|
614
|
+
std::uint64_t mutationRevision = 0;
|
|
615
|
+
std::uint64_t restoreEpoch = 0;
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
enum class TopologyPlanState : std::uint8_t { Idle = 0, Pending = 1 };
|
|
619
|
+
|
|
620
|
+
// Explicit World-class claim for plan vectors. std::vector storage is not
|
|
621
|
+
// routed through InstanceLedger::allocateRaw. Geometry roots and material
|
|
622
|
+
// pose roots keep their existing Geometry-domain charges.
|
|
623
|
+
struct TopologyPlanAccount {
|
|
624
|
+
std::uint64_t worldBytes = 0;
|
|
625
|
+
|
|
626
|
+
TopologyPlanAccount() noexcept = default;
|
|
627
|
+
TopologyPlanAccount(const TopologyPlanAccount&) = delete;
|
|
628
|
+
TopologyPlanAccount& operator=(const TopologyPlanAccount&) = delete;
|
|
629
|
+
TopologyPlanAccount(TopologyPlanAccount&& other) noexcept;
|
|
630
|
+
TopologyPlanAccount& operator=(TopologyPlanAccount&& other) noexcept;
|
|
631
|
+
~TopologyPlanAccount();
|
|
632
|
+
void release() noexcept;
|
|
633
|
+
bool reset(std::uint64_t bytes) noexcept;
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
// One pending edit for this world. The plan owns every staged byte.
|
|
637
|
+
// World scratch members stay available to step, replace, and import.
|
|
638
|
+
struct PreparedTopologyEdit {
|
|
639
|
+
TopologyWorkspace workspace;
|
|
640
|
+
std::vector<double> tickForces;
|
|
641
|
+
std::vector<JointWarmState3D> jointWarm;
|
|
642
|
+
std::vector<std::uint64_t> bodySigs;
|
|
643
|
+
std::vector<std::uint64_t> jointSigs;
|
|
644
|
+
std::vector<double> contactCache;
|
|
645
|
+
std::vector<double> surfaceVelocities;
|
|
646
|
+
WorldTickSupports supports;
|
|
647
|
+
WorldGeometry geometry = std::vector<double>{};
|
|
648
|
+
bool recordGeometry = false;
|
|
649
|
+
WorldPose pose = NativeWorldPose{};
|
|
650
|
+
std::vector<BodyId> removedBodies;
|
|
651
|
+
std::vector<JointId> removedJoints;
|
|
652
|
+
std::vector<FluidId> removedFluids;
|
|
653
|
+
bool emptyCommands = false;
|
|
654
|
+
TopologyPlanAccount account;
|
|
159
655
|
};
|
|
160
656
|
|
|
161
657
|
class World {
|
|
162
658
|
public:
|
|
163
659
|
using Snapshot = std::vector<std::uint8_t>;
|
|
164
660
|
|
|
165
|
-
explicit World(WorldProfile profile = {});
|
|
661
|
+
explicit World(WorldProfile profile = {}, WorldLimits limits = {});
|
|
662
|
+
~World();
|
|
663
|
+
// Copy semantics (clone): clones receive a fresh owner record, so checkpoints
|
|
664
|
+
// captured on the source world cannot be restored into the clone (HandleWrongWorld).
|
|
665
|
+
// A pending topology plan stays on the source. The clone has no plan.
|
|
166
666
|
World(const World& other);
|
|
167
667
|
World& operator=(const World& other);
|
|
668
|
+
// Move semantics: moved-from world receives a fresh owner record (which may allocate,
|
|
669
|
+
// hence move is not noexcept), invalidating pre-move checkpoints against the moved-from
|
|
670
|
+
// world, while moved-to world retains the original record and can restore pre-move checkpoints.
|
|
671
|
+
// A pending topology plan moves with the owner. Move assignment releases both plans.
|
|
168
672
|
World(World&& other);
|
|
169
673
|
World& operator=(World&& other);
|
|
170
674
|
|
|
@@ -172,20 +676,83 @@ class World {
|
|
|
172
676
|
const WorldLimits& limits() const { return limits_; }
|
|
173
677
|
std::uint64_t frame() const { return state_.frame; }
|
|
174
678
|
std::uint64_t restoreEpoch() const { return restoreEpoch_; }
|
|
175
|
-
WorldOwnerToken ownerToken() const { return
|
|
679
|
+
WorldOwnerToken ownerToken() const { return owner_->token; }
|
|
680
|
+
std::uint64_t mutationRevision() const noexcept { return owner_->mutationRevision; }
|
|
681
|
+
bool isAttached() const noexcept { return owner_->attached; }
|
|
682
|
+
std::uint32_t attachmentToken() const noexcept { return owner_->attachmentToken; }
|
|
683
|
+
std::uint32_t uniqueCaptureCount() const noexcept {
|
|
684
|
+
return owner_->uniqueCaptures.load(std::memory_order_acquire);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
WorldError attach(std::uint64_t expectedDigest, std::uint32_t& outputToken);
|
|
688
|
+
WorldError detach(std::uint32_t token);
|
|
176
689
|
|
|
177
690
|
const WorldState& state() const { return state_; }
|
|
178
691
|
const TopologyState& topology() const { return state_.topology; }
|
|
179
692
|
const std::vector<WorldContactEvent>& latestContacts() const {
|
|
180
693
|
return state_.contactEvents;
|
|
181
694
|
}
|
|
695
|
+
const std::vector<WorldJointReaction>& latestJointReactions() const {
|
|
696
|
+
return state_.jointReactions;
|
|
697
|
+
}
|
|
698
|
+
const std::vector<WorldJointBreakEvent>& latestJointBreaks() const {
|
|
699
|
+
return state_.jointBreakEvents;
|
|
700
|
+
}
|
|
701
|
+
const std::vector<WorldFluidInteraction>& latestFluidInteractions() const {
|
|
702
|
+
return state_.fluidInteractions;
|
|
703
|
+
}
|
|
182
704
|
WorldState captureState() const { return state_; }
|
|
705
|
+
// Frame-0 attach compares this digest. The digest covers all world state
|
|
706
|
+
// including the material pose root via WorldDigestVisitor::visitMaterialPose.
|
|
183
707
|
std::uint64_t digest() const;
|
|
184
|
-
|
|
185
|
-
WorldError
|
|
708
|
+
WorldError captureCheckpoint(WorldCheckpoint& output, std::uint32_t attachmentToken = 0);
|
|
709
|
+
WorldError prepareCheckpoint(PreparedCheckpoint& output, std::uint32_t attachmentToken = 0);
|
|
710
|
+
WorldError publishCheckpoint(PreparedCheckpoint&& prepared, WorldCheckpoint& output) noexcept;
|
|
711
|
+
WorldError restoreCheckpoint(
|
|
712
|
+
const WorldCheckpoint& checkpoint,
|
|
713
|
+
std::uint32_t attachmentToken = 0);
|
|
714
|
+
WorldError digestCheckpoint(
|
|
715
|
+
const WorldCheckpoint& checkpoint,
|
|
716
|
+
std::uint64_t& output,
|
|
717
|
+
std::uint32_t attachmentToken = 0) const;
|
|
718
|
+
WorldError strongDigestCheckpoint(
|
|
719
|
+
const WorldCheckpoint& checkpoint,
|
|
720
|
+
std::array<std::uint8_t, 32>& output,
|
|
721
|
+
std::uint32_t attachmentToken = 0) const;
|
|
722
|
+
WorldError importCheckpoint(
|
|
723
|
+
std::span<const std::uint8_t> bytes,
|
|
724
|
+
WorldCheckpoint& output,
|
|
725
|
+
std::uint32_t attachmentToken = 0);
|
|
186
726
|
WorldError captureCheckpointSnapshot(
|
|
187
727
|
const WorldCheckpoint& checkpoint,
|
|
188
|
-
Snapshot& output
|
|
728
|
+
Snapshot& output,
|
|
729
|
+
std::uint32_t attachmentToken = 0) const;
|
|
730
|
+
#if defined(RUNDOT_PHYSICS_PHASE_TEST_HOOKS)
|
|
731
|
+
std::uint64_t liveDigestCount() const noexcept { return liveDigestCount_; }
|
|
732
|
+
std::uint64_t liveRestoreCount() const noexcept { return liveRestoreCount_; }
|
|
733
|
+
std::uint64_t liveSerializationCount() const noexcept { return liveSerializationCount_; }
|
|
734
|
+
std::uint64_t geometryScanCount() const noexcept { return geometryScanCount_; }
|
|
735
|
+
void noteGeometryScanForTest() const noexcept { ++geometryScanCount_; }
|
|
736
|
+
void resetTestCounters() noexcept {
|
|
737
|
+
liveDigestCount_ = 0;
|
|
738
|
+
liveRestoreCount_ = 0;
|
|
739
|
+
liveSerializationCount_ = 0;
|
|
740
|
+
geometryScanCount_ = 0;
|
|
741
|
+
}
|
|
742
|
+
void setTestDefinitionSignatures(std::vector<std::uint64_t> bSigs, std::vector<std::uint64_t> jSigs) {
|
|
743
|
+
bodyDefinitionSignatures_ = std::move(bSigs);
|
|
744
|
+
jointDefinitionSignatures_ = std::move(jSigs);
|
|
745
|
+
}
|
|
746
|
+
void setLimitsForTest(const WorldLimits& limits) noexcept { limits_ = limits; }
|
|
747
|
+
WorldError strongDigestLiveForTest(std::array<std::uint8_t, 32>& output) const;
|
|
748
|
+
WorldError replaceDecodedStateForTest(const WorldState& state);
|
|
749
|
+
WorldError auditBodyTableForTest(CheckpointBodyTable& table) const;
|
|
750
|
+
#endif
|
|
751
|
+
CheckpointBodyTableOwner lastCaptureBodies() const noexcept { return lastCaptureBodies_; }
|
|
752
|
+
void dropCaptureCache() noexcept { lastCaptureBodies_.reset(); }
|
|
753
|
+
std::uint64_t captureCacheBytes() const noexcept {
|
|
754
|
+
return lastCaptureBodies_ ? lastCaptureBodies_->totalAllocatedBytes : 0;
|
|
755
|
+
}
|
|
189
756
|
WorldError validate() const;
|
|
190
757
|
|
|
191
758
|
// Validate all lengths and values before replacing the owned state.
|
|
@@ -197,16 +764,49 @@ class World {
|
|
|
197
764
|
std::span<const TopologyCommand> commands,
|
|
198
765
|
TopologyBatchResult& result);
|
|
199
766
|
|
|
767
|
+
// Internal synchronous split of applyTopologyBatch. One plan per world.
|
|
768
|
+
// This is not a general transaction API.
|
|
769
|
+
WorldError prepareTopologyEdit(
|
|
770
|
+
std::span<const TopologyCommand> commands,
|
|
771
|
+
std::uint64_t expectedRevision,
|
|
772
|
+
std::uint64_t& serial);
|
|
773
|
+
WorldError commitTopologyEdit(
|
|
774
|
+
std::uint64_t serial,
|
|
775
|
+
std::uint64_t revision,
|
|
776
|
+
TopologyBatchResult* result = nullptr) noexcept;
|
|
777
|
+
WorldError abandonTopologyEdit(std::uint64_t serial) noexcept;
|
|
778
|
+
bool readTopologyEditRemoved(
|
|
779
|
+
std::uint64_t serial,
|
|
780
|
+
std::span<const BodyId>& bodies,
|
|
781
|
+
std::span<const JointId>& joints,
|
|
782
|
+
std::span<const FluidId>& fluids) const noexcept;
|
|
783
|
+
bool readTopologyEditCreated(
|
|
784
|
+
std::uint64_t serial,
|
|
785
|
+
std::span<const CreatedBodyIdentity>& bodies,
|
|
786
|
+
std::span<const CreatedJointIdentity>& joints,
|
|
787
|
+
std::span<const CreatedFluidIdentity>& fluids) const noexcept;
|
|
788
|
+
bool hasTopologyPlan() const noexcept { return planState_ == TopologyPlanState::Pending; }
|
|
789
|
+
std::uint64_t topologyPlanSerial() const noexcept { return planSerial_; }
|
|
790
|
+
// Explicit ledger claim. This is not solverRetainedBytes.
|
|
791
|
+
std::uint64_t topologyPlanTrackedBytes() const noexcept { return topologyPlan_.account.worldBytes; }
|
|
792
|
+
std::uint64_t topologyPlanClaimedPeak() const noexcept { return planClaimedPeak_; }
|
|
793
|
+
std::uint64_t geometryAnchorTrackedBytes() const noexcept { return geometryStore_.anchorCapacityBytes(); }
|
|
794
|
+
std::uint64_t topologyPlanDiagnosticBytes() const noexcept;
|
|
795
|
+
|
|
200
796
|
WorldError resolveBody(BodyId id, BodyHandle& output) const;
|
|
201
797
|
WorldError resolveJoint(JointId id, JointHandle& output) const;
|
|
798
|
+
WorldError resolveFluid(FluidId id, FluidHandle& output) const;
|
|
202
799
|
WorldError readBody(BodyId id, std::array<double, kBodyStride>& output) const;
|
|
800
|
+
WorldError readGeometry(BodyId id, WorldGeometryView& output) const;
|
|
203
801
|
WorldError readJoint(
|
|
204
802
|
JointId id,
|
|
205
|
-
|
|
803
|
+
JointRecord& output,
|
|
206
804
|
BodyId& bodyA,
|
|
207
805
|
BodyId& bodyB) const;
|
|
806
|
+
WorldError readFluid(FluidId id, std::array<double, kFluidStride>& output) const;
|
|
208
807
|
WorldError validateHandle(const BodyHandle& handle) const;
|
|
209
808
|
WorldError validateHandle(const JointHandle& handle) const;
|
|
809
|
+
WorldError validateHandle(const FluidHandle& handle) const;
|
|
210
810
|
|
|
211
811
|
WorldError applyImpulse(
|
|
212
812
|
BodyId id,
|
|
@@ -214,6 +814,53 @@ class World {
|
|
|
214
814
|
bool hasPoint,
|
|
215
815
|
const std::array<double, 3>& point);
|
|
216
816
|
|
|
817
|
+
WorldError setBodyForce(BodyId id, const std::array<double, 3>& force,
|
|
818
|
+
const std::array<double, 3>& torque);
|
|
819
|
+
WorldError applyForce(BodyId id, const std::array<double, 3>& force,
|
|
820
|
+
const std::array<double, 3>& torque);
|
|
821
|
+
WorldError applyForceAtPoint(BodyId id, const std::array<double, 3>& force,
|
|
822
|
+
const std::array<double, 3>& point);
|
|
823
|
+
WorldError clearBodyForce(BodyId id);
|
|
824
|
+
|
|
825
|
+
WorldError setBodySurfaceVelocity(
|
|
826
|
+
BodyId id,
|
|
827
|
+
const std::array<double, 3>& velocity);
|
|
828
|
+
WorldError setBodyLinearVelocity(
|
|
829
|
+
BodyId id,
|
|
830
|
+
const std::array<double, 3>& velocity);
|
|
831
|
+
WorldError setBodyAngularVelocity(
|
|
832
|
+
BodyId id,
|
|
833
|
+
const std::array<double, 3>& velocity);
|
|
834
|
+
WorldError setBodyTransform(
|
|
835
|
+
BodyId id,
|
|
836
|
+
const std::array<double, 3>& position,
|
|
837
|
+
const std::array<double, 4>& orientation);
|
|
838
|
+
WorldError setBodyLinearDamping(BodyId id, double damping);
|
|
839
|
+
WorldError wakeBody(BodyId id);
|
|
840
|
+
WorldError writeBodyMotionInto(
|
|
841
|
+
std::span<double> pose,
|
|
842
|
+
std::span<double> velocity,
|
|
843
|
+
std::span<std::uint32_t> ids,
|
|
844
|
+
std::span<std::uint8_t> status,
|
|
845
|
+
BodyMotionWrite& output) const;
|
|
846
|
+
|
|
847
|
+
// Append support records for the next step. The call is atomic.
|
|
848
|
+
// wakeTarget 0 wakes nobody. A real id clears only that body sleep bit.
|
|
849
|
+
WorldError applySupport(
|
|
850
|
+
std::span<const WorldSupportSpringInput> springs,
|
|
851
|
+
std::span<const WorldSupportForceInput> forces,
|
|
852
|
+
BodyId wakeTarget);
|
|
853
|
+
|
|
854
|
+
WorldError readBodyMobility(BodyId id, WorldBodyMobility& output) const;
|
|
855
|
+
WorldError readEffectiveSurfaceVelocity(
|
|
856
|
+
BodyId id, std::array<double, 3>& velocity) const;
|
|
857
|
+
// dt and substeps are the caller tick. h = dt / substeps.
|
|
858
|
+
WorldError readPendingSupportImpulse(
|
|
859
|
+
BodyId id,
|
|
860
|
+
double dt,
|
|
861
|
+
std::uint32_t substeps,
|
|
862
|
+
WorldSupportImpulse& output) const;
|
|
863
|
+
|
|
217
864
|
// Advance one fixed physics tick. State validation happens at replaceState
|
|
218
865
|
// and importSnapshot. Different World objects own independent solver
|
|
219
866
|
// scratch. A World object itself needs external synchronization.
|
|
@@ -224,6 +871,9 @@ class World {
|
|
|
224
871
|
std::span<const double, kQueryInputStride> values,
|
|
225
872
|
BodyId excludedBody,
|
|
226
873
|
std::vector<WorldQueryHit>& output);
|
|
874
|
+
WorldError raycastBody(BodyId body,
|
|
875
|
+
std::span<const double, kQueryInputStride> values,
|
|
876
|
+
BodyId excludedBody, std::vector<WorldQueryHit>& output);
|
|
227
877
|
|
|
228
878
|
// Invalid profiles return an empty snapshot because no canonical bytes can
|
|
229
879
|
// be emitted for an unsupported identity.
|
|
@@ -231,23 +881,39 @@ class World {
|
|
|
231
881
|
|
|
232
882
|
// Import is atomic. The existing state remains usable when parsing,
|
|
233
883
|
// validation, or profile matching fails.
|
|
234
|
-
WorldError importSnapshot(
|
|
884
|
+
WorldError importSnapshot(
|
|
885
|
+
std::span<const std::uint8_t> bytes,
|
|
886
|
+
std::uint32_t attachmentToken = 0);
|
|
235
887
|
|
|
236
888
|
World clone() const;
|
|
889
|
+
// Scratch capacity estimate. This is not allocator or WASM heap telemetry.
|
|
890
|
+
// Empty worlds report 0. The instance ledger reports actual retained bytes.
|
|
237
891
|
std::uint64_t solverRetainedBytes() const noexcept;
|
|
238
892
|
|
|
239
893
|
private:
|
|
240
894
|
WorldProfile profile_;
|
|
241
895
|
WorldLimits limits_;
|
|
242
896
|
WorldState state_;
|
|
243
|
-
|
|
897
|
+
WorldState restoreWorkspace_;
|
|
898
|
+
CheckpointBodyTableOwner lastCaptureBodies_;
|
|
899
|
+
geometry_private::GeometryStore geometryStore_;
|
|
900
|
+
std::vector<GeometryBodyInput> bodyGeometryInputs_;
|
|
901
|
+
std::shared_ptr<NativeWorldOwner> owner_;
|
|
902
|
+
bool worldRegistered_ = false;
|
|
244
903
|
std::uint64_t restoreEpoch_ = 1;
|
|
245
904
|
SolverContext solver_;
|
|
905
|
+
std::unique_ptr<SolverContext> selectedQuerySolver_;
|
|
246
906
|
std::vector<double> candidateBodies_;
|
|
247
907
|
std::vector<double> soaBodies_;
|
|
248
908
|
std::vector<double> candidateJoints_;
|
|
249
909
|
std::vector<double> candidateContactCache_;
|
|
910
|
+
std::vector<double> candidateSurfaceVelocities_;
|
|
911
|
+
std::vector<double> candidateTickForces_;
|
|
912
|
+
std::vector<double> candidateExternalForces_;
|
|
250
913
|
std::vector<WorldContactEvent> candidateContactEvents_;
|
|
914
|
+
std::vector<WorldJointReaction> candidateJointReactions_;
|
|
915
|
+
std::vector<WorldJointBreakEvent> candidateJointBreakEvents_;
|
|
916
|
+
std::vector<WorldFluidInteraction> candidateFluidInteractions_;
|
|
251
917
|
std::vector<JointIdentity> candidateJointIdentities_;
|
|
252
918
|
std::vector<JointWarmState3D> candidateJointWarmState_;
|
|
253
919
|
std::vector<std::uint64_t> candidateJointIds_;
|
|
@@ -256,28 +922,134 @@ class World {
|
|
|
256
922
|
std::vector<std::uint64_t> candidateBodyDefinitionSignatures_;
|
|
257
923
|
std::vector<std::uint64_t> candidateJointDefinitionSignatures_;
|
|
258
924
|
TopologyWorkspace topologyWorkspace_;
|
|
925
|
+
PreparedTopologyEdit topologyPlan_;
|
|
926
|
+
TopologyPlanState planState_ = TopologyPlanState::Idle;
|
|
927
|
+
std::uint64_t planSerial_ = 0;
|
|
928
|
+
std::uint64_t planRevision_ = 0;
|
|
929
|
+
std::uint64_t planEpoch_ = 0;
|
|
930
|
+
std::uint32_t planAttachToken_ = 0;
|
|
931
|
+
std::uint64_t planAttachGeneration_ = 0;
|
|
932
|
+
std::uint64_t planClaimedPeak_ = 0;
|
|
933
|
+
mutable TopologyPlanAccount geometryAnchorAccount_;
|
|
934
|
+
mutable std::uint64_t anchorRecordSize_ = 0;
|
|
935
|
+
mutable std::uint64_t anchorRecordCap_ = 0;
|
|
936
|
+
mutable std::uint64_t anchorRootSize_ = 0;
|
|
937
|
+
mutable std::uint64_t anchorRootCap_ = 0;
|
|
938
|
+
|
|
939
|
+
struct AnchorForecast {
|
|
940
|
+
std::uint64_t recordSize = 0;
|
|
941
|
+
std::uint64_t recordCap = 0;
|
|
942
|
+
std::uint64_t rootSize = 0;
|
|
943
|
+
std::uint64_t rootCap = 0;
|
|
944
|
+
std::uint64_t finalBytes = 0;
|
|
945
|
+
std::uint64_t peakBytes = 0;
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
struct AnchorHold {
|
|
949
|
+
const World& world;
|
|
950
|
+
AnchorForecast forecast{};
|
|
951
|
+
bool armed = false;
|
|
952
|
+
explicit AnchorHold(const World& owner) noexcept : world(owner) {}
|
|
953
|
+
AnchorHold(const AnchorHold&) = delete;
|
|
954
|
+
AnchorHold& operator=(const AnchorHold&) = delete;
|
|
955
|
+
~AnchorHold();
|
|
956
|
+
bool arm(std::uint64_t records, std::uint64_t roots) noexcept;
|
|
957
|
+
};
|
|
259
958
|
|
|
260
959
|
struct MoveReset;
|
|
261
960
|
World(World&& other, MoveReset&& reset);
|
|
262
961
|
void swap(World& other) noexcept;
|
|
962
|
+
void registerThisWorld() noexcept;
|
|
963
|
+
void releaseTopologyPlan() noexcept;
|
|
964
|
+
WorldError stagePreparedTopologyEdit(
|
|
965
|
+
std::span<const TopologyCommand> commands,
|
|
966
|
+
PreparedTopologyEdit& plan);
|
|
967
|
+
void publishPreparedTopologyEdit(TopologyBatchResult* result) noexcept;
|
|
968
|
+
static bool measurePlanVectorBytes(const PreparedTopologyEdit& plan, std::uint64_t& bytes) noexcept;
|
|
969
|
+
static std::uint64_t planChunkHeaderBytes(const PreparedTopologyEdit& plan) noexcept;
|
|
970
|
+
bool untrackedTopologyEditPeak(std::span<const TopologyCommand> commands, std::uint64_t& peak) const noexcept;
|
|
971
|
+
bool geometryStageGrowth(std::span<const TopologyCommand> commands, std::uint64_t& records, std::uint64_t& roots) const noexcept;
|
|
972
|
+
bool forecastAnchorGrowth(std::uint64_t newRecords, std::uint64_t newRoots, AnchorForecast& forecast) const noexcept;
|
|
973
|
+
bool claimAnchorGrowth(std::uint64_t newRecords, std::uint64_t newRoots, AnchorForecast& forecast) const noexcept;
|
|
974
|
+
void commitAnchorGrowth(const AnchorForecast& forecast) const noexcept;
|
|
975
|
+
std::uint64_t geometryAnchorExtra(std::span<const TopologyCommand> commands) const noexcept;
|
|
976
|
+
#if defined(RUNDOT_PHYSICS_PHASE_TEST_HOOKS)
|
|
977
|
+
friend void rundot_kinetix_test_set_mutation_revision(World& world, std::uint64_t revision) noexcept;
|
|
978
|
+
friend void rundot_kinetix_test_set_restore_epoch(World& world, std::uint64_t epoch) noexcept;
|
|
979
|
+
friend void rundot_kinetix_test_corrupt_topology_scratch(World& world);
|
|
980
|
+
friend bool rundot_kinetix_test_topology_edit_peak(
|
|
981
|
+
const World& world,
|
|
982
|
+
std::span<const TopologyCommand> commands,
|
|
983
|
+
std::uint64_t& peak,
|
|
984
|
+
std::uint64_t& anchor) noexcept;
|
|
985
|
+
friend void rundot_kinetix_test_set_attachment_generation(World& world, std::uint64_t generation) noexcept;
|
|
986
|
+
#endif
|
|
987
|
+
|
|
988
|
+
enum class PoseProvenance { Caller, Decoded };
|
|
263
989
|
|
|
264
990
|
static WorldError validateProfile(const WorldProfile& profile);
|
|
265
|
-
WorldError validateState(const WorldState& state) const;
|
|
991
|
+
WorldError validateState(const WorldState& state, PoseProvenance provenance) const;
|
|
266
992
|
WorldError validateStateValues(
|
|
267
993
|
const TopologyState& topology,
|
|
268
994
|
std::span<const double> bodies,
|
|
269
995
|
std::span<const double> joints,
|
|
270
|
-
|
|
996
|
+
const WorldGeometry& geometry,
|
|
271
997
|
std::span<const double> contactCache,
|
|
272
998
|
std::span<const double> forces,
|
|
999
|
+
std::span<const double> fluids,
|
|
273
1000
|
std::span<const JointWarmState3D> jointWarmState) const;
|
|
274
1001
|
WorldError buildDefinitionSignatures(
|
|
275
1002
|
const WorldState& state,
|
|
276
1003
|
std::vector<std::uint64_t>& bodySignatures,
|
|
277
1004
|
std::vector<std::uint64_t>& jointSignatures) const;
|
|
1005
|
+
// poseDomain selects the Root charge class. Checkpoint import uses
|
|
1006
|
+
// Checkpoint. Live snapshot import uses Geometry. The class stays on the
|
|
1007
|
+
// shared object. Restore does not clone the Root into another class.
|
|
1008
|
+
WorldError decodeSnapshot(
|
|
1009
|
+
std::span<const std::uint8_t> bytes,
|
|
1010
|
+
WorldState& candidate,
|
|
1011
|
+
std::vector<std::uint64_t>& candidateBodySigs,
|
|
1012
|
+
std::vector<std::uint64_t>& candidateJointSigs,
|
|
1013
|
+
geometry_private::LedgerDomain poseDomain) const;
|
|
1014
|
+
WorldError packCheckpointData(
|
|
1015
|
+
const WorldState& state,
|
|
1016
|
+
std::span<const std::uint64_t> bodySigs,
|
|
1017
|
+
std::span<const std::uint64_t> jointSigs,
|
|
1018
|
+
const CheckpointBodyTable* prevTable,
|
|
1019
|
+
std::shared_ptr<CheckpointBodyTable>& outTable,
|
|
1020
|
+
std::shared_ptr<const CheckpointData>& outData) const;
|
|
278
1021
|
static WorldError validateOptions(const StepOptions& options);
|
|
279
1022
|
WorldError advanceRestoreEpoch() const;
|
|
280
|
-
|
|
1023
|
+
WorldError advanceMutationRevision();
|
|
1024
|
+
Snapshot captureStateSnapshot(
|
|
1025
|
+
const WorldState& state,
|
|
1026
|
+
const CheckpointBodyTable* bodyTable = nullptr) const;
|
|
1027
|
+
|
|
1028
|
+
#if defined(RUNDOT_PHYSICS_PHASE_TEST_HOOKS)
|
|
1029
|
+
mutable std::uint64_t liveDigestCount_ = 0;
|
|
1030
|
+
mutable std::uint64_t liveRestoreCount_ = 0;
|
|
1031
|
+
mutable std::uint64_t liveSerializationCount_ = 0;
|
|
1032
|
+
mutable std::uint64_t geometryScanCount_ = 0;
|
|
1033
|
+
#endif
|
|
281
1034
|
};
|
|
282
1035
|
|
|
1036
|
+
#if defined(RUNDOT_PHYSICS_PHASE_TEST_HOOKS)
|
|
1037
|
+
void rundot_kinetix_test_set_mutation_revision(World& world, std::uint64_t revision) noexcept;
|
|
1038
|
+
void rundot_kinetix_test_set_restore_epoch(World& world, std::uint64_t epoch) noexcept;
|
|
1039
|
+
void rundot_kinetix_test_set_next_attachment_token(std::uint32_t token) noexcept;
|
|
1040
|
+
void rundot_kinetix_test_fail_next_definition_signatures() noexcept;
|
|
1041
|
+
void rundot_kinetix_test_fail_import_allocation(int index) noexcept;
|
|
1042
|
+
void rundot_kinetix_test_throw_after_capture_claim() noexcept;
|
|
1043
|
+
void rundot_kinetix_test_clear_checkpoint_profile_id(WorldCheckpoint& checkpoint) noexcept;
|
|
1044
|
+
void rundot_kinetix_test_set_topology_plan_serial_cursor(std::uint64_t next) noexcept;
|
|
1045
|
+
std::uint64_t rundot_kinetix_test_topology_plan_serial_cursor() noexcept;
|
|
1046
|
+
void rundot_kinetix_test_corrupt_topology_scratch(World& world);
|
|
1047
|
+
bool rundot_kinetix_test_topology_edit_peak(
|
|
1048
|
+
const World& world,
|
|
1049
|
+
std::span<const TopologyCommand> commands,
|
|
1050
|
+
std::uint64_t& peak,
|
|
1051
|
+
std::uint64_t& anchor) noexcept;
|
|
1052
|
+
void rundot_kinetix_test_set_attachment_generation(World& world, std::uint64_t generation) noexcept;
|
|
1053
|
+
#endif
|
|
1054
|
+
|
|
283
1055
|
} // namespace rundot::kinetix::physics
|