@woosh/meep-engine 2.138.19 → 2.139.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 (496) hide show
  1. package/package.json +2 -1
  2. package/src/core/collection/PairUint32Map.d.ts +100 -0
  3. package/src/core/collection/PairUint32Map.d.ts.map +1 -0
  4. package/src/core/collection/PairUint32Map.js +321 -0
  5. package/src/core/collection/Uint32Map.d.ts +119 -0
  6. package/src/core/collection/Uint32Map.d.ts.map +1 -0
  7. package/src/core/collection/Uint32Map.js +345 -0
  8. package/src/core/collection/array/array_shuffle.d.ts +10 -3
  9. package/src/core/collection/array/array_shuffle.d.ts.map +1 -1
  10. package/src/core/collection/array/array_shuffle.js +27 -22
  11. package/src/core/collection/heap/FibonacciHeap.d.ts +195 -0
  12. package/src/core/collection/heap/FibonacciHeap.d.ts.map +1 -0
  13. package/src/core/collection/heap/FibonacciHeap.js +586 -0
  14. package/src/core/collection/heap/Uint32Heap.js +1 -1
  15. package/src/core/collection/heap/Uint32Heap4.d.ts +169 -0
  16. package/src/core/collection/heap/Uint32Heap4.d.ts.map +1 -0
  17. package/src/core/collection/heap/Uint32Heap4.js +490 -0
  18. package/src/core/geom/3d/line/line3_closest_points_segment_segment.d.ts +27 -0
  19. package/src/core/geom/3d/line/line3_closest_points_segment_segment.d.ts.map +1 -0
  20. package/src/core/geom/3d/line/line3_closest_points_segment_segment.js +88 -0
  21. package/src/core/geom/3d/shape/BoxShape3D.d.ts +61 -0
  22. package/src/core/geom/3d/shape/BoxShape3D.d.ts.map +1 -0
  23. package/src/core/geom/3d/shape/BoxShape3D.js +158 -0
  24. package/src/core/geom/3d/shape/CapsuleShape3D.d.ts +11 -0
  25. package/src/core/geom/3d/shape/CapsuleShape3D.d.ts.map +1 -1
  26. package/src/core/geom/3d/shape/CapsuleShape3D.js +12 -0
  27. package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts +37 -9
  28. package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts.map +1 -1
  29. package/src/core/geom/3d/shape/UnitCubeShape3D.js +45 -98
  30. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts +10 -0
  31. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
  32. package/src/core/geom/3d/shape/UnitSphereShape3D.js +11 -0
  33. package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts +61 -0
  34. package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts.map +1 -0
  35. package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.js +148 -0
  36. package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.d.ts +39 -0
  37. package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.d.ts.map +1 -0
  38. package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.js +147 -0
  39. package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.d.ts +15 -0
  40. package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.d.ts.map +1 -0
  41. package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.js +22 -0
  42. package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.d.ts +2 -0
  43. package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.d.ts.map +1 -0
  44. package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.js +673 -0
  45. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.d.ts +26 -0
  46. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.d.ts.map +1 -0
  47. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.js +222 -0
  48. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.d.ts +34 -0
  49. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.d.ts.map +1 -0
  50. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.js +146 -0
  51. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts +36 -0
  52. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts.map +1 -0
  53. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.js +232 -0
  54. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts +33 -0
  55. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts.map +1 -0
  56. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.js +255 -0
  57. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts +68 -0
  58. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts.map +1 -0
  59. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.js +365 -0
  60. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts +31 -0
  61. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts.map +1 -0
  62. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.js +112 -0
  63. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts +22 -0
  64. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts.map +1 -0
  65. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.js +55 -0
  66. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.d.ts +32 -0
  67. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.d.ts.map +1 -0
  68. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.js +66 -0
  69. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts +22 -0
  70. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts.map +1 -1
  71. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.js +49 -0
  72. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts +134 -0
  73. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts.map +1 -1
  74. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +276 -3
  75. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts +17 -0
  76. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts.map +1 -0
  77. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.js +135 -0
  78. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.d.ts +14 -0
  79. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.d.ts.map +1 -0
  80. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.js +177 -0
  81. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.d.ts.map +1 -1
  82. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.js +20 -4
  83. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts.map +1 -1
  84. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js +5 -3
  85. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.d.ts.map +1 -1
  86. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.js +9 -0
  87. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.d.ts.map +1 -1
  88. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.js +21 -45
  89. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.d.ts.map +1 -1
  90. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.js +7 -1
  91. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts +8 -6
  92. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts.map +1 -1
  93. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.js +8 -6
  94. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.d.ts +22 -0
  95. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.d.ts.map +1 -0
  96. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.js +73 -0
  97. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.d.ts.map +1 -1
  98. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.js +51 -1
  99. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts +10 -0
  100. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts.map +1 -0
  101. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.js +42 -0
  102. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.d.ts +28 -0
  103. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.d.ts.map +1 -0
  104. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.js +227 -0
  105. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.d.ts +13 -0
  106. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.d.ts.map +1 -0
  107. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.js +108 -0
  108. package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.d.ts +11 -0
  109. package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.d.ts.map +1 -0
  110. package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.js +20 -0
  111. package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.d.ts +20 -0
  112. package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.d.ts.map +1 -0
  113. package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.js +38 -0
  114. package/src/core/graph/csr/CSRGraph.d.ts +168 -0
  115. package/src/core/graph/csr/CSRGraph.d.ts.map +1 -0
  116. package/src/core/graph/csr/CSRGraph.js +319 -0
  117. package/src/core/graph/metis/cluster_mesh_metis.d.ts +12 -0
  118. package/src/core/graph/metis/cluster_mesh_metis.d.ts.map +1 -1
  119. package/src/core/graph/metis/cluster_mesh_metis.js +12 -0
  120. package/src/core/graph/metis/metis.d.ts +19 -0
  121. package/src/core/graph/metis/metis.d.ts.map +1 -1
  122. package/src/core/graph/metis/metis.js +20 -0
  123. package/src/core/graph/metis/metis_cluster_bs.d.ts +11 -0
  124. package/src/core/graph/metis/metis_cluster_bs.d.ts.map +1 -1
  125. package/src/core/graph/metis/metis_cluster_bs.js +11 -0
  126. package/src/core/graph/metis/metis_options.d.ts +17 -2
  127. package/src/core/graph/metis/metis_options.d.ts.map +1 -1
  128. package/src/core/graph/metis/metis_options.js +17 -2
  129. package/src/core/graph/metis/native/MetisGraph.d.ts +144 -0
  130. package/src/core/graph/metis/native/MetisGraph.d.ts.map +1 -0
  131. package/src/core/graph/metis/native/MetisGraph.js +212 -0
  132. package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts +72 -0
  133. package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts.map +1 -0
  134. package/src/core/graph/metis/native/bisection/BisectionScratch.js +101 -0
  135. package/src/core/graph/metis/native/bisection/bisect_graph.d.ts +37 -0
  136. package/src/core/graph/metis/native/bisection/bisect_graph.d.ts.map +1 -0
  137. package/src/core/graph/metis/native/bisection/bisect_graph.js +100 -0
  138. package/src/core/graph/metis/native/bisection/compute_2way_params.d.ts +15 -0
  139. package/src/core/graph/metis/native/bisection/compute_2way_params.d.ts.map +1 -0
  140. package/src/core/graph/metis/native/bisection/compute_2way_params.js +84 -0
  141. package/src/core/graph/metis/native/bisection/fm_2way.d.ts +30 -0
  142. package/src/core/graph/metis/native/bisection/fm_2way.d.ts.map +1 -0
  143. package/src/core/graph/metis/native/bisection/fm_2way.js +290 -0
  144. package/src/core/graph/metis/native/bisection/grow_bisection.d.ts +23 -0
  145. package/src/core/graph/metis/native/bisection/grow_bisection.d.ts.map +1 -0
  146. package/src/core/graph/metis/native/bisection/grow_bisection.js +137 -0
  147. package/src/core/graph/metis/native/bisection/split_graph_two_way.d.ts +28 -0
  148. package/src/core/graph/metis/native/bisection/split_graph_two_way.d.ts.map +1 -0
  149. package/src/core/graph/metis/native/bisection/split_graph_two_way.js +119 -0
  150. package/src/core/graph/metis/native/coarsen/coarsen_graph.d.ts +20 -0
  151. package/src/core/graph/metis/native/coarsen/coarsen_graph.d.ts.map +1 -0
  152. package/src/core/graph/metis/native/coarsen/coarsen_graph.js +94 -0
  153. package/src/core/graph/metis/native/coarsen/create_coarse_graph.d.ts +24 -0
  154. package/src/core/graph/metis/native/coarsen/create_coarse_graph.d.ts.map +1 -0
  155. package/src/core/graph/metis/native/coarsen/create_coarse_graph.js +158 -0
  156. package/src/core/graph/metis/native/coarsen/match_shem.d.ts +41 -0
  157. package/src/core/graph/metis/native/coarsen/match_shem.d.ts.map +1 -0
  158. package/src/core/graph/metis/native/coarsen/match_shem.js +175 -0
  159. package/src/core/graph/metis/native/initial/initial_kway_bfs.d.ts +24 -0
  160. package/src/core/graph/metis/native/initial/initial_kway_bfs.d.ts.map +1 -0
  161. package/src/core/graph/metis/native/initial/initial_kway_bfs.js +122 -0
  162. package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.d.ts +29 -0
  163. package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.d.ts.map +1 -0
  164. package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.js +170 -0
  165. package/src/core/graph/metis/native/metis_partition_kway.d.ts +41 -0
  166. package/src/core/graph/metis/native/metis_partition_kway.d.ts.map +1 -0
  167. package/src/core/graph/metis/native/metis_partition_kway.js +126 -0
  168. package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts +62 -0
  169. package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts.map +1 -0
  170. package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.js +261 -0
  171. package/src/core/graph/metis/native/refine/RefinementScratch.d.ts +45 -0
  172. package/src/core/graph/metis/native/refine/RefinementScratch.d.ts.map +1 -0
  173. package/src/core/graph/metis/native/refine/RefinementScratch.js +53 -0
  174. package/src/core/graph/metis/native/refine/compute_kway_params.d.ts +18 -0
  175. package/src/core/graph/metis/native/refine/compute_kway_params.d.ts.map +1 -0
  176. package/src/core/graph/metis/native/refine/compute_kway_params.js +138 -0
  177. package/src/core/graph/metis/native/refine/fm_kway.d.ts +63 -0
  178. package/src/core/graph/metis/native/refine/fm_kway.d.ts.map +1 -0
  179. package/src/core/graph/metis/native/refine/fm_kway.js +462 -0
  180. package/src/core/graph/metis/native/refine/project_kway.d.ts +22 -0
  181. package/src/core/graph/metis/native/refine/project_kway.d.ts.map +1 -0
  182. package/src/core/graph/metis/native/refine/project_kway.js +43 -0
  183. package/src/core/graph/metis/native/refine/refine_kway.d.ts +34 -0
  184. package/src/core/graph/metis/native/refine/refine_kway.d.ts.map +1 -0
  185. package/src/core/graph/metis/native/refine/refine_kway.js +43 -0
  186. package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts +2 -2
  187. package/src/core/math/linalg/eigen/matrix_householder_in_place.js +2 -2
  188. package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts +6 -4
  189. package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts.map +1 -1
  190. package/src/core/math/linalg/eigen/matrix_qr_in_place.js +69 -23
  191. package/src/engine/EngineHarness.d.ts +3 -1
  192. package/src/engine/EngineHarness.d.ts.map +1 -1
  193. package/src/engine/EngineHarness.js +6 -4
  194. package/src/engine/control/first-person/DESIGN.md +30 -6
  195. package/src/engine/control/first-person/DESIGN_EXTENSIONS.md +563 -0
  196. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +102 -9
  197. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
  198. package/src/engine/control/first-person/FirstPersonPlayerController.js +38 -3
  199. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts +533 -4
  200. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts.map +1 -1
  201. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.js +315 -6
  202. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +220 -22
  203. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
  204. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +858 -241
  205. package/src/engine/control/first-person/TODO.md +127 -0
  206. package/src/engine/control/first-person/abilities/Ability.d.ts +101 -0
  207. package/src/engine/control/first-person/abilities/Ability.d.ts.map +1 -0
  208. package/src/engine/control/first-person/abilities/Ability.js +119 -0
  209. package/src/engine/control/first-person/abilities/AbilitySet.d.ts +86 -0
  210. package/src/engine/control/first-person/abilities/AbilitySet.d.ts.map +1 -0
  211. package/src/engine/control/first-person/abilities/AbilitySet.js +185 -0
  212. package/src/engine/control/first-person/abilities/LedgeGrab.d.ts +62 -0
  213. package/src/engine/control/first-person/abilities/LedgeGrab.d.ts.map +1 -0
  214. package/src/engine/control/first-person/abilities/LedgeGrab.js +199 -0
  215. package/src/engine/control/first-person/abilities/Mantle.d.ts +45 -0
  216. package/src/engine/control/first-person/abilities/Mantle.d.ts.map +1 -0
  217. package/src/engine/control/first-person/abilities/Mantle.js +188 -0
  218. package/src/engine/control/first-person/abilities/Slide.d.ts +33 -0
  219. package/src/engine/control/first-person/abilities/Slide.d.ts.map +1 -0
  220. package/src/engine/control/first-person/abilities/Slide.js +158 -0
  221. package/src/engine/control/first-person/abilities/WallJump.d.ts +45 -0
  222. package/src/engine/control/first-person/abilities/WallJump.d.ts.map +1 -0
  223. package/src/engine/control/first-person/abilities/WallJump.js +131 -0
  224. package/src/engine/control/first-person/abilities/WallRun.d.ts +44 -0
  225. package/src/engine/control/first-person/abilities/WallRun.d.ts.map +1 -0
  226. package/src/engine/control/first-person/abilities/WallRun.js +180 -0
  227. package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts +49 -0
  228. package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts.map +1 -0
  229. package/src/engine/control/first-person/composer/EyeOffsetStack.js +60 -0
  230. package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.d.ts +100 -0
  231. package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.d.ts.map +1 -0
  232. package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.js +133 -0
  233. package/src/engine/control/first-person/mastery/DecisionPoint.d.ts +10 -0
  234. package/src/engine/control/first-person/mastery/DecisionPoint.d.ts.map +1 -0
  235. package/src/engine/control/first-person/mastery/DecisionPoint.js +30 -0
  236. package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.d.ts +61 -0
  237. package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.d.ts.map +1 -0
  238. package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.js +109 -0
  239. package/src/engine/control/first-person/mastery/MasteryEvaluator.d.ts +40 -0
  240. package/src/engine/control/first-person/mastery/MasteryEvaluator.d.ts.map +1 -0
  241. package/src/engine/control/first-person/mastery/MasteryEvaluator.js +45 -0
  242. package/src/engine/control/first-person/mastery/MasteryScore.d.ts +68 -0
  243. package/src/engine/control/first-person/mastery/MasteryScore.d.ts.map +1 -0
  244. package/src/engine/control/first-person/mastery/MasteryScore.js +100 -0
  245. package/src/engine/control/first-person/mastery/MasterySet.d.ts +60 -0
  246. package/src/engine/control/first-person/mastery/MasterySet.d.ts.map +1 -0
  247. package/src/engine/control/first-person/mastery/MasterySet.js +86 -0
  248. package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.d.ts +58 -0
  249. package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.d.ts.map +1 -0
  250. package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.js +83 -0
  251. package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.d.ts +69 -0
  252. package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.d.ts.map +1 -0
  253. package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.js +109 -0
  254. package/src/engine/control/first-person/math/Spring.d.ts +56 -0
  255. package/src/engine/control/first-person/math/Spring.d.ts.map +1 -0
  256. package/src/engine/control/first-person/math/Spring.js +71 -0
  257. package/src/engine/control/first-person/math/computeLRCBreathRate.d.ts +26 -0
  258. package/src/engine/control/first-person/math/computeLRCBreathRate.d.ts.map +1 -0
  259. package/src/engine/control/first-person/math/computeLRCBreathRate.js +41 -0
  260. package/src/engine/control/first-person/math/computeMassRatios.d.ts +35 -0
  261. package/src/engine/control/first-person/math/computeMassRatios.d.ts.map +1 -0
  262. package/src/engine/control/first-person/math/computeMassRatios.js +44 -0
  263. package/src/engine/control/first-person/pose/FirstPersonPose.d.ts +31 -1
  264. package/src/engine/control/first-person/pose/FirstPersonPose.d.ts.map +1 -1
  265. package/src/engine/control/first-person/pose/FirstPersonPose.js +49 -3
  266. package/src/engine/control/first-person/pose/FirstPersonPosture.d.ts +7 -0
  267. package/src/engine/control/first-person/pose/FirstPersonPosture.d.ts.map +1 -0
  268. package/src/engine/control/first-person/pose/FirstPersonPosture.js +27 -0
  269. package/src/engine/control/first-person/prototype_first_person_controller.js +550 -119
  270. package/src/engine/control/first-person/sensors/FirstPersonSensors.d.ts +58 -0
  271. package/src/engine/control/first-person/sensors/FirstPersonSensors.d.ts.map +1 -0
  272. package/src/engine/control/first-person/sensors/FirstPersonSensors.js +77 -0
  273. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts +80 -0
  274. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts.map +1 -0
  275. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.js +196 -0
  276. package/src/engine/control/first-person/test/buildTestPlayer.d.ts +20 -0
  277. package/src/engine/control/first-person/test/buildTestPlayer.d.ts.map +1 -0
  278. package/src/engine/control/first-person/test/buildTestPlayer.js +28 -0
  279. package/src/engine/ecs/EntityManager.d.ts +2 -2
  280. package/src/engine/ecs/EntityManager.d.ts.map +1 -1
  281. package/src/engine/ecs/EntityManager.js +13 -8
  282. package/src/engine/ecs/System.d.ts.map +1 -1
  283. package/src/engine/ecs/System.js +2 -2
  284. package/src/engine/graphics/camera/testClippingPlaneComputation.js +0 -2
  285. package/src/engine/graphics/ecs/light/Light.d.ts.map +1 -1
  286. package/src/engine/graphics/ecs/light/Light.js +27 -0
  287. package/src/engine/graphics/ecs/light/LightSystem.js +1 -1
  288. package/src/engine/graphics/ecs/path/PathDisplaySystem.d.ts.map +1 -1
  289. package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
  290. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +0 -2
  291. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -2
  292. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +0 -2
  293. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -2
  294. package/src/engine/navigation/grid/find_path_on_grid_astar.d.ts.map +1 -1
  295. package/src/engine/navigation/grid/find_path_on_grid_astar.js +11 -2
  296. package/src/engine/navigation/mesh/bt_mesh_face_find_path.d.ts.map +1 -1
  297. package/src/engine/navigation/mesh/bt_mesh_face_find_path.js +11 -1
  298. package/src/engine/physics/PLAN.md +236 -0
  299. package/src/engine/physics/body/BodyStorage.d.ts +187 -0
  300. package/src/engine/physics/body/BodyStorage.d.ts.map +1 -0
  301. package/src/engine/physics/body/BodyStorage.js +427 -0
  302. package/src/engine/physics/broadphase/PairList.d.ts +62 -0
  303. package/src/engine/physics/broadphase/PairList.d.ts.map +1 -0
  304. package/src/engine/physics/broadphase/PairList.js +97 -0
  305. package/src/engine/physics/broadphase/aabb_transform_oriented.d.ts +30 -0
  306. package/src/engine/physics/broadphase/aabb_transform_oriented.d.ts.map +1 -0
  307. package/src/engine/physics/broadphase/aabb_transform_oriented.js +93 -0
  308. package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts +16 -0
  309. package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts.map +1 -0
  310. package/src/engine/physics/broadphase/compute_fat_world_aabb.js +61 -0
  311. package/src/engine/physics/broadphase/generate_pairs.d.ts +38 -0
  312. package/src/engine/physics/broadphase/generate_pairs.d.ts.map +1 -0
  313. package/src/engine/physics/broadphase/generate_pairs.js +101 -0
  314. package/src/engine/physics/contact/ManifoldStore.d.ts +226 -0
  315. package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -0
  316. package/src/engine/physics/contact/ManifoldStore.js +499 -0
  317. package/src/engine/physics/ecs/BodyKind.d.ts +23 -0
  318. package/src/engine/physics/ecs/BodyKind.d.ts.map +1 -0
  319. package/src/engine/physics/ecs/BodyKind.js +24 -0
  320. package/src/engine/physics/ecs/Collider.d.ts +98 -0
  321. package/src/engine/physics/ecs/Collider.d.ts.map +1 -0
  322. package/src/engine/physics/ecs/Collider.js +136 -0
  323. package/src/engine/physics/ecs/ColliderFlags.d.ts +14 -0
  324. package/src/engine/physics/ecs/ColliderFlags.d.ts.map +1 -0
  325. package/src/engine/physics/ecs/ColliderFlags.js +15 -0
  326. package/src/engine/physics/ecs/ColliderObserverSystem.d.ts +58 -0
  327. package/src/engine/physics/ecs/ColliderObserverSystem.d.ts.map +1 -0
  328. package/src/engine/physics/ecs/ColliderObserverSystem.js +103 -0
  329. package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts +25 -0
  330. package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts.map +1 -0
  331. package/src/engine/physics/ecs/ColliderSerializationAdapter.js +37 -0
  332. package/src/engine/physics/ecs/PhysicsEvents.d.ts +15 -0
  333. package/src/engine/physics/ecs/PhysicsEvents.d.ts.map +1 -0
  334. package/src/engine/physics/ecs/PhysicsEvents.js +16 -0
  335. package/src/engine/physics/ecs/PhysicsSystem.d.ts +520 -0
  336. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -0
  337. package/src/engine/physics/ecs/PhysicsSystem.js +1159 -0
  338. package/src/engine/physics/ecs/RigidBody.d.ts +197 -0
  339. package/src/engine/physics/ecs/RigidBody.d.ts.map +1 -0
  340. package/src/engine/physics/ecs/RigidBody.js +240 -0
  341. package/src/engine/physics/ecs/RigidBodyFlags.d.ts +21 -0
  342. package/src/engine/physics/ecs/RigidBodyFlags.d.ts.map +1 -0
  343. package/src/engine/physics/ecs/RigidBodyFlags.js +22 -0
  344. package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts +28 -0
  345. package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts.map +1 -0
  346. package/src/engine/physics/ecs/RigidBodySerializationAdapter.js +81 -0
  347. package/src/engine/physics/ecs/SleepState.d.ts +11 -0
  348. package/src/engine/physics/ecs/SleepState.d.ts.map +1 -0
  349. package/src/engine/physics/ecs/SleepState.js +12 -0
  350. package/src/engine/physics/events/ContactEventBuffer.d.ts +46 -0
  351. package/src/engine/physics/events/ContactEventBuffer.d.ts.map +1 -0
  352. package/src/engine/physics/events/ContactEventBuffer.js +83 -0
  353. package/src/engine/physics/events/diff_manifolds.d.ts +25 -0
  354. package/src/engine/physics/events/diff_manifolds.d.ts.map +1 -0
  355. package/src/engine/physics/events/diff_manifolds.js +50 -0
  356. package/src/engine/physics/fluid/FluidField.d.ts +294 -16
  357. package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
  358. package/src/engine/physics/fluid/FluidField.js +510 -66
  359. package/src/engine/physics/fluid/FluidSimulator.d.ts +188 -5
  360. package/src/engine/physics/fluid/FluidSimulator.d.ts.map +1 -1
  361. package/src/engine/physics/fluid/FluidSimulator.js +455 -95
  362. package/src/engine/physics/fluid/SliceVisualiser.d.ts +29 -6
  363. package/src/engine/physics/fluid/SliceVisualiser.d.ts.map +1 -1
  364. package/src/engine/physics/fluid/SliceVisualiser.js +190 -165
  365. package/src/engine/physics/fluid/ecs/FluidComponent.d.ts +154 -0
  366. package/src/engine/physics/fluid/ecs/FluidComponent.d.ts.map +1 -0
  367. package/src/engine/physics/fluid/ecs/FluidComponent.js +238 -0
  368. package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.d.ts +45 -0
  369. package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.d.ts.map +1 -0
  370. package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.js +89 -0
  371. package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +107 -0
  372. package/src/engine/physics/fluid/ecs/FluidSystem.d.ts.map +1 -0
  373. package/src/engine/physics/fluid/ecs/FluidSystem.js +278 -0
  374. package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts +62 -1
  375. package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts.map +1 -1
  376. package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +81 -6
  377. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts +17 -4
  378. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts.map +1 -1
  379. package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +105 -12
  380. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts +43 -0
  381. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts.map +1 -0
  382. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.js +210 -0
  383. package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts +62 -1
  384. package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts.map +1 -1
  385. package/src/engine/physics/fluid/effector/WakeFluidEffector.js +302 -8
  386. package/src/engine/physics/fluid/prototype.js +102 -91
  387. package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts +33 -0
  388. package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts.map +1 -0
  389. package/src/engine/physics/fluid/solver/optimal_sor_omega.js +41 -0
  390. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts +20 -5
  391. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts.map +1 -1
  392. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.js +60 -38
  393. package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts +25 -4
  394. package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts.map +1 -1
  395. package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.js +93 -73
  396. package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.d.ts +23 -0
  397. package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.d.ts.map +1 -0
  398. package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.js +60 -0
  399. package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts +23 -0
  400. package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts.map +1 -0
  401. package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.js +68 -0
  402. package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts +30 -0
  403. package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts.map +1 -0
  404. package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.js +66 -0
  405. package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.d.ts +26 -0
  406. package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.d.ts.map +1 -0
  407. package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.js +113 -0
  408. package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.d.ts +30 -0
  409. package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.d.ts.map +1 -0
  410. package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.js +107 -0
  411. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts +49 -0
  412. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts.map +1 -0
  413. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.js +126 -0
  414. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts +93 -0
  415. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts.map +1 -0
  416. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.js +424 -0
  417. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.d.ts +20 -0
  418. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.d.ts.map +1 -0
  419. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.js +83 -0
  420. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts +26 -0
  421. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts.map +1 -0
  422. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.js +70 -0
  423. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +1 -1
  424. package/src/engine/physics/gjk/expanding_polytope_algorithm.js +8 -10
  425. package/src/engine/physics/inertia/world_inverse_inertia.d.ts +29 -0
  426. package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -0
  427. package/src/engine/physics/inertia/world_inverse_inertia.js +79 -0
  428. package/src/engine/physics/integration/integrate_position.d.ts +16 -0
  429. package/src/engine/physics/integration/integrate_position.d.ts.map +1 -0
  430. package/src/engine/physics/integration/integrate_position.js +48 -0
  431. package/src/engine/physics/integration/integrate_velocity.d.ts +25 -0
  432. package/src/engine/physics/integration/integrate_velocity.d.ts.map +1 -0
  433. package/src/engine/physics/integration/integrate_velocity.js +79 -0
  434. package/src/engine/physics/integration/quat_integrate.d.ts +27 -0
  435. package/src/engine/physics/integration/quat_integrate.d.ts.map +1 -0
  436. package/src/engine/physics/integration/quat_integrate.js +62 -0
  437. package/src/engine/physics/island/IslandBuilder.d.ts +167 -0
  438. package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -0
  439. package/src/engine/physics/island/IslandBuilder.js +411 -0
  440. package/src/engine/physics/island/union_find.d.ts +51 -0
  441. package/src/engine/physics/island/union_find.d.ts.map +1 -0
  442. package/src/engine/physics/island/union_find.js +76 -0
  443. package/src/engine/physics/narrowphase/PosedShape.d.ts +59 -0
  444. package/src/engine/physics/narrowphase/PosedShape.d.ts.map +1 -0
  445. package/src/engine/physics/narrowphase/PosedShape.js +110 -0
  446. package/src/engine/physics/narrowphase/box_box_manifold.d.ts +32 -0
  447. package/src/engine/physics/narrowphase/box_box_manifold.d.ts.map +1 -0
  448. package/src/engine/physics/narrowphase/box_box_manifold.js +543 -0
  449. package/src/engine/physics/narrowphase/capsule_contacts.d.ts +122 -0
  450. package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -0
  451. package/src/engine/physics/narrowphase/capsule_contacts.js +508 -0
  452. package/src/engine/physics/narrowphase/narrowphase_step.d.ts +11 -0
  453. package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -0
  454. package/src/engine/physics/narrowphase/narrowphase_step.js +382 -0
  455. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts +38 -0
  456. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -0
  457. package/src/engine/physics/narrowphase/sphere_box_contact.js +130 -0
  458. package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts +26 -0
  459. package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts.map +1 -0
  460. package/src/engine/physics/narrowphase/sphere_sphere_contact.js +51 -0
  461. package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts +83 -0
  462. package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts.map +1 -0
  463. package/src/engine/physics/queries/PhysicsSurfacePoint.js +100 -0
  464. package/src/engine/physics/queries/raycast.d.ts +20 -0
  465. package/src/engine/physics/queries/raycast.d.ts.map +1 -0
  466. package/src/engine/physics/queries/raycast.js +249 -0
  467. package/src/engine/physics/solver/friction_cone.d.ts +16 -0
  468. package/src/engine/physics/solver/friction_cone.d.ts.map +1 -0
  469. package/src/engine/physics/solver/friction_cone.js +37 -0
  470. package/src/engine/physics/solver/solve_contacts.d.ts +36 -0
  471. package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -0
  472. package/src/engine/physics/solver/solve_contacts.js +598 -0
  473. package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts +0 -34
  474. package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts.map +0 -1
  475. package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.js +0 -66
  476. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts +0 -2
  477. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts.map +0 -1
  478. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.js +0 -54
  479. package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts +0 -2
  480. package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts.map +0 -1
  481. package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.js +0 -26
  482. package/src/engine/ecs/components/Motion.d.ts +0 -21
  483. package/src/engine/ecs/components/Motion.d.ts.map +0 -1
  484. package/src/engine/ecs/components/Motion.js +0 -27
  485. package/src/engine/ecs/components/MotionSerializationAdapter.d.ts +0 -20
  486. package/src/engine/ecs/components/MotionSerializationAdapter.d.ts.map +0 -1
  487. package/src/engine/ecs/components/MotionSerializationAdapter.js +0 -26
  488. package/src/engine/ecs/systems/MotionSystem.d.ts +0 -9
  489. package/src/engine/ecs/systems/MotionSystem.d.ts.map +0 -1
  490. package/src/engine/ecs/systems/MotionSystem.js +0 -29
  491. package/src/engine/physics/fluid/Fluid.d.ts +0 -26
  492. package/src/engine/physics/fluid/Fluid.d.ts.map +0 -1
  493. package/src/engine/physics/fluid/Fluid.js +0 -221
  494. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.d.ts +0 -7
  495. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.d.ts.map +0 -1
  496. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.js +0 -8
