@woosh/meep-engine 3.44.0 → 3.46.0

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 (447) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/package.json +1 -1
  3. package/src/core/assert.d.ts.map +1 -1
  4. package/src/core/assert.js +5 -1
  5. package/src/core/binary/hash/XXH128Hash.d.ts +1 -37
  6. package/src/core/binary/hash/XXH128Hash.d.ts.map +1 -1
  7. package/src/core/binary/hash/XXH128Hash.js +4 -55
  8. package/src/core/binary/hash/XXH3_SECRET.d.ts +1 -12
  9. package/src/core/binary/hash/XXH3_SECRET.d.ts.map +1 -1
  10. package/src/core/binary/hash/XXH3_SECRET.js +4 -25
  11. package/src/core/binary/hash/crc32.d.ts +1 -15
  12. package/src/core/binary/hash/crc32.d.ts.map +1 -1
  13. package/src/core/binary/hash/crc32.js +4 -96
  14. package/src/core/binary/hash/xxh3_128.d.ts +1 -9
  15. package/src/core/binary/hash/xxh3_128.d.ts.map +1 -1
  16. package/src/core/binary/hash/xxh3_128.js +4 -341
  17. package/src/core/binary/hash/xxh3_64.d.ts +1 -8
  18. package/src/core/binary/hash/xxh3_64.d.ts.map +1 -1
  19. package/src/core/binary/hash/xxh3_64.js +4 -241
  20. package/src/core/binary/hash/xxh3_common.d.ts +1 -223
  21. package/src/core/binary/hash/xxh3_common.d.ts.map +1 -1
  22. package/src/core/binary/hash/xxh3_common.js +90 -476
  23. package/src/core/collection/array/array_sort_insertion_ascending.d.ts +19 -0
  24. package/src/core/collection/array/array_sort_insertion_ascending.d.ts.map +1 -0
  25. package/src/core/collection/array/array_sort_insertion_ascending.js +31 -0
  26. package/src/core/collection/array/combine_hash.d.ts +6 -0
  27. package/src/core/collection/array/combine_hash.d.ts.map +1 -1
  28. package/src/core/collection/array/combine_hash.js +6 -0
  29. package/src/core/function/FunctionCompiler.js +2 -2
  30. package/src/core/geom/3d/aabb/aabb3_array_round_outward_f32.d.ts +27 -0
  31. package/src/core/geom/3d/aabb/aabb3_array_round_outward_f32.d.ts.map +1 -0
  32. package/src/core/geom/3d/aabb/aabb3_array_round_outward_f32.js +39 -0
  33. package/src/core/geom/3d/aabb/aabb3_from_v3_array.d.ts.map +1 -1
  34. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +4 -1
  35. package/src/core/geom/3d/aabb/aabb3_transform_oriented.d.ts +2 -2
  36. package/src/core/geom/3d/aabb/aabb3_transform_oriented.d.ts.map +1 -1
  37. package/src/core/geom/3d/aabb/aabb3_transform_oriented.js +1 -1
  38. package/src/core/geom/3d/mat4/m4_multiply.d.ts +3 -0
  39. package/src/core/geom/3d/mat4/m4_multiply.d.ts.map +1 -1
  40. package/src/core/geom/3d/mat4/m4_multiply.js +3 -0
  41. package/src/core/geom/3d/mat4/m4_multiply_f64.d.ts +30 -0
  42. package/src/core/geom/3d/mat4/m4_multiply_f64.d.ts.map +1 -0
  43. package/src/core/geom/3d/mat4/m4_multiply_f64.js +106 -0
  44. package/src/core/geom/3d/pose/pose3_apply_inverse_point_array.d.ts +21 -0
  45. package/src/core/geom/3d/pose/pose3_apply_inverse_point_array.d.ts.map +1 -0
  46. package/src/core/geom/3d/pose/pose3_apply_inverse_point_array.js +36 -0
  47. package/src/core/geom/3d/pose/pose3_apply_point_array.d.ts +25 -0
  48. package/src/core/geom/3d/pose/pose3_apply_point_array.d.ts.map +1 -0
  49. package/src/core/geom/3d/pose/pose3_apply_point_array.js +40 -0
  50. package/src/core/geom/3d/pose/pose3_compose_array.d.ts +28 -0
  51. package/src/core/geom/3d/pose/pose3_compose_array.d.ts.map +1 -0
  52. package/src/core/geom/3d/pose/pose3_compose_array.js +41 -0
  53. package/src/core/geom/3d/pose/pose3_to_local_array.d.ts +29 -0
  54. package/src/core/geom/3d/pose/pose3_to_local_array.d.ts.map +1 -0
  55. package/src/core/geom/3d/pose/pose3_to_local_array.js +42 -0
  56. package/src/core/geom/3d/quaternion/quat3_clamp_angle_array.d.ts +28 -0
  57. package/src/core/geom/3d/quaternion/quat3_clamp_angle_array.d.ts.map +1 -0
  58. package/src/core/geom/3d/quaternion/quat3_clamp_angle_array.js +66 -0
  59. package/src/core/geom/3d/quaternion/quat3_multiply_conjugate_left_array.d.ts +22 -0
  60. package/src/core/geom/3d/quaternion/quat3_multiply_conjugate_left_array.d.ts.map +1 -0
  61. package/src/core/geom/3d/quaternion/quat3_multiply_conjugate_left_array.js +30 -0
  62. package/src/core/geom/3d/quaternion/quat3_multiply_conjugate_right_array.d.ts +23 -0
  63. package/src/core/geom/3d/quaternion/quat3_multiply_conjugate_right_array.d.ts.map +1 -0
  64. package/src/core/geom/3d/quaternion/quat3_multiply_conjugate_right_array.js +31 -0
  65. package/src/core/geom/3d/triangle/tri3_compute_normal_area_weighted_array.d.ts +26 -0
  66. package/src/core/geom/3d/triangle/tri3_compute_normal_area_weighted_array.d.ts.map +1 -0
  67. package/src/core/geom/3d/triangle/tri3_compute_normal_area_weighted_array.js +46 -0
  68. package/src/core/geom/ConicRay.js +2 -2
  69. package/src/core/geom/Vector4.d.ts.map +1 -1
  70. package/src/core/geom/Vector4.js +8 -5
  71. package/src/core/geom/vec3/v3_distance_array.d.ts +11 -0
  72. package/src/core/geom/vec3/v3_distance_array.d.ts.map +1 -0
  73. package/src/core/geom/vec3/v3_distance_array.js +19 -0
  74. package/src/core/geom/vec3/v3_normalize_array_checked.d.ts +23 -0
  75. package/src/core/geom/vec3/v3_normalize_array_checked.d.ts.map +1 -0
  76. package/src/core/geom/vec3/v3_normalize_array_checked.js +49 -0
  77. package/src/core/geom/vec3/v3_reject_array.d.ts +15 -0
  78. package/src/core/geom/vec3/v3_reject_array.d.ts.map +1 -0
  79. package/src/core/geom/vec3/v3_reject_array.js +32 -0
  80. package/src/core/graph/csr/csr_build_incidence.d.ts +26 -0
  81. package/src/core/graph/csr/csr_build_incidence.d.ts.map +1 -0
  82. package/src/core/graph/csr/csr_build_incidence.js +71 -0
  83. package/src/core/graph/csr/csr_graph_color_greedy.d.ts +25 -0
  84. package/src/core/graph/csr/csr_graph_color_greedy.d.ts.map +1 -0
  85. package/src/core/graph/csr/csr_graph_color_greedy.js +83 -0
  86. package/src/core/graph/csr/csr_graph_validate_coloring.d.ts +15 -0
  87. package/src/core/graph/csr/csr_graph_validate_coloring.d.ts.map +1 -0
  88. package/src/core/graph/csr/csr_graph_validate_coloring.js +33 -0
  89. package/src/core/math/hash/XXH128Hash.d.ts +38 -0
  90. package/src/core/math/hash/XXH128Hash.d.ts.map +1 -0
  91. package/src/core/math/hash/XXH128Hash.js +55 -0
  92. package/src/core/math/hash/XXH3_SECRET.d.ts +13 -0
  93. package/src/core/math/hash/XXH3_SECRET.d.ts.map +1 -0
  94. package/src/core/math/hash/XXH3_SECRET.js +25 -0
  95. package/src/core/math/hash/crc32.d.ts +16 -0
  96. package/src/core/math/hash/crc32.d.ts.map +1 -0
  97. package/src/core/math/hash/crc32.js +96 -0
  98. package/src/core/math/hash/xxh3_128.d.ts +10 -0
  99. package/src/core/math/hash/xxh3_128.d.ts.map +1 -0
  100. package/src/core/math/hash/xxh3_128.js +341 -0
  101. package/src/core/math/hash/xxh3_64.d.ts +9 -0
  102. package/src/core/math/hash/xxh3_64.d.ts.map +1 -0
  103. package/src/core/math/hash/xxh3_64.js +241 -0
  104. package/src/core/math/hash/xxh3_common.d.ts +224 -0
  105. package/src/core/math/hash/xxh3_common.d.ts.map +1 -0
  106. package/src/core/math/hash/xxh3_common.js +476 -0
  107. package/src/core/math/linalg/matrix_symmetric_3x3_solve_ldlt.d.ts +26 -0
  108. package/src/core/math/linalg/matrix_symmetric_3x3_solve_ldlt.d.ts.map +1 -0
  109. package/src/core/math/linalg/matrix_symmetric_3x3_solve_ldlt.js +71 -0
  110. package/src/core/math/lookup/ParameterLookupTable.js +2 -2
  111. package/src/core/math/max2_exact.d.ts +15 -0
  112. package/src/core/math/max2_exact.d.ts.map +1 -0
  113. package/src/core/math/max2_exact.js +30 -0
  114. package/src/core/math/min2_exact.d.ts +20 -0
  115. package/src/core/math/min2_exact.d.ts.map +1 -0
  116. package/src/core/math/min2_exact.js +35 -0
  117. package/src/core/model/node-graph/node/NodeInstancePortReference.js +2 -2
  118. package/src/core/model/reactive/model/ReactiveBinaryExpression.js +2 -2
  119. package/src/core/model/reactive/model/terminal/ReactiveReference.js +2 -2
  120. package/src/engine/asset/AssetDescription.js +2 -2
  121. package/src/engine/ecs/animation/Animation.js +2 -2
  122. package/src/engine/ecs/animation/AnimationClip.d.ts.map +1 -1
  123. package/src/engine/ecs/animation/AnimationClip.js +7 -5
  124. package/src/engine/ecs/gui/GUIElement.d.ts.map +1 -1
  125. package/src/engine/ecs/gui/GUIElement.js +7 -5
  126. package/src/engine/ecs/gui/hud/HeadsUpDisplay.js +2 -2
  127. package/src/engine/ecs/gui/position/ViewportPosition.d.ts.map +1 -1
  128. package/src/engine/ecs/gui/position/ViewportPosition.js +11 -7
  129. package/src/engine/ecs/ik/IKGoalSystem.d.ts.map +1 -1
  130. package/src/engine/ecs/ik/IKGoalSystem.js +3 -19
  131. package/src/engine/ecs/parent/parent_entity_model_of.d.ts +17 -0
  132. package/src/engine/ecs/parent/parent_entity_model_of.d.ts.map +1 -0
  133. package/src/engine/ecs/parent/parent_entity_model_of.js +26 -0
  134. package/src/engine/ecs/transform/Transform64.d.ts +1 -1
  135. package/src/engine/ecs/transform/Transform64.d.ts.map +1 -1
  136. package/src/engine/ecs/transform/Transform64.js +5 -4
  137. package/src/engine/ecs/transform/t64_read_pose_array.d.ts +15 -0
  138. package/src/engine/ecs/transform/t64_read_pose_array.d.ts.map +1 -0
  139. package/src/engine/ecs/transform/t64_read_pose_array.js +24 -0
  140. package/src/engine/graphics/ecs/animation/animator/AnimationClip.d.ts.map +1 -1
  141. package/src/engine/graphics/ecs/animation/animator/AnimationClip.js +8 -5
  142. package/src/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -2
  143. package/src/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -2
  144. package/src/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -2
  145. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -2
  146. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +2 -2
  147. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.d.ts.map +1 -1
  148. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +8 -5
  149. package/src/engine/graphics/ecs/decal/v2/Decal.d.ts.map +1 -1
  150. package/src/engine/graphics/ecs/decal/v2/Decal.js +9 -8
  151. package/src/engine/graphics/geometry/geometry_construct_triangle_normal_area_weighted.d.ts +2 -0
  152. package/src/engine/graphics/geometry/geometry_construct_triangle_normal_area_weighted.d.ts.map +1 -1
  153. package/src/engine/graphics/geometry/geometry_construct_triangle_normal_area_weighted.js +10 -21
  154. package/src/engine/graphics/render/frame_graph/resource/TextureResourceDescriptor.d.ts.map +1 -1
  155. package/src/engine/graphics/render/frame_graph/resource/TextureResourceDescriptor.js +9 -6
  156. package/src/engine/graphics3/AnimationGraphSystem.d.ts +5 -0
  157. package/src/engine/graphics3/AnimationGraphSystem.d.ts.map +1 -1
  158. package/src/engine/graphics3/AnimationGraphSystem.js +48 -2
  159. package/src/engine/graphics3/AnimationSystem.d.ts +5 -0
  160. package/src/engine/graphics3/AnimationSystem.d.ts.map +1 -1
  161. package/src/engine/graphics3/AnimationSystem.js +47 -2
  162. package/src/engine/graphics3/ParticipatingMedia.js +204 -204
  163. package/src/engine/graphics3/animation/AnimationClips.d.ts +5 -0
  164. package/src/engine/graphics3/animation/AnimationClips.d.ts.map +1 -1
  165. package/src/engine/graphics3/animation/AnimationClips.js +5 -0
  166. package/src/engine/graphics3/register_clips.d.ts +29 -0
  167. package/src/engine/graphics3/register_clips.d.ts.map +1 -1
  168. package/src/engine/graphics3/register_clips.js +52 -0
  169. package/src/engine/grid/obstacle/GridObstacle.js +2 -2
  170. package/src/engine/intelligence/behavior/selector/WeightedElement.js +2 -2
  171. package/src/engine/interpolation/Interpolated.js +2 -2
  172. package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts +9 -0
  173. package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts.map +1 -1
  174. package/src/engine/physics/broadphase/compute_fat_world_aabb.js +3 -1
  175. package/src/engine/physics/cloth/PLAN.md +10 -8
  176. package/src/engine/physics/cloth/build/cloth_bind_in_frame.d.ts +22 -0
  177. package/src/engine/physics/cloth/build/cloth_bind_in_frame.d.ts.map +1 -1
  178. package/src/engine/physics/cloth/build/cloth_bind_in_frame.js +51 -19
  179. package/src/engine/physics/cloth/build/cloth_proxy_from_joints.d.ts.map +1 -1
  180. package/src/engine/physics/cloth/build/cloth_proxy_from_joints.js +16 -2
  181. package/src/engine/physics/cloth/build/cloth_proxy_from_mesh.d.ts.map +1 -1
  182. package/src/engine/physics/cloth/build/cloth_proxy_from_mesh.js +19 -24
  183. package/src/engine/physics/cloth/collider/ClothColliderIndex.d.ts +7 -0
  184. package/src/engine/physics/cloth/collider/ClothColliderIndex.d.ts.map +1 -1
  185. package/src/engine/physics/cloth/collider/ClothColliderIndex.js +85 -67
  186. package/src/engine/physics/cloth/collider/cloth_collider_bounds.d.ts.map +1 -1
  187. package/src/engine/physics/cloth/collider/cloth_collider_bounds.js +19 -101
  188. package/src/engine/physics/cloth/collider/cloth_collider_pack.d.ts +2 -5
  189. package/src/engine/physics/cloth/collider/cloth_collider_pack.d.ts.map +1 -1
  190. package/src/engine/physics/cloth/collider/cloth_collider_pack.js +7 -15
  191. package/src/engine/physics/cloth/collider/cloth_collider_sdf.d.ts.map +1 -1
  192. package/src/engine/physics/cloth/collider/cloth_collider_sdf.js +16 -61
  193. package/src/engine/physics/cloth/ecs/Cloth.d.ts.map +1 -1
  194. package/src/engine/physics/cloth/ecs/Cloth.js +7 -5
  195. package/src/engine/physics/cloth/ecs/ClothCollider.d.ts.map +1 -1
  196. package/src/engine/physics/cloth/ecs/ClothCollider.js +7 -5
  197. package/src/engine/physics/cloth/ecs/ClothColliderFlags.d.ts +0 -1
  198. package/src/engine/physics/cloth/ecs/ClothColliderFlags.js +6 -19
  199. package/src/engine/physics/cloth/ecs/ClothColliderSystem.d.ts +1 -2
  200. package/src/engine/physics/cloth/ecs/ClothColliderSystem.d.ts.map +1 -1
  201. package/src/engine/physics/cloth/ecs/ClothColliderSystem.js +3 -12
  202. package/src/engine/physics/cloth/ecs/ClothDynamics.d.ts.map +1 -1
  203. package/src/engine/physics/cloth/ecs/ClothDynamics.js +20 -11
  204. package/src/engine/physics/cloth/ecs/ClothWorld.d.ts.map +1 -1
  205. package/src/engine/physics/cloth/ecs/ClothWorld.js +40 -130
  206. package/src/engine/physics/cloth/ecs/cloth_build_rows.d.ts.map +1 -1
  207. package/src/engine/physics/cloth/ecs/cloth_build_rows.js +17 -58
  208. package/src/engine/physics/cloth/ecs/cloth_dynamics_map.d.ts.map +1 -1
  209. package/src/engine/physics/cloth/ecs/cloth_dynamics_map.js +3 -3
  210. package/src/engine/physics/cloth/ecs/cloth_gather_colliders.d.ts.map +1 -1
  211. package/src/engine/physics/cloth/ecs/cloth_gather_colliders.js +44 -104
  212. package/src/engine/physics/cloth/ecs/cloth_geodesic.d.ts.map +1 -1
  213. package/src/engine/physics/cloth/ecs/cloth_geodesic.js +6 -13
  214. package/src/engine/physics/cloth/ecs/cloth_holds.d.ts.map +1 -1
  215. package/src/engine/physics/cloth/ecs/cloth_holds.js +15 -40
  216. package/src/engine/physics/cloth/ecs/cloth_reconstruct_pose.d.ts.map +1 -1
  217. package/src/engine/physics/cloth/ecs/cloth_reconstruct_pose.js +45 -79
  218. package/src/engine/physics/cloth/ecs/cloth_seed_subtree.d.ts.map +1 -1
  219. package/src/engine/physics/cloth/ecs/cloth_seed_subtree.js +7 -27
  220. package/src/engine/physics/cloth/ecs/cloth_write_back.d.ts.map +1 -1
  221. package/src/engine/physics/cloth/ecs/cloth_write_back.js +30 -62
  222. package/src/engine/physics/cloth/playground/cloth_playground_build.d.ts.map +1 -1
  223. package/src/engine/physics/cloth/playground/cloth_playground_build.js +2 -3
  224. package/src/engine/physics/cloth/playground/collide_main.js +2 -28
  225. package/src/engine/physics/cloth/playground/garment_main.js +4 -19
  226. package/src/engine/physics/cloth/playground/main.js +6 -48
  227. package/src/engine/physics/cloth/playground/rig_main.js +947 -955
  228. package/src/engine/physics/cloth/playground/wind_main.js +8 -7
  229. package/src/engine/physics/cloth/solver/ClothState.d.ts.map +1 -1
  230. package/src/engine/physics/cloth/solver/ClothState.js +16 -76
  231. package/src/engine/physics/cloth/solver/cloth_color_particles.d.ts +10 -8
  232. package/src/engine/physics/cloth/solver/cloth_color_particles.d.ts.map +1 -1
  233. package/src/engine/physics/cloth/solver/cloth_color_particles.js +30 -102
  234. package/src/engine/physics/cloth/solver/cloth_contact_find.d.ts.map +1 -1
  235. package/src/engine/physics/cloth/solver/cloth_contact_find.js +3 -2
  236. package/src/engine/physics/cloth/solver/cloth_hold_line.d.ts.map +1 -1
  237. package/src/engine/physics/cloth/solver/cloth_hold_line.js +2 -14
  238. package/src/engine/physics/cloth/solver/cloth_kinetic_energy.d.ts +21 -0
  239. package/src/engine/physics/cloth/solver/cloth_kinetic_energy.d.ts.map +1 -0
  240. package/src/engine/physics/cloth/solver/cloth_kinetic_energy.js +45 -0
  241. package/src/engine/physics/cloth/solver/cloth_particle_coupling.d.ts +32 -0
  242. package/src/engine/physics/cloth/solver/cloth_particle_coupling.d.ts.map +1 -0
  243. package/src/engine/physics/cloth/solver/cloth_particle_coupling.js +133 -0
  244. package/src/engine/physics/cloth/solver/cloth_particle_of_source.d.ts +16 -0
  245. package/src/engine/physics/cloth/solver/cloth_particle_of_source.d.ts.map +1 -0
  246. package/src/engine/physics/cloth/solver/cloth_particle_of_source.js +19 -0
  247. package/src/engine/physics/cloth/solver/cloth_self_find.d.ts.map +1 -1
  248. package/src/engine/physics/cloth/solver/cloth_self_find.js +6 -55
  249. package/src/engine/physics/cloth/solver/cloth_solve_vertex.d.ts.map +1 -1
  250. package/src/engine/physics/cloth/solver/cloth_solve_vertex.js +30 -65
  251. package/src/engine/physics/cloth/solver/cloth_step.d.ts.map +1 -1
  252. package/src/engine/physics/cloth/solver/cloth_step.js +6 -28
  253. package/src/engine/physics/cloth/solver/cloth_step_instance.d.ts.map +1 -1
  254. package/src/engine/physics/cloth/solver/cloth_step_instance.js +2 -3
  255. package/src/engine/physics/cloth/solver/cloth_stretch_residual.d.ts +21 -0
  256. package/src/engine/physics/cloth/solver/cloth_stretch_residual.d.ts.map +1 -0
  257. package/src/engine/physics/cloth/solver/cloth_stretch_residual.js +54 -0
  258. package/src/engine/physics/cloth/solver/cloth_vertex_accumulator.d.ts +15 -0
  259. package/src/engine/physics/cloth/solver/cloth_vertex_accumulator.d.ts.map +1 -1
  260. package/src/engine/physics/cloth/solver/cloth_vertex_accumulator.js +28 -0
  261. package/src/engine/physics/cloth/solver/cloth_worst_tether_ratio.d.ts +30 -0
  262. package/src/engine/physics/cloth/solver/cloth_worst_tether_ratio.d.ts.map +1 -0
  263. package/src/engine/physics/cloth/solver/cloth_worst_tether_ratio.js +56 -0
  264. package/src/engine/physics/cloth/solver/constraint/cloth_contact_row.d.ts.map +1 -1
  265. package/src/engine/physics/cloth/solver/constraint/cloth_contact_row.js +3 -17
  266. package/src/engine/physics/cloth/wind/ClothFluidWind.d.ts +2 -1
  267. package/src/engine/physics/cloth/wind/ClothFluidWind.d.ts.map +1 -1
  268. package/src/engine/physics/cloth/wind/ClothFluidWind.js +7 -25
  269. package/src/engine/physics/cloth/wind/cloth_sample_air.d.ts +3 -1
  270. package/src/engine/physics/cloth/wind/cloth_sample_air.d.ts.map +1 -1
  271. package/src/engine/physics/cloth/wind/cloth_sample_air.js +40 -62
  272. package/src/engine/physics/ecs/ContactProbeSystem.d.ts.map +1 -1
  273. package/src/engine/physics/ecs/ContactProbeSystem.js +2 -18
  274. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  275. package/src/engine/physics/ecs/PhysicsSystem.js +9 -50
  276. package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
  277. package/src/engine/physics/fluid/FluidField.js +7 -5
  278. package/src/engine/physics/fluid/ecs/FluidComponent.d.ts.map +1 -1
  279. package/src/engine/physics/fluid/ecs/FluidComponent.js +19 -11
  280. package/src/engine/physics/fluid/ecs/fluid_sample_domain_bounds.d.ts +24 -0
  281. package/src/engine/physics/fluid/ecs/fluid_sample_domain_bounds.d.ts.map +1 -0
  282. package/src/engine/physics/fluid/ecs/fluid_sample_domain_bounds.js +42 -0
  283. package/src/engine/physics/fluid/ecs/fluid_sample_velocity_world_mps.d.ts +25 -0
  284. package/src/engine/physics/fluid/ecs/fluid_sample_velocity_world_mps.d.ts.map +1 -0
  285. package/src/engine/physics/fluid/ecs/fluid_sample_velocity_world_mps.js +40 -0
  286. package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts +2 -2
  287. package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +2 -2
  288. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts.map +1 -1
  289. package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +11 -7
  290. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts.map +1 -1
  291. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.js +11 -7
  292. package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts.map +1 -1
  293. package/src/engine/physics/fluid/effector/WakeFluidEffector.js +16 -9
  294. package/src/engine/physics/inverse_kinematics/frame_fabrik/frame_fabrik_solve.d.ts.map +1 -1
  295. package/src/engine/physics/inverse_kinematics/frame_fabrik/frame_fabrik_solve.js +40 -90
  296. package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -1
  297. package/src/engine/physics/narrowphase/capsule_contacts.js +3 -5
  298. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.d.ts.map +1 -1
  299. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.js +2 -14
  300. package/src/engine/physics/narrowphase/hull_sphere_contact.d.ts.map +1 -1
  301. package/src/engine/physics/narrowphase/hull_sphere_contact.js +2 -5
  302. package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -1
  303. package/src/engine/physics/narrowphase/narrowphase_step.js +13 -32
  304. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -1
  305. package/src/engine/physics/narrowphase/sphere_box_contact.js +2 -5
  306. package/src/engine/sound/ecs/audio/AudioEmitter.d.ts.map +1 -1
  307. package/src/engine/sound/ecs/audio/AudioEmitter.js +12 -7
  308. package/src/engine/sound/ecs/trigger/AudioEventTrigger.d.ts.map +1 -1
  309. package/src/engine/sound/ecs/trigger/AudioEventTrigger.js +192 -191
  310. package/src/engine/sound/simulation/core/AcousticMedium.js +2 -2
  311. package/src/engine/sound/simulation/definition/AcousticDirectivity.js +2 -2
  312. package/src/engine/sound/simulation/definition/AcousticMaterial.d.ts.map +1 -1
  313. package/src/engine/sound/simulation/definition/AcousticMaterial.js +11 -7
  314. package/src/engine/sound/sopra/definition/BusDefinition.d.ts.map +1 -1
  315. package/src/engine/sound/sopra/definition/BusDefinition.js +5 -4
  316. package/src/engine/sound/sopra/definition/DuckingRule.d.ts.map +1 -1
  317. package/src/engine/sound/sopra/definition/DuckingRule.js +7 -5
  318. package/src/engine/sound/sopra/definition/EventDescription.d.ts.map +1 -1
  319. package/src/engine/sound/sopra/definition/EventDescription.js +23 -13
  320. package/src/engine/sound/sopra/definition/MixerSnapshot.js +2 -2
  321. package/src/engine/sound/sopra/definition/ParameterDefinition.d.ts.map +1 -1
  322. package/src/engine/sound/sopra/definition/ParameterDefinition.js +7 -5
  323. package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.js +2 -2
  324. package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.d.ts.map +1 -1
  325. package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.js +4 -3
  326. package/src/engine/sound/sopra/definition/clip/ContainerAudioClip.js +2 -2
  327. package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.js +3 -3
  328. package/src/engine/sound/sopra/definition/clip/SampleAudioClip.d.ts.map +1 -1
  329. package/src/engine/sound/sopra/definition/clip/SampleAudioClip.js +16 -9
  330. package/src/engine/sound/sopra/definition/clip/SilenceAudioClip.js +2 -2
  331. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts +1 -1
  332. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts.map +1 -1
  333. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.js +2 -2
  334. package/src/engine/sound/sopra/definition/effect/CompressorEffect.d.ts.map +1 -1
  335. package/src/engine/sound/sopra/definition/effect/CompressorEffect.js +7 -5
  336. package/src/engine/sound/sopra/definition/effect/EqEffect.d.ts.map +1 -1
  337. package/src/engine/sound/sopra/definition/effect/EqEffect.js +8 -5
  338. package/src/engine/sound/sopra/definition/effect/ReverbEffect.js +2 -2
  339. package/src/engine/sound/sopra/legacy/SoundEmitter.d.ts.map +1 -1
  340. package/src/engine/sound/sopra/legacy/SoundEmitter.js +357 -352
  341. package/src/engine/sound/sopra/legacy/SoundTrack.d.ts.map +1 -1
  342. package/src/engine/sound/sopra/legacy/SoundTrack.js +281 -278
  343. package/src/format/image/png/PNGReader.js +644 -644
  344. package/src/format/image/png/crc32.d.ts +1 -1
  345. package/src/format/image/png/crc32.js +7 -8
  346. package/src/format/texture/basis/transcode/etc1s_to_astc.d.ts.map +1 -1
  347. package/src/format/texture/basis/transcode/etc1s_to_astc.js +2 -1
  348. package/src/shade/descriptor/binding/BindGroupLayoutDescriptor.js +2 -2
  349. package/src/shade/descriptor/binding/BindGroupLayoutEntry.d.ts.map +1 -1
  350. package/src/shade/descriptor/binding/BindGroupLayoutEntry.js +12 -8
  351. package/src/shade/descriptor/binding/StorageTextureBindingLayout.js +2 -2
  352. package/src/shade/descriptor/binding/TextureBindingLayout.js +2 -2
  353. package/src/shade/descriptor/blend/BlendComponent.js +2 -2
  354. package/src/shade/descriptor/pipeline/PipelineDescriptorBase.js +2 -2
  355. package/src/shade/descriptor/pipeline/PipelineLayoutDescriptor.js +2 -2
  356. package/src/shade/descriptor/pipeline/ProgrammableStage.js +2 -2
  357. package/src/shade/descriptor/pipeline/compute/ComputePipelineDescriptor.js +2 -2
  358. package/src/shade/descriptor/pipeline/render/ColorTargetState.js +2 -2
  359. package/src/shade/descriptor/pipeline/render/FragmentState.js +2 -2
  360. package/src/shade/descriptor/pipeline/render/PrimitiveState.js +2 -2
  361. package/src/shade/descriptor/pipeline/render/RenderPipelineDescriptor.d.ts.map +1 -1
  362. package/src/shade/descriptor/pipeline/render/RenderPipelineDescriptor.js +8 -5
  363. package/src/shade/descriptor/pipeline/render/VertexAttribute.js +2 -2
  364. package/src/shade/descriptor/texture/SamplerDescriptor.d.ts.map +1 -1
  365. package/src/shade/descriptor/texture/SamplerDescriptor.js +20 -12
  366. package/src/shade/descriptor/texture/TextureDescriptor.d.ts.map +1 -1
  367. package/src/shade/descriptor/texture/TextureDescriptor.js +11 -7
  368. package/src/shade/device/graph/BufferResourceDescriptor.d.ts.map +1 -1
  369. package/src/shade/device/graph/BufferResourceDescriptor.js +196 -193
  370. package/src/shade/device/graph/TextureResourceDescriptor.d.ts.map +1 -1
  371. package/src/shade/device/graph/TextureResourceDescriptor.js +178 -173
  372. package/src/shade/device/timing/profile/sgpt_read_header.js +1 -1
  373. package/src/shade/device/timing/profile/sgpt_read_records.js +1 -1
  374. package/src/shade/device/timing/profile/sgpt_write_header.js +1 -1
  375. package/src/shade/device/timing/profile/sgpt_write_record.js +1 -1
  376. package/src/shade/playground/image_decode_bench/main.js +2 -1
  377. package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.d.ts.map +1 -1
  378. package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.js +2 -1
  379. package/src/shade/playground/skinned_mesh_soup/verify_clone_vertices.d.ts.map +1 -1
  380. package/src/shade/playground/skinned_mesh_soup/verify_clone_vertices.js +2 -1
  381. package/src/shade/playground/ssr_variance/statistics.d.ts.map +1 -1
  382. package/src/shade/playground/ssr_variance/statistics.js +2 -1
  383. package/src/shade/playground/texture_encode/main.d.ts.map +1 -1
  384. package/src/shade/playground/texture_encode/main.js +2 -1
  385. package/src/shade/playground/volumetrics_froxel/measure.d.ts.map +1 -1
  386. package/src/shade/playground/volumetrics_froxel/measure.js +2 -1
  387. package/src/shade/renderer/binding/BufferBinding.js +2 -2
  388. package/src/shade/renderer/buffer/table/gpu_database_check_links.d.ts.map +1 -1
  389. package/src/shade/renderer/buffer/table/gpu_database_check_links.js +2 -1
  390. package/src/shade/renderer/camera/Camera.js +2 -2
  391. package/src/shade/renderer/geometry/Attribute.js +2 -2
  392. package/src/shade/renderer/geometry/Geometry.js +2 -2
  393. package/src/shade/renderer/geometry/geometry_deduplicate_vertices.js +2 -2
  394. package/src/shade/renderer/geometry/meshlet/MeshletBatch.js +2 -2
  395. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts.map +1 -1
  396. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.js +3 -2
  397. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_leaf_frontier.d.ts.map +1 -1
  398. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_leaf_frontier.js +2 -1
  399. package/src/shade/renderer/geometry/virtual/build/level/vgeo_partition_into_groups.d.ts.map +1 -1
  400. package/src/shade/renderer/geometry/virtual/build/level/vgeo_partition_into_groups.js +2 -1
  401. package/src/shade/renderer/geometry/virtual/build/level/vgeo_run_round.d.ts.map +1 -1
  402. package/src/shade/renderer/geometry/virtual/build/level/vgeo_run_round.js +2 -1
  403. package/src/shade/renderer/geometry/virtual/build/level/vgeo_try_repack.d.ts.map +1 -1
  404. package/src/shade/renderer/geometry/virtual/build/level/vgeo_try_repack.js +3 -2
  405. package/src/shade/renderer/geometry/virtual/build/partition/vgeo_graph_components.d.ts.map +1 -1
  406. package/src/shade/renderer/geometry/virtual/build/partition/vgeo_graph_components.js +2 -1
  407. package/src/shade/renderer/geometry/virtual/build/partition/vgeo_split_face_set_packed.d.ts.map +1 -1
  408. package/src/shade/renderer/geometry/virtual/build/partition/vgeo_split_face_set_packed.js +2 -1
  409. package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_asset_id.js +13 -13
  410. package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_directory_block_checksum.js +41 -41
  411. package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_frame_checksum.js +41 -41
  412. package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_header_checksum.js +25 -25
  413. package/src/shade/renderer/geometry/virtual/format/vgeo_write_container.d.ts.map +1 -1
  414. package/src/shade/renderer/geometry/virtual/format/vgeo_write_container.js +3 -2
  415. package/src/shade/renderer/material/StandardShadeMaterial.d.ts.map +1 -1
  416. package/src/shade/renderer/material/StandardShadeMaterial.js +13 -8
  417. package/src/shade/renderer/particles/optimizer/dag/particle_vector_extract.d.ts.map +1 -1
  418. package/src/shade/renderer/particles/optimizer/dag/particle_vector_extract.js +3 -2
  419. package/src/shade/renderer/scene/optimization/geometry/internal/triangle_fingerprint_stream.d.ts.map +1 -1
  420. package/src/shade/renderer/scene/optimization/geometry/internal/triangle_fingerprint_stream.js +14 -5
  421. package/src/shade/renderer/scene/optimization/sampler2d_from_image_bitmap.js +1 -1
  422. package/src/shade/renderer/shader/type/WGSLStructField.js +2 -2
  423. package/src/shade/renderer/shader/type/WebGPUArray.js +2 -2
  424. package/src/shade/renderer/shader/type/WebGPUStruct.d.ts.map +1 -1
  425. package/src/shade/renderer/shader/type/WebGPUStruct.js +9 -6
  426. package/src/shade/renderer/texture/ShadeTexture.d.ts.map +1 -1
  427. package/src/shade/renderer/texture/ShadeTexture.js +17 -10
  428. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.js +2 -2
  429. package/src/shade/renderer/water/surface/chunk_water_surface_sample.d.ts +4 -4
  430. package/src/shade/renderer/water/surface/chunk_water_surface_sample.js +6 -6
  431. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.d.ts.map +1 -1
  432. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.js +46 -55
  433. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.d.ts +3 -3
  434. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.d.ts.map +1 -1
  435. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.js +14 -4
  436. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts +10 -1
  437. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts.map +1 -1
  438. package/src/shade/renderer/water/surface/particles/chunk_water_particle.js +82 -40
  439. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.d.ts +4 -1
  440. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.d.ts.map +1 -1
  441. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.js +8 -4
  442. package/src/shade/renderer/water/surface/particles/shader_water_particles.d.ts +98 -86
  443. package/src/shade/renderer/water/surface/particles/shader_water_particles.d.ts.map +1 -1
  444. package/src/shade/renderer/water/surface/particles/shader_water_particles.js +440 -298
  445. package/src/view/common/HTMLElementCacheKey.d.ts.map +1 -1
  446. package/src/view/common/HTMLElementCacheKey.js +4 -3
  447. package/src/view/minimap/MinimapMarker.js +2 -2
