@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.
Files changed (329) hide show
  1. package/README.md +133 -0
  2. package/core/deterministic-math.d.ts +75 -1
  3. package/core/native/instance_ledger.hpp +1095 -0
  4. package/core/native/legacy_checkpoint_ids.hpp +107 -0
  5. package/core/native/physics/abi.cpp +39 -211
  6. package/core/native/physics/abi.hpp +2 -6
  7. package/core/native/physics/articulation.cpp +1434 -0
  8. package/core/native/physics/articulation.hpp +279 -0
  9. package/core/native/physics/buoyancy.cpp +1588 -0
  10. package/core/native/physics/buoyancy.hpp +254 -0
  11. package/core/native/physics/capsule_triangle.cpp +168 -0
  12. package/core/native/physics/capsule_triangle.hpp +40 -0
  13. package/core/native/physics/capsule_triangle_native.inc +291 -0
  14. package/core/native/physics/certified_sum.hpp +218 -0
  15. package/core/native/physics/character.cpp +638 -0
  16. package/core/native/physics/character.hpp +169 -0
  17. package/core/native/physics/checkpoint_schema.hpp +379 -0
  18. package/core/native/physics/cloth.cpp +1401 -0
  19. package/core/native/physics/cloth.hpp +357 -0
  20. package/core/native/physics/constraint_rows.cpp +363 -2
  21. package/core/native/physics/constraint_rows.hpp +72 -1
  22. package/core/native/physics/deformable_query.cpp +1630 -0
  23. package/core/native/physics/deformable_query.hpp +578 -0
  24. package/core/native/physics/distance.cpp +1166 -0
  25. package/core/native/physics/distance.hpp +151 -0
  26. package/core/native/physics/exact/exact-applied.cpp +101 -0
  27. package/core/native/physics/exact/exact-applied.hpp +112 -0
  28. package/core/native/physics/exact/exact-dyadic.cpp +691 -0
  29. package/core/native/physics/exact/exact-dyadic.hpp +58 -0
  30. package/core/native/physics/exact/exact-operation.hpp +51 -0
  31. package/core/native/physics/exact/word-core.hpp +262 -0
  32. package/core/native/physics/extended_abi.cpp +1242 -0
  33. package/core/native/physics/extended_abi.hpp +355 -0
  34. package/core/native/physics/extended_abi_characters.cpp +261 -0
  35. package/core/native/physics/extended_abi_characters.hpp +434 -0
  36. package/core/native/physics/extended_abi_core_features.cpp +713 -0
  37. package/core/native/physics/extended_abi_core_features.hpp +226 -0
  38. package/core/native/physics/extended_abi_deformables.cpp +448 -0
  39. package/core/native/physics/extended_abi_deformables.hpp +867 -0
  40. package/core/native/physics/extended_abi_vehicles.cpp +411 -0
  41. package/core/native/physics/extended_abi_vehicles.hpp +222 -0
  42. package/core/native/physics/fracture.cpp +1981 -0
  43. package/core/native/physics/fracture.hpp +460 -0
  44. package/core/native/physics/gear.cpp +563 -0
  45. package/core/native/physics/gear.hpp +158 -0
  46. package/core/native/physics/geometry_memory.hpp +476 -0
  47. package/core/native/physics/geometry_store.cpp +547 -0
  48. package/core/native/physics/geometry_store.hpp +134 -0
  49. package/core/native/physics/lag_compensation.cpp +1626 -0
  50. package/core/native/physics/lag_compensation.hpp +405 -0
  51. package/core/native/physics/mass_properties.cpp +449 -0
  52. package/core/native/physics/mass_properties.hpp +23 -0
  53. package/core/native/physics/material_pose.hpp +988 -0
  54. package/core/native/physics/particles.cpp +1065 -0
  55. package/core/native/physics/particles.hpp +261 -0
  56. package/core/native/physics/path_joint.cpp +781 -0
  57. package/core/native/physics/path_joint.hpp +154 -0
  58. package/core/native/physics/physics.cpp +13043 -1065
  59. package/core/native/physics/physics.hpp +184 -8
  60. package/core/native/physics/planar_deformable.cpp +2433 -0
  61. package/core/native/physics/planar_deformable.hpp +889 -0
  62. package/core/native/physics/platformer_2d.cpp +1353 -0
  63. package/core/native/physics/platformer_2d.hpp +340 -0
  64. package/core/native/physics/powered_ragdoll.cpp +1100 -0
  65. package/core/native/physics/powered_ragdoll.hpp +279 -0
  66. package/core/native/physics/powertrain.cpp +586 -0
  67. package/core/native/physics/powertrain.hpp +180 -0
  68. package/core/native/physics/pulley.cpp +311 -0
  69. package/core/native/physics/pulley.hpp +121 -0
  70. package/core/native/physics/ragdoll.cpp +586 -0
  71. package/core/native/physics/ragdoll.hpp +221 -0
  72. package/core/native/physics/rope.cpp +692 -0
  73. package/core/native/physics/rope.hpp +215 -0
  74. package/core/native/physics/rounded_convex.cpp +1229 -0
  75. package/core/native/physics/rounded_convex.hpp +287 -0
  76. package/core/native/physics/sdf_geometry.cpp +1821 -0
  77. package/core/native/physics/sdf_geometry.hpp +474 -0
  78. package/core/native/physics/soft_body.cpp +1449 -0
  79. package/core/native/physics/soft_body.hpp +328 -0
  80. package/core/native/physics/soft_collision.cpp +1862 -0
  81. package/core/native/physics/soft_collision.hpp +561 -0
  82. package/core/native/physics/surface_velocity.cpp +366 -0
  83. package/core/native/physics/surface_velocity.hpp +243 -0
  84. package/core/native/physics/topology.cpp +357 -39
  85. package/core/native/physics/topology.hpp +97 -6
  86. package/core/native/physics/tracks.cpp +1179 -0
  87. package/core/native/physics/tracks.hpp +404 -0
  88. package/core/native/physics/vehicle.cpp +629 -0
  89. package/core/native/physics/vehicle.hpp +191 -0
  90. package/core/native/physics/voxel_cooking.cpp +1929 -0
  91. package/core/native/physics/voxel_cooking.hpp +395 -0
  92. package/core/native/physics/world.cpp +5290 -854
  93. package/core/native/physics/world.hpp +796 -24
  94. package/core/native/physics/world_abi.cpp +3840 -306
  95. package/core/native/physics/world_abi.hpp +530 -10
  96. package/core/native/physics/world_digest_visitor.hpp +277 -0
  97. package/core/native/physics/world_strong_digest.hpp +557 -0
  98. package/core/native/physics2d/ccd.cpp +1302 -0
  99. package/core/native/physics2d/ccd.hpp +141 -0
  100. package/core/native/physics2d/checkpoint_memory.hpp +349 -0
  101. package/core/native/physics2d/clock_primitives.hpp +138 -0
  102. package/core/native/physics2d/commands.cpp +174 -28
  103. package/core/native/physics2d/commands.hpp +3 -1
  104. package/core/native/physics2d/compound.cpp +581 -0
  105. package/core/native/physics2d/compound.hpp +248 -0
  106. package/core/native/physics2d/contour.cpp +325 -0
  107. package/core/native/physics2d/contour.hpp +143 -0
  108. package/core/native/physics2d/frame_scope.hpp +124 -0
  109. package/core/native/physics2d/joint_phases.hpp +93 -0
  110. package/core/native/physics2d/joints.cpp +587 -150
  111. package/core/native/physics2d/joints.hpp +5 -0
  112. package/core/native/physics2d/memory_private.hpp +125 -0
  113. package/core/native/physics2d/owned_abi.cpp +1354 -879
  114. package/core/native/physics2d/owned_abi.hpp +190 -52
  115. package/core/native/physics2d/phase_test_hooks.hpp +17 -0
  116. package/core/native/physics2d/physics2d.cpp +2073 -120
  117. package/core/native/physics2d/physics2d.hpp +154 -2
  118. package/core/native/physics2d/queries.cpp +1055 -79
  119. package/core/native/physics2d/queries.hpp +71 -5
  120. package/core/native/physics2d/world.cpp +1313 -353
  121. package/core/native/physics2d/world.hpp +124 -13
  122. package/core/native/sha256/sha256_compress_unsigned.hpp +68 -0
  123. package/core/native/sha256/sha256_fips_constants.hpp +24 -0
  124. package/core/native/sha256/sha256_length.hpp +56 -0
  125. package/core/native/sha256/sha256_memo.hpp +48 -0
  126. package/core/native/sha256/sha256_sink.hpp +234 -0
  127. package/core/physics2d-owned.d.ts +466 -126
  128. package/core/runtime.d.ts +192 -19
  129. package/core/scripts/build-native.mjs +34 -0
  130. package/core/scripts/build-wasm-physics.mjs +272 -23
  131. package/core/scripts/extended-physics-profile.mjs +634 -0
  132. package/core/scripts/generate-physics2d-vectors.mjs +59 -0
  133. package/core/src/kinetix-deterministic-math.d.ts +2 -0
  134. package/core/src/kinetix-deterministic-math.mjs +513 -27
  135. package/core/src/kinetix-owned-runtime-adapter.mjs +788 -0
  136. package/core/src/kinetix-runtime-adapter-utils.mjs +54 -6
  137. package/core/src/kinetix-runtime-contract.mjs +55 -9
  138. package/core/src/kinetix-runtime-identity.mjs +12 -1
  139. package/core/src/kinetix-session-config.mjs +7 -2
  140. package/core/src/kinetix-state-report.mjs +36 -0
  141. package/core/src/physics/abi-constants.mjs +5 -4
  142. package/core/src/physics/articulation.d.mts +194 -0
  143. package/core/src/physics/articulation.mjs +1141 -0
  144. package/core/src/physics/buoyancy.d.mts +143 -0
  145. package/core/src/physics/buoyancy.mjs +268 -0
  146. package/core/src/physics/cloth.d.mts +314 -0
  147. package/core/src/physics/cloth.mjs +1156 -0
  148. package/core/src/physics/deformable-query.d.mts +217 -0
  149. package/core/src/physics/deformable-query.mjs +1412 -0
  150. package/core/src/physics/distance.d.mts +160 -0
  151. package/core/src/physics/distance.mjs +175 -0
  152. package/core/src/physics/extended-wasm-instance.d.mts +5 -0
  153. package/core/src/physics/extended-wasm-instance.mjs +48 -0
  154. package/core/src/physics/feature-api.d.mts +74 -0
  155. package/core/src/physics/feature-api.mjs +98 -0
  156. package/core/src/physics/fracture.d.mts +133 -0
  157. package/core/src/physics/fracture.mjs +1324 -0
  158. package/core/src/physics/gear.d.mts +585 -0
  159. package/core/src/physics/gear.mjs +955 -0
  160. package/core/src/physics/lag-compensation.d.mts +101 -0
  161. package/core/src/physics/lag-compensation.mjs +1100 -0
  162. package/core/src/physics/mass-properties.d.mts +114 -0
  163. package/core/src/physics/mass-properties.mjs +137 -468
  164. package/core/src/physics/particles.d.mts +177 -0
  165. package/core/src/physics/particles.mjs +758 -0
  166. package/core/src/physics/path-joint.d.mts +171 -0
  167. package/core/src/physics/path-joint.mjs +1231 -0
  168. package/core/src/physics/physics-extended-wasm-module.generated.mjs +13 -0
  169. package/core/src/physics/physics-profile-wasm-module.generated.mjs +48 -0
  170. package/core/src/physics/physics-wasm-module.generated.mjs +34 -5
  171. package/core/src/physics/powered-ragdoll.d.mts +188 -0
  172. package/core/src/physics/powered-ragdoll.mjs +1043 -0
  173. package/core/src/physics/powertrain.d.mts +260 -0
  174. package/core/src/physics/powertrain.mjs +621 -0
  175. package/core/src/physics/pulley.d.mts +98 -0
  176. package/core/src/physics/pulley.mjs +686 -0
  177. package/core/src/physics/ragdoll.d.mts +289 -0
  178. package/core/src/physics/ragdoll.mjs +1323 -0
  179. package/core/src/physics/rope.d.mts +241 -0
  180. package/core/src/physics/rope.mjs +319 -0
  181. package/core/src/physics/rounded-convex.d.mts +328 -0
  182. package/core/src/physics/rounded-convex.mjs +1404 -0
  183. package/core/src/physics/sdf-geometry.d.mts +117 -0
  184. package/core/src/physics/sdf-geometry.mjs +1204 -0
  185. package/core/src/physics/soft-body.d.mts +144 -0
  186. package/core/src/physics/soft-body.mjs +1285 -0
  187. package/core/src/physics/soft-collision.d.mts +651 -0
  188. package/core/src/physics/soft-collision.mjs +1883 -0
  189. package/core/src/physics/surface-velocity.d.mts +156 -0
  190. package/core/src/physics/surface-velocity.mjs +722 -0
  191. package/core/src/physics/tracks.d.mts +411 -0
  192. package/core/src/physics/tracks.mjs +1074 -0
  193. package/core/src/physics/vehicle.d.mts +3 -0
  194. package/core/src/physics/vehicle.mjs +172 -0
  195. package/core/src/physics/voxel-cooking.d.mts +219 -0
  196. package/core/src/physics/voxel-cooking.mjs +1499 -0
  197. package/core/src/physics/voxel-swept-quad.mjs +110 -0
  198. package/core/src/physics/wasm-instance.mjs +160 -23
  199. package/core/src/physics/world.d.mts +62 -0
  200. package/core/src/physics/world.mjs +1947 -152
  201. package/core/src/physics2d/body-state.mjs +218 -15
  202. package/core/src/physics2d/collision.d.mts +52 -0
  203. package/core/src/physics2d/collision.mjs +234 -0
  204. package/core/src/physics2d/compound.mjs +454 -0
  205. package/core/src/physics2d/contour-state.mjs +771 -0
  206. package/core/src/physics2d/feature-api.d.mts +211 -0
  207. package/core/src/physics2d/feature-api.mjs +3 -0
  208. package/core/src/physics2d/fluid-state.mjs +145 -0
  209. package/core/src/physics2d/joint-state.mjs +1 -1
  210. package/core/src/physics2d/owned-queries.mjs +3 -1
  211. package/core/src/physics2d/owned-transport.mjs +268 -122
  212. package/core/src/physics2d/owned-world.mjs +353 -230
  213. package/core/src/physics2d/particle-fluid.d.mts +152 -0
  214. package/core/src/physics2d/particle-fluid.mjs +233 -0
  215. package/core/src/physics2d/physics2d-wasm-module.generated.mjs +27 -10
  216. package/core/src/physics2d/query-codec.mjs +61 -13
  217. package/core/src/physics2d/submerged-geometry.d.mts +51 -0
  218. package/core/src/physics2d/submerged-geometry.mjs +186 -0
  219. package/core/src/runtime.mjs +23 -0
  220. package/core/src/shared/bytes.d.mts +2 -0
  221. package/core/src/shared/bytes.mjs +33 -0
  222. package/core/src/shared/sha256.d.mts +3 -0
  223. package/core/src/shared/sha256.mjs +72 -22
  224. package/core/units.d.ts +50 -0
  225. package/core/world.d.ts +253 -5
  226. package/dist/authority-room.d.ts +9 -0
  227. package/dist/authority-room.js +45 -16
  228. package/dist/browser.d.ts +6 -5
  229. package/dist/browser.js +4 -3
  230. package/dist/cadence.d.ts +7 -0
  231. package/dist/cadence.js +19 -0
  232. package/dist/canonical.d.ts +1 -0
  233. package/dist/canonical.js +3 -0
  234. package/dist/checksum-policy.d.ts +10 -0
  235. package/dist/checksum-policy.js +14 -0
  236. package/dist/collider-cooking-hull.d.ts +18 -0
  237. package/dist/collider-cooking-hull.js +248 -0
  238. package/dist/collider-cooking.d.ts +140 -0
  239. package/dist/collider-cooking.js +794 -0
  240. package/dist/compat/v5.d.ts +121 -0
  241. package/dist/compat/v5.js +479 -0
  242. package/dist/creator.d.ts +7 -6
  243. package/dist/creator.js +4 -3
  244. package/dist/game-byte-section.d.ts +36 -0
  245. package/dist/game-byte-section.js +350 -0
  246. package/dist/index.d.ts +13 -6
  247. package/dist/index.js +9 -4
  248. package/dist/instant-replay.d.ts +27 -2
  249. package/dist/instant-replay.js +91 -16
  250. package/dist/lag-compensation3d.js +11 -10
  251. package/dist/match-log.d.ts +21 -4
  252. package/dist/match-log.js +92 -9
  253. package/dist/math.d.ts +2 -0
  254. package/dist/math.js +1 -0
  255. package/dist/modules/character-3d.d.ts +16 -1
  256. package/dist/modules/character-3d.js +42 -5
  257. package/dist/modules/combat.js +6 -5
  258. package/dist/movement3d-revision1.d.ts +2 -0
  259. package/dist/movement3d-revision1.js +973 -0
  260. package/dist/movement3d.d.ts +53 -3
  261. package/dist/movement3d.js +917 -247
  262. package/dist/networked-client.d.ts +15 -0
  263. package/dist/networked-client.js +378 -105
  264. package/dist/node.d.ts +3 -2
  265. package/dist/node.js +2 -1
  266. package/dist/physics/2d.d.ts +38 -4
  267. package/dist/physics/2d.js +57 -36
  268. package/dist/physics/3d.d.ts +755 -111
  269. package/dist/physics/3d.js +2355 -158
  270. package/dist/physics/edit-result-graph.d.ts +36 -0
  271. package/dist/physics/edit-result-graph.js +141 -0
  272. package/dist/physics/game-codec3d.d.ts +41 -0
  273. package/dist/physics/game-codec3d.js +544 -0
  274. package/dist/physics/installed-checkpoint3d.d.ts +13 -0
  275. package/dist/physics/installed-checkpoint3d.js +120 -0
  276. package/dist/physics/installed-runtime3d.d.ts +51 -0
  277. package/dist/physics/installed-runtime3d.js +372 -0
  278. package/dist/physics/installed-state-commitment3d.d.ts +2 -0
  279. package/dist/physics/installed-state-commitment3d.js +24 -0
  280. package/dist/physics/units.d.ts +38 -0
  281. package/dist/physics/units.js +56 -0
  282. package/dist/physics/vehicle-state3d.d.ts +93 -0
  283. package/dist/physics/vehicle-state3d.js +1191 -0
  284. package/dist/physics/voxel-body-state.d.ts +61 -0
  285. package/dist/physics/voxel-body-state.js +410 -0
  286. package/dist/r3f-render-adapter.d.ts +59 -1
  287. package/dist/r3f-render-adapter.js +137 -2
  288. package/dist/replay.d.ts +13 -0
  289. package/dist/replay.js +95 -70
  290. package/dist/run-room-transport.js +5 -1
  291. package/dist/runner.d.ts +17 -2
  292. package/dist/runner.js +472 -84
  293. package/dist/runtime-cleanup.d.ts +54 -0
  294. package/dist/runtime-cleanup.js +266 -0
  295. package/dist/runtime-lease.d.ts +11 -1
  296. package/dist/runtime-lease.js +23 -10
  297. package/dist/runtime-room-metadata.d.ts +2 -8
  298. package/dist/runtime-room-metadata.js +11 -14
  299. package/dist/runtime-session.d.ts +8 -0
  300. package/dist/runtime-session.js +222 -58
  301. package/dist/schema-codegen.js +3 -0
  302. package/dist/schema-dsl-binary.d.ts +10 -4
  303. package/dist/schema-dsl-binary.js +375 -76
  304. package/dist/scratch-pool.d.ts +32 -0
  305. package/dist/scratch-pool.js +60 -0
  306. package/dist/sdk-session.d.ts +1 -0
  307. package/dist/sdk-session.js +4 -0
  308. package/dist/secret-config.js +2 -60
  309. package/dist/secret-crypto.js +70 -36
  310. package/dist/session-snapshot.d.ts +15 -4
  311. package/dist/session-snapshot.js +35 -33
  312. package/dist/session-wire.js +14 -22
  313. package/dist/sparse-set.d.ts +1 -0
  314. package/dist/sparse-set.js +22 -0
  315. package/dist/spatial/spatial-grid-3d.d.ts +41 -0
  316. package/dist/spatial/spatial-grid-3d.js +115 -0
  317. package/dist/synctest.d.ts +9 -0
  318. package/dist/synctest.js +106 -17
  319. package/dist/testing-network.d.ts +2 -0
  320. package/dist/testing-network.js +122 -18
  321. package/dist/testing.d.ts +27 -6
  322. package/dist/testing.js +297 -56
  323. package/dist/tools/index.d.ts +3 -2
  324. package/dist/tools/index.js +3 -2
  325. package/dist/tools/module-certification.d.ts +6 -0
  326. package/dist/tools/module-certification.js +26 -2
  327. package/package.json +18 -5
  328. package/core/scripts/run-box3d-benchmark.mjs +0 -350
  329. package/core/src/physics/index.mjs +0 -3169
