@woosh/meep-engine 2.163.9 → 2.163.11

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 (41) hide show
  1. package/package.json +1 -1
  2. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_capsule.d.ts +22 -0
  3. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_capsule.d.ts.map +1 -0
  4. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_capsule.js +101 -0
  5. package/src/core/collection/heap/IndexedFloatMaxHeap.d.ts.map +1 -0
  6. package/src/core/{graph/metis/native/refine → collection/heap}/IndexedFloatMaxHeap.js +1 -1
  7. package/src/core/geom/3d/capsule/capsule_intersects_aabb3_closed.d.ts +40 -0
  8. package/src/core/geom/3d/capsule/capsule_intersects_aabb3_closed.d.ts.map +1 -0
  9. package/src/core/geom/3d/capsule/capsule_intersects_aabb3_closed.js +67 -0
  10. package/src/core/geom/3d/capsule/capsule_intersects_aabb3_iterative.d.ts +45 -0
  11. package/src/core/geom/3d/capsule/capsule_intersects_aabb3_iterative.d.ts.map +1 -0
  12. package/src/core/geom/3d/capsule/capsule_intersects_aabb3_iterative.js +137 -0
  13. package/src/core/geom/3d/gjk/GJK_REVIEW_NOTES.md +146 -0
  14. package/src/core/geom/3d/line/line3_compute_segment_nearest_point_to_aabb3_t.d.ts +44 -0
  15. package/src/core/geom/3d/line/line3_compute_segment_nearest_point_to_aabb3_t.d.ts.map +1 -0
  16. package/src/core/geom/3d/line/line3_compute_segment_nearest_point_to_aabb3_t.js +153 -0
  17. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts.map +1 -1
  18. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +18 -7
  19. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_resolve_t_junctions.d.ts +6 -0
  20. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_resolve_t_junctions.d.ts.map +1 -1
  21. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_resolve_t_junctions.js +139 -95
  22. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts.map +1 -1
  23. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js +2 -26
  24. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify_by_error.d.ts +19 -0
  25. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify_by_error.d.ts.map +1 -0
  26. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify_by_error.js +555 -0
  27. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_swap_vertex_slots.d.ts +13 -0
  28. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_swap_vertex_slots.d.ts.map +1 -0
  29. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_swap_vertex_slots.js +28 -0
  30. package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts +1 -1
  31. package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts.map +1 -1
  32. package/src/core/graph/metis/native/bisection/BisectionScratch.js +1 -1
  33. package/src/core/graph/metis/native/refine/RefinementScratch.d.ts +1 -1
  34. package/src/core/graph/metis/native/refine/RefinementScratch.d.ts.map +1 -1
  35. package/src/core/graph/metis/native/refine/RefinementScratch.js +1 -1
  36. package/src/engine/navigation/mesh/build/navmesh_build_topology.d.ts.map +1 -1
  37. package/src/engine/navigation/mesh/build/navmesh_build_topology.js +25 -0
  38. package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -1
  39. package/src/engine/physics/narrowphase/capsule_contacts.js +14 -21
  40. package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts.map +0 -1
  41. /package/src/core/{graph/metis/native/refine → collection/heap}/IndexedFloatMaxHeap.d.ts +0 -0