@@ -1,6 +1,7 @@
1
1
  import { EntityComponentDataset } from "../../../ecs/EntityComponentDataset.js";
2
2
  import { FluidComponent } from "../../fluid/ecs/FluidComponent.js";
3
3
  import { fluid_build_world_to_grid } from "../../fluid/ecs/fluid_build_world_to_grid.js";
4
+ import { fluid_sample_velocity_world_mps } from "../../fluid/ecs/fluid_sample_velocity_world_mps.js";
4
5
  import { CLOTH_DYNAMICS_BY_NAME } from "../ecs/cloth_dynamics_library.js";
5
6
  import { cloth_bend_ratio, cloth_drag_response } from "../ecs/cloth_dynamics_map.js";
6
7
  import { cloth_step } from "../solver/cloth_step.js";
@@ -389,14 +390,14 @@ function draw_field() {
389
390
  continue;
390
391
  }
391
392
 
392
- component.sampleVelocityAtWorld(sample, x, y, z);
393
+ // In metres a second, as `ClothFluidWind` reads it.
394
+ fluid_sample_velocity_world_mps(sample, 0, component, x, y, z);
393
395
 
394
- // Cells a second to metres a second, the same conversion
395
- // `ClothFluidWind` makes and for the same reason.
396
- const vx = sample[0] * cell_size;
397
- const vz = sample[2] * cell_size;
396
+ const vx = sample[0];
397
+ const vy = sample[1];
398
+ const vz = sample[2];
398
399
 
