@woosh/meep-engine 2.131.48 → 2.132.1

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 (228) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/core/bvh2/bvh3/ebvh_optimize_treelet.d.ts.map +1 -1
  4. package/src/core/bvh2/bvh3/ebvh_optimize_treelet.js +4 -3
  5. package/src/core/codegen/LineBuilder.js +3 -3
  6. package/src/core/collection/heap/Uint32Heap.d.ts +14 -0
  7. package/src/core/collection/heap/Uint32Heap.d.ts.map +1 -1
  8. package/src/core/collection/heap/Uint32Heap.js +18 -0
  9. package/src/core/collection/map/HashMap.d.ts.map +1 -1
  10. package/src/core/collection/map/HashMap.js +4 -22
  11. package/src/core/collection/map/generate_next_linear_congruential_index.d.ts +15 -0
  12. package/src/core/collection/map/generate_next_linear_congruential_index.d.ts.map +1 -0
  13. package/src/core/collection/map/generate_next_linear_congruential_index.js +18 -0
  14. package/src/core/geom/3d/aabb/AABB3.js +1 -1
  15. package/src/core/geom/3d/line/line3_compute_nearest_point_to_point.d.ts.map +1 -1
  16. package/src/core/geom/3d/line/line3_compute_nearest_point_to_point.js +10 -26
  17. package/src/core/geom/3d/line/line3_compute_segment_nearest_point_to_point_t.d.ts +19 -0
  18. package/src/core/geom/3d/line/line3_compute_segment_nearest_point_to_point_t.d.ts.map +1 -0
  19. package/src/core/geom/3d/line/line3_compute_segment_nearest_point_to_point_t.js +48 -0
  20. package/src/core/geom/3d/line/line3_compute_segment_point_distance.d.ts +15 -0
  21. package/src/core/geom/3d/line/line3_compute_segment_point_distance.d.ts.map +1 -0
  22. package/src/core/geom/3d/line/line3_compute_segment_point_distance.js +24 -0
  23. package/src/core/geom/3d/line/line3_compute_segment_point_distance_eikonal.d.ts +17 -0
  24. package/src/core/geom/3d/line/line3_compute_segment_point_distance_eikonal.d.ts.map +1 -0
  25. package/src/core/geom/3d/line/line3_compute_segment_point_distance_eikonal.js +95 -0
  26. package/src/core/geom/3d/line/line3_compute_segment_point_distance_sqr.d.ts +16 -0
  27. package/src/core/geom/3d/line/line3_compute_segment_point_distance_sqr.d.ts.map +1 -0
  28. package/src/core/geom/3d/line/{line3_computeSegmentPointDistance_sqr.js → line3_compute_segment_point_distance_sqr.js} +16 -3
  29. package/src/core/geom/3d/topology/struct/TopoMesh.d.ts +4 -0
  30. package/src/core/geom/3d/topology/struct/TopoMesh.d.ts.map +1 -1
  31. package/src/core/geom/3d/topology/struct/TopoMesh.js +4 -0
  32. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts +18 -1
  33. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts.map +1 -1
  34. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.js +56 -0
  35. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts +46 -16
  36. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts.map +1 -1
  37. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +85 -15
  38. package/src/core/geom/3d/topology/struct/binary/io/bt_disk_edge_add.d.ts +9 -0
  39. package/src/core/geom/3d/topology/struct/binary/io/bt_disk_edge_add.d.ts.map +1 -0
  40. package/src/core/geom/3d/topology/struct/binary/io/bt_disk_edge_add.js +43 -0
  41. package/src/core/geom/3d/topology/struct/binary/io/bt_disk_edge_remove.d.ts +4 -3
  42. package/src/core/geom/3d/topology/struct/binary/io/bt_disk_edge_remove.d.ts.map +1 -1
  43. package/src/core/geom/3d/topology/struct/binary/io/bt_disk_edge_remove.js +38 -4
  44. package/src/core/geom/3d/topology/struct/binary/io/bt_loop_kill.d.ts +8 -0
  45. package/src/core/geom/3d/topology/struct/binary/io/bt_loop_kill.d.ts.map +1 -0
  46. package/src/core/geom/3d/topology/struct/binary/io/bt_loop_kill.js +36 -0
  47. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_cleanup_faceless_references.d.ts +10 -0
  48. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_cleanup_faceless_references.d.ts.map +1 -0
  49. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_cleanup_faceless_references.js +62 -0
  50. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.d.ts +13 -0
  51. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.d.ts.map +1 -0
  52. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.js +145 -0
  53. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple_islands.d.ts +12 -0
  54. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple_islands.d.ts.map +1 -0
  55. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple_islands.js +111 -0
  56. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_island_erode.d.ts +15 -0
  57. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_island_erode.d.ts.map +1 -0
  58. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_island_erode.js +290 -0
  59. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_from_indexed_geometry.d.ts +11 -0
  60. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_from_indexed_geometry.d.ts.map +1 -0
  61. package/src/core/geom/3d/topology/struct/binary/io/{bt_index_geometry_to_topology.js → bt_mesh_from_indexed_geometry.js} +6 -7
  62. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_from_unindexed_geometry.d.ts +8 -0
  63. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_from_unindexed_geometry.d.ts.map +1 -0
  64. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_from_unindexed_geometry.js +31 -0
  65. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_triangulate.d.ts +7 -0
  66. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_triangulate.d.ts.map +1 -0
  67. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_triangulate.js +22 -0
  68. package/src/core/geom/3d/topology/struct/binary/io/bt_radial_loop_add.d.ts +8 -0
  69. package/src/core/geom/3d/topology/struct/binary/io/bt_radial_loop_add.d.ts.map +1 -0
  70. package/src/core/geom/3d/topology/struct/binary/io/bt_radial_loop_add.js +32 -0
  71. package/src/core/geom/3d/topology/struct/binary/io/bt_radial_loop_remove.d.ts +8 -0
  72. package/src/core/geom/3d/topology/struct/binary/io/bt_radial_loop_remove.d.ts.map +1 -0
  73. package/src/core/geom/3d/topology/struct/binary/io/bt_radial_loop_remove.js +26 -0
  74. package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts.map +1 -0
  75. package/src/core/geom/3d/topology/struct/binary/io/{OrderedEdge.js → edge/OrderedEdge.js} +1 -1
  76. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.d.ts.map +1 -0
  77. package/src/core/geom/3d/topology/struct/binary/io/{bt_edge_create.js → edge/bt_edge_create.js} +1 -1
  78. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.d.ts.map +1 -0
  79. package/src/core/geom/3d/topology/struct/binary/io/{bt_edge_get_or_create.js → edge/bt_edge_get_or_create.js} +1 -1
  80. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.d.ts.map +1 -0
  81. package/src/core/geom/3d/topology/struct/binary/io/{bt_edge_kill.js → edge/bt_edge_kill.js} +6 -3
  82. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_split.d.ts +13 -0
  83. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_split.d.ts.map +1 -0
  84. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_split.js +180 -0
  85. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_kill_only_edge.d.ts.map +1 -0
  86. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts.map +1 -0
  87. package/src/core/geom/3d/topology/struct/binary/io/{bt_mesh_calc_edges.js → edge/bt_mesh_calc_edges.js} +10 -7
  88. package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts.map +1 -0
  89. package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_kill.d.ts +8 -0
  90. package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_kill.d.ts.map +1 -0
  91. package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_kill.js +26 -0
  92. package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_poke.d.ts +15 -0
  93. package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_poke.d.ts.map +1 -0
  94. package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_poke.js +152 -0
  95. package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_triangulate.d.ts +13 -0
  96. package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_triangulate.d.ts.map +1 -0
  97. package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_triangulate.js +124 -0
  98. package/src/core/geom/3d/topology/struct/binary/io/face/bt_kill_only_face.d.ts.map +1 -0
  99. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_kill_only_vert.d.ts.map +1 -0
  100. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_merge_verts_by_distance.d.ts +10 -0
  101. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_merge_verts_by_distance.d.ts.map +1 -0
  102. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_merge_verts_by_distance.js +165 -0
  103. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vert_kill.d.ts.map +1 -0
  104. package/src/core/geom/3d/topology/struct/binary/io/{bt_vert_kill.js → vertex/bt_vert_kill.js} +5 -2
  105. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.d.ts +13 -0
  106. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.d.ts.map +1 -0
  107. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.js +125 -0
  108. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_has_vertex.d.ts +9 -0
  109. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_has_vertex.d.ts.map +1 -0
  110. package/src/core/geom/3d/topology/struct/binary/query/{bt_mesh_edge_has_vertex.js → bt_edge_has_vertex.js} +1 -1
  111. package/src/core/geom/3d/topology/struct/binary/query/{bt_mesh_edge_other_vertex.d.ts → bt_edge_other_vertex.d.ts} +2 -2
  112. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_other_vertex.d.ts.map +1 -0
  113. package/src/core/geom/3d/topology/struct/binary/query/{bt_mesh_edge_other_vertex.js → bt_edge_other_vertex.js} +1 -1
  114. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_attached_faces.d.ts +12 -0
  115. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_attached_faces.d.ts.map +1 -0
  116. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_attached_faces.js +96 -0
  117. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_centroid.d.ts +10 -0
  118. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_centroid.d.ts.map +1 -0
  119. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_centroid.js +75 -0
  120. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_incenter.d.ts +10 -0
  121. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_incenter.d.ts.map +1 -0
  122. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_incenter.js +85 -0
  123. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_neighbour_faces.d.ts +12 -0
  124. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_neighbour_faces.d.ts.map +1 -0
  125. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_neighbour_faces.js +74 -0
  126. package/src/core/geom/3d/topology/struct/binary/query/bt_face_is_degenerate.d.ts +9 -0
  127. package/src/core/geom/3d/topology/struct/binary/query/bt_face_is_degenerate.d.ts.map +1 -0
  128. package/src/core/geom/3d/topology/struct/binary/query/bt_face_is_degenerate.js +78 -0
  129. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_build_boundary_distance_field.d.ts +15 -0
  130. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_build_boundary_distance_field.d.ts.map +1 -0
  131. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_build_boundary_distance_field.js +151 -0
  132. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_compute_edge_distance_eikonal.d.ts +13 -0
  133. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_compute_edge_distance_eikonal.d.ts.map +1 -0
  134. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_compute_edge_distance_eikonal.js +46 -0
  135. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_compute_face_islands.d.ts +9 -0
  136. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_compute_face_islands.d.ts.map +1 -0
  137. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_compute_face_islands.js +78 -0
  138. package/src/core/geom/3d/topology/struct/binary/query/bt_vertex_distance_to_edge.d.ts +10 -0
  139. package/src/core/geom/3d/topology/struct/binary/query/bt_vertex_distance_to_edge.d.ts.map +1 -0
  140. package/src/core/geom/3d/topology/struct/binary/query/bt_vertex_distance_to_edge.js +48 -0
  141. package/src/core/geom/3d/topology/struct/binary/query/bt_vertex_distance_to_vertex.d.ts +9 -0
  142. package/src/core/geom/3d/topology/struct/binary/query/bt_vertex_distance_to_vertex.d.ts.map +1 -0
  143. package/src/core/geom/3d/topology/struct/binary/query/bt_vertex_distance_to_vertex.js +31 -0
  144. package/src/core/geom/3d/topology/struct/prototypeBinaryTopology.js +2 -2
  145. package/src/core/geom/3d/triangle/triangle3_incenter.d.ts +19 -0
  146. package/src/core/geom/3d/triangle/triangle3_incenter.d.ts.map +1 -0
  147. package/src/core/geom/3d/triangle/triangle3_incenter.js +60 -0
  148. package/src/core/math/hash/lowbias32.d.ts +9 -0
  149. package/src/core/math/hash/lowbias32.d.ts.map +1 -0
  150. package/src/core/math/hash/lowbias32.js +20 -0
  151. package/src/core/process/task/util/iteratorTask.d.ts +2 -2
  152. package/src/core/process/task/util/iteratorTask.d.ts.map +1 -1
  153. package/src/core/process/task/util/iteratorTask.js +3 -3
  154. package/src/engine/graphics/particles/particular/engine/utils/distrubuteParticlesOnMesh.d.ts.map +1 -1
  155. package/src/engine/graphics/particles/particular/engine/utils/distrubuteParticlesOnMesh.js +4 -4
  156. package/src/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +4 -4
  157. package/src/engine/navigation/ecs/components/Path.js +3 -3
  158. package/src/engine/navigation/grid/find_path_on_grid_astar.d.ts +4 -4
  159. package/src/engine/navigation/grid/find_path_on_grid_astar.d.ts.map +1 -1
  160. package/src/engine/navigation/grid/find_path_on_grid_astar.js +5 -4
  161. package/src/engine/navigation/mesh/NavigationMesh.d.ts +32 -0
  162. package/src/engine/navigation/mesh/NavigationMesh.d.ts.map +1 -0
  163. package/src/engine/navigation/mesh/NavigationMesh.js +190 -0
  164. package/src/engine/navigation/mesh/NavigationMeshAgent.d.ts +9 -0
  165. package/src/engine/navigation/mesh/NavigationMeshAgent.d.ts.map +1 -0
  166. package/src/engine/navigation/mesh/NavigationMeshAgent.js +11 -0
  167. package/src/engine/navigation/mesh/README.md +3 -0
  168. package/src/engine/navigation/mesh/bt_mesh_face_find_path.d.ts +14 -0
  169. package/src/engine/navigation/mesh/bt_mesh_face_find_path.d.ts.map +1 -0
  170. package/src/engine/navigation/mesh/bt_mesh_face_find_path.js +203 -0
  171. package/src/engine/navigation/mesh/build/bvh_build_from_unindexed_triangles.d.ts +8 -0
  172. package/src/engine/navigation/mesh/build/bvh_build_from_unindexed_triangles.d.ts.map +1 -0
  173. package/src/engine/navigation/mesh/build/bvh_build_from_unindexed_triangles.js +46 -0
  174. package/src/engine/navigation/mesh/build/enforce_agent_height_clearance.d.ts +12 -0
  175. package/src/engine/navigation/mesh/build/enforce_agent_height_clearance.d.ts.map +1 -0
  176. package/src/engine/navigation/mesh/build/enforce_agent_height_clearance.js +204 -0
  177. package/src/engine/navigation/mesh/build/navmesh_build_topology.d.ts +14 -0
  178. package/src/engine/navigation/mesh/build/navmesh_build_topology.d.ts.map +1 -0
  179. package/src/engine/navigation/mesh/build/navmesh_build_topology.js +183 -0
  180. package/src/engine/navigation/mesh/bvh_build_from_bt_mesh.d.ts +7 -0
  181. package/src/engine/navigation/mesh/bvh_build_from_bt_mesh.d.ts.map +1 -0
  182. package/src/engine/navigation/mesh/bvh_build_from_bt_mesh.js +64 -0
  183. package/src/engine/navigation/mesh/funnel_string_pull.d.ts +15 -0
  184. package/src/engine/navigation/mesh/funnel_string_pull.d.ts.map +1 -0
  185. package/src/engine/navigation/mesh/funnel_string_pull.js +225 -0
  186. package/src/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.d.ts +0 -14
  187. package/src/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.d.ts.map +0 -1
  188. package/src/core/geom/3d/topology/struct/binary/io/OrderedEdge.d.ts.map +0 -1
  189. package/src/core/geom/3d/topology/struct/binary/io/bt_edge_create.d.ts.map +0 -1
  190. package/src/core/geom/3d/topology/struct/binary/io/bt_edge_get_or_create.d.ts.map +0 -1
  191. package/src/core/geom/3d/topology/struct/binary/io/bt_edge_kill.d.ts.map +0 -1
  192. package/src/core/geom/3d/topology/struct/binary/io/bt_face_kill.d.ts +0 -7
  193. package/src/core/geom/3d/topology/struct/binary/io/bt_face_kill.d.ts.map +0 -1
  194. package/src/core/geom/3d/topology/struct/binary/io/bt_face_kill.js +0 -8
  195. package/src/core/geom/3d/topology/struct/binary/io/bt_index_geometry_to_topology.d.ts +0 -11
  196. package/src/core/geom/3d/topology/struct/binary/io/bt_index_geometry_to_topology.d.ts.map +0 -1
  197. package/src/core/geom/3d/topology/struct/binary/io/bt_kill_only_edge.d.ts.map +0 -1
  198. package/src/core/geom/3d/topology/struct/binary/io/bt_kill_only_face.d.ts.map +0 -1
  199. package/src/core/geom/3d/topology/struct/binary/io/bt_kill_only_vert.d.ts.map +0 -1
  200. package/src/core/geom/3d/topology/struct/binary/io/bt_merge_verts_by_distance.d.ts +0 -18
  201. package/src/core/geom/3d/topology/struct/binary/io/bt_merge_verts_by_distance.d.ts.map +0 -1
  202. package/src/core/geom/3d/topology/struct/binary/io/bt_merge_verts_by_distance.js +0 -83
  203. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_calc_edges.d.ts.map +0 -1
  204. package/src/core/geom/3d/topology/struct/binary/io/bt_vert_kill.d.ts.map +0 -1
  205. package/src/core/geom/3d/topology/struct/binary/io/get_or_create_edge_map.d.ts.map +0 -1
  206. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_edge_has_vertex.d.ts +0 -9
  207. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_edge_has_vertex.d.ts.map +0 -1
  208. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_edge_other_vertex.d.ts.map +0 -1
  209. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_face_get_neighbour_faces.d.ts +0 -10
  210. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_face_get_neighbour_faces.d.ts.map +0 -1
  211. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_face_get_neighbour_faces.js +0 -44
  212. package/src/engine/navigation/__module.d.ts +0 -2
  213. package/src/engine/navigation/__module.d.ts.map +0 -1
  214. package/src/engine/navigation/__module.js +0 -1
  215. /package/src/core/geom/3d/topology/struct/binary/io/{OrderedEdge.d.ts → edge/OrderedEdge.d.ts} +0 -0
  216. /package/src/core/geom/3d/topology/struct/binary/io/{bt_edge_create.d.ts → edge/bt_edge_create.d.ts} +0 -0
  217. /package/src/core/geom/3d/topology/struct/binary/io/{bt_edge_get_or_create.d.ts → edge/bt_edge_get_or_create.d.ts} +0 -0
  218. /package/src/core/geom/3d/topology/struct/binary/io/{bt_edge_kill.d.ts → edge/bt_edge_kill.d.ts} +0 -0
  219. /package/src/core/geom/3d/topology/struct/binary/io/{bt_kill_only_edge.d.ts → edge/bt_kill_only_edge.d.ts} +0 -0
  220. /package/src/core/geom/3d/topology/struct/binary/io/{bt_kill_only_edge.js → edge/bt_kill_only_edge.js} +0 -0
  221. /package/src/core/geom/3d/topology/struct/binary/io/{bt_mesh_calc_edges.d.ts → edge/bt_mesh_calc_edges.d.ts} +0 -0
  222. /package/src/core/geom/3d/topology/struct/binary/io/{get_or_create_edge_map.d.ts → edge/get_or_create_edge_map.d.ts} +0 -0
  223. /package/src/core/geom/3d/topology/struct/binary/io/{get_or_create_edge_map.js → edge/get_or_create_edge_map.js} +0 -0
  224. /package/src/core/geom/3d/topology/struct/binary/io/{bt_kill_only_face.d.ts → face/bt_kill_only_face.d.ts} +0 -0
  225. /package/src/core/geom/3d/topology/struct/binary/io/{bt_kill_only_face.js → face/bt_kill_only_face.js} +0 -0
  226. /package/src/core/geom/3d/topology/struct/binary/io/{bt_kill_only_vert.d.ts → vertex/bt_kill_only_vert.d.ts} +0 -0
  227. /package/src/core/geom/3d/topology/struct/binary/io/{bt_kill_only_vert.js → vertex/bt_kill_only_vert.js} +0 -0
  228. /package/src/core/geom/3d/topology/struct/binary/io/{bt_vert_kill.d.ts → vertex/bt_vert_kill.d.ts} +0 -0