@@ -41,8 +41,17 @@ import {
41
41
  import {
42
42
  bt_mesh_fill_small_holes
43
43
  } from "../../../../core/geom/3d/topology/struct/binary/io/bt_mesh_fill_small_holes.js";
44
+ import {
45
+ bt_mesh_simplify_by_error
46
+ } from "../../../../core/geom/3d/topology/struct/binary/io/bt_mesh_simplify_by_error.js";
44
47
  import { clip_soup_against_overhangs } from "./clip_soup_against_overhangs.js";
45
48
 
49
+ // Fraction of the agent radius used as the navmesh cleanup error budget (see the cleanup pass in
50
+ // navmesh_build_topology). A larger agent cannot resolve fine surface detail and the walkable
51
+ // surface was already inset by agent_radius during erosion, so a small fraction of it is a safe,
52
+ // navigation-imperceptible bound on how far cleanup may move the surface or the walkable outline.
53
+ const NAVMESH_SIMPLIFY_ERROR_FRACTION = 0.05;
54
+
46
55
 
47
56
  /**
48
57
  * Build from given scene geometry
@@ -98,6 +107,11 @@ export function navmesh_build_topology({
98
107
  let raw_triangles = [];
99
108
  let triangle_count = 0;
100
109
 
110
+ // NOTE: the inherited source tessellation is cleaned up at the end of this function by
111
+ // bt_mesh_simplify_by_error (interior coplanar fans + collinear boundary runs collapsed). A
112
+ // further win -- re-triangulating large flat regions to a minimal polygon set -- is left as a
113
+ // possible follow-up.
114
+
101
115
  for (let face_id = 0; face_id < source_face_count; face_id++) {
102
116
 
103
117
  source.face_read_normal(scratch_normal, 0, face_id);
@@ -234,6 +248,17 @@ export function navmesh_build_topology({
234
248
  }
235
249
  }
236
250
 
251
+ // --- Clean up the dense triangulation inherited from the source render geometry ---
252
+ // The navmesh arrives with far more triangles than navigation needs (a flat floor comes in
253
+ // as many coplanar triangles). Collapse only the geometrically redundant ones -- interior
254
+ // near-coplanar fans and collinear runs of boundary vertices -- without moving the surface
255
+ // or the walkable outline (and obstacle holes) by more than a small fraction of the agent
256
+ // radius. With agent_radius 0 the tolerance is 0 and this is a no-op.
257
+ if (agent_radius > 0) {
258
+ bt_mesh_simplify_by_error(mesh, agent_radius * NAVMESH_SIMPLIFY_ERROR_FRACTION);
259
+ bt_mesh_compact(mesh);
260
+ }
261
+
237
262
  // face normals are consumed by navigation queries (string-pulling portal normals), populate them now
238
263
  bt_mesh_compute_face_normals(mesh);
239
264
 
@@ -1 +1 @@
1
- {"version":3,"file":"capsule_contacts.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/narrowphase/capsule_contacts.js"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;;GAeG;AACH,2CAVW,MAAM,EAAE,GAAC,YAAY,MACrB,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,eACN,MAAM,QAOhB;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,4CAhBW,MAAM,EAAE,GAAC,YAAY,QACrB,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,YACN,MAAM,YACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,YACN,MAAM,GACJ,OAAO,CA6CnB;AAMD;;;;;GAKG;AACH,6CAHW,MAAM,EAAE,GAAC,YAAY,yNACnB,OAAO,CAuEnB;AA8BD;;;;;;;;;GASG;AACH,oDAHW,MAAM,EAAE,GAAC,YAAY,yNACnB,MAAM,CAoHlB;AASD;;;;;;;;;;;;;GAaG;AACH,yCAHW,MAAM,EAAE,GAAC,YAAY,4NACnB,OAAO,CAqGnB;AAyCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,gDAtBW,YAAY,QACZ,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,YACN,MAAM,YACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,GACJ,MAAM,CAsElB;AAzaD;;;;;;;;GAQG;AACH,6CAFU,MAAM,CAEiC;AAEjD;;;;GAIG;AACH,2CAFU,MAAM,CAE8B;AAsQ9C;;;;;;;;;;GAUG;AACH,yCAFU,MAAM,CAE6B;AAE7C;;;;;GAKG;AACH,uCAFU,MAAM,CAE0B"}
1
+ {"version":3,"file":"capsule_contacts.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/narrowphase/capsule_contacts.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;GAeG;AACH,2CAVW,MAAM,EAAE,GAAC,YAAY,MACrB,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,eACN,MAAM,QAOhB;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,4CAhBW,MAAM,EAAE,GAAC,YAAY,QACrB,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,YACN,MAAM,YACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,YACN,MAAM,GACJ,OAAO,CA6CnB;AAMD;;;;;GAKG;AACH,6CAHW,MAAM,EAAE,GAAC,YAAY,yNACnB,OAAO,CAuEnB;AA8BD;;;;;;;;;GASG;AACH,oDAHW,MAAM,EAAE,GAAC,YAAY,yNACnB,MAAM,CAoHlB;AASD;;;;;;;;;;;;;GAaG;AACH,yCAHW,MAAM,EAAE,GAAC,YAAY,4NACnB,OAAO,CA6FnB;AAyCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,gDAtBW,YAAY,QACZ,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,YACN,MAAM,YACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,GACJ,MAAM,CAsElB;AAjaD;;;;;;;;GAQG;AACH,6CAFU,MAAM,CAEiC;AAEjD;;;;GAIG;AACH,2CAFU,MAAM,CAE8B;AA8P9C;;;;;;;;;;GAUG;AACH,yCAFU,MAAM,CAE6B;AAE7C;;;;;GAKG;AACH,uCAFU,MAAM,CAE0B"}
@@ -1,5 +1,6 @@
1
1
  import { line3_closest_points_segment_segment } from "../../../core/geom/3d/line/line3_closest_points_segment_segment.js";
2
2
  import { line3_compute_segment_nearest_point_to_point_t } from "../../../core/geom/3d/line/line3_compute_segment_nearest_point_to_point_t.js";
3
+ import { line3_compute_segment_nearest_point_to_aabb3_t } from "../../../core/geom/3d/line/line3_compute_segment_nearest_point_to_aabb3_t.js";
3
4
  import { v3_quat3_apply } from "../../../core/geom/vec3/v3_quat3_apply.js";
4
5
  import { v3_quat3_apply_inverse } from "../../../core/geom/vec3/v3_quat3_apply_inverse.js";
5
6
  import { sphere_box_contact } from "./sphere_box_contact.js";
@@ -389,27 +390,19 @@ export function capsule_box_contact(
389
390
  const a0lx = scratch_a0_local[0], a0ly = scratch_a0_local[1], a0lz = scratch_a0_local[2];
390
391
  const a1lx = scratch_a1_local[0], a1ly = scratch_a1_local[1], a1lz = scratch_a1_local[2];
391
392
 
392
- // Fixed-point iteration: start with t at the closest point to the box centre.
393
- let t = line3_compute_segment_nearest_point_to_point_t(a0lx, a0ly, a0lz, a1lx, a1ly, a1lz, 0, 0, 0);
394
- let plx = a0lx + (a1lx - a0lx) * t;
395
- let ply = a0ly + (a1ly - a0ly) * t;
396
- let plz = a0lz + (a1lz - a0lz) * t;
397
-
398
- for (let iter = 0; iter < 2; iter++) {
399
- // Clamp current segment point to the box → closest box-surface point.
400
- const qlx = plx < -b_hx ? -b_hx : (plx > b_hx ? b_hx : plx);
401
- const qly = ply < -b_hy ? -b_hy : (ply > b_hy ? b_hy : ply);
402
- const qlz = plz < -b_hz ? -b_hz : (plz > b_hz ? b_hz : plz);
403
-
404
- // Re-find closest segment point to that box point.
405
- t = line3_compute_segment_nearest_point_to_point_t(
406
- a0lx, a0ly, a0lz, a1lx, a1ly, a1lz,
407
- qlx, qly, qlz
408
- );
409
- plx = a0lx + (a1lx - a0lx) * t;
410
- ply = a0ly + (a1ly - a0ly) * t;
411
- plz = a0lz + (a1lz - a0lz) * t;
412
- }
393
+ // Exact closest point on the capsule segment to the box-local AABB [−h, h].
394
+ // Replaces a 2-iteration alternating projection (project onto segment, clamp
395
+ // into box, repeat) that converged too slowly for capsules near-parallel to
396
+ // a box face/edge overestimating the segment-vs-box distance, which
397
+ // under-detected contacts (~0.85% of random configs missed) and mis-placed
398
+ // depth/normal on many more. See core/geom/3d/gjk/GJK_REVIEW_NOTES.md.
399
+ const t = line3_compute_segment_nearest_point_to_aabb3_t(
400
+ a0lx, a0ly, a0lz, a1lx, a1ly, a1lz,
401
+ -b_hx, -b_hy, -b_hz, b_hx, b_hy, b_hz
402
+ );
403
+ const plx = a0lx + (a1lx - a0lx) * t;
404
+ const ply = a0ly + (a1ly - a0ly) * t;
405
+ const plz = a0lz + (a1lz - a0lz) * t;
413
406
 
414
407
  // Final box-side point. `let` because the interior branch snaps it onto
415
408
  // the chosen face — for an inside segment point the clamp is an identity.
@@ -1 +0,0 @@
1
- {"version":3,"file":"IndexedFloatMaxHeap.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/graph/metis/native/refine/IndexedFloatMaxHeap.js"],"names":[],"mappings":"AA6BA;IACI;;;OAGG;IACH,yBAHW,MAAM,0BACN,MAAM,EAsBhB;IAbG,wBAA4C;IAC5C,eAAe;IAEf,2BAA4E;IAC5E,2BAAwD;IACxD,6BAA0D;IAE1D;;;OAGG;IACH,cAFU,WAAW,CAE2B;IAIpD,mBAEC;IAED;;;OAGG;IACH,cAQC;IAED,2BAEC;IAED;;;OAGG;IACH,qBAkBC;IAED;;;;OAIG;IACH,oBAsBC;IAED;;;;OAIG;IACH,kBAYC;IAED,wBAUC;IAED;;;OAGG;IACH,WAHW,MAAM,SACN,MAAM,QAehB;IAED;;OAEG;IACH,WAFa,MAAM,CAuBlB;IAED;;;OAGG;IACH,WAHW,MAAM,aACN,MAAM,QAehB;IAED;;;OAGG;IACH,WAHW,MAAM,GACJ,OAAO,CA+BnB;CACJ"}