@series-inc/rundot-syncplay 5.28.0-beta.5 → 6.0.0-rc.2

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.
Files changed (232) hide show
  1. package/README.md +37 -63
  2. package/core/baker.d.ts +0 -2
  3. package/core/build-native.d.ts +0 -2
  4. package/core/build-wasm-physics.d.ts +0 -3
  5. package/core/compiler.d.ts +0 -2
  6. package/core/deterministic-math.d.ts +2 -6
  7. package/core/envelope.d.ts +0 -2
  8. package/core/f64-bits.d.ts +0 -2
  9. package/core/index.d.ts +0 -59
  10. package/core/native/kinetix-native-main.cpp +8 -11
  11. package/core/native/physics/abi.cpp +8 -0
  12. package/core/native/physics/abi.hpp +2 -0
  13. package/core/native/physics/constraint_rows.hpp +0 -1
  14. package/core/native/physics/physics.cpp +1142 -130
  15. package/core/native/physics/physics.hpp +6 -3
  16. package/core/native/physics/world.cpp +715 -35
  17. package/core/native/physics/world.hpp +74 -0
  18. package/core/native/physics/world_abi.cpp +386 -1
  19. package/core/native/physics/world_abi.hpp +80 -0
  20. package/core/native/physics2d/fluid.cpp +0 -2
  21. package/core/native/physics2d/fluid.hpp +0 -1
  22. package/core/native/physics2d/owned_abi.cpp +112 -0
  23. package/core/native/physics2d/owned_abi.hpp +28 -0
  24. package/core/native/physics2d/world.cpp +365 -1
  25. package/core/native/physics2d/world.hpp +14 -0
  26. package/core/native-product.d.ts +0 -2
  27. package/core/physics2d-owned.d.ts +116 -113
  28. package/core/render-projection.d.ts +0 -2
  29. package/core/render-records.d.ts +0 -2
  30. package/core/scripts/build-native.mjs +0 -2
  31. package/core/scripts/build-wasm-physics.mjs +25 -696
  32. package/core/src/index.mjs +0 -35
  33. package/core/src/physics/abi-constants.mjs +1 -1
  34. package/core/src/physics/index.mjs +52 -814
  35. package/core/src/physics/physics-wasm-module.generated.mjs +4 -4
  36. package/core/src/physics/wasm-instance.mjs +2 -0
  37. package/core/src/physics/world.d.mts +15 -0
  38. package/core/src/physics/world.mjs +409 -95
  39. package/core/src/physics2d/owned-transport.mjs +98 -0
  40. package/core/src/physics2d/owned-world.d.mts +9 -0
  41. package/core/src/physics2d/owned-world.mjs +64 -607
  42. package/core/src/physics2d/physics2d-wasm-module.generated.mjs +3 -3
  43. package/core/src/physics2d/wasm-instance.mjs +8 -171
  44. package/core/world-kernel.d.ts +0 -2
  45. package/core/world.d.ts +102 -0
  46. package/dist/api-deprecations.generated.d.ts +3 -3
  47. package/dist/api-deprecations.generated.js +3 -3
  48. package/dist/browser.d.ts +0 -14
  49. package/dist/browser.js +0 -7
  50. package/dist/creator.d.ts +0 -10
  51. package/dist/creator.js +0 -9
  52. package/dist/index.d.ts +0 -19
  53. package/dist/index.js +0 -9
  54. package/dist/lag-compensation3d.d.ts +22 -11
  55. package/dist/lag-compensation3d.js +70 -48
  56. package/dist/modules/combat.d.ts +7 -5
  57. package/dist/modules/combat.js +19 -12
  58. package/dist/modules/entity-registry.d.ts +1 -0
  59. package/dist/movement3d.d.ts +13 -13
  60. package/dist/movement3d.js +223 -221
  61. package/dist/networked-client.d.ts +1 -1
  62. package/dist/node.d.ts +0 -2
  63. package/dist/node.js +0 -1
  64. package/dist/physics/2d.d.ts +79 -0
  65. package/dist/physics/2d.js +219 -0
  66. package/dist/physics/3d.d.ts +282 -0
  67. package/dist/physics/3d.js +574 -0
  68. package/dist/runner.d.ts +2 -2
  69. package/package.json +18 -50
  70. package/core/box3d-probe.d.ts +0 -22
  71. package/core/build-mobile-native.d.ts +0 -8
  72. package/core/native/mobile/syncplay_native_probe.cpp +0 -114
  73. package/core/native/mobile/syncplay_native_probe_abi.h +0 -46
  74. package/core/native/physics/articulation.cpp +0 -1434
  75. package/core/native/physics/articulation.hpp +0 -279
  76. package/core/native/physics/buoyancy.cpp +0 -1015
  77. package/core/native/physics/buoyancy.hpp +0 -196
  78. package/core/native/physics/buoyancy_probe.cpp +0 -240
  79. package/core/native/physics/character.cpp +0 -638
  80. package/core/native/physics/character.hpp +0 -169
  81. package/core/native/physics/cloth.cpp +0 -1401
  82. package/core/native/physics/cloth.hpp +0 -357
  83. package/core/native/physics/deformable_query.cpp +0 -1630
  84. package/core/native/physics/deformable_query.hpp +0 -578
  85. package/core/native/physics/distance.cpp +0 -1163
  86. package/core/native/physics/distance.hpp +0 -151
  87. package/core/native/physics/extended_abi.cpp +0 -1242
  88. package/core/native/physics/extended_abi.hpp +0 -355
  89. package/core/native/physics/extended_abi_characters.cpp +0 -261
  90. package/core/native/physics/extended_abi_characters.hpp +0 -434
  91. package/core/native/physics/extended_abi_core_features.cpp +0 -711
  92. package/core/native/physics/extended_abi_core_features.hpp +0 -226
  93. package/core/native/physics/extended_abi_deformables.cpp +0 -448
  94. package/core/native/physics/extended_abi_deformables.hpp +0 -867
  95. package/core/native/physics/extended_abi_vehicles.cpp +0 -411
  96. package/core/native/physics/extended_abi_vehicles.hpp +0 -222
  97. package/core/native/physics/extended_world.cpp +0 -2715
  98. package/core/native/physics/extended_world.hpp +0 -429
  99. package/core/native/physics/extended_world_abi.cpp +0 -900
  100. package/core/native/physics/extended_world_abi.hpp +0 -215
  101. package/core/native/physics/fracture.cpp +0 -1981
  102. package/core/native/physics/fracture.hpp +0 -460
  103. package/core/native/physics/gear.cpp +0 -563
  104. package/core/native/physics/gear.hpp +0 -158
  105. package/core/native/physics/joint_warm_probe.cpp +0 -1090
  106. package/core/native/physics/lag_compensation.cpp +0 -1626
  107. package/core/native/physics/lag_compensation.hpp +0 -405
  108. package/core/native/physics/particles.cpp +0 -1065
  109. package/core/native/physics/particles.hpp +0 -261
  110. package/core/native/physics/path_joint.cpp +0 -781
  111. package/core/native/physics/path_joint.hpp +0 -154
  112. package/core/native/physics/planar_deformable.cpp +0 -2433
  113. package/core/native/physics/planar_deformable.hpp +0 -889
  114. package/core/native/physics/platformer_2d.cpp +0 -1353
  115. package/core/native/physics/platformer_2d.hpp +0 -340
  116. package/core/native/physics/powered_ragdoll.cpp +0 -1100
  117. package/core/native/physics/powered_ragdoll.hpp +0 -279
  118. package/core/native/physics/powertrain.cpp +0 -586
  119. package/core/native/physics/powertrain.hpp +0 -180
  120. package/core/native/physics/pulley.cpp +0 -311
  121. package/core/native/physics/pulley.hpp +0 -121
  122. package/core/native/physics/ragdoll.cpp +0 -586
  123. package/core/native/physics/ragdoll.hpp +0 -221
  124. package/core/native/physics/rope.cpp +0 -672
  125. package/core/native/physics/rope.hpp +0 -215
  126. package/core/native/physics/rounded_convex.cpp +0 -1229
  127. package/core/native/physics/rounded_convex.hpp +0 -287
  128. package/core/native/physics/sdf_geometry.cpp +0 -1821
  129. package/core/native/physics/sdf_geometry.hpp +0 -474
  130. package/core/native/physics/soft_body.cpp +0 -1449
  131. package/core/native/physics/soft_body.hpp +0 -328
  132. package/core/native/physics/soft_collision.cpp +0 -1862
  133. package/core/native/physics/soft_collision.hpp +0 -561
  134. package/core/native/physics/surface_velocity.cpp +0 -366
  135. package/core/native/physics/surface_velocity.hpp +0 -243
  136. package/core/native/physics/tracks.cpp +0 -1179
  137. package/core/native/physics/tracks.hpp +0 -404
  138. package/core/native/physics/vehicle.cpp +0 -629
  139. package/core/native/physics/vehicle.hpp +0 -191
  140. package/core/native/physics/voxel_cooking.cpp +0 -1902
  141. package/core/native/physics/voxel_cooking.hpp +0 -395
  142. package/core/native/physics2d/buoyancy_probe.cpp +0 -382
  143. package/core/native/physics2d/ccd.cpp +0 -971
  144. package/core/native/physics2d/ccd.hpp +0 -116
  145. package/core/native/physics2d/compound.cpp +0 -581
  146. package/core/native/physics2d/compound.hpp +0 -248
  147. package/core/native/physics2d/contact_feature_probe.cpp +0 -354
  148. package/core/native/physics2d/fluid_probe.cpp +0 -321
  149. package/core/native/physics2d/gear_probe.cpp +0 -371
  150. package/core/native/physics2d/joints_probe.cpp +0 -927
  151. package/core/native/physics2d/physics2d_probe.cpp +0 -659
  152. package/core/native/physics2d/platformer.hpp +0 -3
  153. package/core/native/physics2d/pulley_probe.cpp +0 -680
  154. package/core/native/physics2d/query_probe.cpp +0 -874
  155. package/core/native/physics2d/world_probe.cpp +0 -1017
  156. package/core/physics.d.ts +0 -1581
  157. package/core/physics2d.d.ts +0 -632
  158. package/core/scripts/build-mobile-native.mjs +0 -127
  159. package/core/src/physics/articulation.mjs +0 -1141
  160. package/core/src/physics/character.mjs +0 -461
  161. package/core/src/physics/cloth.mjs +0 -1156
  162. package/core/src/physics/deformable-query.mjs +0 -1412
  163. package/core/src/physics/distance.mjs +0 -671
  164. package/core/src/physics/extended-wasm-instance.mjs +0 -187
  165. package/core/src/physics/extended-world.mjs +0 -911
  166. package/core/src/physics/fracture.mjs +0 -1324
  167. package/core/src/physics/gear.mjs +0 -956
  168. package/core/src/physics/lag-compensation.mjs +0 -1100
  169. package/core/src/physics/particles.mjs +0 -758
  170. package/core/src/physics/path-joint.mjs +0 -1231
  171. package/core/src/physics/physics-extended-wasm-module.generated.mjs +0 -10
  172. package/core/src/physics/planar-deformable.mjs +0 -1275
  173. package/core/src/physics/platformer-2d.mjs +0 -1137
  174. package/core/src/physics/powered-ragdoll.mjs +0 -1043
  175. package/core/src/physics/powertrain.mjs +0 -621
  176. package/core/src/physics/pulley.mjs +0 -686
  177. package/core/src/physics/ragdoll.mjs +0 -1323
  178. package/core/src/physics/rope.mjs +0 -423
  179. package/core/src/physics/rounded-convex.mjs +0 -1404
  180. package/core/src/physics/sdf-geometry.mjs +0 -1204
  181. package/core/src/physics/sixdof.mjs +0 -386
  182. package/core/src/physics/soft-body.mjs +0 -1285
  183. package/core/src/physics/soft-collision.mjs +0 -1883
  184. package/core/src/physics/surface-velocity.mjs +0 -885
  185. package/core/src/physics/tracks.mjs +0 -1074
  186. package/core/src/physics/vehicle.mjs +0 -423
  187. package/core/src/physics/voxel-cooking.mjs +0 -1475
  188. package/core/src/physics2d/ccd.mjs +0 -632
  189. package/core/src/physics2d/compound.mjs +0 -454
  190. package/core/src/physics2d/fluid-state.mjs +0 -145
  191. package/core/src/physics2d/index.mjs +0 -1463
  192. package/core/src/physics2d/queries.mjs +0 -124
  193. package/dist/api-v1.generated.d.ts +0 -257
  194. package/dist/api-v1.generated.js +0 -730
  195. package/dist/collider-cooking.d.ts +0 -141
  196. package/dist/collider-cooking.js +0 -829
  197. package/dist/cosmetic-physics3d.d.ts +0 -41
  198. package/dist/cosmetic-physics3d.js +0 -196
  199. package/dist/debug-wireframe.d.ts +0 -22
  200. package/dist/debug-wireframe.js +0 -226
  201. package/dist/engine-core-proof.d.ts +0 -26
  202. package/dist/engine-core-proof.js +0 -66
  203. package/dist/physics-cert.d.ts +0 -40
  204. package/dist/physics-cert.js +0 -535
  205. package/dist/physics2d.d.ts +0 -142
  206. package/dist/physics2d.js +0 -747
  207. package/dist/physics3d-destruction-cert.d.ts +0 -35
  208. package/dist/physics3d-destruction-cert.js +0 -283
  209. package/dist/physics3d-heightfield.d.ts +0 -27
  210. package/dist/physics3d-heightfield.js +0 -80
  211. package/dist/physics3d-hull.d.ts +0 -67
  212. package/dist/physics3d-hull.js +0 -421
  213. package/dist/physics3d-joints.d.ts +0 -115
  214. package/dist/physics3d-joints.js +0 -1005
  215. package/dist/physics3d-mass.d.ts +0 -11
  216. package/dist/physics3d-mass.js +0 -126
  217. package/dist/physics3d-recipes.d.ts +0 -29
  218. package/dist/physics3d-recipes.js +0 -193
  219. package/dist/physics3d-solver.d.ts +0 -326
  220. package/dist/physics3d-solver.js +0 -2512
  221. package/dist/physics3d-stacking.d.ts +0 -26
  222. package/dist/physics3d-stacking.js +0 -147
  223. package/dist/physics3d-toi.d.ts +0 -79
  224. package/dist/physics3d-toi.js +0 -267
  225. package/dist/physics3d-vehicle.d.ts +0 -84
  226. package/dist/physics3d-vehicle.js +0 -488
  227. package/dist/physics3d-voxel.d.ts +0 -131
  228. package/dist/physics3d-voxel.js +0 -819
  229. package/dist/physics3d.d.ts +0 -565
  230. package/dist/physics3d.js +0 -4133
  231. package/dist/sample-scenes.d.ts +0 -86
  232. package/dist/sample-scenes.js +0 -732