@@ -0,0 +1,1242 @@
1
+ #include "extended_abi.hpp"
2
+
3
+ #include "gear.hpp"
4
+ #include "pulley.hpp"
5
+ #include "path_joint.hpp"
6
+ #include "particles.hpp"
7
+ #include "ragdoll.hpp"
8
+ #include "powertrain.hpp"
9
+ #include "rounded_convex.hpp"
10
+ #include "surface_velocity.hpp"
11
+
12
+ #include <algorithm>
13
+ #include <array>
14
+ #include <cmath>
15
+ #include <cstdint>
16
+ #include <span>
17
+ #include <vector>
18
+
19
+ namespace {
20
+
21
+ using namespace rundot::kinetix::physics;
22
+
23
+ // Stride constants
24
+ constexpr std::uint32_t kPulleyConfigStrideValue = 22;
25
+ constexpr std::uint32_t kPulleyStateStrideValue = 18;
26
+ constexpr std::uint32_t kPulleyGeometryStrideValue = 27;
27
+
28
+ constexpr std::uint32_t kPathJointSampleStrideValue = 13;
29
+ constexpr std::uint32_t kPathJointControlPointStrideValue = 3;
30
+
31
+ constexpr std::uint32_t kRagdollTransformStrideValue = 7;
32
+ constexpr std::uint32_t kRagdollBodyStrideValue = 7;
33
+ constexpr std::uint32_t kRagdollJointStrideValue = 6;
34
+
35
+ constexpr std::uint32_t kPowertrainConfigStrideValue = 48;
36
+ constexpr std::uint32_t kPowertrainStateStrideValue = 15;
37
+ constexpr std::uint32_t kPowertrainInputStrideValue = 5;
38
+ constexpr std::uint32_t kPowertrainWheelStateStrideValue = 4;
39
+ constexpr std::uint32_t kPowertrainWheelOutputStrideValue = 6;
40
+
41
+ constexpr std::uint32_t kRoundedConvexSphereStrideValue = 4;
42
+ constexpr std::uint32_t kRoundedConvexVertexStrideValue = 3;
43
+ constexpr std::uint32_t kRoundedConvexPoseStrideValue = 7;
44
+ constexpr std::uint32_t kRoundedConvexDirectionStrideValue = 3;
45
+ constexpr std::uint32_t kRoundedConvexSupportStrideValue = 4;
46
+ constexpr std::uint32_t kRoundedConvexCollisionStrideValue = 14;
47
+ constexpr std::uint32_t kRoundedConvexMassPropsStrideValue = 11;
48
+ constexpr std::uint32_t kRoundedConvexRayStrideValue = 7;
49
+ constexpr std::uint32_t kRoundedConvexRayHitStrideValue = 9;
50
+
51
+ // Fixed memory storage to avoid allocations during solver execution
52
+ constexpr std::uint32_t kMaxExtBodies = 1024;
53
+ static std::array<Body, kMaxExtBodies> g_extBodies{};
54
+ static std::array<ConstraintBodyMobility, kMaxExtBodies> g_extMobility{};
55
+
56
+ constexpr std::uint32_t kMaxExtGearConfigs = 256;
57
+ static std::array<GearConstraintConfig, kMaxExtGearConfigs> g_extGearConfigs{};
58
+ static std::array<GearConstraintState, kMaxExtGearConfigs> g_extGearStates{};
59
+
60
+ constexpr std::uint32_t kMaxExtPathSamples = 4096;
61
+ static CookedPath g_extCookedPath{};
62
+ static bool g_extCookedPathInitialized = false;
63
+
64
+ static RagdollSkeletonDef g_extSkeleton{};
65
+ static std::array<RagdollTransform, kRagdollMaxBones> g_extTransformsIn{};
66
+ static std::array<RagdollTransform, kRagdollMaxBones> g_extTransformsOut{};
67
+
68
+ inline void ensureCookedPathCapacity() {
69
+ if (!g_extCookedPathInitialized) {
70
+ g_extCookedPath.samples.reserve(kMaxExtPathSamples);
71
+ g_extCookedPathInitialized = true;
72
+ }
73
+ }
74
+
75
+ inline Body unpackBody(const double* bodyData, std::uint32_t b) {
76
+ const std::uint32_t offset = b * kBodyStride;
77
+ Body body;
78
+ body.x = bodyData[offset + 0];
79
+ body.y = bodyData[offset + 1];
80
+ body.z = bodyData[offset + 2];
81
+ body.vx = bodyData[offset + 3];
82
+ body.vy = bodyData[offset + 4];
83
+ body.vz = bodyData[offset + 5];
84
+
85
+ const std::uint32_t motionType = static_cast<std::uint32_t>(bodyData[offset + 9]);
86
+ const std::uint32_t kind = motionType & kMotionKindMask;
87
+ body.dynamic = (kind == 1);
88
+ body.kinematic = (kind == 2);
89
+ body.trigger = (motionType & kMotionTrigger) != 0;
90
+ body.sensor = (motionType & kMotionSensor) != 0;
91
+ body.sensorLike = body.trigger || body.sensor;
92
+ body.sleeping = body.dynamic && (motionType & kMotionSleeping) != 0;
93
+ body.angularState = (motionType & kMotionAngularState) != 0;
94
+
95
+ body.shape = static_cast<ShapeKind>(static_cast<std::uint32_t>(bodyData[offset + 10]));
96
+ body.gravityScale = bodyData[offset + 13];
97
+ body.linearDamping = bodyData[offset + 14];
98
+ body.mass = bodyData[offset + 18] > 0.0 ? bodyData[offset + 18] : 1.0;
99
+
100
+ body.angularVelX = bodyData[offset + 19];
101
+ body.angularVelY = bodyData[offset + 20];
102
+ body.angularVelZ = bodyData[offset + 21];
103
+
104
+ const double qx = bodyData[offset + 22];
105
+ const double qy = bodyData[offset + 23];
106
+ const double qz = bodyData[offset + 24];
107
+ const double qw = bodyData[offset + 25];
108
+ if (qx * qx + qy * qy + qz * qz + qw * qw > 1e-12) {
109
+ body.orientationX = qx;
110
+ body.orientationY = qy;
111
+ body.orientationZ = qz;
112
+ body.orientationW = qw;
113
+ } else if (bodyData[offset + 10] * bodyData[offset + 10] + bodyData[offset + 11] * bodyData[offset + 11] +
114
+ bodyData[offset + 12] * bodyData[offset + 12] + bodyData[offset + 13] * bodyData[offset + 13] > 1e-12) {
115
+ body.orientationX = bodyData[offset + 10];
116
+ body.orientationY = bodyData[offset + 11];
117
+ body.orientationZ = bodyData[offset + 12];
118
+ body.orientationW = bodyData[offset + 13];
119
+ body.angularVelX = bodyData[offset + 15];
120
+ body.angularVelY = bodyData[offset + 16];
121
+ body.angularVelZ = bodyData[offset + 17];
122
+ } else {
123
+ body.orientationW = 1.0;
124
+ }
125
+
126
+ body.angularDamping = bodyData[offset + 26];
127
+ body.friction = bodyData[offset + 27];
128
+ body.restitution = bodyData[offset + 28];
129
+ body.motionLocks = static_cast<std::uint32_t>(bodyData[offset + 29]);
130
+ body.bullet = (bodyData[offset + 30] != 0.0);
131
+ body.inertiaXX = bodyData[offset + 31] > 0.0 ? bodyData[offset + 31] : 1.0;
132
+ body.inertiaYY = bodyData[offset + 32] > 0.0 ? bodyData[offset + 32] : 1.0;
133
+ body.inertiaZZ = bodyData[offset + 33] > 0.0 ? bodyData[offset + 33] : 1.0;
134
+ body.inertiaXY = bodyData[offset + 34];
135
+ body.inertiaXZ = bodyData[offset + 35];
136
+ body.inertiaYZ = bodyData[offset + 36];
137
+ body.centerOfMassX = bodyData[offset + 37];
138
+ body.centerOfMassY = bodyData[offset + 38];
139
+ body.centerOfMassZ = bodyData[offset + 39];
140
+ body.sleepThreshold = bodyData[offset + 40];
141
+ body.sleepEnabled = (bodyData[offset + 41] != 0.0);
142
+ body.sleepTime = bodyData[offset + 42];
143
+ body.rollingResistance = bodyData[offset + 43];
144
+ return body;
145
+ }
146
+
147
+ inline void packBody(double* bodyData, std::uint32_t b, const Body& body) {
148
+ const std::uint32_t offset = b * kBodyStride;
149
+ bodyData[offset + 3] = body.vx;
150
+ bodyData[offset + 4] = body.vy;
151
+ bodyData[offset + 5] = body.vz;
152
+ bodyData[offset + 19] = body.angularVelX;
153
+ bodyData[offset + 20] = body.angularVelY;
154
+ bodyData[offset + 21] = body.angularVelZ;
155
+ bodyData[offset + 15] = body.angularVelX;
156
+ bodyData[offset + 16] = body.angularVelY;
157
+ bodyData[offset + 17] = body.angularVelZ;
158
+ }
159
+
160
+ inline RagdollStatus unpackSkeletonDef(const double* skeletonData, std::uint32_t boneCount, RagdollSkeletonDef& def) {
161
+ if (skeletonData == nullptr || boneCount == 0 || boneCount > kRagdollMaxBones) {
162
+ return RagdollStatus::InvalidSkeleton;
163
+ }
164
+ def.boneCount = boneCount;
165
+ def.filterAdjacentLimbs = true;
166
+
167
+ for (std::uint32_t i = 0; i < boneCount; ++i) {
168
+ const double* record = skeletonData + i * kRagdollBoneRecordStride;
169
+ RagdollBoneDef& bone = def.bones[i];
170
+ bone.boneId = static_cast<std::uint32_t>(record[0]);
171
+ bone.parentIndex = static_cast<std::int32_t>(record[1]);
172
+ bone.bindPose.position = {record[2], record[3], record[4]};
173
+ bone.bindPose.orientation = {record[5], record[6], record[7], record[8]};
174
+ bone.shape.kind = static_cast<ShapeKind>(record[9]);
175
+ bone.shape.radius = record[10];
176
+ bone.shape.halfHeight = record[11];
177
+ bone.mass = record[12];
178
+ bone.joint.kind = static_cast<RagdollJointKind>(record[13]);
179
+ bone.joint.anchorA = {record[14], record[15], record[16]};
180
+ bone.joint.anchorB = {record[17], record[18], record[19]};
181
+ bone.joint.axisA = {record[20], record[21], record[22]};
182
+ bone.joint.coneAngle = record[23];
183
+
184
+ if (bone.parentIndex >= 0 && bone.parentIndex < static_cast<std::int32_t>(boneCount)) {
185
+ bone.localBindPose = relativeTransform(def.bones[bone.parentIndex].bindPose, bone.bindPose);
186
+ } else {
187
+ bone.localBindPose = bone.bindPose;
188
+ }
189
+ }
190
+ return RagdollStatus::Success;
191
+ }
192
+
193
+ } // namespace
194
+
195
+ extern "C" {
196
+
197
+ // ABI Version
198
+ std::uint32_t rundot_kinetix_ext_abi_version() {
199
+ return 1;
200
+ }
201
+
202
+ // ---------------------------------------------------------------------------
203
+ // Gear and Rack-and-Pinion Constraints (J11)
204
+ // ---------------------------------------------------------------------------
205
+ std::uint32_t rundot_kinetix_ext_gear_config_stride() {
206
+ return kGearConfigStride;
207
+ }
208
+
209
+ std::uint32_t rundot_kinetix_ext_gear_state_stride() {
210
+ return kGearStateStride;
211
+ }
212
+
213
+ std::uint32_t rundot_kinetix_ext_gear_telemetry_stride() {
214
+ return kGearTelemetryStride;
215
+ }
216
+
217
+ std::uint32_t rundot_kinetix_ext_gear_stride() {
218
+ return kGearConfigStride;
219
+ }
220
+
221
+ std::uint32_t rundot_kinetix_ext_gear_size() {
222
+ return kGearConfigStride;
223
+ }
224
+
225
+ std::int32_t rundot_kinetix_ext_gear_solve(
226
+ const double* configData,
227
+ std::uint32_t configCount,
228
+ double* stateData,
229
+ double* bodyData,
230
+ std::uint32_t bodyCount,
231
+ double dt,
232
+ std::uint32_t iterations) {
233
+ if (configData == nullptr || stateData == nullptr || bodyData == nullptr) return -1;
234
+ if (configCount == 0 || bodyCount == 0 || dt <= 0.0) return 0;
235
+ if (configCount > kMaxExtGearConfigs || bodyCount > kMaxExtBodies) return -2;
236
+
237
+ for (std::uint32_t i = 0; i < configCount; ++i) {
238
+ const double* c = configData + i * kGearConfigStride;
239
+ g_extGearConfigs[i].bodyA = static_cast<std::uint32_t>(c[0]);
240
+ g_extGearConfigs[i].bodyB = static_cast<std::uint32_t>(c[1]);
241
+ g_extGearConfigs[i].mode = static_cast<GearCouplingMode>(static_cast<std::uint32_t>(c[2]));
242
+ g_extGearConfigs[i].ratio = c[3];
243
+ g_extGearConfigs[i].phase = c[4];
244
+ g_extGearConfigs[i].axisA = {c[5], c[6], c[7]};
245
+ g_extGearConfigs[i].axisB = {c[8], c[9], c[10]};
246
+ g_extGearConfigs[i].anchorA = {c[11], c[12], c[13]};
247
+ g_extGearConfigs[i].anchorB = {c[14], c[15], c[16]};
248
+ g_extGearConfigs[i].limitMode = static_cast<GearLimitMode>(static_cast<std::uint32_t>(c[17]));
249
+ g_extGearConfigs[i].lowerLimit = c[18];
250
+ g_extGearConfigs[i].upperLimit = c[19];
251
+ g_extGearConfigs[i].frequencyHz = c[20];
252
+ g_extGearConfigs[i].dampingRatio = c[21];
253
+ g_extGearConfigs[i].maxForce = c[22];
254
+ g_extGearConfigs[i].breakForce = c[23];
255
+ g_extGearConfigs[i].breakTorque = c[24];
256
+ g_extGearConfigs[i].enabled = c[25] != 0.0;
257
+
258
+ double* s = stateData + i * kGearStateStride;
259
+ g_extGearStates[i].unwrappedCoordinateA = s[0];
260
+ g_extGearStates[i].previousWrappedAngleA = s[1];
261
+ g_extGearStates[i].unwrappedCoordinateB = s[2];
262
+ g_extGearStates[i].previousWrappedAngleB = s[3];
263
+ g_extGearStates[i].coordinate = s[4];
264
+ g_extGearStates[i].speed = s[5];
265
+ g_extGearStates[i].accumulatedImpulse = s[6];
266
+ g_extGearStates[i].reactionForce = s[7];
267
+ g_extGearStates[i].reactionTorque = s[8];
268
+ g_extGearStates[i].broken = s[9] != 0.0;
269
+ g_extGearStates[i].initialized = s[10] != 0.0;
270
+ }
271
+
272
+ for (std::uint32_t b = 0; b < bodyCount; ++b) {
273
+ g_extBodies[b] = unpackBody(bodyData, b);
274
+ g_extMobility[b] = constraintBodyMobility(g_extBodies[b]);
275
+ }
276
+
277
+ solveGearConstraints(
278
+ std::span<const GearConstraintConfig>(g_extGearConfigs.data(), configCount),
279
+ std::span<GearConstraintState>(g_extGearStates.data(), configCount),
280
+ std::span<Body>(g_extBodies.data(), bodyCount),
281
+ std::span<const ConstraintBodyMobility>(g_extMobility.data(), bodyCount),
282
+ dt, iterations);
283
+
284
+ for (std::uint32_t i = 0; i < configCount; ++i) {
285
+ double* s = stateData + i * kGearStateStride;
286
+ s[0] = g_extGearStates[i].unwrappedCoordinateA;
287
+ s[1] = g_extGearStates[i].previousWrappedAngleA;
288
+ s[2] = g_extGearStates[i].unwrappedCoordinateB;
289
+ s[3] = g_extGearStates[i].previousWrappedAngleB;
290
+ s[4] = g_extGearStates[i].coordinate;
291
+ s[5] = g_extGearStates[i].speed;
292
+ s[6] = g_extGearStates[i].accumulatedImpulse;
293
+ s[7] = g_extGearStates[i].reactionForce;
294
+ s[8] = g_extGearStates[i].reactionTorque;
295
+ s[9] = g_extGearStates[i].broken ? 1.0 : 0.0;
296
+ s[10] = g_extGearStates[i].initialized ? 1.0 : 0.0;
297
+ }
298
+
299
+ for (std::uint32_t b = 0; b < bodyCount; ++b) {
300
+ packBody(bodyData, b, g_extBodies[b]);
301
+ }
302
+
303
+ return 0;
304
+ }
305
+
306
+ std::int32_t rundot_kinetix_ext_gear_step(
307
+ const double* configData,
308
+ std::uint32_t configCount,
309
+ double* stateData,
310
+ double* bodyData,
311
+ std::uint32_t bodyCount,
312
+ double dt,
313
+ std::uint32_t iterations) {
314
+ return rundot_kinetix_ext_gear_solve(
315
+ configData, configCount, stateData, bodyData, bodyCount, dt, iterations);
316
+ }
317
+
318
+ // ---------------------------------------------------------------------------
319
+ // Pulley Constraints (J12)
320
+ // ---------------------------------------------------------------------------
321
+ std::uint32_t rundot_kinetix_ext_pulley_config_stride() {
322
+ return kPulleyConfigStrideValue;
323
+ }
324
+
325
+ std::uint32_t rundot_kinetix_ext_pulley_state_stride() {
326
+ return kPulleyStateStrideValue;
327
+ }
328
+
329
+ std::uint32_t rundot_kinetix_ext_pulley_geometry_stride() {
330
+ return kPulleyGeometryStrideValue;
331
+ }
332
+
333
+ std::uint32_t rundot_kinetix_ext_pulley_stride() {
334
+ return kPulleyConfigStrideValue;
335
+ }
336
+
337
+ std::uint32_t rundot_kinetix_ext_pulley_size() {
338
+ return kPulleyConfigStrideValue;
339
+ }
340
+
341
+ std::int32_t rundot_kinetix_ext_pulley_solve(
342
+ const double* configData,
343
+ std::uint32_t configCount,
344
+ double* stateData,
345
+ double* bodyData,
346
+ std::uint32_t bodyCount,
347
+ double dt,
348
+ std::uint32_t iterations) {
349
+ if (configData == nullptr || bodyData == nullptr) return -1;
350
+ if (configCount == 0 || bodyCount == 0 || dt <= 0.0) return 0;
351
+ if (bodyCount > kMaxExtBodies) return -2;
352
+
353
+ for (std::uint32_t b = 0; b < bodyCount; ++b) {
354
+ g_extBodies[b] = unpackBody(bodyData, b);
355
+ g_extMobility[b] = constraintBodyMobility(g_extBodies[b]);
356
+ }
357
+
358
+ std::span<Body> bodySpan(g_extBodies.data(), bodyCount);
359
+ std::span<const ConstraintBodyMobility> mobilitySpan(g_extMobility.data(), bodyCount);
360
+
361
+ for (std::uint32_t i = 0; i < configCount; ++i) {
362
+ const double* c = configData + i * kPulleyConfigStrideValue;
363
+ PulleyConstraint3D constraint{};
364
+ constraint.bodyA = static_cast<std::uint32_t>(c[0]);
365
+ constraint.bodyB = static_cast<std::uint32_t>(c[1]);
366
+ constraint.groundA = {c[2], c[3], c[4]};
367
+ constraint.groundB = {c[5], c[6], c[7]};
368
+ constraint.anchorA = {c[8], c[9], c[10]};
369
+ constraint.anchorB = {c[11], c[12], c[13]};
370
+ constraint.ratio = c[14];
371
+ constraint.totalLength = c[15];
372
+ constraint.mode = static_cast<PulleyMode3D>(static_cast<std::uint8_t>(c[16]));
373
+ constraint.maxForce = c[17];
374
+ constraint.breakForce = c[18];
375
+ constraint.frequencyHz = c[19];
376
+ constraint.dampingRatio = c[20];
377
+ constraint.initialImpulse = c[21];
378
+
379
+ if (stateData != nullptr) {
380
+ const double* s = stateData + i * kPulleyStateStrideValue;
381
+ if (s[6] != 0.0 && constraint.initialImpulse == 0.0) {
382
+ constraint.initialImpulse = s[6];
383
+ }
384
+ }
385
+
386
+ PulleyState3D state{};
387
+ solvePulleyConstraint(constraint, bodySpan, mobilitySpan, dt, iterations, &state);
388
+
389
+ if (stateData != nullptr) {
390
+ double* s = stateData + i * kPulleyStateStrideValue;
391
+ s[0] = state.lengthA;
392
+ s[1] = state.lengthB;
393
+ s[2] = state.coordinate;
394
+ s[3] = state.targetLength;
395
+ s[4] = state.error;
396
+ s[5] = state.speed;
397
+ s[6] = state.accumulatedImpulse;
398
+ s[7] = state.impulseMagnitude;
399
+ s[8] = state.tensionForce;
400
+ s[9] = state.tensionForceB;
401
+ s[10] = state.reactionForceA.x;
402
+ s[11] = state.reactionForceA.y;
403
+ s[12] = state.reactionForceA.z;
404
+ s[13] = state.reactionForceB.x;
405
+ s[14] = state.reactionForceB.y;
406
+ s[15] = state.reactionForceB.z;
407
+ s[16] = static_cast<double>(state.limitState);
408
+ s[17] = state.broken ? 1.0 : 0.0;
409
+ }
410
+ }
411
+
412
+ for (std::uint32_t b = 0; b < bodyCount; ++b) {
413
+ packBody(bodyData, b, g_extBodies[b]);
414
+ }
415
+
416
+ return 0;
417
+ }
418
+
419
+ std::int32_t rundot_kinetix_ext_pulley_compute_geometry(
420
+ const double* configData,
421
+ const double* bodyData,
422
+ std::uint32_t bodyCount,
423
+ double* outputGeometry) {
424
+ if (configData == nullptr || bodyData == nullptr || outputGeometry == nullptr) return -1;
425
+ const double* c = configData;
426
+ PulleyConstraint3D constraint{};
427
+ constraint.bodyA = static_cast<std::uint32_t>(c[0]);
428
+ constraint.bodyB = static_cast<std::uint32_t>(c[1]);
429
+ if (constraint.bodyA >= bodyCount || constraint.bodyB >= bodyCount) return -2;
430
+
431
+ constraint.groundA = {c[2], c[3], c[4]};
432
+ constraint.groundB = {c[5], c[6], c[7]};
433
+ constraint.anchorA = {c[8], c[9], c[10]};
434
+ constraint.anchorB = {c[11], c[12], c[13]};
435
+ constraint.ratio = c[14];
436
+ constraint.totalLength = c[15];
437
+ constraint.mode = static_cast<PulleyMode3D>(static_cast<std::uint8_t>(c[16]));
438
+ constraint.maxForce = c[17];
439
+ constraint.breakForce = c[18];
440
+ constraint.frequencyHz = c[19];
441
+ constraint.dampingRatio = c[20];
442
+ constraint.initialImpulse = c[21];
443
+
444
+ const Body bodyA = unpackBody(bodyData, constraint.bodyA);
445
+ const Body bodyB = unpackBody(bodyData, constraint.bodyB);
446
+
447
+ PulleyGeometry3D geom{};
448
+ const bool ok = computePulleyGeometry3D(constraint, bodyA, bodyB, geom);
449
+
450
+ outputGeometry[0] = geom.worldAnchorA.x;
451
+ outputGeometry[1] = geom.worldAnchorA.y;
452
+ outputGeometry[2] = geom.worldAnchorA.z;
453
+ outputGeometry[3] = geom.worldAnchorB.x;
454
+ outputGeometry[4] = geom.worldAnchorB.y;
455
+ outputGeometry[5] = geom.worldAnchorB.z;
456
+ outputGeometry[6] = geom.legA.x;
457
+ outputGeometry[7] = geom.legA.y;
458
+ outputGeometry[8] = geom.legA.z;
459
+ outputGeometry[9] = geom.legB.x;
460
+ outputGeometry[10] = geom.legB.y;
461
+ outputGeometry[11] = geom.legB.z;
462
+ outputGeometry[12] = geom.lengthA;
463
+ outputGeometry[13] = geom.lengthB;
464
+ outputGeometry[14] = geom.coordinate;
465
+ outputGeometry[15] = geom.error;
466
+ outputGeometry[16] = geom.speed;
467
+ outputGeometry[17] = geom.unitA.x;
468
+ outputGeometry[18] = geom.unitA.y;
469
+ outputGeometry[19] = geom.unitA.z;
470
+ outputGeometry[20] = geom.unitB.x;
471
+ outputGeometry[21] = geom.unitB.y;
472
+ outputGeometry[22] = geom.unitB.z;
473
+ outputGeometry[23] = geom.angularFactorA.x;
474
+ outputGeometry[24] = geom.angularFactorA.y;
475
+ outputGeometry[25] = geom.angularFactorA.z;
476
+ outputGeometry[26] = ok ? 1.0 : 0.0;
477
+ return ok ? 0 : 1;
478
+ }
479
+
480
+ // ---------------------------------------------------------------------------
481
+ // Path and Spline Constraints (J13)
482
+ // ---------------------------------------------------------------------------
483
+ std::uint32_t rundot_kinetix_ext_path_joint_stride() {
484
+ return kPathJointStride;
485
+ }
486
+
487
+ std::uint32_t rundot_kinetix_ext_path_joint_sample_stride() {
488
+ return kPathJointSampleStrideValue;
489
+ }
490
+
491
+ std::uint32_t rundot_kinetix_ext_path_joint_control_point_stride() {
492
+ return kPathJointControlPointStrideValue;
493
+ }
494
+
495
+ std::uint32_t rundot_kinetix_ext_path_joint_size() {
496
+ return kPathJointStride;
497
+ }
498
+
499
+ std::int32_t rundot_kinetix_ext_path_joint_cook(
500
+ const double* controlPointsData,
501
+ std::uint32_t controlPointCount,
502
+ std::uint32_t curveType,
503
+ std::uint32_t endPolicy,
504
+ std::uint32_t samplesPerSegment,
505
+ double* outSamplesData,
506
+ std::uint32_t maxOutSamples,
507
+ std::uint32_t* outSampleCount,
508
+ double* outTotalLength) {
509
+ if (controlPointsData == nullptr || outSamplesData == nullptr || controlPointCount < 2) return -1;
510
+ if (maxOutSamples == 0) return -2;
511
+
512
+ constexpr std::uint32_t kMaxControlPoints = 512;
513
+ if (controlPointCount > kMaxControlPoints) return -2;
514
+
515
+ std::array<PathVec3, kMaxControlPoints> pts{};
516
+ for (std::uint32_t i = 0; i < controlPointCount; ++i) {
517
+ pts[i] = {controlPointsData[i * 3 + 0], controlPointsData[i * 3 + 1], controlPointsData[i * 3 + 2]};
518
+ }
519
+
520
+ PathCookingOptions options{};
521
+ options.curveType = static_cast<PathCurveType>(curveType);
522
+ options.endPolicy = static_cast<PathEndPolicy>(endPolicy);
523
+ options.samplesPerSegment = samplesPerSegment > 0 ? samplesPerSegment : 16;
524
+
525
+ const CookedPath cooked = cookPath(std::span<const PathVec3>(pts.data(), controlPointCount), options);
526
+ const std::uint32_t count = std::min(static_cast<std::uint32_t>(cooked.samples.size()), maxOutSamples);
527
+
528
+ for (std::uint32_t i = 0; i < count; ++i) {
529
+ double* s = outSamplesData + i * kPathJointSampleStrideValue;
530
+ s[0] = cooked.samples[i].position.x;
531
+ s[1] = cooked.samples[i].position.y;
532
+ s[2] = cooked.samples[i].position.z;
533
+ s[3] = cooked.samples[i].tangent.x;
534
+ s[4] = cooked.samples[i].tangent.y;
535
+ s[5] = cooked.samples[i].tangent.z;
536
+ s[6] = cooked.samples[i].normal.x;
537
+ s[7] = cooked.samples[i].normal.y;
538
+ s[8] = cooked.samples[i].normal.z;
539
+ s[9] = cooked.samples[i].binormal.x;
540
+ s[10] = cooked.samples[i].binormal.y;
541
+ s[11] = cooked.samples[i].binormal.z;
542
+ s[12] = cooked.samples[i].arcLength;
543
+ }
544
+
545
+ if (outSampleCount != nullptr) *outSampleCount = count;
546
+ if (outTotalLength != nullptr) *outTotalLength = cooked.totalLength;
547
+ return 0;
548
+ }
549
+
550
+ std::int32_t rundot_kinetix_ext_path_joint_sample(
551
+ const double* samplesData,
552
+ std::uint32_t sampleCount,
553
+ double arcLength,
554
+ std::uint32_t endPolicy,
555
+ double* outSampleData) {
556
+ if (samplesData == nullptr || outSampleData == nullptr || sampleCount == 0) return -1;
557
+
558
+ ensureCookedPathCapacity();
559
+ const std::uint32_t count = std::min(sampleCount, kMaxExtPathSamples);
560
+ g_extCookedPath.samples.resize(count);
561
+ for (std::uint32_t i = 0; i < count; ++i) {
562
+ const double* s = samplesData + i * kPathJointSampleStrideValue;
563
+ g_extCookedPath.samples[i].position = {s[0], s[1], s[2]};
564
+ g_extCookedPath.samples[i].tangent = {s[3], s[4], s[5]};
565
+ g_extCookedPath.samples[i].normal = {s[6], s[7], s[8]};
566
+ g_extCookedPath.samples[i].binormal = {s[9], s[10], s[11]};
567
+ g_extCookedPath.samples[i].arcLength = s[12];
568
+ }
569
+ g_extCookedPath.endPolicy = static_cast<PathEndPolicy>(endPolicy);
570
+ g_extCookedPath.isLoop = (g_extCookedPath.endPolicy == PathEndPolicy::Loop);
571
+ g_extCookedPath.totalLength = count > 0 ? g_extCookedPath.samples[count - 1].arcLength : 0.0;
572
+
573
+ const PathSample sample = sampleCookedPath(g_extCookedPath, arcLength);
574
+ outSampleData[0] = sample.position.x;
575
+ outSampleData[1] = sample.position.y;
576
+ outSampleData[2] = sample.position.z;
577
+ outSampleData[3] = sample.tangent.x;
578
+ outSampleData[4] = sample.tangent.y;
579
+ outSampleData[5] = sample.tangent.z;
580
+ outSampleData[6] = sample.normal.x;
581
+ outSampleData[7] = sample.normal.y;
582
+ outSampleData[8] = sample.normal.z;
583
+ outSampleData[9] = sample.binormal.x;
584
+ outSampleData[10] = sample.binormal.y;
585
+ outSampleData[11] = sample.binormal.z;
586
+ outSampleData[12] = sample.arcLength;
587
+ return 0;
588
+ }
589
+
590
+ std::int32_t rundot_kinetix_ext_path_joint_closest_arc_length(
591
+ const double* samplesData,
592
+ std::uint32_t sampleCount,
593
+ const double* pointData,
594
+ double* outSampleData,
595
+ double* outArcLength) {
596
+ if (samplesData == nullptr || pointData == nullptr || sampleCount == 0 || outArcLength == nullptr) return -1;
597
+
598
+ ensureCookedPathCapacity();
599
+ const std::uint32_t count = std::min(sampleCount, kMaxExtPathSamples);
600
+ g_extCookedPath.samples.resize(count);
601
+ for (std::uint32_t i = 0; i < count; ++i) {
602
+ const double* s = samplesData + i * kPathJointSampleStrideValue;
603
+ g_extCookedPath.samples[i].position = {s[0], s[1], s[2]};
604
+ g_extCookedPath.samples[i].tangent = {s[3], s[4], s[5]};
605
+ g_extCookedPath.samples[i].normal = {s[6], s[7], s[8]};
606
+ g_extCookedPath.samples[i].binormal = {s[9], s[10], s[11]};
607
+ g_extCookedPath.samples[i].arcLength = s[12];
608
+ }
609
+ g_extCookedPath.totalLength = count > 0 ? g_extCookedPath.samples[count - 1].arcLength : 0.0;
610
+
611
+ const PathVec3 pt{pointData[0], pointData[1], pointData[2]};
612
+ PathSample sample{};
613
+ *outArcLength = findClosestArcLength(g_extCookedPath, pt, &sample);
614
+
615
+ if (outSampleData != nullptr) {
616
+ outSampleData[0] = sample.position.x;
617
+ outSampleData[1] = sample.position.y;
618
+ outSampleData[2] = sample.position.z;
619
+ outSampleData[3] = sample.tangent.x;
620
+ outSampleData[4] = sample.tangent.y;
621
+ outSampleData[5] = sample.tangent.z;
622
+ outSampleData[6] = sample.normal.x;
623
+ outSampleData[7] = sample.normal.y;
624
+ outSampleData[8] = sample.normal.z;
625
+ outSampleData[9] = sample.binormal.x;
626
+ outSampleData[10] = sample.binormal.y;
627
+ outSampleData[11] = sample.binormal.z;
628
+ outSampleData[12] = sample.arcLength;
629
+ }
630
+ return 0;
631
+ }
632
+
633
+ std::int32_t rundot_kinetix_ext_path_joint_solve(
634
+ double* constraintData,
635
+ const double* samplesData,
636
+ std::uint32_t sampleCount,
637
+ double* bodyData,
638
+ std::uint32_t bodyCount,
639
+ double dt,
640
+ std::uint32_t iterations) {
641
+ if (constraintData == nullptr || samplesData == nullptr || bodyData == nullptr) return -1;
642
+ if (sampleCount == 0 || bodyCount == 0 || dt <= 0.0 || iterations == 0) return 0;
643
+ if (bodyCount > kMaxExtBodies) return -2;
644
+
645
+ ensureCookedPathCapacity();
646
+ const std::uint32_t count = std::min(sampleCount, kMaxExtPathSamples);
647
+ g_extCookedPath.samples.resize(count);
648
+ for (std::uint32_t i = 0; i < count; ++i) {
649
+ const double* s = samplesData + i * kPathJointSampleStrideValue;
650
+ g_extCookedPath.samples[i].position = {s[0], s[1], s[2]};
651
+ g_extCookedPath.samples[i].tangent = {s[3], s[4], s[5]};
652
+ g_extCookedPath.samples[i].normal = {s[6], s[7], s[8]};
653
+ g_extCookedPath.samples[i].binormal = {s[9], s[10], s[11]};
654
+ g_extCookedPath.samples[i].arcLength = s[12];
655
+ }
656
+ g_extCookedPath.endPolicy = static_cast<PathEndPolicy>(static_cast<std::uint8_t>(constraintData[14]));
657
+ g_extCookedPath.isLoop = (g_extCookedPath.endPolicy == PathEndPolicy::Loop);
658
+ g_extCookedPath.totalLength = count > 0 ? g_extCookedPath.samples[count - 1].arcLength : 0.0;
659
+
660
+ for (std::uint32_t b = 0; b < bodyCount; ++b) {
661
+ g_extBodies[b] = unpackBody(bodyData, b);
662
+ g_extMobility[b] = constraintBodyMobility(g_extBodies[b]);
663
+ }
664
+
665
+ PathConstraint pc{};
666
+ pc.bodyA = static_cast<std::uint32_t>(constraintData[0]);
667
+ pc.bodyB = static_cast<std::uint32_t>(constraintData[1]);
668
+ pc.anchorA = {constraintData[2], constraintData[3], constraintData[4]};
669
+ pc.anchorB = {constraintData[5], constraintData[6], constraintData[7]};
670
+ pc.frameOrientationB = {constraintData[8], constraintData[9], constraintData[10], constraintData[11]};
671
+ pc.currentArcLength = constraintData[12];
672
+ pc.orientationPolicy = static_cast<PathOrientationPolicy>(static_cast<std::uint8_t>(constraintData[13]));
673
+ pc.endPolicy = static_cast<PathEndPolicy>(static_cast<std::uint8_t>(constraintData[14]));
674
+ pc.limit.enabled = constraintData[15] != 0.0;
675
+ pc.limit.lower = constraintData[16];
676
+ pc.limit.upper = constraintData[17];
677
+ pc.limit.maxForce = constraintData[18];
678
+ pc.motor.enabled = constraintData[19] != 0.0;
679
+ pc.motor.targetVelocity = constraintData[20];
680
+ pc.motor.maxForce = constraintData[21];
681
+ pc.spring.enabled = constraintData[22] != 0.0;
682
+ pc.spring.frequencyHz = constraintData[23];
683
+ pc.spring.dampingRatio = constraintData[24];
684
+ pc.spring.targetPosition = constraintData[25];
685
+ pc.spring.maxForce = constraintData[26];
686
+ pc.maxNormalForce = constraintData[27];
687
+ pc.path = &g_extCookedPath;
688
+
689
+ const std::uint32_t rowsSolved = solvePathConstraint(
690
+ pc,
691
+ std::span<Body>(g_extBodies.data(), bodyCount),
692
+ std::span<const ConstraintBodyMobility>(g_extMobility.data(), bodyCount),
693
+ dt, iterations);
694
+
695
+ constraintData[12] = pc.currentArcLength;
696
+
697
+ for (std::uint32_t b = 0; b < bodyCount; ++b) {
698
+ packBody(bodyData, b, g_extBodies[b]);
699
+ }
700
+
701
+ return static_cast<std::int32_t>(rowsSolved);
702
+ }
703
+
704
+ // ---------------------------------------------------------------------------
705
+ // Particle System and Granular Material (A07)
706
+ // ---------------------------------------------------------------------------
707
+ std::uint32_t rundot_kinetix_ext_particles_particle_stride() {
708
+ return rundot_kinetix_physics_particles_particle_stride();
709
+ }
710
+
711
+ std::uint32_t rundot_kinetix_ext_particles_emitter_stride() {
712
+ return rundot_kinetix_physics_particles_emitter_stride();
713
+ }
714
+
715
+ std::uint32_t rundot_kinetix_ext_particles_params_stride() {
716
+ return rundot_kinetix_physics_particles_params_stride();
717
+ }
718
+
719
+ std::uint32_t rundot_kinetix_ext_particles_max_capacity() {
720
+ return rundot_kinetix_physics_particles_max_capacity();
721
+ }
722
+
723
+ std::uint32_t rundot_kinetix_ext_particles_max_emitters() {
724
+ return kMaxEmitters;
725
+ }
726
+
727
+ std::uint32_t rundot_kinetix_ext_particles_stride() {
728
+ return rundot_kinetix_physics_particles_particle_stride();
729
+ }
730
+
731
+ std::uint32_t rundot_kinetix_ext_particles_size() {
732
+ return rundot_kinetix_physics_particles_particle_stride();
733
+ }
734
+
735
+ std::int32_t rundot_kinetix_ext_particles_step(
736
+ double* particleData,
737
+ std::uint32_t maxParticles,
738
+ std::uint32_t* activeParticleCount,
739
+ double* emitterData,
740
+ std::uint32_t emitterCount,
741
+ const double* bodyData,
742
+ std::uint32_t bodyCount,
743
+ const double* paramsData,
744
+ double dt,
745
+ std::uint64_t tick) {
746
+ return rundot_kinetix_physics_particles_step(
747
+ particleData, maxParticles, activeParticleCount,
748
+ emitterData, emitterCount, bodyData, bodyCount, paramsData, dt, tick);
749
+ }
750
+
751
+ std::int32_t rundot_kinetix_ext_particles_emit(
752
+ double* particleData,
753
+ std::uint32_t maxParticles,
754
+ std::uint32_t* activeParticleCount,
755
+ const double* emitterData,
756
+ std::uint32_t emitterIndex,
757
+ std::uint32_t count,
758
+ std::uint64_t tick,
759
+ std::uint64_t seed) {
760
+ return rundot_kinetix_physics_particles_emit(
761
+ particleData, maxParticles, activeParticleCount,
762
+ emitterData, emitterIndex, count, tick, seed);
763
+ }
764
+
765
+ std::int32_t rundot_kinetix_ext_particles_reset(
766
+ double* particleData,
767
+ std::uint32_t maxParticles,
768
+ std::uint32_t* activeParticleCount) {
769
+ return rundot_kinetix_physics_particles_reset(
770
+ particleData, maxParticles, activeParticleCount);
771
+ }
772
+
773
+ // ---------------------------------------------------------------------------
774
+ // Ragdoll and Constrained Pose Solver (K05)
775
+ // ---------------------------------------------------------------------------
776
+ std::uint32_t rundot_kinetix_ext_ragdoll_bone_stride() {
777
+ return kRagdollBoneRecordStride;
778
+ }
779
+
780
+ std::uint32_t rundot_kinetix_ext_ragdoll_transform_stride() {
781
+ return kRagdollTransformStrideValue;
782
+ }
783
+
784
+ std::uint32_t rundot_kinetix_ext_ragdoll_body_stride() {
785
+ return kRagdollBodyStrideValue;
786
+ }
787
+
788
+ std::uint32_t rundot_kinetix_ext_ragdoll_joint_stride() {
789
+ return kRagdollJointStrideValue;
790
+ }
791
+
792
+ std::uint32_t rundot_kinetix_ext_ragdoll_max_bones() {
793
+ return kRagdollMaxBones;
794
+ }
795
+
796
+ std::uint32_t rundot_kinetix_ext_ragdoll_max_joints() {
797
+ return kRagdollMaxJoints;
798
+ }
799
+
800
+ std::uint32_t rundot_kinetix_ext_ragdoll_max_filter_pairs() {
801
+ return kRagdollMaxFilterPairs;
802
+ }
803
+
804
+ std::uint32_t rundot_kinetix_ext_ragdoll_stride() {
805
+ return kRagdollBoneRecordStride;
806
+ }
807
+
808
+ std::uint32_t rundot_kinetix_ext_ragdoll_size() {
809
+ return kRagdollBoneRecordStride;
810
+ }
811
+
812
+ std::int32_t rundot_kinetix_ext_ragdoll_construct(
813
+ const double* skeletonData,
814
+ std::uint32_t boneCount,
815
+ double* outBodyData,
816
+ double* outJointData,
817
+ std::uint32_t* outFilterPairs,
818
+ std::uint32_t* outFilterCount) {
819
+ return rundot_ragdoll_construct(
820
+ skeletonData, boneCount, outBodyData, outJointData, outFilterPairs, outFilterCount);
821
+ }
822
+
823
+ std::int32_t rundot_kinetix_ext_ragdoll_forward_kinematics(
824
+ const double* skeletonData,
825
+ std::uint32_t boneCount,
826
+ const double* localTransformsData,
827
+ double* outWorldTransformsData) {
828
+ if (skeletonData == nullptr || localTransformsData == nullptr || outWorldTransformsData == nullptr) return -1;
829
+ const RagdollStatus s = unpackSkeletonDef(skeletonData, boneCount, g_extSkeleton);
830
+ if (s != RagdollStatus::Success) return static_cast<std::int32_t>(s);
831
+
832
+ for (std::uint32_t i = 0; i < boneCount; ++i) {
833
+ const double* t = localTransformsData + i * kRagdollTransformStrideValue;
834
+ g_extTransformsIn[i].position = {t[0], t[1], t[2]};
835
+ g_extTransformsIn[i].orientation = {t[3], t[4], t[5], t[6]};
836
+ }
837
+
838
+ const RagdollStatus res = forwardKinematics(
839
+ g_extSkeleton,
840
+ std::span<const RagdollTransform>(g_extTransformsIn.data(), boneCount),
841
+ std::span<RagdollTransform>(g_extTransformsOut.data(), boneCount));
842
+ if (res != RagdollStatus::Success) return static_cast<std::int32_t>(res);
843
+
844
+ for (std::uint32_t i = 0; i < boneCount; ++i) {
845
+ double* t = outWorldTransformsData + i * kRagdollTransformStrideValue;
846
+ t[0] = g_extTransformsOut[i].position.x;
847
+ t[1] = g_extTransformsOut[i].position.y;
848
+ t[2] = g_extTransformsOut[i].position.z;
849
+ t[3] = g_extTransformsOut[i].orientation.x;
850
+ t[4] = g_extTransformsOut[i].orientation.y;
851
+ t[5] = g_extTransformsOut[i].orientation.z;
852
+ t[6] = g_extTransformsOut[i].orientation.w;
853
+ }
854
+ return 0;
855
+ }
856
+
857
+ std::int32_t rundot_kinetix_ext_ragdoll_inverse_kinematics(
858
+ const double* skeletonData,
859
+ std::uint32_t boneCount,
860
+ const double* worldTransformsData,
861
+ double* outLocalTransformsData) {
862
+ if (skeletonData == nullptr || worldTransformsData == nullptr || outLocalTransformsData == nullptr) return -1;
863
+ const RagdollStatus s = unpackSkeletonDef(skeletonData, boneCount, g_extSkeleton);
864
+ if (s != RagdollStatus::Success) return static_cast<std::int32_t>(s);
865
+
866
+ for (std::uint32_t i = 0; i < boneCount; ++i) {
867
+ const double* t = worldTransformsData + i * kRagdollTransformStrideValue;
868
+ g_extTransformsIn[i].position = {t[0], t[1], t[2]};
869
+ g_extTransformsIn[i].orientation = {t[3], t[4], t[5], t[6]};
870
+ }
871
+
872
+ const RagdollStatus res = inverseKinematicsLocal(
873
+ g_extSkeleton,
874
+ std::span<const RagdollTransform>(g_extTransformsIn.data(), boneCount),
875
+ std::span<RagdollTransform>(g_extTransformsOut.data(), boneCount));
876
+ if (res != RagdollStatus::Success) return static_cast<std::int32_t>(res);
877
+
878
+ for (std::uint32_t i = 0; i < boneCount; ++i) {
879
+ double* t = outLocalTransformsData + i * kRagdollTransformStrideValue;
880
+ t[0] = g_extTransformsOut[i].position.x;
881
+ t[1] = g_extTransformsOut[i].position.y;
882
+ t[2] = g_extTransformsOut[i].position.z;
883
+ t[3] = g_extTransformsOut[i].orientation.x;
884
+ t[4] = g_extTransformsOut[i].orientation.y;
885
+ t[5] = g_extTransformsOut[i].orientation.z;
886
+ t[6] = g_extTransformsOut[i].orientation.w;
887
+ }
888
+ return 0;
889
+ }
890
+
891
+ std::int32_t rundot_kinetix_ext_ragdoll_constrain_pose(
892
+ const double* skeletonData,
893
+ std::uint32_t boneCount,
894
+ const double* inputWorldPosesData,
895
+ double* outConstrainedWorldPosesData) {
896
+ if (skeletonData == nullptr || inputWorldPosesData == nullptr || outConstrainedWorldPosesData == nullptr) return -1;
897
+ const RagdollStatus s = unpackSkeletonDef(skeletonData, boneCount, g_extSkeleton);
898
+ if (s != RagdollStatus::Success) return static_cast<std::int32_t>(s);
899
+
900
+ for (std::uint32_t i = 0; i < boneCount; ++i) {
901
+ const double* t = inputWorldPosesData + i * kRagdollTransformStrideValue;
902
+ g_extTransformsIn[i].position = {t[0], t[1], t[2]};
903
+ g_extTransformsIn[i].orientation = {t[3], t[4], t[5], t[6]};
904
+ }
905
+
906
+ const RagdollStatus res = constrainPose(
907
+ g_extSkeleton,
908
+ std::span<const RagdollTransform>(g_extTransformsIn.data(), boneCount),
909
+ std::span<RagdollTransform>(g_extTransformsOut.data(), boneCount));
910
+ if (res != RagdollStatus::Success) return static_cast<std::int32_t>(res);
911
+
912
+ for (std::uint32_t i = 0; i < boneCount; ++i) {
913
+ double* t = outConstrainedWorldPosesData + i * kRagdollTransformStrideValue;
914
+ t[0] = g_extTransformsOut[i].position.x;
915
+ t[1] = g_extTransformsOut[i].position.y;
916
+ t[2] = g_extTransformsOut[i].position.z;
917
+ t[3] = g_extTransformsOut[i].orientation.x;
918
+ t[4] = g_extTransformsOut[i].orientation.y;
919
+ t[5] = g_extTransformsOut[i].orientation.z;
920
+ t[6] = g_extTransformsOut[i].orientation.w;
921
+ }
922
+ return 0;
923
+ }
924
+
925
+ // ---------------------------------------------------------------------------
926
+ // Vehicle Powertrain and Brakes (V03)
927
+ // ---------------------------------------------------------------------------
928
+ std::uint32_t rundot_kinetix_ext_powertrain_config_stride() {
929
+ return kPowertrainConfigStrideValue;
930
+ }
931
+
932
+ std::uint32_t rundot_kinetix_ext_powertrain_state_stride() {
933
+ return kPowertrainStateStrideValue;
934
+ }
935
+
936
+ std::uint32_t rundot_kinetix_ext_powertrain_input_stride() {
937
+ return kPowertrainInputStrideValue;
938
+ }
939
+
940
+ std::uint32_t rundot_kinetix_ext_powertrain_wheel_state_stride() {
941
+ return kPowertrainWheelStateStrideValue;
942
+ }
943
+
944
+ std::uint32_t rundot_kinetix_ext_powertrain_wheel_output_stride() {
945
+ return kPowertrainWheelOutputStrideValue;
946
+ }
947
+
948
+ std::uint32_t rundot_kinetix_ext_powertrain_max_wheels() {
949
+ return rundot_kinetix_powertrain_max_wheels();
950
+ }
951
+
952
+ std::uint32_t rundot_kinetix_ext_powertrain_max_gears() {
953
+ return rundot_kinetix_powertrain_max_gears();
954
+ }
955
+
956
+ std::uint32_t rundot_kinetix_ext_powertrain_stride() {
957
+ return kPowertrainConfigStrideValue;
958
+ }
959
+
960
+ std::uint32_t rundot_kinetix_ext_powertrain_size() {
961
+ return kPowertrainConfigStrideValue;
962
+ }
963
+
964
+ std::int32_t rundot_kinetix_ext_powertrain_step(
965
+ const double* configData,
966
+ const double* stateData,
967
+ const double* inputData,
968
+ const double* wheelStatesData,
969
+ std::uint32_t wheelCount,
970
+ double dt,
971
+ double* outputData) {
972
+ return rundot_kinetix_powertrain_step(
973
+ configData, stateData, inputData, wheelStatesData, wheelCount, dt, outputData);
974
+ }
975
+
976
+ std::int32_t rundot_kinetix_ext_powertrain_sample_engine_curve(
977
+ const double* engineConfigData,
978
+ double rpm,
979
+ double* outTorque) {
980
+ return rundot_kinetix_powertrain_sample_engine_curve(engineConfigData, rpm, outTorque);
981
+ }
982
+
983
+ // ---------------------------------------------------------------------------
984
+ // Rounded Convex and Multi-Sphere Shapes (G10)
985
+ // ---------------------------------------------------------------------------
986
+ std::uint32_t rundot_kinetix_ext_rounded_convex_sphere_stride() {
987
+ return kRoundedConvexSphereStrideValue;
988
+ }
989
+
990
+ std::uint32_t rundot_kinetix_ext_rounded_convex_vertex_stride() {
991
+ return kRoundedConvexVertexStrideValue;
992
+ }
993
+
994
+ std::uint32_t rundot_kinetix_ext_rounded_convex_pose_stride() {
995
+ return kRoundedConvexPoseStrideValue;
996
+ }
997
+
998
+ std::uint32_t rundot_kinetix_ext_rounded_convex_direction_stride() {
999
+ return kRoundedConvexDirectionStrideValue;
1000
+ }
1001
+
1002
+ std::uint32_t rundot_kinetix_ext_rounded_convex_support_stride() {
1003
+ return kRoundedConvexSupportStrideValue;
1004
+ }
1005
+
1006
+ std::uint32_t rundot_kinetix_ext_rounded_convex_collision_stride() {
1007
+ return kRoundedConvexCollisionStrideValue;
1008
+ }
1009
+
1010
+ std::uint32_t rundot_kinetix_ext_rounded_convex_mass_properties_stride() {
1011
+ return kRoundedConvexMassPropsStrideValue;
1012
+ }
1013
+
1014
+ std::uint32_t rundot_kinetix_ext_rounded_convex_ray_stride() {
1015
+ return kRoundedConvexRayStrideValue;
1016
+ }
1017
+
1018
+ std::uint32_t rundot_kinetix_ext_rounded_convex_rayhit_stride() {
1019
+ return kRoundedConvexRayHitStrideValue;
1020
+ }
1021
+
1022
+ std::uint32_t rundot_kinetix_ext_rounded_convex_max_spheres() {
1023
+ return rundot::kinetix::physics::rounded_convex::kMultiSphereMaxSpheres;
1024
+ }
1025
+
1026
+ std::uint32_t rundot_kinetix_ext_rounded_convex_max_vertices() {
1027
+ return rundot::kinetix::physics::rounded_convex::kRoundedHullMaxVertices;
1028
+ }
1029
+
1030
+ std::uint32_t rundot_kinetix_ext_rounded_convex_input_stride() {
1031
+ return rundot::kinetix::physics::rounded_convex::kRoundedConvexInputStride;
1032
+ }
1033
+
1034
+ std::uint32_t rundot_kinetix_ext_rounded_convex_output_stride() {
1035
+ return rundot::kinetix::physics::rounded_convex::kRoundedConvexOutputStride;
1036
+ }
1037
+
1038
+ std::uint32_t rundot_kinetix_ext_rounded_convex_stride() {
1039
+ return rundot::kinetix::physics::rounded_convex::kRoundedConvexInputStride;
1040
+ }
1041
+
1042
+ std::uint32_t rundot_kinetix_ext_rounded_convex_size() {
1043
+ return rundot::kinetix::physics::rounded_convex::kRoundedConvexInputStride;
1044
+ }
1045
+
1046
+ std::int32_t rundot_kinetix_ext_rounded_convex_support(
1047
+ const double* verticesData,
1048
+ std::uint32_t vertexCount,
1049
+ double convexRadius,
1050
+ const double* poseData,
1051
+ const double* directionData,
1052
+ double* outSupportPoint) {
1053
+ return rundot_kinetix_physics_rounded_convex_support(
1054
+ verticesData, vertexCount, convexRadius, poseData, directionData, outSupportPoint);
1055
+ }
1056
+
1057
+ std::int32_t rundot_kinetix_ext_rounded_convex_multi_sphere_support(
1058
+ const double* spheresData,
1059
+ std::uint32_t sphereCount,
1060
+ const double* poseData,
1061
+ const double* directionData,
1062
+ double* outSupportPoint) {
1063
+ return rundot_kinetix_physics_multi_sphere_support(
1064
+ spheresData, sphereCount, poseData, directionData, outSupportPoint);
1065
+ }
1066
+
1067
+ std::int32_t rundot_kinetix_ext_rounded_convex_collide(
1068
+ const double* verticesA,
1069
+ std::uint32_t vertexCountA,
1070
+ double convexRadiusA,
1071
+ const double* poseA,
1072
+ const double* verticesB,
1073
+ std::uint32_t vertexCountB,
1074
+ double convexRadiusB,
1075
+ const double* poseB,
1076
+ double* outCollision) {
1077
+ return rundot_kinetix_physics_rounded_convex_collision(
1078
+ verticesA, vertexCountA, convexRadiusA, poseA,
1079
+ verticesB, vertexCountB, convexRadiusB, poseB, outCollision);
1080
+ }
1081
+
1082
+ std::int32_t rundot_kinetix_ext_rounded_convex_collision(
1083
+ const double* verticesA,
1084
+ std::uint32_t vertexCountA,
1085
+ double convexRadiusA,
1086
+ const double* poseA,
1087
+ const double* verticesB,
1088
+ std::uint32_t vertexCountB,
1089
+ double convexRadiusB,
1090
+ const double* poseB,
1091
+ double* outCollision) {
1092
+ return rundot_kinetix_ext_rounded_convex_collide(
1093
+ verticesA, vertexCountA, convexRadiusA, poseA,
1094
+ verticesB, vertexCountB, convexRadiusB, poseB, outCollision);
1095
+ }
1096
+
1097
+ std::int32_t rundot_kinetix_ext_rounded_convex_multi_sphere_collide(
1098
+ const double* spheresA,
1099
+ std::uint32_t sphereCountA,
1100
+ const double* poseA,
1101
+ const double* spheresB,
1102
+ std::uint32_t sphereCountB,
1103
+ const double* poseB,
1104
+ double* outCollision) {
1105
+ return rundot_kinetix_physics_multi_sphere_collision(
1106
+ spheresA, sphereCountA, poseA, spheresB, sphereCountB, poseB, outCollision);
1107
+ }
1108
+
1109
+ std::int32_t rundot_kinetix_ext_rounded_convex_multi_sphere_collision(
1110
+ const double* spheresA,
1111
+ std::uint32_t sphereCountA,
1112
+ const double* poseA,
1113
+ const double* spheresB,
1114
+ std::uint32_t sphereCountB,
1115
+ const double* poseB,
1116
+ double* outCollision) {
1117
+ return rundot_kinetix_ext_rounded_convex_multi_sphere_collide(
1118
+ spheresA, sphereCountA, poseA, spheresB, sphereCountB, poseB, outCollision);
1119
+ }
1120
+
1121
+ std::int32_t rundot_kinetix_ext_rounded_convex_compute_mass_properties(
1122
+ const double* verticesData,
1123
+ std::uint32_t vertexCount,
1124
+ double convexRadius,
1125
+ double density,
1126
+ double* outMassProperties) {
1127
+ return rundot_kinetix_physics_rounded_convex_mass_properties(
1128
+ verticesData, vertexCount, convexRadius, density, outMassProperties);
1129
+ }
1130
+
1131
+ std::int32_t rundot_kinetix_ext_rounded_convex_mass_properties(
1132
+ const double* verticesData,
1133
+ std::uint32_t vertexCount,
1134
+ double convexRadius,
1135
+ double density,
1136
+ double* outMassProperties) {
1137
+ return rundot_kinetix_ext_rounded_convex_compute_mass_properties(
1138
+ verticesData, vertexCount, convexRadius, density, outMassProperties);
1139
+ }
1140
+
1141
+ std::int32_t rundot_kinetix_ext_rounded_convex_multi_sphere_compute_mass_properties(
1142
+ const double* spheresData,
1143
+ std::uint32_t sphereCount,
1144
+ double density,
1145
+ double* outMassProperties) {
1146
+ return rundot_kinetix_physics_multi_sphere_mass_properties(
1147
+ spheresData, sphereCount, density, outMassProperties);
1148
+ }
1149
+
1150
+ std::int32_t rundot_kinetix_ext_rounded_convex_multi_sphere_mass_properties(
1151
+ const double* spheresData,
1152
+ std::uint32_t sphereCount,
1153
+ double density,
1154
+ double* outMassProperties) {
1155
+ return rundot_kinetix_ext_rounded_convex_multi_sphere_compute_mass_properties(
1156
+ spheresData, sphereCount, density, outMassProperties);
1157
+ }
1158
+
1159
+ std::int32_t rundot_kinetix_ext_rounded_convex_raycast(
1160
+ const double* verticesData,
1161
+ std::uint32_t vertexCount,
1162
+ double convexRadius,
1163
+ const double* poseData,
1164
+ const double* rayData,
1165
+ double* outHit) {
1166
+ return rundot_kinetix_physics_rounded_convex_raycast(
1167
+ verticesData, vertexCount, convexRadius, poseData, rayData, outHit);
1168
+ }
1169
+
1170
+ // ---------------------------------------------------------------------------
1171
+ // Surface Velocity and Contact Material Rules (G21)
1172
+ // ---------------------------------------------------------------------------
1173
+ std::uint32_t rundot_kinetix_ext_surface_velocity_record_stride() {
1174
+ return kSurfaceVelocityRecordStride;
1175
+ }
1176
+
1177
+ std::uint32_t rundot_kinetix_ext_surface_velocity_rule_stride() {
1178
+ return kContactMaterialRuleStride;
1179
+ }
1180
+
1181
+ std::uint32_t rundot_kinetix_ext_surface_velocity_properties_stride() {
1182
+ return kContactSurfacePropertiesStride;
1183
+ }
1184
+
1185
+ std::uint32_t rundot_kinetix_ext_surface_velocity_stride() {
1186
+ return kSurfaceVelocityRecordStride;
1187
+ }
1188
+
1189
+ std::uint32_t rundot_kinetix_ext_surface_velocity_size() {
1190
+ return kSurfaceVelocityRecordStride;
1191
+ }
1192
+
1193
+ std::int32_t rundot_kinetix_ext_surface_velocity_evaluate_rules(
1194
+ const double* ruleBuffer,
1195
+ std::uint32_t ruleCount,
1196
+ std::uint64_t bodyKeyA,
1197
+ std::uint64_t bodyKeyB,
1198
+ double defaultFrictionA,
1199
+ double defaultFrictionB,
1200
+ double defaultRestitutionA,
1201
+ double defaultRestitutionB,
1202
+ double* outputProps) {
1203
+ return rundot_kinetix_physics_evaluate_material_rule(
1204
+ ruleBuffer, ruleCount, bodyKeyA, bodyKeyB,
1205
+ defaultFrictionA, defaultFrictionB,
1206
+ defaultRestitutionA, defaultRestitutionB,
1207
+ outputProps);
1208
+ }
1209
+
1210
+ std::int32_t rundot_kinetix_ext_surface_velocity_solve_conveyor_friction(
1211
+ double relVelX, double relVelY, double relVelZ,
1212
+ double normalX, double normalY, double normalZ,
1213
+ double tangentMass1, double tangentMass2,
1214
+ double friction, double normalTotal,
1215
+ double bias1, double bias2,
1216
+ double inAccum1, double inAccum2,
1217
+ double* outAccum1, double* outAccum2,
1218
+ double* outDelta1, double* outDelta2) {
1219
+ return rundot_kinetix_physics_solve_conveyor_friction(
1220
+ relVelX, relVelY, relVelZ, normalX, normalY, normalZ,
1221
+ tangentMass1, tangentMass2, friction, normalTotal,
1222
+ bias1, bias2, inAccum1, inAccum2,
1223
+ outAccum1, outAccum2, outDelta1, outDelta2);
1224
+ }
1225
+
1226
+ std::int32_t rundot_kinetix_ext_surface_velocity_solve_friction(
1227
+ double relVelX, double relVelY, double relVelZ,
1228
+ double normalX, double normalY, double normalZ,
1229
+ double tangentMass1, double tangentMass2,
1230
+ double friction, double normalTotal,
1231
+ double bias1, double bias2,
1232
+ double inAccum1, double inAccum2,
1233
+ double* outAccum1, double* outAccum2,
1234
+ double* outDelta1, double* outDelta2) {
1235
+ return rundot_kinetix_ext_surface_velocity_solve_conveyor_friction(
1236
+ relVelX, relVelY, relVelZ, normalX, normalY, normalZ,
1237
+ tangentMass1, tangentMass2, friction, normalTotal,
1238
+ bias1, bias2, inAccum1, inAccum2,
1239
+ outAccum1, outAccum2, outDelta1, outDelta2);
1240
+ }
1241
+
1242
+ }