@@ -0,0 +1,365 @@
1
+ import { assert } from "../../../assert.js";
2
+ import { compute_tetrahedron_quality } from "./compute_tetrahedron_quality.js";
3
+ import {
4
+ tetrahedral_mesh_find_tets_around_edge
5
+ } from "./tetrahedral_mesh_find_tets_around_edge.js";
6
+ import {
7
+ tetrahedral_mesh_find_tets_attached_to_vertex
8
+ } from "./tetrahedral_mesh_find_tets_attached_to_vertex.js";
9
+ import { tetrahedral_mesh_flip_23 } from "./tetrahedral_mesh_flip_23.js";
10
+ import { tetrahedral_mesh_flip_32 } from "./tetrahedral_mesh_flip_32.js";
11
+ import {
12
+ tetrahedral_mesh_smooth_vertex
13
+ } from "./tetrahedral_mesh_smooth_vertex.js";
14
+ import {
15
+ tetrahedral_mesh_vertex_is_boundary
16
+ } from "./tetrahedral_mesh_vertex_is_boundary.js";
17
+ import { tetrahedron_compute_quality } from "./tetrahedron_compute_quality.js";
18
+ import { INVALID_NEIGHBOUR } from "./TetrahedralMesh.js";
19
+
20
+ // Face-vertex layout for a positively-oriented tet (identical to the
21
+ // table inside tetrahedral_mesh_flip_23.js). Inlined here so we can score
22
+ // a hypothetical 2-3 flip without doing-and-undoing it on the live mesh.
23
+ const FACE_VERTICES_BY_OPPOSITE = [
24
+ [1, 3, 2],
25
+ [0, 2, 3],
26
+ [0, 3, 1],
27
+ [0, 1, 2],
28
+ ];
29
+
30
+ // Scratch for the 2-3 / 3-2 flip out-parameters and for collecting tets
31
+ // during local quality re-evaluation. Module-level — the driver is not
32
+ // re-entrant.
33
+ const scratch_out_23 = new Uint32Array(3);
34
+ const scratch_out_32 = new Uint32Array(2);
35
+ const scratch_edge_ring = new Array(16);
36
+ const scratch_ring_closed = [0];
37
+ let scratch_local_tets = new Array(64);
38
+
39
+ // The 6 unique vertex-pair (i, j) slots in a 4-vertex tet, enumerating
40
+ // every edge once. Used to iterate the 6 edges of a candidate tet during
41
+ // 3-2 flip search.
42
+ const EDGE_SLOT_PAIRS = [
43
+ [0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3],
44
+ ];
45
+
46
+ /**
47
+ * Driver: improve the shape quality of an existing tetrahedral mesh by
48
+ * locally smoothing low-quality tets and applying 2-3 / 3-2 flips that
49
+ * monotonically increase the per-tet minimum quality.
50
+ *
51
+ * Algorithm — one pass:
52
+ * 1. Scan every live tet, compute its radius-ratio quality.
53
+ * 2. For each tet below `target_quality`, try in order:
54
+ * a. Laplacian smoothing on each non-boundary vertex. Accept the
55
+ * move only if the worst-of-the-1-ring quality strictly improves;
56
+ * otherwise revert the position.
57
+ * b. 2-3 flip across each of the tet's 4 internal faces. Tentatively
58
+ * apply the flip, score the 3 new tets; accept only if the
59
+ * minimum-of-three exceeds the original min-of-two. Otherwise
60
+ * apply the inverse 3-2 flip to roll back.
61
+ * 3. Repeat until no operation in a pass improves anything, or
62
+ * `max_passes` is reached.
63
+ *
64
+ * The "do then maybe undo" pattern for flips keeps the driver simple: no
65
+ * separate "preview the flip" code path. The cost is a wasted reverse-flip
66
+ * per rejected candidate. In practice most candidate flips on bad tets are
67
+ * either clearly beneficial (accepted) or clearly bad (rejected after one
68
+ * round-trip), so the overhead is small.
69
+ *
70
+ * Mesh topology and points are mutated in place. Surface vertices (any
71
+ * vertex incident to a face with INVALID_NEIGHBOUR) are NEVER moved by
72
+ * smoothing — moving them would change the surface shape, which is
73
+ * usually a hard constraint for the caller.
74
+ *
75
+ * @param {TetrahedralMesh} mesh — mutated in place
76
+ * @param {Float32Array|number[]} points — flat (x,y,z) positions, mutated
77
+ * @param {{
78
+ * target_quality?: number,
79
+ * max_passes?: number,
80
+ * smoothing_weight?: number,
81
+ * enable_flips?: boolean,
82
+ * enable_smoothing?: boolean,
83
+ * }} [options]
84
+ * @returns {{
85
+ * passes_run: number,
86
+ * smoothings_committed: number,
87
+ * smoothings_reverted: number,
88
+ * flips_23_committed: number,
89
+ * flips_23_rejected: number,
90
+ * flips_32_committed: number,
91
+ * flips_32_rejected: number,
92
+ * initial_min_quality: number,
93
+ * final_min_quality: number,
94
+ * }}
95
+ */
96
+ export function tetrahedral_mesh_improve_quality(mesh, points, options = {}) {
97
+ assert.defined(mesh, 'mesh');
98
+ assert.defined(points, 'points');
99
+
100
+ const target_quality = options.target_quality ?? 0.1;
101
+ const max_passes = options.max_passes ?? 5;
102
+ const smoothing_weight = options.smoothing_weight ?? 0.5;
103
+ const enable_flips = options.enable_flips ?? true;
104
+ const enable_smoothing = options.enable_smoothing ?? true;
105
+
106
+ const stats = {
107
+ passes_run: 0,
108
+ smoothings_committed: 0,
109
+ smoothings_reverted: 0,
110
+ flips_23_committed: 0,
111
+ flips_23_rejected: 0,
112
+ flips_32_committed: 0,
113
+ flips_32_rejected: 0,
114
+ initial_min_quality: scan_min_quality(mesh, points),
115
+ final_min_quality: 1,
116
+ };
117
+
118
+ for (let pass = 0; pass < max_passes; pass++) {
119
+ let any_improvement = false;
120
+
121
+ // Snapshot the live tet IDs so iteration is stable even as flips
122
+ // delete and re-introduce tet IDs underneath us.
123
+ const live = mesh.getLive();
124
+
125
+ for (let li = 0; li < live.length; li++) {
126
+ const tet = live[li];
127
+ if (!mesh.exists(tet)) continue;
128
+
129
+ let q = compute_tetrahedron_quality(mesh, points, tet);
130
+ if (q >= target_quality) continue;
131
+
132
+ // ---- Smoothing ---------------------------------------------------
133
+ if (enable_smoothing) {
134
+ for (let i = 0; i < 4; i++) {
135
+ if (!mesh.exists(tet)) break;
136
+ const v_id = mesh.getVertexIndex(tet, i);
137
+ if (tetrahedral_mesh_vertex_is_boundary(mesh, v_id)) continue;
138
+
139
+ const v3 = v_id * 3;
140
+ const old_x = points[v3];
141
+ const old_y = points[v3 + 1];
142
+ const old_z = points[v3 + 2];
143
+
144
+ const old_min = local_min_quality_around_vertex(mesh, points, v_id);
145
+
146
+ const moved = tetrahedral_mesh_smooth_vertex(mesh, points, v_id, smoothing_weight);
147
+ if (!moved) continue;
148
+
149
+ const new_min = local_min_quality_around_vertex(mesh, points, v_id);
150
+ if (new_min > old_min) {
151
+ stats.smoothings_committed++;
152
+ any_improvement = true;
153
+ // Re-fetch quality of `tet` — it may have improved.
154
+ q = compute_tetrahedron_quality(mesh, points, tet);
155
+ if (q >= target_quality) break;
156
+ } else {
157
+ points[v3] = old_x;
158
+ points[v3 + 1] = old_y;
159
+ points[v3 + 2] = old_z;
160
+ stats.smoothings_reverted++;
161
+ }
162
+ }
163
+ }
164
+
165
+ if (!mesh.exists(tet)) continue;
166
+ q = compute_tetrahedron_quality(mesh, points, tet);
167
+ if (q >= target_quality) continue;
168
+
169
+ // ---- 2-3 flip across each internal face -------------------------
170
+ // We SCORE the candidate flip by computing what the 3 new tets'
171
+ // vertex IDs WOULD BE, evaluating quality from the indexed
172
+ // primitive — without touching mesh topology. The actual flip is
173
+ // only applied on accepted candidates, so the mesh never sees a
174
+ // bad transient state and we don't need to invert anything.
175
+ if (enable_flips) {
176
+ for (let face_slot = 0; face_slot < 4; face_slot++) {
177
+ if (!mesh.exists(tet)) break;
178
+
179
+ const enc = mesh.getNeighbour(tet, face_slot);
180
+ if (enc === INVALID_NEIGHBOUR) continue;
181
+ const neighbour_tet = enc >>> 2;
182
+ if (!mesh.exists(neighbour_tet)) continue;
183
+ const shared_i2 = enc & 3;
184
+
185
+ const q_before = Math.min(
186
+ compute_tetrahedron_quality(mesh, points, tet),
187
+ compute_tetrahedron_quality(mesh, points, neighbour_tet)
188
+ );
189
+
190
+ // Derive the would-be vertex IDs of the 3 new tets.
191
+ // d / e: the two apex vertices (the one opposite the
192
+ // shared face in each of tet and neighbour). p / q / r:
193
+ // the shared face's vertices in CCW-from-outside-tet
194
+ // order.
195
+ const d = mesh.getVertexIndex(tet, face_slot);
196
+ const e = mesh.getVertexIndex(neighbour_tet, shared_i2);
197
+ const face = FACE_VERTICES_BY_OPPOSITE[face_slot];
198
+ const p = mesh.getVertexIndex(tet, face[0]);
199
+ const q = mesh.getVertexIndex(tet, face[1]);
200
+ const r = mesh.getVertexIndex(tet, face[2]);
201
+
202
+ // Canonical layouts: T_α = (r, q, d, e); T_β = (p, r, d, e);
203
+ // T_γ = (q, p, d, e). Mirrors tetrahedral_mesh_flip_23.
204
+ const q_alpha = tetrahedron_compute_quality(points, r, q, d, e);
205
+ const q_beta = tetrahedron_compute_quality(points, p, r, d, e);
206
+ const q_gamma = tetrahedron_compute_quality(points, q, p, d, e);
207
+ const q_after = Math.min(q_alpha, q_beta, q_gamma);
208
+
209
+ if (q_after > q_before) {
210
+ // Commit: actually perform the flip.
211
+ tetrahedral_mesh_flip_23(mesh, tet, neighbour_tet, scratch_out_23);
212
+ stats.flips_23_committed++;
213
+ any_improvement = true;
214
+ // `tet` may have been re-used and now represents a
215
+ // different shape; stop probing its faces and let
216
+ // the next outer loop iteration pick up the new
217
+ // low-quality tets.
218
+ break;
219
+ }
220
+
221
+ stats.flips_23_rejected++;
222
+ }
223
+ }
224
+
225
+ if (!mesh.exists(tet)) continue;
226
+ q = compute_tetrahedron_quality(mesh, points, tet);
227
+ if (q >= target_quality) continue;
228
+
229
+ // ---- 3-2 flip on each edge whose ring has exactly 3 tets --------
230
+ // For each of the 6 edges of `tet`, walk the surrounding ring.
231
+ // If exactly 3 tets sit around that edge, we have a valid 3-2
232
+ // candidate. Score it analytically (using the same "compute
233
+ // ring layout from t1's canonical winding" rule as
234
+ // tetrahedral_mesh_flip_32) and commit only if the new pair's
235
+ // min quality beats the old triple's.
236
+ if (enable_flips) {
237
+ for (let ep = 0; ep < EDGE_SLOT_PAIRS.length; ep++) {
238
+ if (!mesh.exists(tet)) break;
239
+
240
+ const slot_a = EDGE_SLOT_PAIRS[ep][0];
241
+ const slot_b = EDGE_SLOT_PAIRS[ep][1];
242
+ const v_a = mesh.getVertexIndex(tet, slot_a);
243
+ const v_b = mesh.getVertexIndex(tet, slot_b);
244
+
245
+ const ring_count = tetrahedral_mesh_find_tets_around_edge(
246
+ scratch_edge_ring, 0, mesh, tet, v_a, v_b, scratch_ring_closed
247
+ );
248
+ // 3-2 flips are only defined on a CLOSED ring of
249
+ // exactly 3 tets. The ring walker may return 3 tets
250
+ // for an open chain on the mesh boundary (e.g. a
251
+ // vertex where two boundary faces meet at an edge);
252
+ // those aren't a valid 3-2 input — flip_32 would
253
+ // throw on them.
254
+ if (ring_count !== 3 || scratch_ring_closed[0] !== 1) continue;
255
+
256
+ const r0 = scratch_edge_ring[0];
257
+ const r1 = scratch_edge_ring[1];
258
+ const r2 = scratch_edge_ring[2];
259
+
260
+ const q_before_32 = Math.min(
261
+ compute_tetrahedron_quality(mesh, points, r0),
262
+ compute_tetrahedron_quality(mesh, points, r1),
263
+ compute_tetrahedron_quality(mesh, points, r2)
264
+ );
265
+
266
+ // Compute the 3-2 flip's would-be new tet vertex IDs.
267
+ // Mirrors the derivation in tetrahedral_mesh_flip_32:
268
+ // read r0's face opposite v_b in CCW-from-outside order,
269
+ // locate v_a within that triple, and the next two
270
+ // cyclic positions give the t1-side ring (v_X, v_Y) in
271
+ // CCW-from-v_a order. v_missing is the third ring vertex
272
+ // — present in r1 or r2 but not r0.
273
+ const slot_a_r0 = find_slot(mesh, r0, v_a);
274
+ const slot_b_r0 = find_slot(mesh, r0, v_b);
275
+ const face_opp_b = FACE_VERTICES_BY_OPPOSITE[slot_b_r0];
276
+ const f0 = mesh.getVertexIndex(r0, face_opp_b[0]);
277
+ const f1 = mesh.getVertexIndex(r0, face_opp_b[1]);
278
+ const f2 = mesh.getVertexIndex(r0, face_opp_b[2]);
279
+ let pos_a = -1;
280
+ if (f0 === v_a) pos_a = 0;
281
+ else if (f1 === v_a) pos_a = 1;
282
+ else if (f2 === v_a) pos_a = 2;
283
+ const face_array = [f0, f1, f2];
284
+ const v_X = face_array[(pos_a + 1) % 3];
285
+ const v_Y = face_array[(pos_a + 2) % 3];
286
+
287
+ // v_missing is the only ring vertex not in r0. It's in
288
+ // both r1 and r2; finding it requires walking another
289
+ // tet's vertices.
290
+ let v_missing = -1;
291
+ for (let i = 0; i < 4; i++) {
292
+ const v = mesh.getVertexIndex(r1, i);
293
+ if (v !== v_a && v !== v_b && v !== v_X && v !== v_Y) {
294
+ v_missing = v;
295
+ break;
296
+ }
297
+ }
298
+ if (v_missing < 0) continue; // shouldn't happen, but guard
299
+
300
+ // Canonical new layouts (mirrors flip_32):
301
+ // new_tet_a = (v_X, v_missing, v_Y, v_a)
302
+ // new_tet_b = (v_X, v_Y, v_missing, v_b)
303
+ const q_new_a = tetrahedron_compute_quality(points, v_X, v_missing, v_Y, v_a);
304
+ const q_new_b = tetrahedron_compute_quality(points, v_X, v_Y, v_missing, v_b);
305
+ const q_after_32 = Math.min(q_new_a, q_new_b);
306
+
307
+ if (q_after_32 > q_before_32) {
308
+ tetrahedral_mesh_flip_32(mesh, r0, r1, r2, scratch_out_32);
309
+ stats.flips_32_committed++;
310
+ any_improvement = true;
311
+ break; // tet's identity may now be one of the new tets
312
+ }
313
+
314
+ stats.flips_32_rejected++;
315
+ }
316
+ }
317
+ }
318
+
319
+ stats.passes_run = pass + 1;
320
+ if (!any_improvement) break;
321
+ }
322
+
323
+ stats.final_min_quality = scan_min_quality(mesh, points);
324
+ return stats;
325
+ }
326
+
327
+ /**
328
+ * Index of `vertex_id` within `tet`'s 4 slots, or -1 if absent.
329
+ */
330
+ function find_slot(mesh, tet, vertex_id) {
331
+ for (let i = 0; i < 4; i++) {
332
+ if (mesh.getVertexIndex(tet, i) === vertex_id) return i;
333
+ }
334
+ return -1;
335
+ }
336
+
337
+ /**
338
+ * Min quality across every live tet in the mesh.
339
+ */
340
+ function scan_min_quality(mesh, points) {
341
+ let min_q = 1;
342
+ mesh.forEach((tet, m) => {
343
+ const q = compute_tetrahedron_quality(m, points, tet);
344
+ if (q < min_q) min_q = q;
345
+ });
346
+ return min_q;
347
+ }
348
+
349
+ /**
350
+ * Min quality across all tets containing `v_id`. Used to score the local
351
+ * effect of moving (or undoing the move of) a single vertex.
352
+ */
353
+ function local_min_quality_around_vertex(mesh, points, v_id) {
354
+ if (scratch_local_tets.length < mesh.count) {
355
+ scratch_local_tets = new Array(Math.max(mesh.count, scratch_local_tets.length * 2));
356
+ }
357
+ const n = tetrahedral_mesh_find_tets_attached_to_vertex(scratch_local_tets, 0, mesh, v_id);
358
+
359
+ let min_q = 1;
360
+ for (let i = 0; i < n; i++) {
361
+ const q = compute_tetrahedron_quality(mesh, points, scratch_local_tets[i]);
362
+ if (q < min_q) min_q = q;
363
+ }
364
+ return min_q;
365
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Move a vertex toward the centroid of its 1-ring neighbours (Laplacian
3
+ * smoothing), at the given weight: `w == 0` keeps the vertex where it is,
4
+ * `w == 1` snaps it to the centroid, `0 < w < 1` blends. Default `w = 1`.
5
+ *
6
+ * Mutates `points` in place. Does NOT touch the mesh topology.
7
+ *
8
+ * The 1-ring is computed by finding every tet that contains `vertex_id` and
9
+ * collecting the OTHER 3 vertices of each tet, deduplicated. For typical
10
+ * meshes this is fast; for very heavy use over many vertices in tight
11
+ * loops, build a vertex-to-tet adjacency map once and call a lower-level
12
+ * smoothing primitive instead.
13
+ *
14
+ * Does NOT check whether the vertex sits on the mesh boundary — the caller
15
+ * is responsible for skipping boundary vertices (via
16
+ * {@link tetrahedral_mesh_vertex_is_boundary}) if surface preservation
17
+ * matters. Moving a boundary vertex changes the mesh's external shape.
18
+ *
19
+ * Returns `true` if the vertex was actually moved (i.e. it had ≥ 1 neighbour
20
+ * and the centroid differs from the current position), `false` otherwise
21
+ * (isolated vertex, or w == 0, or already at the centroid). The boolean
22
+ * lets a quality-improvement driver short-circuit on "nothing happened".
23
+ *
24
+ * @param {TetrahedralMesh} mesh
25
+ * @param {Float32Array|number[]} points flat (x,y,z) positions — mutated in place
26
+ * @param {number} vertex_id
27
+ * @param {number} [weight] move fraction, default 1.0
28
+ * @returns {boolean} true if `points` was modified
29
+ */
30
+ export function tetrahedral_mesh_smooth_vertex(mesh: TetrahedralMesh, points: Float32Array | number[], vertex_id: number, weight?: number): boolean;
31
+ //# sourceMappingURL=tetrahedral_mesh_smooth_vertex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tetrahedral_mesh_smooth_vertex.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,8EALW,YAAY,GAAC,MAAM,EAAE,aACrB,MAAM,WACN,MAAM,GACJ,OAAO,CAyEnB"}
@@ -0,0 +1,112 @@
1
+ import { assert } from "../../../assert.js";
2
+ import {
3
+ tetrahedral_mesh_find_tets_attached_to_vertex
4
+ } from "./tetrahedral_mesh_find_tets_attached_to_vertex.js";
5
+
6
+ // Module-level scratch buffers, sized for typical vertex valence (~20-40
7
+ // incident tets, ~30-60 1-ring neighbours). Grow on demand. Re-used across
8
+ // calls — the function is therefore NOT re-entrant.
9
+ let scratch_tets = new Array(64);
10
+ let scratch_neighbours = new Array(128);
11
+
12
+ /**
13
+ * Move a vertex toward the centroid of its 1-ring neighbours (Laplacian
14
+ * smoothing), at the given weight: `w == 0` keeps the vertex where it is,
15
+ * `w == 1` snaps it to the centroid, `0 < w < 1` blends. Default `w = 1`.
16
+ *
17
+ * Mutates `points` in place. Does NOT touch the mesh topology.
18
+ *
19
+ * The 1-ring is computed by finding every tet that contains `vertex_id` and
20
+ * collecting the OTHER 3 vertices of each tet, deduplicated. For typical
21
+ * meshes this is fast; for very heavy use over many vertices in tight
22
+ * loops, build a vertex-to-tet adjacency map once and call a lower-level
23
+ * smoothing primitive instead.
24
+ *
25
+ * Does NOT check whether the vertex sits on the mesh boundary — the caller
26
+ * is responsible for skipping boundary vertices (via
27
+ * {@link tetrahedral_mesh_vertex_is_boundary}) if surface preservation
28
+ * matters. Moving a boundary vertex changes the mesh's external shape.
29
+ *
30
+ * Returns `true` if the vertex was actually moved (i.e. it had ≥ 1 neighbour
31
+ * and the centroid differs from the current position), `false` otherwise
32
+ * (isolated vertex, or w == 0, or already at the centroid). The boolean
33
+ * lets a quality-improvement driver short-circuit on "nothing happened".
34
+ *
35
+ * @param {TetrahedralMesh} mesh
36
+ * @param {Float32Array|number[]} points flat (x,y,z) positions — mutated in place
37
+ * @param {number} vertex_id
38
+ * @param {number} [weight] move fraction, default 1.0
39
+ * @returns {boolean} true if `points` was modified
40
+ */
41
+ export function tetrahedral_mesh_smooth_vertex(mesh, points, vertex_id, weight = 1.0) {
42
+ assert.defined(mesh, 'mesh');
43
+ assert.defined(points, 'points');
44
+ assert.isNonNegativeInteger(vertex_id, 'vertex_id');
45
+ assert.isNumber(weight, 'weight');
46
+
47
+ if (weight === 0) return false;
48
+
49
+ // 1. Find tets containing the vertex.
50
+ if (scratch_tets.length < mesh.count) {
51
+ scratch_tets = new Array(Math.max(mesh.count, scratch_tets.length * 2));
52
+ }
53
+ const tet_count = tetrahedral_mesh_find_tets_attached_to_vertex(
54
+ scratch_tets, 0, mesh, vertex_id
55
+ );
56
+
57
+ if (tet_count === 0) return false;
58
+
59
+ // 2. Collect 1-ring neighbours (the other 3 vertices of each incident
60
+ // tet), deduplicated. Linear search dedup — fine for typical valences
61
+ // (the neighbour list rarely exceeds a few dozen).
62
+ let neighbour_count = 0;
63
+ for (let i = 0; i < tet_count; i++) {
64
+ const tet = scratch_tets[i];
65
+ for (let j = 0; j < 4; j++) {
66
+ const v = mesh.getVertexIndex(tet, j);
67
+ if (v === vertex_id) continue;
68
+ let already = false;
69
+ for (let k = 0; k < neighbour_count; k++) {
70
+ if (scratch_neighbours[k] === v) { already = true; break; }
71
+ }
72
+ if (!already) {
73
+ if (neighbour_count >= scratch_neighbours.length) {
74
+ scratch_neighbours.length = scratch_neighbours.length * 2;
75
+ }
76
+ scratch_neighbours[neighbour_count++] = v;
77
+ }
78
+ }
79
+ }
80
+
81
+ if (neighbour_count === 0) return false;
82
+
83
+ // 3. Compute 1-ring centroid.
84
+ let cx = 0, cy = 0, cz = 0;
85
+ for (let i = 0; i < neighbour_count; i++) {
86
+ const v3 = scratch_neighbours[i] * 3;
87
+ cx += points[v3];
88
+ cy += points[v3 + 1];
89
+ cz += points[v3 + 2];
90
+ }
91
+ const inv_n = 1 / neighbour_count;
92
+ cx *= inv_n;
93
+ cy *= inv_n;
94
+ cz *= inv_n;
95
+
96
+ // 4. Blend toward centroid.
97
+ const v3 = vertex_id * 3;
98
+ const old_x = points[v3];
99
+ const old_y = points[v3 + 1];
100
+ const old_z = points[v3 + 2];
101
+
102
+ const new_x = old_x + weight * (cx - old_x);
103
+ const new_y = old_y + weight * (cy - old_y);
104
+ const new_z = old_z + weight * (cz - old_z);
105
+
106
+ if (new_x === old_x && new_y === old_y && new_z === old_z) return false;
107
+
108
+ points[v3] = new_x;
109
+ points[v3 + 1] = new_y;
110
+ points[v3 + 2] = new_z;
111
+ return true;
112
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Return true if the given vertex lies on the boundary of the
3
+ * tetrahedral mesh — equivalently, if it sits on any face that has no
4
+ * neighbouring tet (INVALID_NEIGHBOUR).
5
+ *
6
+ * Used by quality-improvement passes to skip boundary vertices when
7
+ * smoothing or collapsing, because moving them would change the mesh's
8
+ * external surface (which usually represents some geometric constraint
9
+ * the caller wants preserved).
10
+ *
11
+ * Cost: O(N) over the live tets, same as
12
+ * {@link tetrahedral_mesh_find_tets_attached_to_vertex} which it shares
13
+ * the same scan structure with. For repeated calls over many vertices,
14
+ * caller should precompute a boundary bitset rather than calling this in
15
+ * a loop.
16
+ *
17
+ * @param {TetrahedralMesh} mesh
18
+ * @param {number} vertex_id
19
+ * @returns {boolean}
20
+ */
21
+ export function tetrahedral_mesh_vertex_is_boundary(mesh: TetrahedralMesh, vertex_id: number): boolean;
22
+ //# sourceMappingURL=tetrahedral_mesh_vertex_is_boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tetrahedral_mesh_vertex_is_boundary.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,sFAHW,MAAM,GACJ,OAAO,CAiCnB"}
@@ -0,0 +1,55 @@
1
+ import { assert } from "../../../assert.js";
2
+ import { INVALID_NEIGHBOUR } from "./TetrahedralMesh.js";
3
+
4
+ /**
5
+ * Return true if the given vertex lies on the boundary of the
6
+ * tetrahedral mesh — equivalently, if it sits on any face that has no
7
+ * neighbouring tet (INVALID_NEIGHBOUR).
8
+ *
9
+ * Used by quality-improvement passes to skip boundary vertices when
10
+ * smoothing or collapsing, because moving them would change the mesh's
11
+ * external surface (which usually represents some geometric constraint
12
+ * the caller wants preserved).
13
+ *
14
+ * Cost: O(N) over the live tets, same as
15
+ * {@link tetrahedral_mesh_find_tets_attached_to_vertex} which it shares
16
+ * the same scan structure with. For repeated calls over many vertices,
17
+ * caller should precompute a boundary bitset rather than calling this in
18
+ * a loop.
19
+ *
20
+ * @param {TetrahedralMesh} mesh
21
+ * @param {number} vertex_id
22
+ * @returns {boolean}
23
+ */
24
+ export function tetrahedral_mesh_vertex_is_boundary(mesh, vertex_id) {
25
+ assert.defined(mesh, 'mesh');
26
+ assert.isNonNegativeInteger(vertex_id, 'vertex_id');
27
+
28
+ let is_boundary = false;
29
+
30
+ mesh.forEach((tet, m) => {
31
+ if (is_boundary) return;
32
+
33
+ // Find the slot of vertex_id in this tet (if any).
34
+ let v_slot = -1;
35
+ for (let i = 0; i < 4; i++) {
36
+ if (m.getVertexIndex(tet, i) === vertex_id) {
37
+ v_slot = i;
38
+ break;
39
+ }
40
+ }
41
+ if (v_slot < 0) return;
42
+
43
+ // The 3 faces containing vertex_id are the ones NOT opposite v_slot.
44
+ // (The face opposite v_slot is the only face that excludes vertex_id.)
45
+ for (let j = 0; j < 4; j++) {
46
+ if (j === v_slot) continue;
47
+ if (m.getNeighbour(tet, j) === INVALID_NEIGHBOUR) {
48
+ is_boundary = true;
49
+ return;
50
+ }
51
+ }
52
+ });
53
+
54
+ return is_boundary;
55
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Compute the radius-ratio shape quality of a tetrahedron given by 4 vertex
3
+ * indices into the points array. Normalised so a regular tet returns 1 and
4
+ * a degenerate (zero-volume) tet returns 0.
5
+ *
6
+ * Formula: 3 · r_in / r_circ where
7
+ * r_in = inscribed-sphere radius = 3·|V| / S_total
8
+ * r_circ = circumscribed-sphere radius
9
+ * S_total = sum of the 4 face areas
10
+ * |V| = absolute signed volume
11
+ *
12
+ * Quality bands (rough rule of thumb for the radius-ratio metric):
13
+ * 1.0 regular tet
14
+ * ≥ 0.5 well-shaped, safe for FEM / fluid
15
+ * 0.1–0.5 acceptable, may slow convergence
16
+ * 0.01–0.1 sliver — usually a target for flipping / smoothing
17
+ * < 0.01 near-degenerate, almost flat
18
+ *
19
+ * Indexed form (not mesh-bound) so callers can score hypothetical tets
20
+ * during a flip-candidate search without committing the flip first. The
21
+ * existing mesh-form wrapper {@link compute_tetrahedron_quality} fetches
22
+ * the four vertex IDs and forwards here.
23
+ *
24
+ * @param {ArrayLike<number>} points flat (x,y,z) positions
25
+ * @param {number} a vertex index
26
+ * @param {number} b vertex index
27
+ * @param {number} c vertex index
28
+ * @param {number} d vertex index
29
+ * @returns {number} quality in [0, 1]
30
+ */
31
+ export function tetrahedron_compute_quality(points: ArrayLike<number>, a: number, b: number, c: number, d: number): number;
32
+ //# sourceMappingURL=tetrahedron_compute_quality.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tetrahedron_compute_quality.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,oDAPW,UAAU,MAAM,CAAC,KACjB,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CA+BlB"}