package/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # RUN Syncplay
2
2
 
3
- Syncplay is the orchestration layer over a signed deterministic runtime. The
4
- deterministic core ships inside this package under the `/core` subpaths
5
- (`@series-inc/rundot-syncplay/core/...`): it owns deterministic state, RNG
6
- streams, stepping, opaque checkpoints, serialization, hydration, and checksums.
7
- Syncplay owns inputs, prediction, confirmation, rollback policy, replay logs,
8
- late join, secrets, and transport.
3
+ Syncplay is the orchestration layer over a signed deterministic runtime. Public
4
+ runtime utilities use the `/core` subpaths. Public physics uses `/physics/2d`
5
+ and `/physics/3d`. Both physics APIs use the canonical C++ core compiled to
6
+ WASM. Syncplay owns inputs, prediction, confirmation, rollback policy, replay
7
+ logs, late join, secrets, and transport.
9
8
 
10
9
  ## Installation
11
10
 
@@ -134,7 +133,8 @@ The published JavaScript graph has a committed exhaustive side-effect audit.
134
133
  effects and are preserved through the package's precise `sideEffects` allowlist.
135
134
 
136
135
  > **Upgrading an existing game?** See
137
- > [MIGRATING-SESSION-PRIMITIVES.md](./MIGRATING-SESSION-PRIMITIVES.md). Two
136
+ > [the RC1 migration guide](https://github.com/series-ai/venus/blob/develop/packages/sdk-docs/rundot-developer-platform/api/SYNCPLAY-RC1-MIGRATION.md)
137
+ > and [the session primitive guide](https://github.com/series-ai/venus/blob/develop/packages/syncplay/MIGRATING-SESSION-PRIMITIVES.md). Two
138
138
  > changes are not additive: the runner now rejects an unsafe input codec at
139
139
  > construction, and the effects adapter now dedupes on your event `dedupeKey`.
140
140
 
@@ -158,8 +158,9 @@ dependency float cannot keep the same engine hash.
158
158
  | Subpath | Role |
159
159
  |---------|------|
160
160
  | `/core/runtime` | `createInstalledRuntimeAdapter`, identity helpers |
161
- | `/core/physics` | WASM physics (`initPhysics`, …) — reference solver |
162
- | `/` or `/browser` | KCC, runner, session, **TypeScript** physics — the solver `stepDeterministicKcc3D` collides against |
161
+ | `/physics/2d` | Canonical TypeScript 2D API over the C++/WASM core |
162
+ | `/physics/3d` | Canonical TypeScript 3D API over the C++/WASM core |
163
+ | `/` or `/browser` | Runner, session, and 3D character movement |
163
164
  | `/testing` | Simulated multi-peer / synctest |
164
165
  | `/node` | Authority room helpers (not for browser bundles) |
165
166
 
@@ -447,57 +448,30 @@ and `assertPresentationParity` cover the runner seam — a real runner driven on
447
448
  a fully controlled clock against the simulated match. Failures name the phase,
448
449
  frame, and disagreeing checksums.
449
450
 
450
- ## Physics parity program
451
-
452
- The physics parity program is in progress. The native 3D solver now performs
453
- collision work in each substep. Core queries require explicit initialization.
454
- The native 3D physics ABI is 18, as reported by `PHYSICS_ABI_VERSION` in
455
- `core/src/physics/abi-constants.mjs`. It adds `breakForce` and `breakTorque`
456
- joint limits and joint reactions in `world.jointCache`. The flat impulse fields remain
457
- for compatibility. ABI16 physics snapshots are rejected, so affected checkpoint
458
- histories need a rebuild or restart.
459
- The new `core/physics2d` API is experimental. It supports circles, boxes,
460
- capsules, and convex polygons with angular motion through the shared C++/WASM
461
- source. Constant finite fluid regions provide native buoyancy and coupled drag.
462
-
463
- It also supports eight experimental 2D joint primitives: distance, revolute,
464
- prismatic, weld, wheel, motor, mouse and rope. Gear joints couple two revolute or prismatic sources.
465
- Joint time uses seconds. Angles use radians. Body frames use the authoring
466
- origin. World frames use world coordinates. Endpoint A defines prismatic and
467
- wheel axes. `breakForce` and `breakTorque` are finite non-negative limits, and
468
- zero disables each limit. Linear drives require `maxForce`; angular drives
469
- require `maxTorque`; motor requires both caps; mouse requires `maxForce`.
470
- Zero caps are valid. Unsupported fields and invalid nested values fail before
471
- the native step.
472
-
473
- Linear speeds use world units per second. Angular speeds use radians per
474
- second. Force uses mass times world units per second squared. Torque uses mass
475
- times world units squared per second squared.
476
-
477
- Worlds expose sorted read-only `joints`, `jointState`, `jointTelemetry` and
478
- `jointBreakEvents` arrays. Warm signatures are `bigint` values. Matching
479
- normalized definitions retain warm state through `withPhysicsJoints2D`; changed
480
- definitions reset state. Pass `{ resetState: true }` to reset a matching
481
- definition. Definition edits clear latest telemetry and break events. Fluid
482
- edits preserve joint state. Reactions report native endpoint-B mean force and
483
- direct anchor couple, with full-step and substep durations. The mean uses the full tick duration. The default `KRTCP002` checkpoint codec preserves
484
- joint `bigint` state, so do not JSON-round-trip a world.
485
-
486
- A gear requires `sourceA`, `sourceB`, a finite nonzero `ratio`, a matching
487
- `ratioUnit`, and explicit `phase`. Its equation is `qB + ratio * qA = phase`.
488
- A positive break limit requires a source and endpoint selector. Gear telemetry
489
- has four ordered `endpointReactions`. Narrow `entry.type` before reading a
490
- primitive `reaction`. Source edits reset dependent gear warm state. Remove
491
- gears in the same update that removes a source. See the SDK physics guide for
492
- units, reaction semantics, and a checked example.
493
-
494
- The core hydrostatic buoyancy helper supports spheres and oriented boxes under
495
- a horizontal water plane. Full fluid, joint, 2D and cross-device parity remains
496
- open. Native 2D joints remain in progress. These additions do not declare
497
- Syncplay 1.0 complete. The capability ledger contains all 175 required feature
498
- rows and separates source findings from behavioral, replay, device and
499
- performance evidence.
500
-
501
- See the SDK physics and migration pages before adopting these changes. The
502
- default checkpoint codec is now `KRTCP002`. Physics trajectory changes require a
503
- new game deterministic version. The provisional release checks remain open.
451
+ ## Physics API v1
452
+
453
+ Syncplay RC1 has one public TypeScript API for each physics dimension. Import
454
+ 2D physics from `@series-inc/rundot-syncplay/physics/2d`. Import 3D physics from
455
+ `@series-inc/rundot-syncplay/physics/3d`. Do not import a raw physics adapter
456
+ from `/core`.
457
+
458
+ Call `initPhysics2D()` or `initPhysics3D()` before world creation. Create an
459
+ owned world with `createPhysicsWorld2D()` or `createPhysicsWorld3D()`. Each
460
+ world provides fixed stepping, atomic edits, retained queries, opaque native
461
+ checkpoints, portable checkpoint bytes, a state digest, and explicit disposal.
462
+
463
+ The TypeScript facade does not contain a second solver. Both dimensions run in
464
+ the canonical C++ core compiled to WASM. The internal solver algorithm, state
465
+ layout, WASM boundary, schedule, and checkpoint representation can change when
466
+ a complete benchmark proves a faster design. Each replacement must keep the
467
+ public contract, deterministic results, rollback controls, and bounded memory.
468
+
469
+ RC1 starts a new physics numeric epoch. Do not load a beta physics checkpoint
470
+ or replay into an RC1 world. Change the game deterministic version. Start new
471
+ rollback, replay, and late-join history.
472
+
473
+ Read the [2D guide](https://github.com/series-ai/venus/blob/develop/packages/sdk-docs/rundot-developer-platform/api/SYNCPLAY-PHYSICS-2D.md),
474
+ the [3D guide](https://github.com/series-ai/venus/blob/develop/packages/sdk-docs/rundot-developer-platform/api/SYNCPLAY-PHYSICS.md), and
475
+ the [RC1 migration helper](https://github.com/series-ai/venus/blob/develop/packages/sdk-docs/rundot-developer-platform/api/SYNCPLAY-RC1-MIGRATION.md).
476
+ Physical-phone performance remains a release gate. Do not infer phone results
477
+ from desktop measurements.
package/core/baker.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  // Generated. Declares the runtime exports of ./core/baker.
2
- // Constants carry exact values, function parameters carry real names typed `any`.
3
- // Regenerate: node scripts/generate-physics-declarations.mjs --write
4
2
 
5
3
  export declare function assertKinetixProductContract(products: any): any;
6
4
  export declare function assertKinetixRuntimeIdentityMatchesProducts(products: any, identity: any): any;
@@ -1,5 +1,3 @@
1
1
  // Generated. Declares the runtime exports of ./core/build-native.
2
- // Constants carry exact values, function parameters carry real names typed `any`.
3
- // Regenerate: node scripts/generate-physics-declarations.mjs --write
4
2
 
5
3
  export declare function buildNative(): any;
@@ -1,9 +1,6 @@
1
1
  // Generated. Declares the runtime exports of ./core/build-wasm-physics.
2
- // Constants carry exact values, function parameters carry real names typed `any`.
3
- // Regenerate: node scripts/generate-physics-declarations.mjs --write
4
2
 
5
3
  export declare function buildWasmPhysics(options?: any): any;
6
4
  export declare function buildWasmPhysics2D(options?: any): any;
7
- export declare function buildWasmPhysicsExtended(options?: any): any;
8
5
  export declare function getWasmNumericProfile(arg0?: any): any;
9
6
  export declare function getWasmPhysicsSourceHashes(): any;
@@ -1,6 +1,4 @@
1
1
  // Generated. Declares the runtime exports of ./core/compiler.
2
- // Constants carry exact values, function parameters carry real names typed `any`.
3
- // Regenerate: node scripts/generate-physics-declarations.mjs --write
4
2
 
5
3
  export declare function compileKinetixProject(arg0?: any): any;
6
4
  export declare function compileTrustedKinetixSource(arg0: any): any;
@@ -1,6 +1,2 @@
1
- // Generated. Declares the runtime exports of ./core/deterministic-math.
2
- // Constants carry exact values, function parameters carry real names typed `any`.
3
- // Regenerate: node scripts/generate-physics-declarations.mjs --write
4
-
5
- export declare const DETERMINISTIC_MATH_SOURCE: "(() => {\n if (globalThis.__deterministicMathInstalled) return;\n globalThis.__deterministicMathInstalled = true;\n\n const f64 = new Float64Array(1);\n const u32 = new Uint32Array(f64.buffer);\n // Little-endian assumed (x86_64/arm64); index 1 = high word.\n const HI = (x) => { f64[0] = x; return u32[1] | 0; };\n const LO = (x) => { f64[0] = x; return u32[0] | 0; };\n const fromWords = (hi, lo) => { u32[1] = hi >>> 0; u32[0] = lo >>> 0; return f64[0]; };\n const setHi = (x, hi) => { f64[0] = x; u32[1] = hi >>> 0; return f64[0]; };\n const setLo = (x, lo) => { f64[0] = x; u32[0] = lo >>> 0; return f64[0]; };\n\n const abs = Math.abs, sqrt = Math.sqrt, floor = Math.floor;\n\n const two1023 = 8.98846567431157953865e+307;\n function scalbn2(x, n) {\n let hx = HI(x), lx = LO(x);\n let k = (hx & 0x7ff00000) >> 20;\n if (k === 0) {\n if ((lx | (hx & 0x7fffffff)) === 0) return x;\n x *= 18014398509481984.0;\n hx = HI(x);\n k = ((hx & 0x7ff00000) >> 20) - 54;\n if (n < -50000) return 1e-300 * x;\n }\n if (k === 0x7ff) return x + x;\n k = k + n;\n if (k > 0x7fe) return 1e300 * (x > 0 ? 1e300 : -1e300);\n if (k > 0) return setHi(x, (hx & 0x800fffff) | (k << 20));\n if (k <= -54) {\n if (n > 50000) return 1e300 * (x > 0 ? 1e300 : -1e300);\n return 1e-300 * (x > 0 ? 1e-300 : -1e-300);\n }\n k += 54;\n x = setHi(x, (hx & 0x800fffff) | (k << 20));\n return x * 5.55112312578270211816e-17; // 2^-54\n }\n\n // ---- __kernel_sin / __kernel_cos / __kernel_tan (fdlibm) ----------------\n const S1 = -1.66666666666666324348e-01, S2 = 8.33333333332248946124e-03,\n S3 = -1.98412698298579493134e-04, S4 = 2.75573137070700676789e-06,\n S5 = -2.50507602534068634195e-08, S6 = 1.58969099521155010221e-10;\n function kernelSin(x, y, iy) {\n const z = x * x;\n const v = z * x;\n const r = S2 + z * (S3 + z * (S4 + z * (S5 + z * S6)));\n if (iy === 0) return x + v * (S1 + z * r);\n return x - ((z * (0.5 * y - v * r) - y) - v * S1);\n }\n const C1 = 4.16666666666666019037e-02, C2 = -1.38888888888741095749e-03,\n C3 = 2.48015872894767294178e-05, C4 = -2.75573143513906633035e-07,\n C5 = 2.08757232129817482790e-09, C6 = -1.13596475577881948265e-11;\n function kernelCos(x, y) {\n const z = x * x;\n const r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * C6)))));\n const hz = 0.5 * z;\n const w = 1.0 - hz;\n return w + (((1.0 - w) - hz) + (z * r - x * y));\n }\n const T = [\n 3.33333333333334091986e-01, 1.33333333333201242699e-01, 5.39682539762260521377e-02,\n 2.18694882948595424599e-02, 8.86323982359930005737e-03, 3.59207910759131235356e-03,\n 1.45620945432529025516e-03, 5.88041240820264096874e-04, 2.46463134818469906812e-04,\n 7.81794442939557092300e-05, 7.14072491382608190305e-05, -1.85586374855275456654e-05,\n 2.59073051863633712884e-05,\n ];\n const pio4 = 7.85398163397448278999e-01, pio4lo = 3.06161699786838301793e-17;\n function kernelTan(x, y, iy) {\n let z, r, v, w, s;\n const hx = HI(x);\n const ix = hx & 0x7fffffff;\n if (ix >= 0x3FE59428) { // |x| >= 0.6744\n if (hx < 0) { x = -x; y = -y; }\n z = pio4 - x;\n w = pio4lo - y;\n x = z + w; y = 0.0;\n }\n z = x * x;\n w = z * z;\n r = T[1] + w * (T[3] + w * (T[5] + w * (T[7] + w * (T[9] + w * T[11]))));\n v = z * (T[2] + w * (T[4] + w * (T[6] + w * (T[8] + w * (T[10] + w * T[12])))));\n s = z * x;\n r = y + z * (s * (r + v) + y);\n r += T[0] * s;\n w = x + r;\n if (ix >= 0x3FE59428) {\n v = iy;\n return (1 - ((hx >> 30) & 2)) * (v - 2.0 * (x - (w * w / (w + v) - r)));\n }\n if (iy === 1) return w;\n // compute -1/(x+r) accurately\n z = w;\n z = setLo(z, 0);\n v = r - (z - x);\n let t = -1.0 / w;\n let a = t;\n a = setLo(a, 0);\n s = 1.0 + a * z;\n return a + t * (s + a * v);\n }\n\n // ---- __rem_pio2 (fdlibm, incl. Payne-Hanek for large args) ---------------\n const twoOverPi = [\n 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 0x95993C, 0x439041,\n 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C,\n 0xFE1DEB, 0x1CB129, 0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41,\n 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, 0x97FFDE, 0x05980F,\n 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, 0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D,\n 0x7527BA, 0xC7EBE5, 0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08,\n 0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, 0x91615E, 0xE61B08,\n 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9,\n 0x60E27B, 0xC08C6B,\n ];\n const PIo2 = [\n 1.57079625129699707031e+00, 7.54978941586159635335e-08, 5.39030252995776476554e-15,\n 3.28200341580791294123e-22, 1.27065575308067607349e-29, 1.22933308981111328932e-36,\n 2.73370053816464559624e-44, 2.16741683877804819444e-51,\n ];\n const two24 = 1.67772160000000000000e+07, twon24 = 5.96046447753906250000e-08;\n function kernelRemPio2(x, y, e0, nx) {\n // prec = 2 (double), jk = 4\n const jk = 4, jp = 4;\n let jx = nx - 1;\n let jv = ((e0 - 3) / 24) | 0; if (jv < 0) jv = 0;\n let q0 = e0 - 24 * (jv + 1);\n const f = new Array(20).fill(0);\n const q = new Array(20).fill(0);\n const iq = new Array(20).fill(0);\n const fw0 = new Array(20).fill(0);\n let i, j, k, m, n, ih, z, fw, carry;\n for (i = 0, j = jv - jx; i <= jx + jk; i++, j++) f[i] = j < 0 ? 0 : twoOverPi[j];\n for (i = 0; i <= jk; i++) {\n fw = 0;\n for (j = 0; j <= jx; j++) fw += x[j] * f[jx + i - j];\n q[i] = fw;\n }\n let jz = jk;\n let recomputeNeeded = true;\n while (recomputeNeeded) {\n recomputeNeeded = false;\n // distill q[] into iq[] reversingly\n for (i = 0, j = jz, z = q[jz]; j > 0; i++, j--) {\n fw = Math.floor(twon24 * z);\n iq[i] = (z - two24 * fw) | 0;\n z = q[j - 1] + fw;\n }\n z = scalbn2(z, q0);\n z -= 8.0 * floor(z * 0.125);\n n = z | 0;\n z -= n;\n ih = 0;\n if (q0 > 0) {\n i = (iq[jz - 1] >> (24 - q0));\n n += i;\n iq[jz - 1] -= i << (24 - q0);\n ih = iq[jz - 1] >> (23 - q0);\n } else if (q0 === 0) ih = iq[jz - 1] >> 23;\n else if (z >= 0.5) ih = 2;\n if (ih > 0) {\n n += 1; carry = 0;\n for (i = 0; i < jz; i++) {\n j = iq[i];\n if (carry === 0) {\n if (j !== 0) { carry = 1; iq[i] = 0x1000000 - j; }\n } else iq[i] = 0xffffff - j;\n }\n if (q0 > 0) {\n switch (q0) {\n case 1: iq[jz - 1] &= 0x7fffff; break;\n case 2: iq[jz - 1] &= 0x3fffff; break;\n }\n }\n if (ih === 2) {\n z = 1.0 - z;\n if (carry !== 0) z -= scalbn2(1.0, q0);\n }\n }\n if (z === 0) {\n j = 0;\n for (i = jz - 1; i >= jk; i--) j |= iq[i];\n if (j === 0) {\n for (k = 1; iq[jk - k] === 0; k++) { }\n for (i = jz + 1; i <= jz + k; i++) {\n f[jx + i] = twoOverPi[jv + i];\n for (j = 0, fw = 0; j <= jx; j++) fw += x[j] * f[jx + i - j];\n q[i] = fw;\n }\n jz += k;\n recomputeNeeded = true;\n continue;\n }\n }\n if (z === 0) {\n jz -= 1; q0 -= 24;\n while (iq[jz] === 0) { jz--; q0 -= 24; }\n } else {\n z = scalbn2(z, -q0);\n if (z >= two24) {\n fw = Math.floor(twon24 * z);\n iq[jz] = (z - two24 * fw) | 0;\n jz += 1; q0 += 24;\n iq[jz] = fw | 0;\n } else iq[jz] = z | 0;\n }\n fw = scalbn2(1.0, q0);\n for (i = jz; i >= 0; i--) { q[i] = fw * iq[i]; fw *= twon24; }\n for (i = jz; i >= 0; i--) {\n for (fw = 0, k = 0; k <= jp && k <= jz - i; k++) fw += PIo2[k] * q[i + k];\n fw0[jz - i] = fw;\n }\n // compress fw0 into y[] (prec 2)\n fw = 0;\n for (i = jz; i >= 0; i--) fw += fw0[i];\n y[0] = ih === 0 ? fw : -fw;\n fw = fw0[0] - fw;\n for (i = 1; i <= jz; i++) fw += fw0[i];\n y[1] = ih === 0 ? fw : -fw;\n }\n return n & 7;\n }\n\n const invpio2 = 6.36619772367581382433e-01;\n const pio2_1 = 1.57079632673412561417e+00, pio2_1t = 6.07710050650619224932e-11;\n const pio2_2 = 6.07710050630396597660e-11, pio2_2t = 2.02226624879595063154e-21;\n const pio2_3 = 2.02226624871116645580e-21, pio2_3t = 8.47842766036889956997e-32;\n const npio2_hw = [\n 0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C,\n 0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C,\n 0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A,\n 0x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C, 0x4042106C, 0x4042D97C,\n 0x4043A28C, 0x40446B9C, 0x404534AC, 0x4045FDBB, 0x4046C6CB, 0x40478FDB,\n 0x404858EB, 0x404921FB,\n ];\n function remPio2(x, y) {\n const hx = HI(x);\n const ix = hx & 0x7fffffff;\n if (ix <= 0x3fe921fb) { y[0] = x; y[1] = 0; return 0; }\n if (ix < 0x4002d97c) { // |x| < 3pi/4\n if (hx > 0) {\n let z = x - pio2_1;\n if (ix !== 0x3ff921fb) { y[0] = z - pio2_1t; y[1] = (z - y[0]) - pio2_1t; }\n else { z -= pio2_2; y[0] = z - pio2_2t; y[1] = (z - y[0]) - pio2_2t; }\n return 1;\n }\n let z = x + pio2_1;\n if (ix !== 0x3ff921fb) { y[0] = z + pio2_1t; y[1] = (z - y[0]) + pio2_1t; }\n else { z += pio2_2; y[0] = z + pio2_2t; y[1] = (z - y[0]) + pio2_2t; }\n return -1;\n }\n if (ix <= 0x413921fb) { // |x| <= 2^19 pi/2\n const t = abs(x);\n const n = (t * invpio2 + 0.5) | 0;\n const fn = n;\n let r = t - fn * pio2_1;\n let w = fn * pio2_1t;\n if (n < 32 && ix !== npio2_hw[n - 1]) {\n y[0] = r - w;\n } else {\n const high = HI(x);\n let j = ix >> 20;\n y[0] = r - w;\n let i = j - (((HI(y[0])) >> 20) & 0x7ff);\n if (i > 16) {\n let t2 = r;\n w = fn * pio2_2;\n r = t2 - w;\n w = fn * pio2_2t - ((t2 - r) - w);\n y[0] = r - w;\n i = j - (((HI(y[0])) >> 20) & 0x7ff);\n if (i > 49) {\n let t3 = r;\n w = fn * pio2_3;\n r = t3 - w;\n w = fn * pio2_3t - ((t3 - r) - w);\n y[0] = r - w;\n }\n }\n }\n y[1] = (r - y[0]) - w;\n if (hx < 0) { y[0] = -y[0]; y[1] = -y[1]; return -n; }\n return n;\n }\n if (ix >= 0x7ff00000) { y[0] = y[1] = x - x; return 0; }\n // Payne-Hanek\n const lx = LO(x);\n const e0 = (ix >> 20) - 1046;\n let z = setHi(0, ix - (e0 << 20));\n z = setLo(z, lx);\n const tx = [0, 0, 0];\n for (let i = 0; i < 2; i++) { tx[i] = z | 0; z = (z - tx[i]) * two24; }\n tx[2] = z;\n let nx = 3;\n while (nx > 0 && tx[nx - 1] === 0) nx--;\n const n = kernelRemPio2(tx, y, e0, nx);\n if (hx < 0) { y[0] = -y[0]; y[1] = -y[1]; return -n; }\n return n;\n }\n\n function detSin(x) {\n const ix = HI(x) & 0x7fffffff;\n if (ix <= 0x3fe921fb) {\n if (ix < 0x3e400000) { if ((x | 0) === 0 && x === x) return x; }\n return kernelSin(x, 0, 0);\n }\n if (ix >= 0x7ff00000) return x - x;\n const y = [0, 0];\n const n = remPio2(x, y);\n switch (n & 3) {\n case 0: return kernelSin(y[0], y[1], 1);\n case 1: return kernelCos(y[0], y[1]);\n case 2: return -kernelSin(y[0], y[1], 1);\n default: return -kernelCos(y[0], y[1]);\n }\n }\n function detCos(x) {\n const ix = HI(x) & 0x7fffffff;\n if (ix <= 0x3fe921fb) {\n if (ix < 0x3e400000) return 1.0;\n return kernelCos(x, 0);\n }\n if (ix >= 0x7ff00000) return x - x;\n const y = [0, 0];\n const n = remPio2(x, y);\n switch (n & 3) {\n case 0: return kernelCos(y[0], y[1]);\n case 1: return -kernelSin(y[0], y[1], 1);\n case 2: return -kernelCos(y[0], y[1]);\n default: return kernelSin(y[0], y[1], 1);\n }\n }\n function detTan(x) {\n const ix = HI(x) & 0x7fffffff;\n if (ix <= 0x3fe921fb) {\n if (ix < 0x3e300000) { if ((x | 0) === 0 && x === x) return x; }\n return kernelTan(x, 0, 1);\n }\n if (ix >= 0x7ff00000) return x - x;\n const y = [0, 0];\n const n = remPio2(x, y);\n return kernelTan(y[0], y[1], 1 - ((n & 1) << 1));\n }\n\n // ---- log / log10 (fdlibm e_log) ------------------------------------------\n const ln2_hi = 6.93147180369123816490e-01, ln2_lo = 1.90821492927058770002e-10;\n const Lg1 = 6.666666666666735130e-01, Lg2 = 3.999999999940941908e-01,\n Lg3 = 2.857142874366239149e-01, Lg4 = 2.222219843214978396e-01,\n Lg5 = 1.818357216161805012e-01, Lg6 = 1.531383769920937332e-01,\n Lg7 = 1.479819860511658591e-01;\n const two54 = 1.80143985094819840000e+16;\n function detLog(x) {\n let hx = HI(x), lx = LO(x);\n let k = 0;\n if (hx < 0x00100000) {\n if (((hx & 0x7fffffff) | lx) === 0) return -Infinity;\n if (hx < 0) return (x - x) / 0;\n k -= 54; x *= two54; hx = HI(x);\n }\n if (hx >= 0x7ff00000) return x + x;\n k += (hx >> 20) - 1023;\n hx &= 0x000fffff;\n const i = (hx + 0x95f64) & 0x100000;\n x = setHi(x, hx | (i ^ 0x3ff00000));\n k += i >> 20;\n const f = x - 1.0;\n if ((0x000fffff & (2 + hx)) < 3) {\n if (f === 0) { if (k === 0) return 0; return k * ln2_hi + k * ln2_lo; }\n const R = f * f * (0.5 - 0.33333333333333333 * f);\n if (k === 0) return f - R;\n return k * ln2_hi - ((R - k * ln2_lo) - f);\n }\n const s = f / (2.0 + f);\n const dk = k;\n const z = s * s;\n const ii = hx - 0x6147a;\n const w = z * z;\n const jj = 0x6b851 - hx;\n const t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n const t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n const ij = ii | jj;\n const R = t2 + t1;\n if (ij > 0) {\n const hfsq = 0.5 * f * f;\n if (k === 0) return f - (hfsq - s * (hfsq + R));\n return dk * ln2_hi - ((hfsq - (s * (hfsq + R) + dk * ln2_lo)) - f);\n }\n if (k === 0) return f - s * (f - R);\n return dk * ln2_hi - ((s * (f - R) - dk * ln2_lo) - f);\n }\n const ivln10 = 4.34294481903251816668e-01;\n const log10_2hi = 3.01029995663611771306e-01, log10_2lo = 3.69423907715893078616e-13;\n function detLog10(x) {\n let hx = HI(x), lx = LO(x);\n let k = 0;\n if (hx < 0x00100000) {\n if (((hx & 0x7fffffff) | lx) === 0) return -Infinity;\n if (hx < 0) return (x - x) / 0;\n k -= 54; x *= two54; hx = HI(x);\n }\n if (hx >= 0x7ff00000) return x + x;\n k += (hx >> 20) - 1023;\n const i = (k & 0x80000000) >>> 31;\n hx = (hx & 0x000fffff) | ((0x3ff - i) << 20);\n const y = k + i;\n x = setHi(x, hx);\n const z = y * log10_2lo + ivln10 * detLog(x);\n return z + y * log10_2hi;\n }\n\n // ---- asin / acos (fdlibm) -------------------------------------------------\n const pio2_hi = 1.57079632679489655800e+00, pio2_lo = 6.12323399573676603587e-17;\n const pio4_hi = 7.85398163397448278999e-01;\n const pS0 = 1.66666666666666657415e-01, pS1 = -3.25565818622400915405e-01,\n pS2 = 2.01212532134862925881e-01, pS3 = -4.00555345006794114027e-02,\n pS4 = 7.91534994289814532176e-04, pS5 = 3.47933107596021167570e-05,\n qS1 = -2.40339491173441421878e+00, qS2 = 2.02094576023350569471e+00,\n qS3 = -6.88283971605453293030e-01, qS4 = 7.70381505559019352791e-02;\n function detAsin(x) {\n const hx = HI(x);\n const ix = hx & 0x7fffffff;\n if (ix >= 0x3ff00000) {\n if (((ix - 0x3ff00000) | LO(x)) === 0) return x * pio2_hi + x * pio2_lo;\n return (x - x) / (x - x);\n }\n if (ix < 0x3fe00000) {\n if (ix < 0x3e400000) return x;\n const t = x * x;\n const p = t * (pS0 + t * (pS1 + t * (pS2 + t * (pS3 + t * (pS4 + t * pS5)))));\n const q = 1.0 + t * (qS1 + t * (qS2 + t * (qS3 + t * qS4)));\n const w = p / q;\n return x + x * w;\n }\n let w = 1.0 - abs(x);\n let t = w * 0.5;\n let p = t * (pS0 + t * (pS1 + t * (pS2 + t * (pS3 + t * (pS4 + t * pS5)))));\n let q = 1.0 + t * (qS1 + t * (qS2 + t * (qS3 + t * qS4)));\n const s = sqrt(t);\n if (ix >= 0x3FEF3333) {\n w = p / q;\n t = pio2_hi - (2.0 * (s + s * w) - pio2_lo);\n } else {\n w = s;\n w = setLo(w, 0);\n const c = (t - w * w) / (s + w);\n const r = p / q;\n p = 2.0 * s * r - (pio2_lo - 2.0 * c);\n q = pio4_hi - 2.0 * w;\n t = pio4_hi - (p - q);\n }\n return hx > 0 ? t : -t;\n }\n function detAcos(x) {\n const hx = HI(x);\n const ix = hx & 0x7fffffff;\n if (ix >= 0x3ff00000) {\n if (((ix - 0x3ff00000) | LO(x)) === 0) return hx > 0 ? 0.0 : Math.PI;\n return (x - x) / (x - x);\n }\n if (ix < 0x3fe00000) {\n if (ix <= 0x3c600000) return pio2_hi + pio2_lo;\n const z = x * x;\n const p = z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5)))));\n const q = 1.0 + z * (qS1 + z * (qS2 + z * (qS3 + z * qS4)));\n const r = p / q;\n return pio2_hi - (x - (pio2_lo - x * r));\n }\n if (hx < 0) {\n const z = (1.0 + x) * 0.5;\n const p = z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5)))));\n const q = 1.0 + z * (qS1 + z * (qS2 + z * (qS3 + z * qS4)));\n const s = sqrt(z);\n const r = p / q;\n const w = r * s - pio2_lo;\n return Math.PI - 2.0 * (s + w);\n }\n const z = (1.0 - x) * 0.5;\n const s = sqrt(z);\n let df = s;\n df = setLo(df, 0);\n const c = (z - df * df) / (s + df);\n const p = z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5)))));\n const q = 1.0 + z * (qS1 + z * (qS2 + z * (qS3 + z * qS4)));\n const r = p / q;\n const w = r * s + c;\n return 2.0 * (df + w);\n }\n\n // ---- expm1 (fdlibm s_expm1) ----------------------------------------------\n const o_threshold = 7.09782712893383973096e+02;\n const invln2 = 1.44269504088896338700e+00;\n const Q1 = -3.33333333333331316428e-02, Q2 = 1.58730158725481460165e-03,\n Q3 = -7.93650757867487942473e-05, Q4 = 4.00821782732936239552e-06,\n Q5 = -2.01099218183624371326e-07;\n function detExpm1(x) {\n const hx = HI(x);\n const xsb = hx & 0x80000000;\n let y = xsb === 0 ? x : -x;\n const ix = hx & 0x7fffffff;\n if (ix >= 0x4043687A) {\n if (ix >= 0x40862E42) {\n if (ix >= 0x7ff00000) {\n if (((ix & 0xfffff) | LO(x)) !== 0) return x + x;\n return xsb === 0 ? x : -1.0;\n }\n if (x > o_threshold) return Infinity;\n }\n if (xsb !== 0) return -1.0 + 1e-300 * 1e-300 * 0; // x < -56*ln2: -1 (tiny inexact ignored)\n }\n let k, t, c = 0, hi, lo;\n if (ix > 0x3fd62e42) {\n if (ix < 0x3FF0A2B2) {\n if (xsb === 0) { hi = x - 6.93147180369123816490e-01; lo = 1.90821492927058770002e-10; k = 1; }\n else { hi = x + 6.93147180369123816490e-01; lo = -1.90821492927058770002e-10; k = -1; }\n } else {\n k = (invln2 * x + (xsb === 0 ? 0.5 : -0.5)) | 0;\n t = k;\n hi = x - t * 6.93147180369123816490e-01;\n lo = t * 1.90821492927058770002e-10;\n }\n x = hi - lo;\n c = (hi - x) - lo;\n } else if (ix < 0x3c900000) {\n return x;\n } else k = 0;\n const hfx = 0.5 * x;\n const hxs = x * hfx;\n const r1 = 1.0 + hxs * (Q1 + hxs * (Q2 + hxs * (Q3 + hxs * (Q4 + hxs * Q5))));\n t = 3.0 - r1 * hfx;\n let e = hxs * ((r1 - t) / (6.0 - x * t));\n if (k === 0) return x - (x * e - hxs);\n e = (x * (e - c) - c);\n e -= hxs;\n if (k === -1) return 0.5 * (x - e) - 0.5;\n if (k === 1) {\n if (x < -0.25) return -2.0 * (e - (x + 0.5));\n return 1.0 + 2.0 * (x - e);\n }\n if (k <= -2 || k > 56) {\n y = 1.0 - (e - x);\n if (k === 1024) y = y * 2.0 * two1023;\n else y = y * scalbn2(1.0, k);\n return y - 1.0;\n }\n t = scalbn2(1.0, -k);\n if (k < 20) {\n y = (x - e + (1 - t)) * scalbn2(1.0, k);\n } else {\n y = (x - (e + t) + 1) * scalbn2(1.0, k);\n }\n return y;\n }\n\n // ---- exp (fdlibm e_exp — native exp diverges cross-engine on rare inputs)\n const halF = [0.5, -0.5];\n const u_threshold = -7.45133219101941108420e+02;\n const ln2HI = [6.93147180369123816490e-01, -6.93147180369123816490e-01];\n const ln2LO = [1.90821492927058770002e-10, -1.90821492927058770002e-10];\n const P1 = 1.66666666666666019037e-01, P2 = -2.77777777770155933842e-03,\n P3 = 6.61375632143793436117e-05, P4 = -1.65339022054652515390e-06,\n P5 = 4.13813679705723846039e-08;\n const twom1000 = 9.33263618503218878990e-302;\n function detExp(x) {\n let hx = HI(x);\n const xsb = (hx >> 31) & 1;\n hx &= 0x7fffffff;\n if (hx >= 0x40862E42) {\n if (hx >= 0x7ff00000) {\n if (((hx & 0xfffff) | LO(x)) !== 0) return x + x;\n return xsb === 0 ? x : 0.0;\n }\n if (x > o_threshold) return Infinity;\n if (x < u_threshold) return 0;\n }\n let k = 0, hi = 0, lo = 0, t;\n if (hx > 0x3fd62e42) {\n if (hx < 0x3FF0A2B2) { hi = x - ln2HI[xsb]; lo = ln2LO[xsb]; k = 1 - xsb - xsb; }\n else {\n k = (invln2 * x + halF[xsb]) | 0;\n t = k;\n hi = x - t * ln2HI[0];\n lo = t * ln2LO[0];\n }\n x = hi - lo;\n } else if (hx < 0x3e300000) {\n return 1.0 + x;\n }\n t = x * x;\n const c = x - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));\n if (k === 0) return 1.0 - ((x * c) / (c - 2.0) - x);\n let y = 1.0 - ((lo - (x * c) / (2.0 - c)) - hi);\n if (k >= -1021) return setHi(y, HI(y) + (k << 20));\n y = setHi(y, HI(y) + ((k + 1000) << 20));\n return y * twom1000;\n }\n\n // ---- sinh / cosh / tanh from expm1 + deterministic exp -------------------\n const nativeExp = detExp;\n function detSinh(x) {\n const hx = HI(x);\n const ix = hx & 0x7fffffff;\n if (ix >= 0x7ff00000) return x + x;\n const h = hx < 0 ? -0.5 : 0.5;\n if (ix < 0x40360000) {\n if (ix < 0x3e300000) return x;\n const t = detExpm1(abs(x));\n if (ix < 0x3ff00000) return h * (2.0 * t - t * t / (t + 1.0));\n return h * (t + t / (t + 1.0));\n }\n if (ix < 0x40862E42) return h * nativeExp(abs(x));\n const lx = LO(x);\n if (ix < 0x408633CE || (ix === 0x408633CE && lx <= 0x8fb9f87d)) {\n const w = nativeExp(0.5 * abs(x));\n const t = h * w;\n return t * w;\n }\n return x * 1e307 * 1e307;\n }\n function detCosh(x) {\n const ix = HI(x) & 0x7fffffff;\n if (ix >= 0x7ff00000) return x * x;\n if (ix < 0x3fd62e43) {\n const t = detExpm1(abs(x));\n const w = 1.0 + t;\n if (ix < 0x3c800000) return w;\n return 1.0 + (t * t) / (w + w);\n }\n if (ix < 0x40360000) {\n const t = nativeExp(abs(x));\n return 0.5 * t + 0.5 / t;\n }\n if (ix < 0x40862E42) return 0.5 * nativeExp(abs(x));\n const lx = LO(x);\n if (ix < 0x408633CE || (ix === 0x408633CE && lx <= 0x8fb9f87d)) {\n const w = nativeExp(0.5 * abs(x));\n return (0.5 * w) * w;\n }\n return 1e307 * 1e307;\n }\n function detTanh(x) {\n const hx = HI(x);\n const ix = hx & 0x7fffffff;\n if (ix >= 0x7ff00000) {\n if (hx >= 0) return 1.0 / x + 1.0;\n return 1.0 / x - 1.0;\n }\n let z;\n if (ix < 0x40360000) {\n if (ix < 0x3c800000) return x * (1.0 + x);\n if (ix >= 0x3ff00000) {\n const t = detExpm1(2.0 * abs(x));\n z = 1.0 - 2.0 / (t + 2.0);\n } else {\n const t = detExpm1(-2.0 * abs(x));\n z = -t / (t + 2.0);\n }\n } else z = 1.0 - 1e-300;\n return hx >= 0 ? z : -z;\n }\n\n // ---- atan / atan2 (fdlibm s_atan / e_atan2) -------------------------------\n const atanhi = [\n 4.63647609000806093515e-01, 7.85398163397448278999e-01,\n 9.82793723247329054082e-01, 1.57079632679489655800e+00,\n ];\n const atanlo = [\n 2.26987774529616870924e-17, 3.06161699786838301793e-17,\n 1.39033110312309984516e-17, 6.12323399573676603587e-17,\n ];\n const aT = [\n 3.33333333333329318027e-01, -1.99999999998764832476e-01, 1.42857142725034663711e-01,\n -1.11111104054623557880e-01, 9.09088713343650656196e-02, -7.69187620504482999495e-02,\n 6.66107313738753120669e-02, -5.83357013379057348645e-02, 4.97687799461593236017e-02,\n -3.65315727442169155270e-02, 1.62858201153657823623e-02,\n ];\n function detAtan(x) {\n const hx = HI(x);\n const ix = hx & 0x7fffffff;\n if (ix >= 0x44100000) {\n if (ix > 0x7ff00000 || (ix === 0x7ff00000 && LO(x) !== 0)) return x + x;\n return hx > 0 ? atanhi[3] + atanlo[3] : -atanhi[3] - atanlo[3];\n }\n let id;\n if (ix < 0x3fdc0000) {\n if (ix < 0x3e200000) return x;\n id = -1;\n } else {\n x = abs(x);\n if (ix < 0x3ff30000) {\n if (ix < 0x3fe60000) { id = 0; x = (2.0 * x - 1.0) / (2.0 + x); }\n else { id = 1; x = (x - 1.0) / (x + 1.0); }\n } else {\n if (ix < 0x40038000) { id = 2; x = (x - 1.5) / (1.0 + 1.5 * x); }\n else { id = 3; x = -1.0 / x; }\n }\n }\n const z = x * x;\n const w = z * z;\n const s1 = z * (aT[0] + w * (aT[2] + w * (aT[4] + w * (aT[6] + w * (aT[8] + w * aT[10])))));\n const s2 = w * (aT[1] + w * (aT[3] + w * (aT[5] + w * (aT[7] + w * aT[9]))));\n if (id < 0) return x - x * (s1 + s2);\n const zz = atanhi[id] - ((x * (s1 + s2) - atanlo[id]) - x);\n return hx < 0 ? -zz : zz;\n }\n const tiny_atan2 = 1.0e-300;\n const pi_o_4 = 7.8539816339744827900e-01, pi_o_2 = 1.5707963267948965580e+00;\n const detPi = 3.1415926535897931160e+00, pi_lo = 1.2246467991473531772e-16;\n function detAtan2(y, x) {\n const hx = HI(x), lx = LO(x), hy = HI(y), ly = LO(y);\n const ix = hx & 0x7fffffff, iy = hy & 0x7fffffff;\n if ((ix | ((lx | -lx) >>> 31)) > 0x7ff00000 || (iy | ((ly | -ly) >>> 31)) > 0x7ff00000) return x + y;\n if (hx === 0x3ff00000 && lx === 0) return detAtan(y);\n const m = ((hy >> 31) & 1) | ((hx >> 30) & 2);\n if ((iy | ly) === 0) {\n switch (m) {\n case 0: case 1: return y;\n case 2: return detPi + tiny_atan2;\n default: return -detPi - tiny_atan2;\n }\n }\n if ((ix | lx) === 0) return hy < 0 ? -pi_o_2 - tiny_atan2 : pi_o_2 + tiny_atan2;\n if (ix === 0x7ff00000) {\n if (iy === 0x7ff00000) {\n switch (m) {\n case 0: return pi_o_4 + tiny_atan2;\n case 1: return -pi_o_4 - tiny_atan2;\n case 2: return 3.0 * pi_o_4 + tiny_atan2;\n default: return -3.0 * pi_o_4 - tiny_atan2;\n }\n } else {\n switch (m) {\n case 0: return 0.0;\n case 1: return -0.0;\n case 2: return detPi + tiny_atan2;\n default: return -detPi - tiny_atan2;\n }\n }\n }\n if (iy === 0x7ff00000) return hy < 0 ? -pi_o_2 - tiny_atan2 : pi_o_2 + tiny_atan2;\n const k = (iy - ix) >> 20;\n let z;\n if (k > 60) z = pi_o_2 + 0.5 * pi_lo;\n else if (hx < 0 && k < -60) z = 0.0;\n else z = detAtan(abs(y / x));\n switch (m) {\n case 0: return z;\n case 1: return -z;\n case 2: return detPi - (z - pi_lo);\n default: return (z - pi_lo) - detPi;\n }\n }\n\n // ---- log1p (fdlibm s_log1p) -----------------------------------------------\n function detLog1p(x) {\n const hx = HI(x);\n const ax = hx & 0x7fffffff;\n let k = 1, f = 0, hu = 0, c = 0, u;\n if (hx < 0x3FDA827A) {\n if (ax >= 0x3ff00000) {\n if (x === -1.0) return -Infinity;\n return (x - x) / (x - x);\n }\n if (ax < 0x3e200000) {\n if (ax < 0x3c900000) return x;\n return x - x * x * 0.5;\n }\n if (hx > 0 || hx <= (0xbfd2bec3 | 0)) { k = 0; f = x; hu = 1; }\n }\n if (k !== 0) {\n if (hx < 0x43400000) {\n u = 1.0 + x;\n hu = HI(u);\n k = (hu >> 20) - 1023;\n c = k > 0 ? 1.0 - (u - x) : x - (u - 1.0);\n c /= u;\n } else {\n u = x;\n hu = HI(u);\n k = (hu >> 20) - 1023;\n c = 0;\n }\n hu &= 0x000fffff;\n if (hu < 0x6a09e) {\n u = setHi(u, hu | 0x3ff00000);\n } else {\n k += 1;\n u = setHi(u, hu | 0x3fe00000);\n hu = (0x00100000 - hu) >> 2;\n }\n f = u - 1.0;\n }\n const hfsq = 0.5 * f * f;\n let R, s, z;\n if (hu === 0) {\n if (f === 0) {\n if (k === 0) return 0;\n c += k * ln2_lo;\n return k * ln2_hi + c;\n }\n R = hfsq * (1.0 - 0.66666666666666666 * f);\n if (k === 0) return f - R;\n return k * ln2_hi - ((R - (k * ln2_lo + c)) - f);\n }\n s = f / (2.0 + f);\n z = s * s;\n R = z * (Lg1 + z * (Lg2 + z * (Lg3 + z * (Lg4 + z * (Lg5 + z * (Lg6 + z * Lg7))))));\n if (k === 0) return f - (hfsq - s * (hfsq + R));\n return k * ln2_hi - ((hfsq - (s * (hfsq + R) + (k * ln2_lo + c))) - f);\n }\n\n // ---- asinh / acosh / atanh (fdlibm, via deterministic log/log1p/sqrt) ----\n const det_ln2 = 6.93147180559945286227e-01;\n function detAsinh(x) {\n const hx = HI(x);\n const ix = hx & 0x7fffffff;\n if (ix >= 0x7ff00000) return x + x;\n if (ix < 0x3e300000) return x;\n let w;\n const t = abs(x);\n if (ix > 0x41b00000) w = detLog(t) + det_ln2;\n else if (ix > 0x40000000) w = detLog(2.0 * t + 1.0 / (sqrt(t * t + 1.0) + t));\n else { const xx = t * t; w = detLog1p(t + xx / (1.0 + sqrt(1.0 + xx))); }\n return hx > 0 ? w : -w;\n }\n function detAcosh(x) {\n const hx = HI(x);\n if (hx < 0x3ff00000) return (x - x) / (x - x);\n if (hx >= 0x41b00000) {\n if (hx >= 0x7ff00000) return x + x;\n return detLog(x) + det_ln2;\n }\n if (((hx - 0x3ff00000) | LO(x)) === 0) return 0;\n if (hx > 0x40000000) {\n const t = x * x;\n return detLog(2.0 * x - 1.0 / (x + sqrt(t - 1.0)));\n }\n const t = x - 1.0;\n return detLog1p(t + sqrt(2.0 * t + t * t));\n }\n function detAtanh(x) {\n const hx = HI(x);\n const ix = hx & 0x7fffffff;\n if (ix > 0x3ff00000 || (ix === 0x3ff00000 && LO(x) !== 0)) return (x - x) / (x - x);\n if (ix === 0x3ff00000 && LO(x) === 0) return x / 0;\n if (ix < 0x3e300000) return x;\n const t0 = abs(x);\n let t;\n if (ix < 0x3fe00000) {\n const t2 = t0 + t0;\n t = 0.5 * detLog1p(t2 + t2 * t0 / (1.0 - t0));\n } else {\n t = 0.5 * detLog1p((t0 + t0) / (1.0 - t0));\n }\n return hx >= 0 ? t : -t;\n }\n\n // ---- log2 (FreeBSD e_log2 + k_log1p kernel) -------------------------------\n // Added 2026-07-09: JavaScriptCore disagrees bitwise with V8 on log2, cbrt\n // and hypot (5k-input battery); V8 13.x vs 14.x had agreed, so these three\n // stayed native until the JSC port measured them.\n const ivln2hi = 1.44269504072144627571e+00, ivln2lo = 1.67517131648865118353e-10;\n function kLog1p(f) {\n const s = f / (2.0 + f);\n const z = s * s;\n const w = z * z;\n const t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n const t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n const hfsq = 0.5 * f * f;\n return s * (hfsq + (t2 + t1));\n }\n\n function detLog2(x) {\n let hx = HI(x), lx = LO(x);\n let k = 0;\n if (hx < 0x00100000) {\n if (((hx & 0x7fffffff) | lx) === 0) return -Infinity;\n if (hx < 0) return (x - x) / 0;\n k -= 54; x *= two54; hx = HI(x); lx = LO(x);\n }\n if (hx >= 0x7ff00000) return x + x;\n if (hx === 0x3ff00000 && lx === 0) return 0.0;\n k += (hx >> 20) - 1023;\n hx &= 0x000fffff;\n const i = (hx + 0x95f64) & 0x100000;\n x = setHi(x, hx | (i ^ 0x3ff00000));\n k += i >> 20;\n const y = k;\n const f = x - 1.0;\n const hfsq = 0.5 * f * f;\n const r = kLog1p(f);\n let hi = f - hfsq;\n hi = setLo(hi, 0);\n const lo = (f - hi) - hfsq + r;\n let valHi = hi * ivln2hi;\n let valLo = (lo + hi) * ivln2lo + lo * ivln2hi;\n const w = y + valHi;\n valLo += (y - w) + valHi;\n return valLo + w;\n }\n\n // ---- cbrt (FreeBSD s_cbrt) ------------------------------------------------\n const cbrtB1 = 715094163, cbrtB2 = 696219795;\n const cbrtP0 = 1.87595182427177009643, cbrtP1 = -1.88497979543377169875,\n cbrtP2 = 1.621429720105354466140, cbrtP3 = -0.758397934778766047437,\n cbrtP4 = 0.145996192886612446982;\n\n function detCbrt(x) {\n let hx = HI(x);\n const sign = hx & 0x80000000;\n hx &= 0x7fffffff;\n if (hx >= 0x7ff00000) return x + x;\n let t;\n if (hx < 0x00100000) {\n if ((hx | LO(x)) === 0) return x;\n t = two54 * x;\n t = setHi(t, (sign | ((((HI(t) & 0x7fffffff) / 3) | 0) + cbrtB2)) >>> 0);\n } else {\n t = fromWords((sign | (((hx / 3) | 0) + cbrtB1)) >>> 0, 0);\n }\n const r0 = (t * t) * (t / x);\n t *= cbrtP0 + r0 * (cbrtP1 + r0 * (cbrtP2 + r0 * (cbrtP3 + r0 * cbrtP4)));\n // round t to 23 bits, away from zero: bits = (bits + 0x80000000) & ~0x3fffffff\n let tHi = HI(t), tLo = LO(t) >>> 0;\n tHi = (tHi + (tLo >= 0x80000000 ? 1 : 0)) | 0;\n tLo = (tLo + 0x80000000) >>> 0;\n t = fromWords(tHi >>> 0, tLo & 0xc0000000);\n const s = t * t;\n let r = x / s;\n const w = t + t;\n r = (r - t) / (w + r);\n return t + t * r;\n }\n\n // ---- hypot (FreeBSD e_hypot, folded left for arity > 2) -------------------\n function detHypot2(x, y) {\n let ha = HI(x) & 0x7fffffff;\n let hb = HI(y) & 0x7fffffff;\n let a, b;\n if (hb > ha) { a = y; b = x; const j = ha; ha = hb; hb = j; } else { a = x; b = y; }\n a = abs(a); b = abs(b);\n if (ha - hb > 0x3c00000) return a + b;\n let k = 0;\n if (ha > 0x5f300000) {\n if (ha >= 0x7ff00000) {\n let w = abs(x + 0.0) - abs(y + 0.0);\n if (((ha & 0xfffff) | LO(a)) === 0) w = a;\n if ((((hb ^ 0x7ff00000) | 0) | LO(b)) === 0) w = b;\n return w;\n }\n ha -= 0x25800000; hb -= 0x25800000; k += 600;\n a = setHi(a, ha >>> 0);\n b = setHi(b, hb >>> 0);\n }\n if (hb < 0x20b00000) {\n if (hb <= 0x000fffff) {\n if ((hb | LO(b)) === 0) return a;\n const scale = fromWords(0x7fd00000, 0);\n b *= scale;\n a *= scale;\n k -= 1022;\n ha = HI(a); hb = HI(b);\n } else {\n ha += 0x25800000; hb += 0x25800000; k -= 600;\n a = setHi(a, ha >>> 0);\n b = setHi(b, hb >>> 0);\n }\n }\n let w = a - b;\n if (w > b) {\n const t1 = fromWords(ha >>> 0, 0);\n const t2 = a - t1;\n w = sqrt(t1 * t1 - (b * (-b) - t2 * (a + t1)));\n } else {\n a = a + a;\n const y1 = fromWords(hb >>> 0, 0);\n const y2 = b - y1;\n const t1 = fromWords((ha + 0x00100000) >>> 0, 0);\n const t2 = a - t1;\n w = sqrt(t1 * y1 - (w * (-w) - (t1 * y2 + t2 * b)));\n }\n if (k !== 0) {\n const scale = setHi(1.0, (HI(1.0) + (k << 20)) >>> 0);\n return scale * w;\n }\n return w;\n }\n\n function detHypot(...values) {\n // Left fold of the pairwise kernel: deterministic on every engine; for\n // arity > 2 this is NOT the same rounding as a simultaneous algorithm,\n // which is exactly why it must be pinned here.\n let w = 0.0;\n for (let i = 0; i < values.length; i += 1) w = detHypot2(w, +values[i]);\n return w;\n }\n\n Math.exp = detExp;\n Math.atan = detAtan;\n Math.atan2 = detAtan2;\n Math.log1p = detLog1p;\n Math.asinh = detAsinh;\n Math.acosh = detAcosh;\n Math.atanh = detAtanh;\n Math.sin = detSin;\n Math.cos = detCos;\n Math.tan = detTan;\n Math.log = detLog;\n Math.log10 = detLog10;\n Math.asin = detAsin;\n Math.acos = detAcos;\n Math.sinh = detSinh;\n Math.cosh = detCosh;\n Math.tanh = detTanh;\n Math.expm1 = detExpm1;\n Math.log2 = detLog2;\n Math.cbrt = detCbrt;\n Math.hypot = detHypot;\n})();";
6
- export declare function installDeterministicMath(): any;
1
+ export declare const DETERMINISTIC_MATH_SOURCE: string;
2
+ export declare function installDeterministicMath(): void;
@@ -1,6 +1,4 @@
1
1
  // Generated. Declares the runtime exports of ./core/envelope.
2
- // Constants carry exact values, function parameters carry real names typed `any`.
3
- // Regenerate: node scripts/generate-physics-declarations.mjs --write
4
2
 
5
3
  export declare const kinetixDomains: readonly ["simulation", "presentation", "binding"];
6
4
  export declare function kinetixEnvelopeDigest(envelope: any): any;
@@ -1,6 +1,4 @@
1
1
  // Generated. Declares the runtime exports of ./core/f64-bits.
2
- // Constants carry exact values, function parameters carry real names typed `any`.
3
- // Regenerate: node scripts/generate-physics-declarations.mjs --write
4
2
 
5
3
  export declare function f64FromHex(hex: any): any;
6
4
  export declare function hexFromF64(value: any): any;
package/core/index.d.ts CHANGED
@@ -31,64 +31,6 @@ export {
31
31
  createDeterministicMath,
32
32
  DeterministicRandom,
33
33
  } from './deterministic-stdlib';
34
- export {
35
- applyDeterministicImpulse3D,
36
- applyDeterministicImpulses3D,
37
- applyDeterministicWorldEdit3D,
38
- applyPhysicsImpulse,
39
- applyPhysicsImpulses,
40
- applyPhysicsWorldEdit,
41
- createPhysicsWorld,
42
- createDeterministicPhysicsWorld3D,
43
- createTrustedDeterministicPhysicsWorld3D,
44
- cookPhysicsCollider,
45
- contactDetailsDeterministicPhysics3D,
46
- contactDetailsPhysics,
47
- initPhysics,
48
- initPhysics3D,
49
- overlapDeterministicPhysics3D,
50
- overlapPhysics,
51
- physicsReady,
52
- physics3DReady,
53
- physicsWasmMetadata,
54
- raycastDeterministicPhysics3D,
55
- raycastDeterministicPhysics3DDetailed,
56
- raycastPhysics,
57
- raycastPhysicsDetailed,
58
- resetPhysics3DCache,
59
- setDeterministicBodyVelocity3D,
60
- setPhysicsBodyVelocity,
61
- shapeCastDeterministicPhysics3D,
62
- shapeCastPhysics,
63
- shapeCastPhysicsDetailed,
64
- calculatePhysicsBuoyancy,
65
- shapeCastDeterministicPhysics3DDetailed,
66
- stepPhysicsWorld,
67
- stepDeterministicPhysicsWorld3D,
68
- } from './physics';
69
- export type {
70
- KinetixPhysicsActivePair,
71
- KinetixPhysicsBody,
72
- KinetixPhysicsContactCacheEntry,
73
- KinetixPhysicsContactDetail,
74
- KinetixPhysicsContactEvent,
75
- KinetixPhysicsHit,
76
- KinetixPhysicsDetailedHit,
77
- KinetixPhysicsBuoyancyOptions,
78
- KinetixPhysicsBuoyancyResult,
79
- KinetixPhysicsJointCacheEntry,
80
- KinetixPhysicsOverlapQuery,
81
- KinetixPhysicsQuaternion,
82
- KinetixPhysicsQueryOptions,
83
- KinetixPhysicsRaycastQuery,
84
- KinetixPhysicsScheduledQuery,
85
- KinetixPhysicsShape,
86
- KinetixPhysicsShapeCastQuery,
87
- KinetixPhysicsStepOptions,
88
- KinetixPhysicsStepResult,
89
- KinetixPhysicsVec3,
90
- KinetixPhysicsWorld,
91
- } from './physics';
92
34
  export type {
93
35
  DeterministicMathApi,
94
36
  DeterministicQuaternion,
@@ -283,7 +225,6 @@ export function deriveCustomRuntimeIdentity(
283
225
  ): import('./runtime').KinetixRuntimeIdentity;
284
226
  export const kinetixBakerVersion: string;
285
227
  export const kinetixPhases: readonly string[];
286
- /** The three product kinds a Kinetix package may declare. */
287
228
  export const kinetixProductKinds: readonly ['simulation', 'presentation', 'binding'];
288
229
 
289
230
  export function createKinetixWorld(options: {
@@ -273,17 +273,14 @@ int runPhysicsSession() {
273
273
  << " status=" << status << '\n';
274
274
  return 2;
275
275
  }
276
- const std::uint32_t telemetryCount = rundot::kinetix::physics::contactTelemetryCount();
277
- const double* telemetry = rundot::kinetix::physics::contactTelemetryData();
278
- contactCache.resize(static_cast<std::size_t>(telemetryCount) * rundot::kinetix::physics::kContactCacheStride);
279
- for (std::uint32_t index = 0; index < telemetryCount; index += 1) {
280
- const double* source = telemetry + static_cast<std::size_t>(index)
281
- * rundot::kinetix::physics::kContactTelemetryStride;
282
- double* target = contactCache.data() + static_cast<std::size_t>(index)
283
- * rundot::kinetix::physics::kContactCacheStride;
284
- for (std::uint32_t field = 0; field < rundot::kinetix::physics::kContactCacheStride; field += 1) {
285
- target[field] = source[field];
286
- }
276
+ const std::uint32_t contactCount = rundot::kinetix::physics::contactCacheCount();
277
+ const double* cacheData = rundot::kinetix::physics::contactCacheData();
278
+ if (contactCount == 0) {
279
+ contactCache.clear();
280
+ } else {
281
+ contactCache.assign(cacheData, cacheData
282
+ + static_cast<std::size_t>(contactCount)
283
+ * rundot::kinetix::physics::kContactCacheStride);
287
284
  }
288
285
  for (std::uint32_t bodyIndex = 0; bodyIndex < bodyCount; bodyIndex += 1) {
289
286
  const std::size_t offset = static_cast<std::size_t>(bodyIndex) * stride;
@@ -39,6 +39,14 @@ extern "C" std::uintptr_t rundot_kinetix_physics_contact_data() {
39
39
  return reinterpret_cast<std::uintptr_t>(rundot::kinetix::physics::contactTelemetryData());
40
40
  }
41
41
 
42
+ extern "C" std::uint32_t rundot_kinetix_physics_contact_cache_count() {
43
+ return rundot::kinetix::physics::contactCacheCount();
44
+ }
45
+
46
+ extern "C" std::uintptr_t rundot_kinetix_physics_contact_cache_data() {
47
+ return reinterpret_cast<std::uintptr_t>(rundot::kinetix::physics::contactCacheData());
48
+ }
49
+
42
50
  constexpr std::uint32_t kMaxSixDofCapacity = 256;
43
51
  constexpr std::uint32_t kMaxStandardJointCapacity = 10000;
44
52
  constexpr std::uint32_t kMaxTelemetryEntries = kMaxStandardJointCapacity + kMaxSixDofCapacity;
@@ -26,6 +26,8 @@ void rundot_kinetix_physics_set_external_forces(
26
26
  std::uint32_t force_values);
27
27
  std::uint32_t rundot_kinetix_physics_contact_count();
28
28
  std::uintptr_t rundot_kinetix_physics_contact_data();
29
+ std::uint32_t rundot_kinetix_physics_contact_cache_count();
30
+ std::uintptr_t rundot_kinetix_physics_contact_cache_data();
29
31
  std::uint32_t rundot_kinetix_physics_joint_count();
30
32
  std::uintptr_t rundot_kinetix_physics_joint_data();
31
33
  std::uint32_t rundot_kinetix_physics_query_count();
@@ -149,4 +149,3 @@ std::uint32_t solveSixDofConstraint(
149
149
  std::uint32_t iterations);
150
150
 
151
151
  } // namespace rundot::kinetix::physics
152
-