399
- const speed = Math.hypot(vx, sample[1] * cell_size, vz);
400
+ const speed = Math.hypot(vx, vy, vz);
400
401
 
401
402
  if (speed < 1e-3) {
402
403
  continue;
@@ -406,7 +407,7 @@ function draw_field() {
406
407
 
407
408
  const depth = project(from, camera, x, y, z, width, height);
408
409
 
409
- project(to, camera, x + vx * scale, y + sample[1] * cell_size * scale, z + vz * scale, width, height);
410
+ project(to, camera, x + vx * scale, y + vy * scale, z + vz * scale, width, height);
410
411
 
411
412
  if (depth <= 0) {
412
413
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"ClothState.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/cloth/solver/ClothState.js"],"names":[],"mappings":";;;8BAkHU,MAAM;;;;;;AAkBhB;;;GAGG;AACH,sCAFU,MAAM,CAEyB;AAEzC;IAyjBI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH;QAzB8C,QAAQ,EAA3C,YAAY,GAAC,MAAM,EAAE;QACc,YAAY,EAA/C,YAAY,GAAC,MAAM,EAAE;QACa,gBAAgB,GAAlD,UAAU,GAAC,MAAM,EAAE;QACiB,YAAY,GAAhD,YAAY,GAAC,MAAM,EAAE;QACe,iBAAiB,GAArD,YAAY,GAAC,MAAM,EAAE;QACe,iBAAiB,GAArD,YAAY,GAAC,MAAM,EAAE;QACe,iBAAiB,GAArD,YAAY,GAAC,MAAM,EAAE;QACa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;;;;;;;;;;;OAqBG;IACH,aAFU,MAAM,CAEA;IAEhB;;;;;;;;;;;;;;OAcG;IACH,WAFU,UAAU,CAEH;IAEjB;;;OAGG;IACH,YAFU,MAAM,CAED;IAEf;;;;;;;;;;OAUG;IACH,YAFU,YAAY,CAEJ;IAElB;;;;OAIG;IACH,cAFU,YAAY,CAEF;IAEpB;;;;;;;;;;OAUG;IACH,gBAFU,YAAY,CAEA;IAEtB;;;;;;;;;;;;;;;;;OAiBG;IACH,cAFU,YAAY,CAEF;IAEpB;;;;;;;;;;;;OAYG;IACH,kBAFU,YAAY,CAEE;IAExB;;;;;;;;;;OAUG;IACH,uBAFU,YAAY,CAEO;IAyN7B;;OAEG;IACH,kBAFa,OAAO,CAInB;IAED;;;;;;;;;;OAUG;IACH,uBAHa;QAAC,MAAM,EAAE,iBAAiB,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QACtF,UAAc,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAC,CAc1F;CA+BJ"}
@@ -1,6 +1,8 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
+ import { csr_build_incidence } from "../../../../core/graph/csr/csr_build_incidence.js";
2
3
  import { CCR_STRIDE } from "../collider/ClothColliderRecord.js";
3
4
  import { cloth_color_order, cloth_color_particles } from "./cloth_color_particles.js";
5
+ import { cloth_particle_of_source } from "./cloth_particle_of_source.js";
4
6
  import { CLOTH_COLLIDER_SLOTS } from "./cloth_solver_constants.js";
5
7
  import { CLOTH_SELF_PAIRS_PER_PARTICLE } from "./cloth_self_find.js";
6
8
  import { CLOTH_CONTACT_SLOTS } from "./constraint/cloth_contact_row.js";
@@ -787,9 +789,7 @@ export class ClothState {
787
789
  // `order` maps permuted → source; the rows need source → permuted.
788
790
  const particle_of_source = new Int32Array(particle_count);
789
791
 
790
- for (let i = 0; i < particle_count; i++) {
791
- particle_of_source[order[i]] = i;
792
- }
792
+ cloth_particle_of_source(particle_of_source, order, particle_count);
793
793
 
794
794
  const state = new ClothState();
795
795
 
@@ -852,9 +852,15 @@ export class ClothState {
852
852
  state.bend_penalty[row] = stiffness < Infinity ? stiffness : 0;
853
853
  }
854
854
 
855
- build_adjacency(
855
+ // Grouping the flat particle table gives the flat index `row·2 + slot`,
856
+ // which is the packed `(row << 1) | slot` the stretch accumulation
857
+ // decodes, already in ascending row order within each particle — so the
858
+ // row tables are walked forwards during a sweep even though the
859
+ // particles are in colour order. The bend table below is the same with
860
+ // `(row << 2) | slot`.
861
+ csr_build_incidence(
856
862
  state.stretch_adjacency_offset, state.stretch_adjacency,
857
- state.stretch_particle, stretch_count, 2, particle_count
863
+ state.stretch_particle, stretch_count * 2, particle_count
858
864
  );
859
865
 
860
866
  for (let row = 0; row < leash_count; row++) {
@@ -877,12 +883,13 @@ export class ClothState {
877
883
  : particle_of_source[leash_source[row]];
878
884
  }
879
885
 
880
- build_adjacency(
886
+ csr_build_incidence(
881
887
  state.bend_adjacency_offset, state.bend_adjacency,
882
- state.bend_particle, bend_count, 4, particle_count
888
+ state.bend_particle, bend_count * 4, particle_count
883
889
  );
884
890
 
885
- build_unary_adjacency(
891
+ // A unary row kind's flat index is its row index: nothing to unpack.
892
+ csr_build_incidence(
886
893
  state.leash_adjacency_offset, state.leash_adjacency,
887
894
  state.leash_particle, leash_count, particle_count
888
895
  );
@@ -904,7 +911,7 @@ export class ClothState {
904
911
  state.backstop_plane[row * 6 + 4] = 1;
905
912
  }
906
913
 
907
- build_unary_adjacency(
914
+ csr_build_incidence(
908
915
  state.backstop_adjacency_offset, state.backstop_adjacency,
909
916
  state.backstop_particle, backstop_count, particle_count
910
917
  );
@@ -1215,70 +1222,3 @@ function allocate(
1215
1222
 
1216
1223
  assert.equal(cursor, total, 'buffer cursor at end of allocation');
1217
1224
  }
1218
-
1219
- /**
1220
- * The {@link build_adjacency} of a **unary** row kind: one particle per row, so
1221
- * an entry is a bare row index rather than a packed `(row, slot)` pair and
1222
- * there is nothing to shift.
1223
- *
1224
- * @param {Int32Array} offset out, `particle_count + 1`
1225
- * @param {Int32Array} adjacency out, `row_count`
1226
- * @param {Int32Array} row_particle particle index per row
1227
- * @param {number} row_count
1228
- * @param {number} particle_count
1229
- * @private
1230
- */
1231
- function build_unary_adjacency(offset, adjacency, row_particle, row_count, particle_count) {
1232
- for (let row = 0; row < row_count; row++) {
1233
- offset[row_particle[row] + 1]++;
1234
- }
1235
-
1236
- for (let i = 0; i < particle_count; i++) {
1237
- offset[i + 1] += offset[i];
1238
- }
1239
-
1240
- const cursor = offset.slice(0, particle_count);
1241
-
1242
- for (let row = 0; row < row_count; row++) {
1243
- adjacency[cursor[row_particle[row]]++] = row;
1244
- }
1245
- }
1246
-
1247
- /**
1248
- * Counting sort of `(particle, row, slot)` incidences into CSR, with the slot
1249
- * folded into the low bits of each entry so the accumulation loop reads one
1250
- * word per row it touches.
1251
- *
1252
- * Entries within a particle come out in ascending row order, which keeps the
1253
- * row tables walked forwards during a sweep even though the particles are in
1254
- * colour order.
1255
- *
1256
- * @param {Int32Array} offset out, `particle_count + 1`
1257
- * @param {Int32Array} adjacency out, `row_count * arity`
1258
- * @param {Int32Array} row_particle particle indices, `arity` per row
1259
- * @param {number} row_count
1260
- * @param {number} arity 2 for stretch, 4 for bend
1261
- * @param {number} particle_count
1262
- * @private
1263
- */
1264
- function build_adjacency(offset, adjacency, row_particle, row_count, arity, particle_count) {
1265
- const shift = arity === 2 ? 1 : 2;
1266
-
1267
- for (let i = 0; i < row_count * arity; i++) {
1268
- offset[row_particle[i] + 1]++;
1269
- }
1270
-
1271
- for (let i = 0; i < particle_count; i++) {
1272
- offset[i + 1] += offset[i];
1273
- }
1274
-
1275
- const cursor = offset.slice(0, particle_count);
1276
-
1277
- for (let row = 0; row < row_count; row++) {
1278
- for (let slot = 0; slot < arity; slot++) {
1279
- const particle = row_particle[row * arity + slot];
1280
-
1281
- adjacency[cursor[particle]++] = (row << shift) | slot;
1282
- }
1283
- }
1284
- }
@@ -19,17 +19,19 @@
19
19
  * against 76 for its 14,802 tetrahedra — the same asymmetry, and the reason
20
20
  * this design colours vertices rather than constraints.
21
21
  *
22
- * This runs **once**, at build time, on a `Graph` object. The runtime never
23
- * sees a graph: {@link ClothState} bakes the result into a permuted particle
24
- * order plus a range per colour, so the sweep is a pair of nested counted
25
- * loops over contiguous indices.
22
+ * This runs **once**, at build time, on the sorted CSR adjacency
23
+ * {@link cloth_particle_coupling} builds — the same edge set the
24
+ * self-collision exclusions are. The runtime never sees a graph:
25
+ * {@link ClothState} bakes the result into a permuted particle order plus a
26
+ * range per colour, so the sweep is a pair of nested counted loops over
27
+ * contiguous indices.
26
28
  *
27
29
  * The greedy colouriser is fed a largest-degree-first order (Welsh–Powell),
28
30
  * which is the cheap heuristic that gets a regular triangulated sheet down to
29
- * the 8–10 colours §5.4 predicts. The result is checked with the engine's own
30
- * {@link validateGraphColoring} behind `assert.*`, so a colouring that would
31
- * let two coupled particles race is caught in a dev build and compiles out of
32
- * a shipped one.
31
+ * the 8–10 colours §5.4 predicts. The result is checked with
32
+ * {@link csr_graph_validate_coloring} behind `assert.*`, so a colouring that
33
+ * would let two coupled particles race is caught in a dev build and compiles
34
+ * out of a shipped one.
33
35
  *
34
36
  * @author Alex Goldring
35
37
  * @copyright Company Named Limited (c) 2026
@@ -1 +1 @@
1
- {"version":3,"file":"cloth_color_particles.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/cloth/solver/cloth_color_particles.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH;;;;;;;;;GASG;AACH,sDAPW,MAAM,oBACN,UAAU,GAAC,MAAM,EAAE,iBACnB,MAAM,iBACN,UAAU,GAAC,MAAM,EAAE,cACnB,MAAM,GACJ,WAAW,CAyFvB;AAmCD;;;;;;;;;;;;;GAaG;AACH,0CANW,WAAW,kBACX,MAAM,GACJ;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAC,CAmChF"}
1
+ {"version":3,"file":"cloth_color_particles.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/cloth/solver/cloth_color_particles.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;;;;;;GASG;AACH,sDAPW,MAAM,oBACN,UAAU,GAAC,MAAM,EAAE,iBACnB,MAAM,iBACN,UAAU,GAAC,MAAM,EAAE,cACnB,MAAM,GACJ,WAAW,CA+BvB;AA8BD;;;;;;;;;;;;;GAaG;AACH,0CANW,WAAW,kBACX,MAAM,GACJ;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAC,CAuBhF"}
@@ -1,7 +1,8 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
- import { colorizeGraphGreedy } from "../../../../core/graph/coloring/colorizeGraphGreedy.js";
3
- import { validateGraphColoring } from "../../../../core/graph/coloring/validateGraphColoring.js";
4
- import { Graph } from "../../../../core/graph/v2/Graph.js";
2
+ import { csr_build_incidence } from "../../../../core/graph/csr/csr_build_incidence.js";
3
+ import { csr_graph_color_greedy } from "../../../../core/graph/csr/csr_graph_color_greedy.js";
4
+ import { csr_graph_validate_coloring } from "../../../../core/graph/csr/csr_graph_validate_coloring.js";
5
+ import { cloth_particle_coupling } from "./cloth_particle_coupling.js";
5
6
 
6
7
  /**
7
8
  * # Particle-graph colouring for the cloth solver
@@ -24,17 +25,19 @@ import { Graph } from "../../../../core/graph/v2/Graph.js";
24
25
  * against 76 for its 14,802 tetrahedra — the same asymmetry, and the reason
25
26
  * this design colours vertices rather than constraints.
26
27
  *
27
- * This runs **once**, at build time, on a `Graph` object. The runtime never
28
- * sees a graph: {@link ClothState} bakes the result into a permuted particle
29
- * order plus a range per colour, so the sweep is a pair of nested counted
30
- * loops over contiguous indices.
28
+ * This runs **once**, at build time, on the sorted CSR adjacency
29
+ * {@link cloth_particle_coupling} builds — the same edge set the
30
+ * self-collision exclusions are. The runtime never sees a graph:
31
+ * {@link ClothState} bakes the result into a permuted particle order plus a
32
+ * range per colour, so the sweep is a pair of nested counted loops over
33
+ * contiguous indices.
31
34
  *
32
35
  * The greedy colouriser is fed a largest-degree-first order (Welsh–Powell),
33
36
  * which is the cheap heuristic that gets a regular triangulated sheet down to
34
- * the 8–10 colours §5.4 predicts. The result is checked with the engine's own
35
- * {@link validateGraphColoring} behind `assert.*`, so a colouring that would
36
- * let two coupled particles race is caught in a dev build and compiles out of
37
- * a shipped one.
37
+ * the 8–10 colours §5.4 predicts. The result is checked with
38
+ * {@link csr_graph_validate_coloring} behind `assert.*`, so a colouring that
39
+ * would let two coupled particles race is caught in a dev build and compiles
40
+ * out of a shipped one.
38
41
  *
39
42
  * @author Alex Goldring
40
43
  * @copyright Company Named Limited (c) 2026
@@ -56,83 +59,25 @@ export function cloth_color_particles(
56
59
  bend_particle, bend_count
57
60
  ) {
58
61
  assert.isNonNegativeInteger(particle_count, 'particle_count');
59
- assert.isNonNegativeInteger(stretch_count, 'stretch_count');
60
- assert.isNonNegativeInteger(bend_count, 'bend_count');
61
62
 
62
- if (particle_count === 0) {
63
- return new Uint32Array(0);
64
- }
65
-
66
- const graph = new Graph();
67
-
68
- // Nodes are the particle indices themselves, inserted in order, so the
69
- // colouriser's node array is the identity permutation and `colors[i]` is
70
- // the colour of particle `i` without a second lookup.
71
- for (let i = 0; i < particle_count; i++) {
72
- graph.addNode(i);
73
- }
74
-
75
- // `Graph#hasEdge` is identity-based, so the same pair added twice becomes
76
- // two edges and shows up twice in a neighbour list. A garment adds every
77
- // hinge's shared edge once as a stretch row and again as a bend pair, so
78
- // the duplicates are the common case rather than the exception; they cost
79
- // the colouriser a linear `indexOf` each. Fold them here instead.
80
- const seen = new Set();
81
-
82
- /**
83
- * @param {number} a
84
- * @param {number} b
85
- */
86
- const couple = (a, b) => {
87
- if (a === b) {
88
- return;
89
- }
90
-
91
- const key = a < b ? a * particle_count + b : b * particle_count + a;
63
+ const colors = new Uint32Array(particle_count);
92
64
 
93
- if (seen.has(key)) {
94
- return;
95
- }
96
-
97
- seen.add(key);
98
-
99
- graph.createEdge(a, b);
100
- };
101
-
102
- // A stretch row couples its two endpoints.
103
- for (let row = 0; row < stretch_count; row++) {
104
- const a = stretch_particle[row * 2];
105
- const b = stretch_particle[row * 2 + 1];
106
-
107
- assert.ok(a >= 0 && a < particle_count, `stretch row ${row} particle 0 (=${a}) out of range`);
108
- assert.ok(b >= 0 && b < particle_count, `stretch row ${row} particle 1 (=${b}) out of range`);
109
-
110
- couple(a, b);
65
+ if (particle_count === 0) {
66
+ return colors;
111
67
  }
112
68
 
113
- // A bend stencil couples all six pairs of its four particles — every one
114
- // of them appears in the same row, so any two of them writing at once is
115
- // the race the colouring exists to prevent.
116
- for (let row = 0; row < bend_count; row++) {
117
- const base = row * 4;
118
-
119
- for (let i = 0; i < 4; i++) {
120
- const a = bend_particle[base + i];
121
-
122
- assert.ok(a >= 0 && a < particle_count, `bend row ${row} particle ${i} (=${a}) out of range`);
123
-
124
- for (let j = i + 1; j < 4; j++) {
125
- couple(a, bend_particle[base + j]);
126
- }
127
- }
128
- }
69
+ const { offset, partner } = cloth_particle_coupling(
70
+ particle_count,
71
+ stretch_particle, stretch_count,
72
+ bend_particle, bend_count
73
+ );
129
74
 
130
- const order = order_by_descending_degree(graph, particle_count);
75
+ const order = order_by_descending_degree(offset, particle_count);
131
76
 
132
- const colors = colorizeGraphGreedy(graph, order);
77
+ csr_graph_color_greedy(colors, offset, partner, order, particle_count);
133
78
 
134
79
  assert.ok(
135
- validateGraphColoring(colors, graph),
80
+ csr_graph_validate_coloring(colors, offset, partner, particle_count),
136
81
  'cloth particle colouring is invalid — two coupled particles share a colour'
137
82
  );
138
83
 
@@ -147,18 +92,13 @@ export function cloth_color_particles(
147
92
  * Ties are broken by particle index so the ordering — and therefore the whole
148
93
  * baked layout — is a deterministic function of the topology alone.
149
94
  *
150
- * @param {Graph<number>} graph
95
+ * @param {Int32Array} offset CSR offsets of the deduplicated particle graph, so
96
+ * a row's length is the particle's degree
151
97
  * @param {number} particle_count
152
98
  * @returns {Uint32Array}
153
99
  * @private
154
100
  */
155
- function order_by_descending_degree(graph, particle_count) {
156
- const degree = new Int32Array(particle_count);
157
-
158
- for (let i = 0; i < particle_count; i++) {
159
- degree[i] = graph.getNeighbours(i).length;
160
- }
161
-
101
+ function order_by_descending_degree(offset, particle_count) {
162
102
  const order = new Uint32Array(particle_count);
163
103
 
164
104
  for (let i = 0; i < particle_count; i++) {
@@ -167,7 +107,7 @@ function order_by_descending_degree(graph, particle_count) {
167
107
 
168
108
  // `Array#sort` over a typed array is a numeric sort already; the comparator
169
109
  // is here for the tie-break, not for the ordering of the degrees.
170
- order.sort((a, b) => (degree[b] - degree[a]) || (a - b));
110
+ order.sort((a, b) => ((offset[b + 1] - offset[b]) - (offset[a + 1] - offset[a])) || (a - b));
171
111
 
172
112
  return order;
173
113
  }
@@ -200,21 +140,9 @@ export function cloth_color_order(colors, particle_count) {
200
140
  }
201
141
 
202
142
  const colour_offset = new Int32Array(colour_count + 1);
203
-
204
- for (let i = 0; i < particle_count; i++) {
205
- colour_offset[colors[i] + 1]++;
206
- }
207
-
208
- for (let c = 0; c < colour_count; c++) {
209
- colour_offset[c + 1] += colour_offset[c];
210
- }
211
-
212
- const cursor = colour_offset.slice(0, colour_count);
213
143
  const order = new Int32Array(particle_count);
214
144
 
215
- for (let i = 0; i < particle_count; i++) {
216
- order[cursor[colors[i]]++] = i;
217
- }
145
+ csr_build_incidence(colour_offset, order, colors, particle_count, colour_count);
218
146
 
219
147
  return { colour_count, colour_offset, order };
220
148
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cloth_contact_find.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/cloth/solver/cloth_contact_find.js"],"names":[],"mappings":"AAgHA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,6DAbW,YAAY,GAAC,YAAY,QACzB,UAAU,SACV,MAAM,MACN,MAAM,oBAGN,MAAM,GAKJ,MAAM,CAwLlB;AAvSD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AAEH;;;;;;;;;GASG;AACH,mCAFU,MAAM,CAEsB"}
1
+ {"version":3,"file":"cloth_contact_find.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/cloth/solver/cloth_contact_find.js"],"names":[],"mappings":"AAiHA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,6DAbW,YAAY,GAAC,YAAY,QACzB,UAAU,SACV,MAAM,MACN,MAAM,oBAGN,MAAM,GAKJ,MAAM,CAwLlB;AAvSD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AAEH;;;;;;;;;GASG;AACH,mCAFU,MAAM,CAEsB"}
@@ -1,3 +1,4 @@
1
+ import { v3_length } from "../../../../core/geom/vec3/v3_length.js";
1
2
  import {
2
3
  CCR_AABB_MAX_X,
3
4
  CCR_AABB_MAX_Y,
@@ -172,7 +173,7 @@ export function cloth_contact_find(state, table, keys, count, dt, kinematic_trav
172
173
  for (let record = 0; record < count; record++) {
173
174
  const r = record * CCR_STRIDE;
174
175
 
175
- TRAVEL[record] = Math.hypot(
176
+ TRAVEL[record] = v3_length(
176
177
  table[r + CCR_TX] - table[r + CCR_PREV_TX],
177
178
  table[r + CCR_TY] - table[r + CCR_PREV_TY],
178
179
  table[r + CCR_TZ] - table[r + CCR_PREV_TZ]
@@ -218,7 +219,7 @@ export function cloth_contact_find(state, table, keys, count, dt, kinematic_trav
218
219
  // How far this particle carries its current velocity across the step.
219
220
  // Hoisted out of the record loop: it is a property of the particle, and
220
221
  // the loop below is the hot one.
221
- const travel = dt * Math.hypot(velocity[p], velocity[p + 1], velocity[p + 2]) + kinematic_travel;
222
+ const travel = dt * v3_length(velocity[p], velocity[p + 1], velocity[p + 2]) + kinematic_travel;
222
223
 
223
224
  let found = 0;
224
225
 
@@ -1 +1 @@
1
- {"version":3,"file":"cloth_hold_line.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/cloth/solver/cloth_hold_line.js"],"names":[],"mappings":"AAyGA;;;;;;;;;;;;;;GAcG;AACH,0CAPW,YAAY,YACZ,YAAY,QACZ,UAAU,cACV,MAAM,GACJ,OAAO,CAiGnB;AAED;;;;;;;;;;GAUG;AACH,8DANW,YAAY,qBACZ,MAAM,kBACN,YAAY,GAAC,YAAY,GAAC,IAAI,GAE5B,MAAM,CAiIlB;AAjVD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEH;;;;;;;;;;;;;GAaG;AACH,wCAFU,MAAM,CAEkC;AAElD;;;GAGG;AACH,oCAFU,MAAM,CAEuB"}
1
+ {"version":3,"file":"cloth_hold_line.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/cloth/solver/cloth_hold_line.js"],"names":[],"mappings":"AAyGA;;;;;;;;;;;;;;GAcG;AACH,0CAPW,YAAY,YACZ,YAAY,QACZ,UAAU,cACV,MAAM,GACJ,OAAO,CAiGnB;AAED;;;;;;;;;;GAUG;AACH,8DANW,YAAY,qBACZ,MAAM,kBACN,YAAY,GAAC,YAAY,GAAC,IAAI,GAE5B,MAAM,CAqHlB;AArUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEH;;;;;;;;;;;;;GAaG;AACH,wCAFU,MAAM,CAEkC;AAElD;;;GAGG;AACH,oCAFU,MAAM,CAEuB"}
@@ -12,7 +12,7 @@ import {
12
12
  CVA_H_YZ,
13
13
  CVA_H_ZZ,
14
14
  CVA_STRIDE,
15
- CVA_TRUST
15
+ cloth_vertex_accumulator_seed
16
16
  } from "./cloth_vertex_accumulator.js";
17
17
 
18
18
  /**
@@ -268,19 +268,7 @@ export function cloth_hold_line_turn(state, line, inverse_h_squared, collider_ta
268
268
 
269
269
  // The vertex update's assembly, seeded the same way, with only the rows
270
270
  // the turn can see.
271
- const mass_over_h_squared = inverse_h_squared / inverse_mass;
272
-
273
- accumulator[CVA_F_X] = -mass_over_h_squared * (x - inertial[p]);
274
- accumulator[CVA_F_Y] = -mass_over_h_squared * (y - inertial[p + 1]);
275
- accumulator[CVA_F_Z] = -mass_over_h_squared * (z - inertial[p + 2]);
276
-
277
- accumulator[CVA_H_XX] = mass_over_h_squared;
278
- accumulator[CVA_H_YY] = mass_over_h_squared;
279
- accumulator[CVA_H_ZZ] = mass_over_h_squared;
280
- accumulator[CVA_H_XY] = 0;
281
- accumulator[CVA_H_XZ] = 0;
282
- accumulator[CVA_H_YZ] = 0;
283
- accumulator[CVA_TRUST] = Infinity;
271
+ cloth_vertex_accumulator_seed(accumulator, position, inertial, p, inverse_h_squared / inverse_mass);
284
272
 
285
273
  cloth_leash_accumulate(accumulator, state, i);
286
274
  cloth_backstop_accumulate(accumulator, state, i);
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Total kinetic energy of a cloth's free particles, `Σ ½·|v|²/w` over every
3
+ * particle with a non-zero inverse mass `w`, in joules.
4
+ *
5
+ * A held particle (`w = 0`) is skipped rather than treated as infinitely heavy:
6
+ * its velocity is whatever its holder gave it, and a cloth hanging still from a
7
+ * moving hand has come to rest in every sense §7 P5 means. A cloth that has
8
+ * settled reads zero and a cloth that is ringing does not, which is why the
9
+ * measurements read this rather than a displacement threshold.
10
+ *
11
+ * A diagnostic for specs, measurements and the playgrounds; nothing in the
12
+ * step reads it.
13
+ *
14
+ * @param {ClothState} state
15
+ * @returns {number} joules
16
+ *
17
+ * @author Alex Goldring
18
+ * @copyright Company Named Limited (c) 2026
19
+ */
20
+ export function cloth_kinetic_energy(state: ClothState): number;
21
+ //# sourceMappingURL=cloth_kinetic_energy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloth_kinetic_energy.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/cloth/solver/cloth_kinetic_energy.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,yDALa,MAAM,CA8BlB"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Total kinetic energy of a cloth's free particles, `Σ ½·|v|²/w` over every
3
+ * particle with a non-zero inverse mass `w`, in joules.
4
+ *
5
+ * A held particle (`w = 0`) is skipped rather than treated as infinitely heavy:
6
+ * its velocity is whatever its holder gave it, and a cloth hanging still from a
7
+ * moving hand has come to rest in every sense §7 P5 means. A cloth that has
8
+ * settled reads zero and a cloth that is ringing does not, which is why the
9
+ * measurements read this rather than a displacement threshold.
10
+ *
11
+ * A diagnostic for specs, measurements and the playgrounds; nothing in the
12
+ * step reads it.
13
+ *
14
+ * @param {ClothState} state
15
+ * @returns {number} joules
16
+ *
17
+ * @author Alex Goldring
18
+ * @copyright Company Named Limited (c) 2026
19
+ */
20
+ export function cloth_kinetic_energy(state) {
21
+ const particle_count = state.particle_count;
22
+
23
+ const mass_inverse = state.mass_inverse;
24
+ const velocity = state.velocity;
25
+
26
+ let energy = 0;
27
+
28
+ for (let i = 0; i < particle_count; i++) {
29
+ const w = mass_inverse[i];
30
+
31
+ if (w === 0) {
32
+ continue;
33
+ }
34
+
35
+ const p = i * 3;
36
+
37
+ const vx = velocity[p];
38
+ const vy = velocity[p + 1];
39
+ const vz = velocity[p + 2];
40
+
41
+ energy += 0.5 * (vx * vx + vy * vy + vz * vz) / w;
42
+ }
43
+
44
+ return energy;
45
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The particle graph a cloth's rows imply: an edge between every two particles
3
+ * that share a row, as a sorted CSR adjacency.
4
+ *
5
+ * A stretch row couples its two endpoints; a bend stencil couples all six pairs
6
+ * of its four particles, since every one of them appears in the same row. Two
7
+ * build-time consumers want exactly this set — the colouring, where an edge is
8
+ * a pair that must not be updated at once (`cloth_color_particles.js`), and the
9
+ * self-collision exclusions, where it is a pair a row already governs
10
+ * (`cloth_self_find.js`) — and this is the one place it is built.
11
+ *
12
+ * The set is deduplicated, because a garment adds every hinge's shared edge
13
+ * once as a stretch row and again as a bend pair, so duplicates are the common
14
+ * case; and a row that names one particle twice couples nothing. Each particle's
15
+ * partners come out ascending, which is the contract the exclusion scans read.
16
+ *
17
+ * Build-time only: it allocates its result and a scratch the size of the
18
+ * half-edge list.
19
+ *
20
+ * @param {number} particle_count
21
+ * @param {Int32Array|number[]} stretch_particle particle index pairs, 2 per row
22
+ * @param {number} stretch_count
23
+ * @param {Int32Array|number[]} bend_particle particle index quads, 4 per row
24
+ * @param {number} bend_count
25
+ * @returns {{offset: Int32Array, partner: Int32Array}} `partner[offset[i] .. offset[i + 1])` are the
26
+ * particles sharing a row with `i`, ascending, without `i` itself
27
+ */
28
+ export function cloth_particle_coupling(particle_count: number, stretch_particle: Int32Array | number[], stretch_count: number, bend_particle: Int32Array | number[], bend_count: number): {
29
+ offset: Int32Array;
30
+ partner: Int32Array;
31
+ };
32
+ //# sourceMappingURL=cloth_particle_coupling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloth_particle_coupling.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/cloth/solver/cloth_particle_coupling.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wDARW,MAAM,oBACN,UAAU,GAAC,MAAM,EAAE,iBACnB,MAAM,iBACN,UAAU,GAAC,MAAM,EAAE,cACnB,MAAM,GACJ;IAAC,MAAM,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAC,CAyGrD"}