@@ -0,0 +1,152 @@
1
+ import { assert } from "../../../../../../../assert.js";
2
+ import { NULL_POINTER } from "../../BinaryTopology.js";
3
+ import { bt_edge_create } from "../edge/bt_edge_create.js";
4
+
5
+ const normal = new Float32Array(3);
6
+
7
+ /**
8
+ * Pokes a face by adding a vertex at the specified coordinates and fan-tessellating the face.
9
+ * Reuses bt_edge_create to handle the complex vertex-disk linking automatically.
10
+ *
11
+ * Coordinates of the new vertex must be co-planar with the face.
12
+ *
13
+ * @param {BinaryTopology} mesh
14
+ * @param {number} face_id
15
+ * @param {number} x
16
+ * @param {number} y
17
+ * @param {number} z
18
+ * @returns {number} vertex ID of the new center vertex, NULL_POINTER if face is degenerate or does not exist.
19
+ */
20
+ export function bt_mesh_face_poke(
21
+ mesh,
22
+ face_id,
23
+ x, y, z
24
+ ) {
25
+
26
+ assert.isNumber(x, 'x');
27
+ assert.isNumber(y, 'y');
28
+ assert.isNumber(z, 'z');
29
+
30
+ // 1. Validate and Gather Initial State
31
+ // We must collect the original loops/vertices first because we will be modifying the topology.
32
+ const loop_ids = [];
33
+ const first_loop_id = mesh.face_read_loop(face_id);
34
+
35
+ if (first_loop_id === NULL_POINTER) {
36
+ return NULL_POINTER;
37
+ }
38
+
39
+ let iter_loop = first_loop_id;
40
+ do {
41
+ loop_ids.push(iter_loop);
42
+ iter_loop = mesh.loop_read_next(iter_loop);
43
+ } while (iter_loop !== first_loop_id);
44
+
45
+ const count = loop_ids.length;
46
+
47
+ if (count < 3) {
48
+ // Degenerate face
49
+ return NULL_POINTER;
50
+ }
51
+
52
+ // 2. Create the Central Vertex
53
+ const v_center = mesh.vertices.allocate();
54
+ mesh.vertex_write_coordinate(v_center, [x, y, z], 0);
55
+ mesh.vertex_write_edge(v_center, NULL_POINTER); // Initialize with no edges
56
+
57
+ // 3. Create Spoke Edges using bt_edge_create
58
+ // This handles all the complexity of linking edges into the vertices' disk cycles.
59
+ const spoke_edges = new Uint32Array(count);
60
+
61
+ for (let i = 0; i < count; i++) {
62
+ const v_curr = mesh.loop_read_vertex(loop_ids[i]);
63
+
64
+ // REUSE: bt_edge_create handles the allocation and the disk-cycle linking
65
+ // for both v_curr and the new v_center.
66
+ spoke_edges[i] = bt_edge_create(mesh, v_curr, v_center);
67
+ }
68
+
69
+ // 4. Tessellate (Create Faces and Loops)
70
+ for (let i = 0; i < count; i++) {
71
+ const idx_curr = i;
72
+ const idx_next = (i + 1) % count;
73
+
74
+ const l_old = loop_ids[idx_curr];
75
+ const v_next = mesh.loop_read_vertex(loop_ids[idx_next]);
76
+
77
+ // Determine which face ID to use (reuse original for the first triangle)
78
+ let f_active;
79
+ if (i === 0) {
80
+ f_active = face_id;
81
+ mesh.face_write_loop(f_active, l_old);
82
+ } else {
83
+ f_active = mesh.faces.allocate();
84
+ // Copy normal from original face
85
+ mesh.face_read_normal(normal, 0, face_id);
86
+ mesh.face_write_normal(f_active, normal, 0);
87
+ mesh.face_write_loop(f_active, l_old);
88
+ }
89
+
90
+ // Create the two new loops required for the triangle fan
91
+ const l_next_spoke = mesh.loop_create();
92
+ const l_center_spoke = mesh.loop_create();
93
+
94
+ // --- Configure Loop 1 (The Original Loop) ---
95
+ // Reuse l_old. It keeps its Vertex and Edge (outer edge).
96
+ // Just update Face and Links.
97
+ mesh.loop_write_face(l_old, f_active);
98
+ mesh.loop_write_next(l_old, l_next_spoke);
99
+ mesh.loop_write_prev(l_old, l_center_spoke);
100
+
101
+ // --- Configure Loop 2 (At V_next, pointing to V_center) ---
102
+ mesh.loop_write_vertex(l_next_spoke, v_next);
103
+ mesh.loop_write_face(l_next_spoke, f_active);
104
+ mesh.loop_write_next(l_next_spoke, l_center_spoke);
105
+ mesh.loop_write_prev(l_next_spoke, l_old);
106
+
107
+ // Link to the spoke edge (Radial Cycle)
108
+ _link_loop_to_edge_local(mesh, l_next_spoke, spoke_edges[idx_next]);
109
+
110
+ // --- Configure Loop 3 (At V_center, pointing to V_curr) ---
111
+ mesh.loop_write_vertex(l_center_spoke, v_center);
112
+ mesh.loop_write_face(l_center_spoke, f_active);
113
+ mesh.loop_write_next(l_center_spoke, l_old);
114
+ mesh.loop_write_prev(l_center_spoke, l_next_spoke);
115
+
116
+ // Link to the spoke edge (Radial Cycle)
117
+ _link_loop_to_edge_local(mesh, l_center_spoke, spoke_edges[idx_curr]);
118
+ }
119
+
120
+ return v_center;
121
+ }
122
+
123
+ /**
124
+ * Local helper to link a loop to an edge's radial cycle.
125
+ * Replicates logic from 'link_loop_to_edge' since it is not exported.
126
+ * @param {BinaryTopology} mesh
127
+ * @param {number} loop_id
128
+ * @param {number} edge_id
129
+ */
130
+ function _link_loop_to_edge_local(mesh, loop_id, edge_id) {
131
+ mesh.loop_write_edge(loop_id, edge_id);
132
+
133
+ const existing_loop = mesh.edge_read_loop(edge_id);
134
+
135
+ if (existing_loop === NULL_POINTER) {
136
+ // First loop on this edge
137
+ mesh.edge_write_loop(edge_id, loop_id);
138
+
139
+ // Link to self
140
+ mesh.loop_write_radial_next(loop_id, loop_id);
141
+ mesh.loop_write_radial_prev(loop_id, loop_id);
142
+ } else {
143
+ // Insert into doubly linked list
144
+ const next = mesh.loop_read_radial_next(existing_loop);
145
+
146
+ mesh.loop_write_radial_next(existing_loop, loop_id);
147
+ mesh.loop_write_radial_prev(next, loop_id);
148
+
149
+ mesh.loop_write_radial_next(loop_id, next);
150
+ mesh.loop_write_radial_prev(loop_id, existing_loop);
151
+ }
152
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Triangulate a face in a binary topology mesh.
3
+ *
4
+ * Assumes that each face is a convex polygon.
5
+ *
6
+ * If the face is already a triangle, no action is taken.
7
+ *
8
+ * @param {BinaryTopology} mesh
9
+ * @param {number} face Face ID
10
+ * @return {boolean} True if the face was triangulated, false if it was already a triangle.
11
+ */
12
+ export function bt_face_triangulate(mesh: BinaryTopology, face: number): boolean;
13
+ //# sourceMappingURL=bt_face_triangulate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bt_face_triangulate.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/geom/3d/topology/struct/binary/io/face/bt_face_triangulate.js"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,gEAHW,MAAM,GACL,OAAO,CA8GlB"}
@@ -0,0 +1,124 @@
1
+ import { NULL_POINTER } from "../../BinaryTopology.js";
2
+ import { bt_radial_loop_add } from "../bt_radial_loop_add.js";
3
+ import { bt_edge_create } from "../edge/bt_edge_create.js";
4
+
5
+ /**
6
+ * Triangulate a face in a binary topology mesh.
7
+ *
8
+ * Assumes that each face is a convex polygon.
9
+ *
10
+ * If the face is already a triangle, no action is taken.
11
+ *
12
+ * @param {BinaryTopology} mesh
13
+ * @param {number} face Face ID
14
+ * @return {boolean} True if the face was triangulated, false if it was already a triangle.
15
+ */
16
+ export function bt_face_triangulate(
17
+ mesh,
18
+ face
19
+ ) {
20
+ // 1. Validate Face and Count Loops
21
+ const first_loop = mesh.face_read_loop(face);
22
+ if (first_loop === NULL_POINTER){
23
+ // should never happen, but just in case
24
+ return false;
25
+ }
26
+
27
+ let count = 0;
28
+ let iter = first_loop;
29
+ do {
30
+ count++;
31
+ iter = mesh.loop_read_next(iter);
32
+ } while (iter !== first_loop);
33
+
34
+ if (count < 4) {
35
+ // looks like a triangle
36
+ return false;
37
+ }
38
+
39
+ // 2. Prepare for Triangulation (Fan method at first vertex)
40
+ let l_prev = first_loop; // Vertex 0 (Anchor)
41
+ let l_curr = mesh.loop_read_next(l_prev); // Vertex 1
42
+ let l_next = mesh.loop_read_next(l_curr); // Vertex 2
43
+
44
+ const cuts = count - 3;
45
+
46
+ // Cache normal to apply to new faces
47
+ const normal = new Float32Array(3);
48
+ mesh.face_read_normal(normal, 0, face);
49
+
50
+ for (let i = 0; i < cuts; i++) {
51
+ // We cut the triangle (l_prev, l_curr, l_next) out of 'face'.
52
+ // New Edge connects V(l_prev) <-> V(l_next).
53
+
54
+ const v_anchor = mesh.loop_read_vertex(l_prev);
55
+ const v_target = mesh.loop_read_vertex(l_next);
56
+
57
+ // --- A. Create Topology Elements ---
58
+ // Reuse: Handles allocation and Vertex Disk Cycle linking
59
+ const e_new = bt_edge_create(mesh, v_anchor, v_target);
60
+
61
+ const f_new = mesh.faces.allocate();
62
+ const l_tri = mesh.loop_create(); // Loop at v_target (for the Triangle)
63
+ const l_poly = mesh.loop_create(); // Loop at v_anchor (for the Polygon)
64
+
65
+ // --- B. Setup Loops & Radial Cycles ---
66
+
67
+ // 1. Setup l_tri properties
68
+ mesh.loop_write_vertex(l_tri, v_target);
69
+ mesh.loop_write_face(l_tri, f_new);
70
+
71
+ // 2. Setup l_poly properties
72
+ mesh.loop_write_vertex(l_poly, v_anchor);
73
+ mesh.loop_write_face(l_poly, face); // Stays part of the shrinking polygon
74
+
75
+ // 3. Reuse: Link loops to the edge's Radial Cycle
76
+ bt_radial_loop_add(mesh, l_tri, e_new);
77
+ bt_radial_loop_add(mesh, l_poly, e_new);
78
+
79
+ // --- C. Re-link Face Loop Topology (Next/Prev) ---
80
+
81
+ // 1. Get the loop entering the anchor from the polygon side
82
+ const l_prev_prev = mesh.loop_read_prev(l_prev);
83
+
84
+ // 2. Assign l_prev and l_curr to the new Triangle Face
85
+ mesh.loop_write_face(l_prev, f_new);
86
+ mesh.loop_write_face(l_curr, f_new);
87
+
88
+ // 3. Close the New Triangle (l_prev -> l_curr -> l_tri)
89
+ mesh.loop_write_next(l_prev, l_curr);
90
+ mesh.loop_write_prev(l_prev, l_tri);
91
+
92
+ mesh.loop_write_next(l_curr, l_tri);
93
+ mesh.loop_write_prev(l_curr, l_prev);
94
+
95
+ mesh.loop_write_next(l_tri, l_prev);
96
+ mesh.loop_write_prev(l_tri, l_curr);
97
+
98
+ // Set properties for the new face
99
+ mesh.face_write_loop(f_new, l_prev);
100
+ mesh.face_write_normal(f_new, normal, 0);
101
+
102
+ // 4. Close the Remaining Polygon (l_prev_prev -> l_poly -> l_next)
103
+ mesh.loop_write_next(l_prev_prev, l_poly);
104
+ // l_prev_prev's prev pointer remains unchanged
105
+
106
+ mesh.loop_write_prev(l_poly, l_prev_prev);
107
+ mesh.loop_write_next(l_poly, l_next);
108
+
109
+ mesh.loop_write_prev(l_next, l_poly);
110
+ // l_next's next pointer remains unchanged
111
+
112
+ // Update Polygon Face pointer (ensure it points to a valid loop in the poly)
113
+ mesh.face_write_loop(face, l_poly);
114
+
115
+ // --- D. Advance Fan ---
116
+ // The polygon now starts at l_poly (at v0).
117
+ // The next triangle will use l_poly as its "prev", l_next as "curr".
118
+ l_prev = l_poly;
119
+ l_curr = l_next;
120
+ l_next = mesh.loop_read_next(l_next);
121
+ }
122
+
123
+ return true;
124
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bt_kill_only_face.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/geom/3d/topology/struct/binary/io/face/bt_kill_only_face.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,2DAFW,MAAM,QAIhB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bt_kill_only_vert.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/geom/3d/topology/struct/binary/io/vertex/bt_kill_only_vert.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,2DAFW,MAAM,QAIhB"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Only considers distance, no other attributes are accounted for.
3
+ * Performs operation in-place. Note that the duplicate vertices are not removed from the mesh itself, they are still present but are not linked to anything.
4
+ * You typically want to perform a cleanup phase afterward to remove such unliked vertices.
5
+ * @param {BinaryTopology} mesh
6
+ * @param {number} [max_distance] Inclusive distance between vertices within which we perform the merge.
7
+ * @returns {number} number of removed duplicate vertices
8
+ */
9
+ export function bt_merge_verts_by_distance(mesh: BinaryTopology, max_distance?: number): number;
10
+ //# sourceMappingURL=bt_merge_verts_by_distance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bt_merge_verts_by_distance.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/geom/3d/topology/struct/binary/io/vertex/bt_merge_verts_by_distance.js"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,gFAHW,MAAM,GACJ,MAAM,CAoJlB"}
@@ -0,0 +1,165 @@
1
+ import { assert } from "../../../../../../../assert.js";
2
+ import { ceilPowerOfTwo } from "../../../../../../../binary/operations/ceilPowerOfTwo.js";
3
+ import {
4
+ generate_next_linear_congruential_index
5
+ } from "../../../../../../../collection/map/generate_next_linear_congruential_index.js";
6
+ import { lowbias32 } from "../../../../../../../math/hash/lowbias32.js";
7
+ import { v3_distance_sqr } from "../../../../../../vec3/v3_distance_sqr.js";
8
+ import { NULL_POINTER } from "../../BinaryTopology.js";
9
+ import { bt_vertex_replace } from "./bt_vertex_replace.js";
10
+
11
+ /**
12
+ * Only considers distance, no other attributes are accounted for.
13
+ * Performs operation in-place. Note that the duplicate vertices are not removed from the mesh itself, they are still present but are not linked to anything.
14
+ * You typically want to perform a cleanup phase afterward to remove such unliked vertices.
15
+ * @param {BinaryTopology} mesh
16
+ * @param {number} [max_distance] Inclusive distance between vertices within which we perform the merge.
17
+ * @returns {number} number of removed duplicate vertices
18
+ */
19
+ export function bt_merge_verts_by_distance(
20
+ mesh,
21
+ max_distance = 0.0001
22
+ ) {
23
+
24
+ assert.defined(mesh, "mesh");
25
+ assert.greaterThan(max_distance, 0, "max_distance must be greater than 0");
26
+
27
+ assert.defined(mesh, "mesh");
28
+ assert.greaterThan(max_distance, 0, "max_distance must be greater than 0");
29
+
30
+ const max_distance2 = max_distance * max_distance;
31
+ const grid_cell_size = max_distance + 1e-10;
32
+
33
+ /**
34
+ * Hashes pre-quantized integer cell coordinates
35
+ * @param {number} cx
36
+ * @param {number} cy
37
+ * @param {number} cz
38
+ * @returns {number}
39
+ */
40
+ function hash_int3(cx, cy, cz) {
41
+ const hx = lowbias32(cx);
42
+ const hy = lowbias32(cy);
43
+ const hz = lowbias32(cz);
44
+
45
+ return lowbias32(
46
+ hx
47
+ ^ Math.imul(hy, 73856093)
48
+ ^ Math.imul(hz, 19349663)
49
+ );
50
+ }
51
+
52
+ const vertices = mesh.vertices;
53
+ const vertex_count = vertices.size;
54
+
55
+ const grid_bin_count = ceilPowerOfTwo(Math.max(32, Math.ceil(vertex_count * 1.2)));
56
+ const grid_bin_mask = grid_bin_count - 1;
57
+
58
+ const vertex_grid = new Uint32Array(grid_bin_count);
59
+ vertex_grid.fill(NULL_POINTER);
60
+
61
+ const scratch_vertex1 = new Float32Array(3);
62
+
63
+ /**
64
+ * @param {number} x Original float coordinate
65
+ * @param {number} y Original float coordinate
66
+ * @param {number} z Original float coordinate
67
+ * @param {number} initial_bin Start index for probing
68
+ * @returns {number}
69
+ */
70
+ function hash_grid_get(x, y, z, initial_bin) {
71
+ let bin_index = initial_bin;
72
+
73
+ for (;;) {
74
+ const entry = vertex_grid[bin_index];
75
+
76
+ if (entry === NULL_POINTER) {
77
+ return NULL_POINTER;
78
+ }
79
+
80
+ mesh.vertex_read_coordinate(scratch_vertex1, 0, entry);
81
+
82
+ const d2 = v3_distance_sqr(
83
+ x, y, z,
84
+ scratch_vertex1[0], scratch_vertex1[1], scratch_vertex1[2],
85
+ );
86
+
87
+ if (d2 <= max_distance2) {
88
+ return entry;
89
+ }
90
+
91
+ bin_index = generate_next_linear_congruential_index(bin_index, grid_bin_mask);
92
+ }
93
+ }
94
+
95
+ /**
96
+ * @param {number} vertex
97
+ * @param {number} initial_bin
98
+ */
99
+ function hash_grid_set(vertex, initial_bin) {
100
+ let bin_index = initial_bin;
101
+
102
+ for (;;) {
103
+ const entry = vertex_grid[bin_index];
104
+
105
+ if (entry === NULL_POINTER) {
106
+ vertex_grid[bin_index] = vertex;
107
+ return;
108
+ }
109
+
110
+ bin_index = generate_next_linear_congruential_index(bin_index, grid_bin_mask);
111
+ }
112
+ }
113
+
114
+ let removed_count = 0;
115
+ const scratch_vertex = new Float32Array(3);
116
+
117
+ for (let vertex = 0; vertex < vertex_count; vertex++) {
118
+ if (vertices.is_allocated(vertex) === false) {
119
+ continue;
120
+ }
121
+
122
+ mesh.vertex_read_coordinate(scratch_vertex, 0, vertex);
123
+
124
+ const _x = scratch_vertex[0];
125
+ const _y = scratch_vertex[1];
126
+ const _z = scratch_vertex[2];
127
+
128
+ // 1. Calculate the base integer cell coordinates
129
+ const cx = Math.floor(_x / grid_cell_size) | 0;
130
+ const cy = Math.floor(_y / grid_cell_size) | 0;
131
+ const cz = Math.floor(_z / grid_cell_size) | 0;
132
+
133
+ const initial_bin = hash_int3(cx, cy, cz) & grid_bin_mask;
134
+ let master_vertex = hash_grid_get(_x, _y, _z, initial_bin);
135
+
136
+ // 2. Check NULL_POINTER instead of undefined
137
+ if (master_vertex === NULL_POINTER) {
138
+
139
+ // 3. Search integer neighbors
140
+ search_loop: for (let iz = -1; iz <= 1; iz++) {
141
+ for (let iy = -1; iy <= 1; iy++) {
142
+ for (let ix = -1; ix <= 1; ix++) {
143
+ if (iz === 0 && iy === 0 && ix === 0) continue;
144
+
145
+ const _bin = hash_int3(cx + ix, cy + iy, cz + iz) & grid_bin_mask;
146
+ master_vertex = hash_grid_get(_x, _y, _z, _bin);
147
+
148
+ if (master_vertex !== NULL_POINTER) {
149
+ break search_loop;
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }
155
+
156
+ if (master_vertex === NULL_POINTER) {
157
+ hash_grid_set(vertex, initial_bin);
158
+ } else {
159
+ bt_vertex_replace(mesh, vertex, master_vertex);
160
+ removed_count++;
161
+ }
162
+ }
163
+
164
+ return removed_count;
165
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bt_vert_kill.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/geom/3d/topology/struct/binary/io/vertex/bt_vert_kill.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,sDAFW,MAAM,QAWhB"}
@@ -1,5 +1,6 @@
1
- import { NULL_POINTER } from "../BinaryTopology.js";
2
- import { bt_edge_kill } from "./bt_edge_kill.js";
1
+ import { assert } from "../../../../../../../assert.js";
2
+ import { NULL_POINTER } from "../../BinaryTopology.js";
3
+ import { bt_edge_kill } from "../edge/bt_edge_kill.js";
3
4
  import { bt_kill_only_vert } from "./bt_kill_only_vert.js";
4
5
 
5
6
 
@@ -9,6 +10,8 @@ import { bt_kill_only_vert } from "./bt_kill_only_vert.js";
9
10
  * @param {number} v
10
11
  */
11
12
  export function bt_vert_kill(mesh, v) {
13
+ assert.isNonNegativeInteger(v, 'v');
14
+
12
15
  let e = NULL_POINTER;
13
16
  while ((e = mesh.vertex_read_edge(v)) !== NULL_POINTER) {
14
17
  bt_edge_kill(mesh, e);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Patch mesh structure to make all loops/edges/faces point to this new replacement vertex instead of the victim.
3
+ * This effectively removes any usage of the victim from the mesh enabling us to safely remove it.
4
+ *
5
+ * Note: both victim and replacement vertices must be part of the mesh.
6
+ * Note: does not actually remove the victim vertex from the mesh, only links that point to it that will now point to `replacement` instead.
7
+ * Note: may create degenerate edges if victim and replacement are a part of the same edge originally.
8
+ * @param {BinaryTopology} mesh
9
+ * @param {number} victim
10
+ * @param {number} replacement
11
+ */
12
+ export function bt_vertex_replace(mesh: BinaryTopology, victim: number, replacement: number): void;
13
+ //# sourceMappingURL=bt_vertex_replace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bt_vertex_replace.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.js"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,gEAHW,MAAM,eACN,MAAM,QA8GhB"}
@@ -0,0 +1,125 @@
1
+ import { assert } from "../../../../../../../assert.js";
2
+ import { NULL_POINTER } from "../../BinaryTopology.js";
3
+
4
+ const scratch_edges = new Uint32Array(1024);
5
+
6
+ /**
7
+ * Patch mesh structure to make all loops/edges/faces point to this new replacement vertex instead of the victim.
8
+ * This effectively removes any usage of the victim from the mesh enabling us to safely remove it.
9
+ *
10
+ * Note: both victim and replacement vertices must be part of the mesh.
11
+ * Note: does not actually remove the victim vertex from the mesh, only links that point to it that will now point to `replacement` instead.
12
+ * Note: may create degenerate edges if victim and replacement are a part of the same edge originally.
13
+ * @param {BinaryTopology} mesh
14
+ * @param {number} victim
15
+ * @param {number} replacement
16
+ */
17
+ export function bt_vertex_replace(
18
+ mesh,
19
+ victim,
20
+ replacement
21
+ ) {
22
+
23
+ if (victim === replacement) {
24
+ // special case
25
+ return;
26
+ }
27
+
28
+ // 1. Traverse and collect all edges attached to the victim vertex.
29
+ // We collect them into an array first because we will be mutating their disk cycles
30
+ // during the loop, which would break an inline traversal.
31
+ let edges_to_move_count = 0;
32
+ let curr_e = mesh.vertex_read_edge(victim);
33
+
34
+ if (curr_e !== NULL_POINTER) {
35
+ let start_e = curr_e;
36
+ do {
37
+
38
+ assert.lessThan(edges_to_move_count, scratch_edges.length, "edges_to_move_count");
39
+
40
+ scratch_edges[edges_to_move_count++] = curr_e;
41
+
42
+ // Move to the next edge in the victim's disk cycle
43
+ if (mesh.edge_read_vertex1(curr_e) === victim) {
44
+ curr_e = mesh.edge_read_v1_disk_next(curr_e);
45
+ } else {
46
+ curr_e = mesh.edge_read_v2_disk_next(curr_e);
47
+ }
48
+ } while (curr_e !== start_e && curr_e !== NULL_POINTER);
49
+ }
50
+
51
+ // 2. Unlink the victim vertex by clearing its edge pointer.
52
+ mesh.vertex_write_edge(victim, NULL_POINTER);
53
+
54
+ // 3. Process each edge: update loops, update vertices, and insert into replacement's disk cycle.
55
+ for (let i = 0; i < edges_to_move_count; i++) {
56
+ const e = scratch_edges[i];
57
+
58
+ // --- Update Loops ---
59
+ // Loops are corner representations; we must check the radial cycle of loops around this edge
60
+ let curr_l = mesh.edge_read_loop(e);
61
+ if (curr_l !== NULL_POINTER) {
62
+ let start_l = curr_l;
63
+ do {
64
+ if (mesh.loop_read_vertex(curr_l) === victim) {
65
+ mesh.loop_write_vertex(curr_l, replacement);
66
+ }
67
+ curr_l = mesh.loop_read_radial_next(curr_l);
68
+ } while (curr_l !== start_l && curr_l !== NULL_POINTER);
69
+ }
70
+
71
+ // --- Update Edge Vertices ---
72
+ const is_v1 = mesh.edge_read_vertex1(e) === victim;
73
+ if (is_v1) {
74
+ mesh.edge_write_vertex1(e, replacement);
75
+ } else {
76
+ mesh.edge_write_vertex2(e, replacement);
77
+ }
78
+
79
+ // --- Insert Edge into Replacement's Disk Cycle ---
80
+ const base_edge = mesh.vertex_read_edge(replacement);
81
+
82
+ if (base_edge === NULL_POINTER) {
83
+ // This is the first edge attached to the replacement vertex
84
+ mesh.vertex_write_edge(replacement, e);
85
+ if (is_v1) {
86
+ mesh.edge_write_v1_disk_next(e, e);
87
+ mesh.edge_write_v1_disk_prev(e, e);
88
+ } else {
89
+ mesh.edge_write_v2_disk_next(e, e);
90
+ mesh.edge_write_v2_disk_prev(e, e);
91
+ }
92
+ } else {
93
+ // Splice this edge into the existing disk cycle before base_edge
94
+ const base_is_v1 = mesh.edge_read_vertex1(base_edge) === replacement;
95
+ const base_prev = base_is_v1
96
+ ? mesh.edge_read_v1_disk_prev(base_edge)
97
+ : mesh.edge_read_v2_disk_prev(base_edge);
98
+
99
+ const prev_is_v1 = mesh.edge_read_vertex1(base_prev) === replacement;
100
+
101
+ // 1. Link base_prev -> e
102
+ if (prev_is_v1) {
103
+ mesh.edge_write_v1_disk_next(base_prev, e);
104
+ } else {
105
+ mesh.edge_write_v2_disk_next(base_prev, e);
106
+ }
107
+
108
+ // 2. Link e -> base_prev & e -> base_edge
109
+ if (is_v1) {
110
+ mesh.edge_write_v1_disk_prev(e, base_prev);
111
+ mesh.edge_write_v1_disk_next(e, base_edge);
112
+ } else {
113
+ mesh.edge_write_v2_disk_prev(e, base_prev);
114
+ mesh.edge_write_v2_disk_next(e, base_edge);
115
+ }
116
+
117
+ // 3. Link base_edge -> e
118
+ if (base_is_v1) {
119
+ mesh.edge_write_v1_disk_prev(base_edge, e);
120
+ } else {
121
+ mesh.edge_write_v2_disk_prev(base_edge, e);
122
+ }
123
+ }
124
+ }
125
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ * @param {BinaryTopology} mesh
4
+ * @param {number} edge_id
5
+ * @param {number} vertex_id
6
+ * @returns {boolean}
7
+ */
8
+ export function bt_edge_has_vertex(mesh: BinaryTopology, edge_id: number, vertex_id: number): boolean;
9
+ //# sourceMappingURL=bt_edge_has_vertex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bt_edge_has_vertex.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/geom/3d/topology/struct/binary/query/bt_edge_has_vertex.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,kEAJW,MAAM,aACN,MAAM,GACJ,OAAO,CAUnB"}
@@ -5,7 +5,7 @@
5
5
  * @param {number} vertex_id
6
6
  * @returns {boolean}
7
7
  */
8
- export function bt_mesh_edge_has_vertex(mesh, edge_id, vertex_id) {
8
+ export function bt_edge_has_vertex(mesh, edge_id, vertex_id) {
9
9
  const v1 = mesh.edge_read_vertex1(edge_id);
10
10
 
11
11
  if (v1 === vertex_id) {