@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
|
@@ -4,23 +4,27 @@ const maxUint64 = 0xffffffffffffffffn;
|
|
|
4
4
|
const littleEndian = true;
|
|
5
5
|
|
|
6
6
|
export const ownedTransportAbi = Object.freeze({
|
|
7
|
-
cAbiVersion:
|
|
8
|
-
worldStorageAbiVersion:
|
|
9
|
-
snapshotVersion:
|
|
7
|
+
cAbiVersion: 6,
|
|
8
|
+
worldStorageAbiVersion: 7,
|
|
9
|
+
snapshotVersion: 6,
|
|
10
10
|
settingsAbiVersion: 1,
|
|
11
11
|
physicsProfile: 1,
|
|
12
|
-
bodyAbiVersion:
|
|
12
|
+
bodyAbiVersion: 5,
|
|
13
13
|
jointAbiVersion: 2,
|
|
14
14
|
fluidAbiVersion: 1,
|
|
15
|
-
queryAbiVersion:
|
|
15
|
+
queryAbiVersion: 3,
|
|
16
16
|
maxWorlds: 65_535,
|
|
17
17
|
maxBodies: 4096,
|
|
18
|
+
maxCheckpoints: 4096,
|
|
19
|
+
defaultCheckpoints: 64,
|
|
18
20
|
maxJoints: 4096,
|
|
19
21
|
maxFluids: 64,
|
|
22
|
+
maxContactPairs: 262_144,
|
|
23
|
+
maxContourEdges: 65_536,
|
|
20
24
|
maxCommands: 16_512,
|
|
21
25
|
maxGearReactions: 16_384,
|
|
22
26
|
worldKeyBytes: 16,
|
|
23
|
-
worldCapacityBytes:
|
|
27
|
+
worldCapacityBytes: 24,
|
|
24
28
|
settingsBytes: 32,
|
|
25
29
|
worldInfoBytes: 168,
|
|
26
30
|
latestOutputInfoBytes: 56,
|
|
@@ -28,16 +32,19 @@ export const ownedTransportAbi = Object.freeze({
|
|
|
28
32
|
commandBytes: 88,
|
|
29
33
|
handleBytes: 24,
|
|
30
34
|
removedIdentityBytes: 8,
|
|
31
|
-
bodyPayloadBytes:
|
|
32
|
-
|
|
35
|
+
bodyPayloadBytes: 296,
|
|
36
|
+
contactEventBytes: 32,
|
|
37
|
+
bodyBytes: 160,
|
|
33
38
|
polygonGeometryBytes: 136,
|
|
39
|
+
contourEdgeBytes: 72,
|
|
40
|
+
contourHeaderBytes: 32,
|
|
34
41
|
jointBytes: 160,
|
|
35
42
|
jointStateBytes: 128,
|
|
36
43
|
fluidBytes: 112,
|
|
37
44
|
telemetryBytes: 80,
|
|
38
45
|
breakEventBytes: 16,
|
|
39
46
|
gearReactionBytes: 64,
|
|
40
|
-
queryFilterBytes:
|
|
47
|
+
queryFilterBytes: 16,
|
|
41
48
|
raycastQueryBytes: 48,
|
|
42
49
|
overlapQueryBytes: 192,
|
|
43
50
|
shapeCastQueryBytes: 216,
|
|
@@ -45,6 +52,7 @@ export const ownedTransportAbi = Object.freeze({
|
|
|
45
52
|
castHitBytes: 64,
|
|
46
53
|
overlapHitBytes: 8,
|
|
47
54
|
closestPointHitBytes: 40,
|
|
55
|
+
overlapContactHitBytes: 80,
|
|
48
56
|
});
|
|
49
57
|
|
|
50
58
|
const ownedFunctions = Object.freeze([
|
|
@@ -53,9 +61,10 @@ const ownedFunctions = Object.freeze([
|
|
|
53
61
|
'rundot_physics2d_owned_snapshot_version',
|
|
54
62
|
'rundot_physics2d_owned_required_settings_abi_version',
|
|
55
63
|
'rundot_physics2d_owned_physics_profile',
|
|
56
|
-
'
|
|
57
|
-
'rundot_physics2d_owned_registry_alignment',
|
|
64
|
+
'rundot_physics2d_owned_max_registries',
|
|
58
65
|
'rundot_physics2d_owned_max_worlds_per_registry',
|
|
66
|
+
'rundot_physics2d_owned_buffer_allocate',
|
|
67
|
+
'rundot_physics2d_owned_buffer_free',
|
|
59
68
|
'rundot_physics2d_owned_world_key_size',
|
|
60
69
|
'rundot_physics2d_owned_world_capacity_size',
|
|
61
70
|
'rundot_physics2d_owned_world_settings_size',
|
|
@@ -66,8 +75,9 @@ const ownedFunctions = Object.freeze([
|
|
|
66
75
|
'rundot_physics2d_owned_entity_handle_size',
|
|
67
76
|
'rundot_physics2d_owned_removed_identity_size',
|
|
68
77
|
'rundot_physics2d_owned_body_payload_size',
|
|
69
|
-
'
|
|
70
|
-
'
|
|
78
|
+
'rundot_physics2d_owned_contact_event_size',
|
|
79
|
+
'rundot_physics2d_owned_registry_create',
|
|
80
|
+
'rundot_physics2d_owned_registry_destroy',
|
|
71
81
|
'rundot_physics2d_owned_world_create',
|
|
72
82
|
'rundot_physics2d_owned_world_destroy',
|
|
73
83
|
'rundot_physics2d_owned_world_info',
|
|
@@ -80,6 +90,7 @@ const ownedFunctions = Object.freeze([
|
|
|
80
90
|
'rundot_physics2d_owned_world_read_body',
|
|
81
91
|
'rundot_physics2d_owned_world_read_joint',
|
|
82
92
|
'rundot_physics2d_owned_world_read_fluid',
|
|
93
|
+
'rundot_physics2d_owned_world_read_contour_edges',
|
|
83
94
|
'rundot_physics2d_owned_world_copy_latest_outputs',
|
|
84
95
|
'rundot_physics2d_owned_world_capture',
|
|
85
96
|
'rundot_physics2d_owned_world_restore',
|
|
@@ -91,6 +102,7 @@ const ownedFunctions = Object.freeze([
|
|
|
91
102
|
'rundot_physics2d_owned_world_checkpoint_capture_snapshot',
|
|
92
103
|
'rundot_physics2d_owned_world_raycast',
|
|
93
104
|
'rundot_physics2d_owned_world_overlap',
|
|
105
|
+
'rundot_physics2d_owned_world_overlap_contacts',
|
|
94
106
|
'rundot_physics2d_owned_world_shape_cast',
|
|
95
107
|
'rundot_physics2d_owned_world_closest_points',
|
|
96
108
|
]);
|
|
@@ -101,6 +113,7 @@ const metadataChecks = Object.freeze([
|
|
|
101
113
|
['rundot_physics2d_owned_snapshot_version', ownedTransportAbi.snapshotVersion],
|
|
102
114
|
['rundot_physics2d_owned_required_settings_abi_version', ownedTransportAbi.settingsAbiVersion],
|
|
103
115
|
['rundot_physics2d_owned_physics_profile', ownedTransportAbi.physicsProfile],
|
|
116
|
+
['rundot_physics2d_owned_max_registries', 64],
|
|
104
117
|
['rundot_physics2d_owned_max_worlds_per_registry', ownedTransportAbi.maxWorlds],
|
|
105
118
|
['rundot_physics2d_owned_world_key_size', ownedTransportAbi.worldKeyBytes],
|
|
106
119
|
['rundot_physics2d_owned_world_capacity_size', ownedTransportAbi.worldCapacityBytes],
|
|
@@ -112,6 +125,7 @@ const metadataChecks = Object.freeze([
|
|
|
112
125
|
['rundot_physics2d_owned_entity_handle_size', ownedTransportAbi.handleBytes],
|
|
113
126
|
['rundot_physics2d_owned_removed_identity_size', ownedTransportAbi.removedIdentityBytes],
|
|
114
127
|
['rundot_physics2d_owned_body_payload_size', ownedTransportAbi.bodyPayloadBytes],
|
|
128
|
+
['rundot_physics2d_owned_contact_event_size', ownedTransportAbi.contactEventBytes],
|
|
115
129
|
['rundot_physics2d_abi_version', ownedTransportAbi.bodyAbiVersion],
|
|
116
130
|
['rundot_physics2d_body_size', ownedTransportAbi.bodyBytes],
|
|
117
131
|
['rundot_physics2d_polygon_geometry_size', ownedTransportAbi.polygonGeometryBytes],
|
|
@@ -135,6 +149,7 @@ const metadataChecks = Object.freeze([
|
|
|
135
149
|
['rundot_physics2d_query_filter_size', ownedTransportAbi.queryFilterBytes],
|
|
136
150
|
['rundot_physics2d_cast_hit_size', ownedTransportAbi.castHitBytes],
|
|
137
151
|
['rundot_physics2d_overlap_hit_size', ownedTransportAbi.overlapHitBytes],
|
|
152
|
+
['rundot_physics2d_overlap_contact_hit_size', ownedTransportAbi.overlapContactHitBytes],
|
|
138
153
|
['rundot_physics2d_closest_point_hit_size', ownedTransportAbi.closestPointHitBytes],
|
|
139
154
|
]);
|
|
140
155
|
|
|
@@ -152,6 +167,11 @@ const querySpecs = Object.freeze({
|
|
|
152
167
|
requestBytes: ownedTransportAbi.overlapQueryBytes,
|
|
153
168
|
outputBytes: ownedTransportAbi.overlapHitBytes,
|
|
154
169
|
}),
|
|
170
|
+
overlapContacts: Object.freeze({
|
|
171
|
+
functionName: 'rundot_physics2d_owned_world_overlap_contacts',
|
|
172
|
+
requestBytes: ownedTransportAbi.overlapQueryBytes,
|
|
173
|
+
outputBytes: ownedTransportAbi.overlapContactHitBytes,
|
|
174
|
+
}),
|
|
155
175
|
shapeCast: Object.freeze({
|
|
156
176
|
functionName: 'rundot_physics2d_owned_world_shape_cast',
|
|
157
177
|
requestBytes: ownedTransportAbi.shapeCastQueryBytes,
|
|
@@ -206,6 +226,8 @@ const repairByStatus = Object.freeze({
|
|
|
206
226
|
[-209]: 'Release memory or reduce the edit batch, then retry.',
|
|
207
227
|
[-210]: 'Repair the final staged topology before retry.',
|
|
208
228
|
[-211]: 'Increase the handle or removed-record output capacity.',
|
|
229
|
+
[-212]: 'Increase the contour edge capacity.',
|
|
230
|
+
[-213]: 'Check contour vertex and edge definitions.',
|
|
209
231
|
[-300]: 'Check the transport record lengths, counts, and numeric ranges.',
|
|
210
232
|
[-301]: 'Create a new initialized registry transport.',
|
|
211
233
|
[-302]: 'Create a new registry transport because this registry is disposed.',
|
|
@@ -217,7 +239,8 @@ const repairByStatus = Object.freeze({
|
|
|
217
239
|
[-308]: 'Rebuild the adapter and native artifact with the same settings ABI.',
|
|
218
240
|
[-309]: 'Increase the output capacity and retry.',
|
|
219
241
|
[-310]: 'Use separate transport scratch spans.',
|
|
220
|
-
[-
|
|
242
|
+
[-315]: 'Pass a live buffer from rundot_physics2d_owned_buffer_allocate.',
|
|
243
|
+
[-316]: 'Wait for the call that pins this buffer to finish.',
|
|
221
244
|
});
|
|
222
245
|
|
|
223
246
|
function transportError(operation, result, repair, detail) {
|
|
@@ -406,6 +429,7 @@ class ScratchArena {
|
|
|
406
429
|
#exports;
|
|
407
430
|
#pointer = 0;
|
|
408
431
|
#capacity = 0;
|
|
432
|
+
#pendingFree = new Set();
|
|
409
433
|
|
|
410
434
|
constructor(exports) {
|
|
411
435
|
this.#exports = exports;
|
|
@@ -450,26 +474,58 @@ class ScratchArena {
|
|
|
450
474
|
}
|
|
451
475
|
|
|
452
476
|
dispose() {
|
|
477
|
+
for (const pointer of this.#pendingFree) {
|
|
478
|
+
decodePackedResult(this.#exports.rundot_physics2d_owned_buffer_free(pointer), 'dispose pending scratch');
|
|
479
|
+
this.#pendingFree.delete(pointer);
|
|
480
|
+
}
|
|
453
481
|
if (this.#pointer === 0) return;
|
|
454
482
|
const pointer = this.#pointer;
|
|
483
|
+
decodePackedResult(this.#exports.rundot_physics2d_owned_buffer_free(pointer), 'dispose scratch');
|
|
455
484
|
this.#pointer = 0;
|
|
456
485
|
this.#capacity = 0;
|
|
457
|
-
this.#exports.free(pointer);
|
|
458
486
|
}
|
|
459
487
|
|
|
460
488
|
#reserve(operation, required) {
|
|
461
489
|
if (required <= this.#capacity) return;
|
|
462
|
-
const pointer = this.#exports.
|
|
490
|
+
const pointer = this.#exports.rundot_physics2d_owned_buffer_allocate(required);
|
|
463
491
|
const memoryBytes = this.#exports.memory.buffer.byteLength;
|
|
464
492
|
if (!Number.isSafeInteger(pointer) || pointer <= 0 || pointer > maxUint32
|
|
465
|
-
|| pointer %
|
|
466
|
-
|
|
467
|
-
|
|
493
|
+
|| pointer % 16 !== 0 || required > memoryBytes || pointer > memoryBytes - required) {
|
|
494
|
+
if (Number.isSafeInteger(pointer) && pointer > 0) {
|
|
495
|
+
try {
|
|
496
|
+
decodePackedResult(this.#exports.rundot_physics2d_owned_buffer_free(pointer), operation);
|
|
497
|
+
} catch {
|
|
498
|
+
// The invalid allocation is reported by the failure below.
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (pointer === 0) {
|
|
502
|
+
localFailure(operation, `Owned buffer allocation failed for ${required} bytes.`,
|
|
503
|
+
'Release memory or reduce the request, then retry.', -101);
|
|
504
|
+
}
|
|
505
|
+
localFailure(operation, 'The artifact returned an invalid owned buffer pointer.',
|
|
506
|
+
'Rebuild the adapter and native artifact from the same source.', -308);
|
|
468
507
|
}
|
|
469
508
|
const previous = this.#pointer;
|
|
509
|
+
if (previous !== 0) {
|
|
510
|
+
try {
|
|
511
|
+
decodePackedResult(this.#exports.rundot_physics2d_owned_buffer_free(previous), operation);
|
|
512
|
+
} catch (freeError) {
|
|
513
|
+
let newFreeError;
|
|
514
|
+
try {
|
|
515
|
+
decodePackedResult(this.#exports.rundot_physics2d_owned_buffer_free(pointer), operation);
|
|
516
|
+
} catch (err) {
|
|
517
|
+
newFreeError = err;
|
|
518
|
+
}
|
|
519
|
+
if (newFreeError !== undefined) {
|
|
520
|
+
this.#pendingFree.add(pointer);
|
|
521
|
+
throw new AggregateError([freeError, newFreeError],
|
|
522
|
+
`KINETIX_PHYSICS2D_OWNED_TRANSPORT: ${operation} failed and cleanup also failed.`);
|
|
523
|
+
}
|
|
524
|
+
throw freeError;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
470
527
|
this.#pointer = pointer;
|
|
471
528
|
this.#capacity = required;
|
|
472
|
-
if (previous !== 0) this.#exports.free(previous);
|
|
473
529
|
}
|
|
474
530
|
}
|
|
475
531
|
|
|
@@ -518,7 +574,7 @@ function requireExports(exports) {
|
|
|
518
574
|
localFailure('validate exports', 'memory must be a WebAssembly.Memory.',
|
|
519
575
|
'Build a standalone WASM artifact that exports memory.');
|
|
520
576
|
}
|
|
521
|
-
for (const name of
|
|
577
|
+
for (const name of ownedFunctions) {
|
|
522
578
|
if (typeof exports[name] !== 'function') {
|
|
523
579
|
localFailure('validate exports', `Missing function ${name}.`,
|
|
524
580
|
'Rebuild the WASM artifact with every owned transport export.');
|
|
@@ -535,25 +591,18 @@ function requireExports(exports) {
|
|
|
535
591
|
'Rebuild the adapter and native artifact from the same source.', -308);
|
|
536
592
|
}
|
|
537
593
|
}
|
|
538
|
-
|
|
539
|
-
const registryAlignment = exports.rundot_physics2d_owned_registry_alignment();
|
|
540
|
-
if (!Number.isSafeInteger(registryBytes) || registryBytes <= 0 || registryBytes > maxUint32
|
|
541
|
-
|| registryAlignment !== 8 || registryBytes % registryAlignment !== 0) {
|
|
542
|
-
localFailure('validate exports', 'The registry size or alignment is invalid.',
|
|
543
|
-
'Rebuild the adapter and native artifact from the same source.', -308);
|
|
544
|
-
}
|
|
545
|
-
return Object.freeze({ registryBytes, registryAlignment });
|
|
594
|
+
return Object.freeze({ maxRegistries: 64 });
|
|
546
595
|
}
|
|
547
596
|
|
|
548
|
-
function decodeWorldKey(view, offset, operation) {
|
|
597
|
+
function decodeWorldKey(view, offset, operation, registryHandle) {
|
|
549
598
|
const result = Object.freeze({
|
|
550
599
|
registryToken: view.getBigUint64(offset, littleEndian),
|
|
551
600
|
slot: view.getUint32(offset + 8, littleEndian),
|
|
552
601
|
generation: view.getUint32(offset + 12, littleEndian),
|
|
553
602
|
});
|
|
554
|
-
if (result.registryToken === 0n || result.generation === 0) {
|
|
603
|
+
if (result.registryToken === 0n || result.generation === 0 || result.registryToken !== registryHandle) {
|
|
555
604
|
localFailure(operation, 'The native world key output is invalid.',
|
|
556
|
-
'Rebuild the adapter and native artifact from the same source.');
|
|
605
|
+
'Rebuild the adapter and native artifact from the same source.', -308);
|
|
557
606
|
}
|
|
558
607
|
return result;
|
|
559
608
|
}
|
|
@@ -583,6 +632,8 @@ function decodeWorldInfo(view, offset, operation) {
|
|
|
583
632
|
bodyCapacity: view.getUint32(offset + 44, littleEndian),
|
|
584
633
|
jointCapacity: view.getUint32(offset + 48, littleEndian),
|
|
585
634
|
fluidCapacity: view.getUint32(offset + 52, littleEndian),
|
|
635
|
+
latestContactEventCount: view.getUint32(offset + 56, littleEndian),
|
|
636
|
+
contactCapacity: view.getUint32(offset + 60, littleEndian),
|
|
586
637
|
owner: view.getBigUint64(offset + 64, littleEndian),
|
|
587
638
|
epoch: view.getBigUint64(offset + 72, littleEndian),
|
|
588
639
|
frame: view.getBigUint64(offset + 80, littleEndian),
|
|
@@ -600,8 +651,6 @@ function decodeWorldInfo(view, offset, operation) {
|
|
|
600
651
|
|| result.snapshotVersion !== ownedTransportAbi.snapshotVersion
|
|
601
652
|
|| result.settingsAbiVersion !== ownedTransportAbi.settingsAbiVersion
|
|
602
653
|
|| result.physicsProfile !== ownedTransportAbi.physicsProfile
|
|
603
|
-
|| view.getUint32(offset + 56, littleEndian) !== 0
|
|
604
|
-
|| view.getUint32(offset + 60, littleEndian) !== 0
|
|
605
654
|
|| result.owner === 0n || result.fixedDt <= 0
|
|
606
655
|
|| result.fixedSubsteps === 0 || result.fixedVelocityIterations === 0) {
|
|
607
656
|
localFailure(operation, 'The native world info record is invalid.',
|
|
@@ -648,7 +697,7 @@ class OwnedWorldRawTransport {
|
|
|
648
697
|
{ name: 'info', bytes: ownedTransportAbi.worldInfoBytes },
|
|
649
698
|
]);
|
|
650
699
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_info(
|
|
651
|
-
this.#registry.
|
|
700
|
+
this.#registry.handle,
|
|
652
701
|
frame.pointer('key'),
|
|
653
702
|
frame.pointer('info'),
|
|
654
703
|
), operation);
|
|
@@ -656,12 +705,14 @@ class OwnedWorldRawTransport {
|
|
|
656
705
|
if (result.bodyCapacity !== this.#capacity.body
|
|
657
706
|
|| result.jointCapacity !== this.#capacity.joint
|
|
658
707
|
|| result.fluidCapacity !== this.#capacity.fluid
|
|
708
|
+
|| result.contactCapacity !== this.#capacity.contact
|
|
659
709
|
|| result.bodyCount > result.bodyCapacity
|
|
660
710
|
|| result.jointCount > result.jointCapacity
|
|
661
711
|
|| result.fluidCount > result.fluidCapacity
|
|
662
712
|
|| result.latestTelemetryCount > result.jointCapacity
|
|
663
713
|
|| result.latestBreakEventCount > ownedTransportAbi.maxJoints
|
|
664
714
|
|| result.latestGearReactionCount > ownedTransportAbi.maxGearReactions
|
|
715
|
+
|| result.latestContactEventCount > result.contactCapacity * 2
|
|
665
716
|
|| result.captureBytes > BigInt(maxUint32)) {
|
|
666
717
|
localFailure(operation, 'The native world counts or capacities are invalid.',
|
|
667
718
|
'Rebuild the adapter and native artifact from the same source.', -308);
|
|
@@ -674,7 +725,7 @@ class OwnedWorldRawTransport {
|
|
|
674
725
|
const operation = 'world step';
|
|
675
726
|
const frame = this.#frame(operation);
|
|
676
727
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_step(
|
|
677
|
-
this.#registry.
|
|
728
|
+
this.#registry.handle,
|
|
678
729
|
frame.pointer('key'),
|
|
679
730
|
), operation);
|
|
680
731
|
}
|
|
@@ -685,7 +736,7 @@ class OwnedWorldRawTransport {
|
|
|
685
736
|
finite(gravityY, operation, 'gravityY');
|
|
686
737
|
const frame = this.#frame(operation);
|
|
687
738
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_set_gravity(
|
|
688
|
-
this.#registry.
|
|
739
|
+
this.#registry.handle,
|
|
689
740
|
frame.pointer('key'),
|
|
690
741
|
gravityX,
|
|
691
742
|
gravityY,
|
|
@@ -701,7 +752,7 @@ class OwnedWorldRawTransport {
|
|
|
701
752
|
{ name: 'count', bytes: 4, alignment: 4, clear: true },
|
|
702
753
|
]);
|
|
703
754
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_capture(
|
|
704
|
-
this.#registry.
|
|
755
|
+
this.#registry.handle,
|
|
705
756
|
frame.pointer('key'),
|
|
706
757
|
frame.pointer('snapshot'),
|
|
707
758
|
capacity,
|
|
@@ -727,7 +778,7 @@ class OwnedWorldRawTransport {
|
|
|
727
778
|
const frame = this.#frame(operation, [{ name: 'snapshot', bytes: source.byteLength }]);
|
|
728
779
|
frame.write('snapshot', source);
|
|
729
780
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_restore(
|
|
730
|
-
this.#registry.
|
|
781
|
+
this.#registry.handle,
|
|
731
782
|
frame.pointer('key'),
|
|
732
783
|
frame.pointer('snapshot'),
|
|
733
784
|
source.byteLength,
|
|
@@ -742,7 +793,7 @@ class OwnedWorldRawTransport {
|
|
|
742
793
|
{ name: 'digest', bytes: 8, alignment: 8, clear: true },
|
|
743
794
|
]);
|
|
744
795
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_digest(
|
|
745
|
-
this.#registry.
|
|
796
|
+
this.#registry.handle,
|
|
746
797
|
frame.pointer('key'),
|
|
747
798
|
frame.pointer('digest'),
|
|
748
799
|
), operation);
|
|
@@ -755,7 +806,7 @@ class OwnedWorldRawTransport {
|
|
|
755
806
|
{ name: 'checkpoint', bytes: 4, alignment: 4, clear: true },
|
|
756
807
|
]);
|
|
757
808
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_checkpoint_capture(
|
|
758
|
-
this.#registry.
|
|
809
|
+
this.#registry.handle,
|
|
759
810
|
frame.pointer('key'),
|
|
760
811
|
frame.pointer('checkpoint'),
|
|
761
812
|
), operation);
|
|
@@ -776,7 +827,7 @@ class OwnedWorldRawTransport {
|
|
|
776
827
|
}
|
|
777
828
|
const frame = this.#frame(operation);
|
|
778
829
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_checkpoint_restore(
|
|
779
|
-
this.#registry.
|
|
830
|
+
this.#registry.handle,
|
|
780
831
|
frame.pointer('key'),
|
|
781
832
|
checkpointHandle,
|
|
782
833
|
), operation);
|
|
@@ -788,7 +839,7 @@ class OwnedWorldRawTransport {
|
|
|
788
839
|
const operation = 'release checkpoint';
|
|
789
840
|
const frame = this.#frame(operation);
|
|
790
841
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_checkpoint_release(
|
|
791
|
-
this.#registry.
|
|
842
|
+
this.#registry.handle,
|
|
792
843
|
frame.pointer('key'),
|
|
793
844
|
checkpointHandle,
|
|
794
845
|
), operation);
|
|
@@ -800,7 +851,7 @@ class OwnedWorldRawTransport {
|
|
|
800
851
|
{ name: 'count', bytes: 4, alignment: 4, clear: true },
|
|
801
852
|
]);
|
|
802
853
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_checkpoint_capture_size(
|
|
803
|
-
this.#registry.
|
|
854
|
+
this.#registry.handle,
|
|
804
855
|
sizeFrame.pointer('key'),
|
|
805
856
|
checkpointHandle,
|
|
806
857
|
sizeFrame.pointer('count'),
|
|
@@ -811,7 +862,7 @@ class OwnedWorldRawTransport {
|
|
|
811
862
|
{ name: 'count', bytes: 4, alignment: 4, clear: true },
|
|
812
863
|
]);
|
|
813
864
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_checkpoint_capture_snapshot(
|
|
814
|
-
this.#registry.
|
|
865
|
+
this.#registry.handle,
|
|
815
866
|
frame.pointer('key'),
|
|
816
867
|
checkpointHandle,
|
|
817
868
|
frame.pointer('snapshot'),
|
|
@@ -837,6 +888,8 @@ class OwnedWorldRawTransport {
|
|
|
837
888
|
ownedTransportAbi.jointBytes, ownedTransportAbi.maxCommands, this.#exports.memory);
|
|
838
889
|
const fluids = records(batch.fluidPayloads, operation, 'fluidPayloads',
|
|
839
890
|
ownedTransportAbi.fluidBytes, ownedTransportAbi.maxCommands, this.#exports.memory);
|
|
891
|
+
const contourEdges = records(batch.contourEdgePayloads, operation, 'contourEdgePayloads',
|
|
892
|
+
ownedTransportAbi.contourEdgeBytes, ownedTransportAbi.maxContourEdges, this.#exports.memory);
|
|
840
893
|
const required = records(batch.requiredResults, operation, 'requiredResults',
|
|
841
894
|
ownedTransportAbi.entityReferenceBytes, ownedTransportAbi.maxCommands, this.#exports.memory);
|
|
842
895
|
const handleCapacity = u32(
|
|
@@ -864,6 +917,7 @@ class OwnedWorldRawTransport {
|
|
|
864
917
|
{ name: 'joints', bytes: joints.bytes.byteLength },
|
|
865
918
|
{ name: 'fluids', bytes: fluids.bytes.byteLength },
|
|
866
919
|
{ name: 'required', bytes: required.bytes.byteLength },
|
|
920
|
+
{ name: 'contourEdges', bytes: contourEdges.bytes.byteLength },
|
|
867
921
|
{ name: 'handles', bytes: handleBytes },
|
|
868
922
|
{ name: 'handleCount', bytes: 4, alignment: 4, clear: true },
|
|
869
923
|
{ name: 'removed', bytes: removedBytes },
|
|
@@ -871,12 +925,12 @@ class OwnedWorldRawTransport {
|
|
|
871
925
|
]);
|
|
872
926
|
for (const [name, value] of [
|
|
873
927
|
['commands', commands.bytes], ['bodies', bodies.bytes], ['joints', joints.bytes],
|
|
874
|
-
['fluids', fluids.bytes], ['required', required.bytes],
|
|
928
|
+
['fluids', fluids.bytes], ['required', required.bytes], ['contourEdges', contourEdges.bytes],
|
|
875
929
|
]) {
|
|
876
930
|
if (value.byteLength > 0) frame.write(name, value);
|
|
877
931
|
}
|
|
878
932
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_edit(
|
|
879
|
-
this.#registry.
|
|
933
|
+
this.#registry.handle,
|
|
880
934
|
frame.pointer('key'),
|
|
881
935
|
frame.pointer('commands'), commands.count,
|
|
882
936
|
frame.pointer('bodies'), bodies.count,
|
|
@@ -885,6 +939,7 @@ class OwnedWorldRawTransport {
|
|
|
885
939
|
frame.pointer('required'), required.count,
|
|
886
940
|
frame.pointer('handles'), handleCapacity, frame.pointer('handleCount'),
|
|
887
941
|
frame.pointer('removed'), removedCapacity, frame.pointer('removedCount'),
|
|
942
|
+
frame.pointer('contourEdges'), contourEdges.count,
|
|
888
943
|
), operation);
|
|
889
944
|
const view = frame.view();
|
|
890
945
|
const handleCount = view.getUint32(frame.pointer('handleCount'), littleEndian);
|
|
@@ -921,7 +976,7 @@ class OwnedWorldRawTransport {
|
|
|
921
976
|
if (id === 0) localFailure(operation, 'numericId must be positive.');
|
|
922
977
|
const frame = this.#frame(operation, [{ name: 'handle', bytes: ownedTransportAbi.handleBytes }]);
|
|
923
978
|
decodePackedResult(this.#exports[`rundot_physics2d_owned_world_resolve_${kind}`](
|
|
924
|
-
this.#registry.
|
|
979
|
+
this.#registry.handle,
|
|
925
980
|
frame.pointer('key'),
|
|
926
981
|
id,
|
|
927
982
|
frame.pointer('handle'),
|
|
@@ -929,6 +984,32 @@ class OwnedWorldRawTransport {
|
|
|
929
984
|
return decodeHandle(frame.view(), frame.pointer('handle'), operation);
|
|
930
985
|
}
|
|
931
986
|
|
|
987
|
+
readContourEdges(handle, maxEdges = 256) {
|
|
988
|
+
const operation = 'read contour edges';
|
|
989
|
+
const edgeCapacity = u32(maxEdges, operation, 'maxEdges', ownedTransportAbi.maxContourEdges);
|
|
990
|
+
const frame = this.#frame(operation, [
|
|
991
|
+
{ name: 'handle', bytes: ownedTransportAbi.handleBytes },
|
|
992
|
+
{ name: 'edges', bytes: checkedProduct(edgeCapacity,
|
|
993
|
+
ownedTransportAbi.contourEdgeBytes, operation, 'contour edge output') },
|
|
994
|
+
{ name: 'edgeCount', bytes: 4, alignment: 4, clear: true },
|
|
995
|
+
]);
|
|
996
|
+
writeHandle(frame.view(), frame.pointer('handle'), handle, operation, 'body');
|
|
997
|
+
decodePackedResult(this.#exports.rundot_physics2d_owned_world_read_contour_edges(
|
|
998
|
+
this.#registry.handle,
|
|
999
|
+
frame.pointer('key'),
|
|
1000
|
+
frame.pointer('handle'),
|
|
1001
|
+
frame.pointer('edges'),
|
|
1002
|
+
edgeCapacity,
|
|
1003
|
+
frame.pointer('edgeCount'),
|
|
1004
|
+
), operation);
|
|
1005
|
+
const count = frame.view().getUint32(frame.pointer('edgeCount'), littleEndian);
|
|
1006
|
+
if (count > edgeCapacity) {
|
|
1007
|
+
localFailure(operation, 'The native contour edge count exceeds its capacity.',
|
|
1008
|
+
'Rebuild the adapter and native artifact from the same source.', -308);
|
|
1009
|
+
}
|
|
1010
|
+
return frame.copy('edges', count * ownedTransportAbi.contourEdgeBytes);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
932
1013
|
read(kind, handle) {
|
|
933
1014
|
const operation = `read ${String(kind)}`;
|
|
934
1015
|
const specs = {
|
|
@@ -950,7 +1031,7 @@ class OwnedWorldRawTransport {
|
|
|
950
1031
|
writeHandle(frame.view(), frame.pointer('handle'), handle, operation, kind);
|
|
951
1032
|
const pointers = specs.map(([name]) => frame.pointer(name));
|
|
952
1033
|
decodePackedResult(this.#exports[`rundot_physics2d_owned_world_read_${kind}`](
|
|
953
|
-
this.#registry.
|
|
1034
|
+
this.#registry.handle,
|
|
954
1035
|
frame.pointer('key'),
|
|
955
1036
|
frame.pointer('handle'),
|
|
956
1037
|
...pointers,
|
|
@@ -960,6 +1041,7 @@ class OwnedWorldRawTransport {
|
|
|
960
1041
|
|
|
961
1042
|
latest() {
|
|
962
1043
|
const operation = 'copy latest outputs';
|
|
1044
|
+
const currentInfo = this.info();
|
|
963
1045
|
const telemetryCapacity = this.#capacity.joint;
|
|
964
1046
|
const breakEventCapacity = this.#capacity.joint;
|
|
965
1047
|
const gearReactionCapacity = Math.min(
|
|
@@ -973,14 +1055,17 @@ class OwnedWorldRawTransport {
|
|
|
973
1055
|
ownedTransportAbi.breakEventBytes, operation, 'break output') },
|
|
974
1056
|
{ name: 'gearReactions', bytes: checkedProduct(gearReactionCapacity,
|
|
975
1057
|
ownedTransportAbi.gearReactionBytes, operation, 'gear output') },
|
|
1058
|
+
{ name: 'contactEvents', bytes: checkedProduct(currentInfo.latestContactEventCount,
|
|
1059
|
+
ownedTransportAbi.contactEventBytes, operation, 'contact output') },
|
|
976
1060
|
{ name: 'info', bytes: ownedTransportAbi.latestOutputInfoBytes },
|
|
977
1061
|
]);
|
|
978
1062
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_copy_latest_outputs(
|
|
979
|
-
this.#registry.
|
|
1063
|
+
this.#registry.handle,
|
|
980
1064
|
frame.pointer('key'),
|
|
981
1065
|
frame.pointer('telemetry'), telemetryCapacity,
|
|
982
1066
|
frame.pointer('breakEvents'), breakEventCapacity,
|
|
983
1067
|
frame.pointer('gearReactions'), gearReactionCapacity,
|
|
1068
|
+
frame.pointer('contactEvents'), currentInfo.latestContactEventCount,
|
|
984
1069
|
frame.pointer('info'),
|
|
985
1070
|
), operation);
|
|
986
1071
|
const view = frame.view();
|
|
@@ -988,10 +1073,11 @@ class OwnedWorldRawTransport {
|
|
|
988
1073
|
const telemetryCount = view.getUint32(infoOffset, littleEndian);
|
|
989
1074
|
const breakEventCount = view.getUint32(infoOffset + 4, littleEndian);
|
|
990
1075
|
const gearReactionCount = view.getUint32(infoOffset + 8, littleEndian);
|
|
991
|
-
|
|
992
|
-
|
|
1076
|
+
const contactEventCount = view.getUint32(infoOffset + 12, littleEndian);
|
|
1077
|
+
if (telemetryCount > telemetryCapacity
|
|
993
1078
|
|| breakEventCount > breakEventCapacity
|
|
994
|
-
|| gearReactionCount > gearReactionCapacity
|
|
1079
|
+
|| gearReactionCount > gearReactionCapacity
|
|
1080
|
+
|| contactEventCount !== currentInfo.latestContactEventCount) {
|
|
995
1081
|
localFailure(operation, 'The native latest output info is invalid.',
|
|
996
1082
|
'Rebuild the adapter and native artifact from the same source.', -308);
|
|
997
1083
|
}
|
|
@@ -999,6 +1085,7 @@ class OwnedWorldRawTransport {
|
|
|
999
1085
|
telemetryCount,
|
|
1000
1086
|
breakEventCount,
|
|
1001
1087
|
gearReactionCount,
|
|
1088
|
+
contactEventCount,
|
|
1002
1089
|
frame: view.getBigUint64(infoOffset + 16, littleEndian),
|
|
1003
1090
|
latestStepOptions: decodeStepOptions(view, infoOffset + 24, operation),
|
|
1004
1091
|
});
|
|
@@ -1007,6 +1094,7 @@ class OwnedWorldRawTransport {
|
|
|
1007
1094
|
telemetry: frame.copy('telemetry', telemetryCount * ownedTransportAbi.telemetryBytes),
|
|
1008
1095
|
breakEvents: frame.copy('breakEvents', breakEventCount * ownedTransportAbi.breakEventBytes),
|
|
1009
1096
|
gearReactions: frame.copy('gearReactions', gearReactionCount * ownedTransportAbi.gearReactionBytes),
|
|
1097
|
+
contactEvents: frame.copy('contactEvents', contactEventCount * ownedTransportAbi.contactEventBytes),
|
|
1010
1098
|
});
|
|
1011
1099
|
}
|
|
1012
1100
|
|
|
@@ -1084,10 +1172,11 @@ class OwnedWorldRawTransport {
|
|
|
1084
1172
|
frame.write('filter', filter);
|
|
1085
1173
|
if (excludedBytes.byteLength > 0) frame.write('excluded', excludedBytes);
|
|
1086
1174
|
decodePackedResult(this.#exports[spec.functionName](
|
|
1087
|
-
this.#registry.
|
|
1175
|
+
this.#registry.handle,
|
|
1088
1176
|
frame.pointer('key'),
|
|
1089
1177
|
frame.pointer('request'),
|
|
1090
1178
|
frame.pointer('filter'),
|
|
1179
|
+
excludedBodyIds.length,
|
|
1091
1180
|
frame.pointer('excluded'),
|
|
1092
1181
|
frame.pointer('output'),
|
|
1093
1182
|
outputCapacity,
|
|
@@ -1102,16 +1191,21 @@ class OwnedWorldRawTransport {
|
|
|
1102
1191
|
}
|
|
1103
1192
|
|
|
1104
1193
|
dispose() {
|
|
1105
|
-
if (this.#disposed)
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1194
|
+
if (!this.#disposed) {
|
|
1195
|
+
const operation = 'destroy world';
|
|
1196
|
+
const frame = this.#frame(operation);
|
|
1197
|
+
try {
|
|
1198
|
+
decodePackedResult(this.#exports.rundot_physics2d_owned_world_destroy(
|
|
1199
|
+
this.#registry.handle,
|
|
1200
|
+
frame.pointer('key'),
|
|
1201
|
+
), operation);
|
|
1202
|
+
} catch (error) {
|
|
1203
|
+
if (error?.status !== -305 && error?.status !== -302) throw error;
|
|
1204
|
+
}
|
|
1205
|
+
this.#disposed = true;
|
|
1206
|
+
this.#registry.release(this);
|
|
1207
|
+
}
|
|
1113
1208
|
this.#scratch.dispose();
|
|
1114
|
-
this.#registry.release(this);
|
|
1115
1209
|
}
|
|
1116
1210
|
|
|
1117
1211
|
#frame(operation, entries = []) {
|
|
@@ -1132,10 +1226,11 @@ class OwnedWorldRawTransport {
|
|
|
1132
1226
|
class OwnedRegistryTransport {
|
|
1133
1227
|
#exports;
|
|
1134
1228
|
#metadata;
|
|
1135
|
-
#
|
|
1229
|
+
#handle = 0n;
|
|
1136
1230
|
#capacity;
|
|
1137
1231
|
#scratch;
|
|
1138
1232
|
#worlds = new Set();
|
|
1233
|
+
#pendingCleanup = new Set();
|
|
1139
1234
|
#disposed = false;
|
|
1140
1235
|
|
|
1141
1236
|
constructor(exports, options) {
|
|
@@ -1145,45 +1240,31 @@ class OwnedRegistryTransport {
|
|
|
1145
1240
|
if (!options || typeof options !== 'object') localFailure(operation, 'options must be an object.');
|
|
1146
1241
|
this.#capacity = u32(options.worldCapacity, operation, 'worldCapacity', ownedTransportAbi.maxWorlds);
|
|
1147
1242
|
this.#scratch = new ScratchArena(exports);
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|| this.#metadata.registryBytes > memoryBytes
|
|
1153
|
-
|| pointer > memoryBytes - this.#metadata.registryBytes) {
|
|
1154
|
-
let scratchError;
|
|
1155
|
-
try {
|
|
1156
|
-
this.#scratch.dispose();
|
|
1157
|
-
} catch (err) {
|
|
1158
|
-
scratchError = err;
|
|
1159
|
-
}
|
|
1160
|
-
const failure = transportError(operation, {
|
|
1161
|
-
status: -101,
|
|
1162
|
-
nativeStatus: 0,
|
|
1163
|
-
domainCode: 1,
|
|
1164
|
-
index: noIndex,
|
|
1165
|
-
}, 'Release memory or reduce the registry capacity, then retry.',
|
|
1166
|
-
`WASM malloc failed for ${this.#metadata.registryBytes} registry bytes.`);
|
|
1167
|
-
if (scratchError !== undefined) {
|
|
1168
|
-
throwCleanupFailure(operation, failure, scratchError);
|
|
1169
|
-
}
|
|
1170
|
-
throw failure;
|
|
1171
|
-
}
|
|
1172
|
-
this.#pointer = pointer;
|
|
1173
|
-
new Uint8Array(exports.memory.buffer, pointer, this.#metadata.registryBytes).fill(0);
|
|
1243
|
+
const frame = this.#scratch.prepare(operation, [
|
|
1244
|
+
{ name: 'registry', bytes: 8, alignment: 8, clear: true },
|
|
1245
|
+
]);
|
|
1246
|
+
let handle = 0n;
|
|
1174
1247
|
try {
|
|
1175
|
-
decodePackedResult(exports.
|
|
1176
|
-
pointer,
|
|
1177
|
-
this.#metadata.registryBytes,
|
|
1248
|
+
decodePackedResult(exports.rundot_physics2d_owned_registry_create(
|
|
1178
1249
|
this.#capacity,
|
|
1250
|
+
frame.pointer('registry'),
|
|
1179
1251
|
), operation);
|
|
1252
|
+
handle = frame.view().getBigUint64(frame.pointer('registry'), littleEndian);
|
|
1253
|
+
const index = Number(handle & 0xffffffffn);
|
|
1254
|
+
const generation = Number(handle >> 32n);
|
|
1255
|
+
if (handle === 0n || generation === 0 || index >= this.#metadata.maxRegistries) {
|
|
1256
|
+
localFailure(operation, 'The native registry handle is invalid.',
|
|
1257
|
+
repairByStatus[-308], -308);
|
|
1258
|
+
}
|
|
1259
|
+
this.#handle = handle;
|
|
1180
1260
|
} catch (error) {
|
|
1181
|
-
this.#pointer = 0;
|
|
1182
1261
|
let cleanupError;
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1262
|
+
if (handle !== 0n) {
|
|
1263
|
+
try {
|
|
1264
|
+
decodePackedResult(exports.rundot_physics2d_owned_registry_destroy(handle), operation);
|
|
1265
|
+
} catch (err) {
|
|
1266
|
+
cleanupError = err;
|
|
1267
|
+
}
|
|
1187
1268
|
}
|
|
1188
1269
|
try {
|
|
1189
1270
|
this.#scratch.dispose();
|
|
@@ -1192,6 +1273,7 @@ class OwnedRegistryTransport {
|
|
|
1192
1273
|
? new AggregateError([cleanupError, err], 'multiple cleanup failures')
|
|
1193
1274
|
: err;
|
|
1194
1275
|
}
|
|
1276
|
+
this.#handle = 0n;
|
|
1195
1277
|
if (cleanupError !== undefined) {
|
|
1196
1278
|
throwCleanupFailure(operation, error, cleanupError);
|
|
1197
1279
|
}
|
|
@@ -1203,8 +1285,8 @@ class OwnedRegistryTransport {
|
|
|
1203
1285
|
return this.#exports;
|
|
1204
1286
|
}
|
|
1205
1287
|
|
|
1206
|
-
get
|
|
1207
|
-
return this.#
|
|
1288
|
+
get handle() {
|
|
1289
|
+
return this.#handle;
|
|
1208
1290
|
}
|
|
1209
1291
|
|
|
1210
1292
|
get disposed() {
|
|
@@ -1232,10 +1314,14 @@ class OwnedRegistryTransport {
|
|
|
1232
1314
|
const source = input.capacity;
|
|
1233
1315
|
if (!source || typeof source !== 'object') localFailure(operation, 'capacity must be an object.');
|
|
1234
1316
|
const capacity = Object.freeze({
|
|
1317
|
+
checkpoint: u32(source.checkpoint ?? ownedTransportAbi.defaultCheckpoints, operation, 'capacity.checkpoint', ownedTransportAbi.maxCheckpoints),
|
|
1235
1318
|
body: u32(source.body, operation, 'capacity.body', ownedTransportAbi.maxBodies),
|
|
1236
1319
|
joint: u32(source.joint, operation, 'capacity.joint', ownedTransportAbi.maxJoints),
|
|
1237
1320
|
fluid: u32(source.fluid, operation, 'capacity.fluid', ownedTransportAbi.maxFluids),
|
|
1321
|
+
contact: u32(source.contact, operation, 'capacity.contact', ownedTransportAbi.maxContactPairs),
|
|
1322
|
+
contourEdge: u32(source.contourEdge ?? source.contourEdges ?? 0, operation, 'capacity.contourEdge', ownedTransportAbi.maxContourEdges),
|
|
1238
1323
|
});
|
|
1324
|
+
if (capacity.checkpoint === 0) localFailure(operation, 'capacity.checkpoint must be positive.');
|
|
1239
1325
|
const frame = this.#scratch.prepare(operation, [
|
|
1240
1326
|
{ name: 'settings', bytes: ownedTransportAbi.settingsBytes },
|
|
1241
1327
|
{ name: 'capacity', bytes: ownedTransportAbi.worldCapacityBytes },
|
|
@@ -1246,7 +1332,9 @@ class OwnedRegistryTransport {
|
|
|
1246
1332
|
view.setUint32(frame.pointer('capacity'), capacity.body, littleEndian);
|
|
1247
1333
|
view.setUint32(frame.pointer('capacity') + 4, capacity.joint, littleEndian);
|
|
1248
1334
|
view.setUint32(frame.pointer('capacity') + 8, capacity.fluid, littleEndian);
|
|
1249
|
-
view.setUint32(frame.pointer('capacity') + 12,
|
|
1335
|
+
view.setUint32(frame.pointer('capacity') + 12, capacity.contact, littleEndian);
|
|
1336
|
+
view.setUint32(frame.pointer('capacity') + 16, capacity.contourEdge, littleEndian);
|
|
1337
|
+
view.setUint32(frame.pointer('capacity') + 20, capacity.checkpoint, littleEndian);
|
|
1250
1338
|
const worldScratch = new ScratchArena(this.#exports);
|
|
1251
1339
|
worldScratch.prepare('prepare world wrapper', [
|
|
1252
1340
|
{ name: 'key', bytes: ownedTransportAbi.worldKeyBytes },
|
|
@@ -1256,7 +1344,7 @@ class OwnedRegistryTransport {
|
|
|
1256
1344
|
let created = false;
|
|
1257
1345
|
try {
|
|
1258
1346
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_create(
|
|
1259
|
-
this.#
|
|
1347
|
+
this.#handle,
|
|
1260
1348
|
ownedTransportAbi.settingsAbiVersion,
|
|
1261
1349
|
frame.pointer('settings'),
|
|
1262
1350
|
ownedTransportAbi.settingsBytes,
|
|
@@ -1264,13 +1352,13 @@ class OwnedRegistryTransport {
|
|
|
1264
1352
|
frame.pointer('key'),
|
|
1265
1353
|
), operation);
|
|
1266
1354
|
created = true;
|
|
1267
|
-
key = decodeWorldKey(frame.view(), frame.pointer('key'), operation);
|
|
1355
|
+
key = decodeWorldKey(frame.view(), frame.pointer('key'), operation, this.#handle);
|
|
1268
1356
|
} catch (error) {
|
|
1269
1357
|
let cleanupError;
|
|
1270
1358
|
if (created) {
|
|
1271
1359
|
try {
|
|
1272
1360
|
decodePackedResult(this.#exports.rundot_physics2d_owned_world_destroy(
|
|
1273
|
-
this.#
|
|
1361
|
+
this.#handle,
|
|
1274
1362
|
frame.pointer('key'),
|
|
1275
1363
|
), 'clean failed world creation');
|
|
1276
1364
|
} catch (cleanup) {
|
|
@@ -1295,17 +1383,22 @@ class OwnedRegistryTransport {
|
|
|
1295
1383
|
world.info();
|
|
1296
1384
|
return world;
|
|
1297
1385
|
} catch (error) {
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1386
|
+
this.discardFailedWorld(world, error);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
discardFailedWorld(world, primary) {
|
|
1391
|
+
try {
|
|
1392
|
+
world.dispose();
|
|
1393
|
+
} catch (cleanup) {
|
|
1394
|
+
this.#pendingCleanup.add(world);
|
|
1395
|
+
throwCleanupFailure('clean failed world creation', primary, cleanup);
|
|
1304
1396
|
}
|
|
1397
|
+
throw primary;
|
|
1305
1398
|
}
|
|
1306
1399
|
|
|
1307
1400
|
checkActive(operation) {
|
|
1308
|
-
if (this.#disposed || this.#
|
|
1401
|
+
if (this.#disposed || this.#handle === 0n) {
|
|
1309
1402
|
localFailure(operation, 'The registry transport is disposed.',
|
|
1310
1403
|
'Create a new registry transport.', -302);
|
|
1311
1404
|
}
|
|
@@ -1316,20 +1409,73 @@ class OwnedRegistryTransport {
|
|
|
1316
1409
|
}
|
|
1317
1410
|
|
|
1318
1411
|
dispose() {
|
|
1319
|
-
if (this.#disposed) return;
|
|
1320
1412
|
const operation = 'dispose registry';
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1413
|
+
disposeOwnedLeases(this.#exports);
|
|
1414
|
+
for (const world of this.#pendingCleanup) {
|
|
1415
|
+
world.dispose();
|
|
1416
|
+
this.#pendingCleanup.delete(world);
|
|
1417
|
+
}
|
|
1418
|
+
if (!this.#disposed) {
|
|
1419
|
+
try {
|
|
1420
|
+
decodePackedResult(this.#exports.rundot_physics2d_owned_registry_destroy(
|
|
1421
|
+
this.#handle,
|
|
1422
|
+
), operation);
|
|
1423
|
+
} catch (error) {
|
|
1424
|
+
if (error?.status !== -302) throw error;
|
|
1425
|
+
for (const world of this.#worlds) world.dispose();
|
|
1426
|
+
}
|
|
1427
|
+
this.#handle = 0n;
|
|
1428
|
+
this.#disposed = true;
|
|
1429
|
+
if (this.#worlds.size !== 0) {
|
|
1430
|
+
localFailure(operation, 'Native destroy succeeded while world wrappers remain live.',
|
|
1431
|
+
'Rebuild the adapter and native artifact from the same source.', -308);
|
|
1432
|
+
}
|
|
1327
1433
|
}
|
|
1328
|
-
const pointer = this.#pointer;
|
|
1329
|
-
this.#pointer = 0;
|
|
1330
|
-
this.#disposed = true;
|
|
1331
1434
|
this.#scratch.dispose();
|
|
1332
|
-
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
const pendingOwnedLeases = new WeakMap();
|
|
1439
|
+
|
|
1440
|
+
export function disposeOwnedLeases(exports) {
|
|
1441
|
+
const pending = pendingOwnedLeases.get(exports);
|
|
1442
|
+
if (pending === undefined) return;
|
|
1443
|
+
for (const arena of pending) {
|
|
1444
|
+
arena.dispose();
|
|
1445
|
+
pending.delete(arena);
|
|
1446
|
+
}
|
|
1447
|
+
if (pending.size === 0) pendingOwnedLeases.delete(exports);
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
export function withOwnedLease(exports, bytes, fn) {
|
|
1451
|
+
disposeOwnedLeases(exports);
|
|
1452
|
+
u32(bytes, 'allocate owned lease', 'bytes');
|
|
1453
|
+
if (bytes === 0) localFailure('allocate owned lease', 'bytes must be positive.');
|
|
1454
|
+
const arena = new ScratchArena(exports);
|
|
1455
|
+
const frame = arena.prepare('allocate owned lease', [{ name: 'lease', bytes, alignment: 16 }]);
|
|
1456
|
+
const pointer = frame.pointer('lease');
|
|
1457
|
+
let callError;
|
|
1458
|
+
try {
|
|
1459
|
+
return fn(pointer);
|
|
1460
|
+
} catch (error) {
|
|
1461
|
+
callError = error;
|
|
1462
|
+
throw error;
|
|
1463
|
+
} finally {
|
|
1464
|
+
try {
|
|
1465
|
+
arena.dispose();
|
|
1466
|
+
} catch (freeError) {
|
|
1467
|
+
let pending = pendingOwnedLeases.get(exports);
|
|
1468
|
+
if (pending === undefined) {
|
|
1469
|
+
pending = new Set();
|
|
1470
|
+
pendingOwnedLeases.set(exports, pending);
|
|
1471
|
+
}
|
|
1472
|
+
pending.add(arena);
|
|
1473
|
+
if (callError !== undefined) {
|
|
1474
|
+
throw new AggregateError([callError, freeError],
|
|
1475
|
+
'KINETIX_PHYSICS2D_OWNED_TRANSPORT: free owned lease failed and the call also failed.');
|
|
1476
|
+
}
|
|
1477
|
+
throw freeError;
|
|
1478
|
+
}
|
|
1333
1479
|
}
|
|
1334
1480
|
}
|
|
1335
1481
|
|