@woosh/meep-engine 2.153.0 → 2.154.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 (96) hide show
  1. package/package.json +1 -1
  2. package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts +112 -0
  3. package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts.map +1 -0
  4. package/src/core/geom/3d/shape/ConvexHullShape3D.js +325 -0
  5. package/src/engine/graphics/ecs/trail2d/Trail2D.d.ts +4 -0
  6. package/src/engine/graphics/ecs/trail2d/Trail2D.d.ts.map +1 -1
  7. package/src/engine/graphics/ecs/trail2d/Trail2D.js +21 -0
  8. package/src/engine/physics/PLAN.md +4 -4
  9. package/src/engine/physics/body/BodyStorage.d.ts +3 -1
  10. package/src/engine/physics/body/BodyStorage.d.ts.map +1 -1
  11. package/src/engine/physics/body/BodyStorage.js +452 -450
  12. package/src/engine/physics/body/SolverBodyState.d.ts.map +1 -1
  13. package/src/engine/physics/body/SolverBodyState.js +6 -5
  14. package/src/engine/physics/broadphase/generate_pairs.d.ts.map +1 -1
  15. package/src/engine/physics/broadphase/generate_pairs.js +9 -1
  16. package/src/engine/physics/ccd/linear_sweep.d.ts.map +1 -1
  17. package/src/engine/physics/ccd/linear_sweep.js +237 -238
  18. package/src/engine/physics/computeInterceptPoint.d.ts.map +1 -1
  19. package/src/engine/physics/computeInterceptPoint.js +8 -3
  20. package/src/engine/physics/contact/ManifoldStore.d.ts +0 -16
  21. package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -1
  22. package/src/engine/physics/contact/ManifoldStore.js +1 -38
  23. package/src/engine/physics/ecs/BodyKind.d.ts +3 -2
  24. package/src/engine/physics/ecs/BodyKind.d.ts.map +1 -1
  25. package/src/engine/physics/ecs/BodyKind.js +25 -24
  26. package/src/engine/physics/ecs/PhysicsEvents.d.ts +4 -5
  27. package/src/engine/physics/ecs/PhysicsEvents.d.ts.map +1 -1
  28. package/src/engine/physics/ecs/PhysicsEvents.js +15 -16
  29. package/src/engine/physics/ecs/PhysicsSystem.d.ts +5 -30
  30. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  31. package/src/engine/physics/ecs/PhysicsSystem.js +13 -45
  32. package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts.map +1 -1
  33. package/src/engine/physics/ecs/RigidBodySerializationAdapter.js +85 -81
  34. package/src/engine/physics/ecs/is_sensor.d.ts +18 -0
  35. package/src/engine/physics/ecs/is_sensor.d.ts.map +1 -0
  36. package/src/engine/physics/ecs/is_sensor.js +27 -0
  37. package/src/engine/physics/events/ContactEventBuffer.d.ts +2 -1
  38. package/src/engine/physics/events/ContactEventBuffer.d.ts.map +1 -1
  39. package/src/engine/physics/events/ContactEventBuffer.js +84 -83
  40. package/src/engine/physics/gjk/gjk.d.ts +0 -26
  41. package/src/engine/physics/gjk/gjk.d.ts.map +1 -1
  42. package/src/engine/physics/gjk/gjk.js +3 -52
  43. package/src/engine/physics/gjk/gjk_epa_penetration.d.ts +16 -0
  44. package/src/engine/physics/gjk/gjk_epa_penetration.d.ts.map +1 -0
  45. package/src/engine/physics/gjk/gjk_epa_penetration.js +255 -0
  46. package/src/engine/physics/gjk/minkowski_support.d.ts +4 -9
  47. package/src/engine/physics/gjk/minkowski_support.d.ts.map +1 -1
  48. package/src/engine/physics/gjk/minkowski_support.js +70 -75
  49. package/src/engine/physics/gjk/mpr.d.ts +1 -1
  50. package/src/engine/physics/gjk/mpr.d.ts.map +1 -1
  51. package/src/engine/physics/gjk/mpr.js +362 -344
  52. package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -1
  53. package/src/engine/physics/island/IslandBuilder.js +431 -428
  54. package/src/engine/physics/narrowphase/box_box_manifold.d.ts.map +1 -1
  55. package/src/engine/physics/narrowphase/box_box_manifold.js +4 -81
  56. package/src/engine/physics/narrowphase/box_triangle_contact.d.ts.map +1 -1
  57. package/src/engine/physics/narrowphase/box_triangle_contact.js +4 -39
  58. package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -1
  59. package/src/engine/physics/narrowphase/capsule_contacts.js +459 -462
  60. package/src/engine/physics/narrowphase/clip_against_axis_uv.d.ts.map +1 -1
  61. package/src/engine/physics/narrowphase/clip_against_axis_uv.js +4 -1
  62. package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts +83 -0
  63. package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts.map +1 -0
  64. package/src/engine/physics/narrowphase/convex_convex_manifold.js +425 -0
  65. package/src/engine/physics/narrowphase/convex_decomposition.d.ts +32 -0
  66. package/src/engine/physics/narrowphase/convex_decomposition.d.ts.map +1 -0
  67. package/src/engine/physics/narrowphase/convex_decomposition.js +293 -0
  68. package/src/engine/physics/narrowphase/mesh_convex_hull.d.ts +41 -0
  69. package/src/engine/physics/narrowphase/mesh_convex_hull.d.ts.map +1 -0
  70. package/src/engine/physics/narrowphase/mesh_convex_hull.js +106 -0
  71. package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.d.ts +8 -0
  72. package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.d.ts.map +1 -0
  73. package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.js +117 -0
  74. package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -1
  75. package/src/engine/physics/narrowphase/narrowphase_step.js +105 -102
  76. package/src/engine/physics/narrowphase/reduce_manifold_contacts.d.ts +29 -0
  77. package/src/engine/physics/narrowphase/reduce_manifold_contacts.d.ts.map +1 -0
  78. package/src/engine/physics/narrowphase/reduce_manifold_contacts.js +69 -0
  79. package/src/engine/physics/narrowphase/refine_ray_concave.d.ts.map +1 -1
  80. package/src/engine/physics/narrowphase/refine_ray_concave.js +152 -145
  81. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -1
  82. package/src/engine/physics/narrowphase/sphere_box_contact.js +132 -123
  83. package/src/engine/physics/queries/overlap_shape.d.ts.map +1 -1
  84. package/src/engine/physics/queries/overlap_shape.js +16 -17
  85. package/src/engine/physics/queries/raycast.d.ts +5 -0
  86. package/src/engine/physics/queries/raycast.d.ts.map +1 -1
  87. package/src/engine/physics/queries/raycast.js +16 -8
  88. package/src/engine/physics/queries/shape_cast.d.ts.map +1 -1
  89. package/src/engine/physics/queries/shape_cast.js +13 -7
  90. package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -1
  91. package/src/engine/physics/solver/solve_contacts.js +8 -11
  92. package/src/engine/physics/vehicle/RaycastVehicle.d.ts.map +1 -1
  93. package/src/engine/physics/vehicle/RaycastVehicle.js +339 -333
  94. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts +0 -13
  95. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +0 -1
  96. package/src/engine/physics/gjk/expanding_polytope_algorithm.js +0 -399
@@ -1,75 +1,70 @@
1
- import { v3_length } from "../../../core/geom/vec3/v3_length.js";
2
-
3
- /**
4
- * Compute the Minkowski-difference support point for two convex shapes.
5
- *
6
- * `support_{A−B}(d) = support_A(+d) − support_B(−d)`
7
- *
8
- * This is the bread-and-butter operation of both GJK and MPR — every
9
- * iteration of either algorithm calls it once with a search direction
10
- * to extend the simplex or portal. Factoring it lets the two
11
- * algorithms share the per-call scratch buffers (the support results
12
- * for A and B before the subtraction) so a build that imports both
13
- * doesn't carry duplicate state.
14
- *
15
- * The supplied direction need not be unit — we normalise here, since
16
- * the {@link AbstractShape3D#support} contract assumes a unit vector
17
- * and shape support implementations (sphere especially) don't bother
18
- * to renormalise internally.
19
- *
20
- * NOTE: EPA (`expanding_polytope_algorithm.js`) computes the Minkowski
21
- * support inline rather than calling this. Its convention is the
22
- * opposite sign (B−A rather than A−B), and it skips the normalisation
23
- * because the search directions it constructs from face normals are
24
- * already unit-length. The narrowphase consumer of EPA's output then
25
- * negates the result to get the contact normal in the "B → A" stored
26
- * convention. Folding EPA onto this helper would require both flipping
27
- * its sign convention and changing the narrowphase call site — not
28
- * worth the churn for one call site.
29
- *
30
- * @param {Float64Array|number[]} result 3-vector destination
31
- * @param {number} result_offset
32
- * @param {AbstractShape3D} shape_a
33
- * @param {AbstractShape3D} shape_b
34
- * @param {number} dir_x search direction (any non-zero magnitude)
35
- * @param {number} dir_y
36
- * @param {number} dir_z
37
- */
38
- export function minkowski_support(
39
- result, result_offset,
40
- shape_a,
41
- shape_b,
42
- dir_x, dir_y, dir_z
43
- ) {
44
- const len = v3_length(dir_x, dir_y, dir_z);
45
-
46
- if (len > 0) {
47
- // normalise
48
-
49
- const inv = 1 / len;
50
-
51
- dir_x *= inv;
52
- dir_y *= inv;
53
- dir_z *= inv;
54
-
55
- }
56
-
57
- shape_a.support(scratch_support_a, 0, dir_x, dir_y, dir_z);
58
- shape_b.support(scratch_support_b, 0, -dir_x, -dir_y, -dir_z);
59
-
60
- result[result_offset] = scratch_support_a[0] - scratch_support_b[0];
61
- result[result_offset + 1] = scratch_support_a[1] - scratch_support_b[1];
62
- result[result_offset + 2] = scratch_support_a[2] - scratch_support_b[2];
63
- }
64
-
65
- /**
66
- * Per-shape scratch buffers for the support-function results before
67
- * they're subtracted into the Minkowski-difference point. Module-scoped
68
- * because the physics step is single-threaded; both GJK and MPR run
69
- * sequentially within one narrowphase iteration.
70
- *
71
- * Float64 — matches the precision-sweep treatment of the rest of the
72
- * solver path.
73
- */
74
- const scratch_support_a = new Float64Array(3);
75
- const scratch_support_b = new Float64Array(3);
1
+ import { v3_length } from "../../../core/geom/vec3/v3_length.js";
2
+
3
+ /**
4
+ * Compute the Minkowski-difference support point for two convex shapes.
5
+ *
6
+ * `support_{A−B}(d) = support_A(+d) − support_B(−d)`
7
+ *
8
+ * This is the bread-and-butter operation of both GJK and MPR — every
9
+ * iteration of either algorithm calls it once with a search direction
10
+ * to extend the simplex or portal. Factoring it lets the two
11
+ * algorithms share the per-call scratch buffers (the support results
12
+ * for A and B before the subtraction) so a build that imports both
13
+ * doesn't carry duplicate state.
14
+ *
15
+ * The supplied direction need not be unit — we normalise here, since
16
+ * the {@link AbstractShape3D#support} contract assumes a unit vector
17
+ * and shape support implementations (sphere especially) don't bother
18
+ * to renormalise internally.
19
+ *
20
+ * NOTE: the robust penetration query (`gjk_epa_penetration.js`) computes
21
+ * its own Minkowski-difference support inline rather than calling this
22
+ * helper it is self-contained (its own GJK + EPA) and works on world-
23
+ * space support providers, so it does not share this body-space path.
24
+ *
25
+ * @param {Float64Array|number[]} result 3-vector destination
26
+ * @param {number} result_offset
27
+ * @param {AbstractShape3D} shape_a
28
+ * @param {AbstractShape3D} shape_b
29
+ * @param {number} dir_x search direction (any non-zero magnitude)
30
+ * @param {number} dir_y
31
+ * @param {number} dir_z
32
+ */
33
+ export function minkowski_support(
34
+ result, result_offset,
35
+ shape_a,
36
+ shape_b,
37
+ dir_x, dir_y, dir_z
38
+ ) {
39
+ const len = v3_length(dir_x, dir_y, dir_z);
40
+
41
+ if (len > 0) {
42
+ // normalise
43
+
44
+ const inv = 1 / len;
45
+
46
+ dir_x *= inv;
47
+ dir_y *= inv;
48
+ dir_z *= inv;
49
+
50
+ }
51
+
52
+ shape_a.support(scratch_support_a, 0, dir_x, dir_y, dir_z);
53
+ shape_b.support(scratch_support_b, 0, -dir_x, -dir_y, -dir_z);
54
+
55
+ result[result_offset] = scratch_support_a[0] - scratch_support_b[0];
56
+ result[result_offset + 1] = scratch_support_a[1] - scratch_support_b[1];
57
+ result[result_offset + 2] = scratch_support_a[2] - scratch_support_b[2];
58
+ }
59
+
60
+ /**
61
+ * Per-shape scratch buffers for the support-function results before
62
+ * they're subtracted into the Minkowski-difference point. Module-scoped
63
+ * because the physics step is single-threaded; both GJK and MPR run
64
+ * sequentially within one narrowphase iteration.
65
+ *
66
+ * Float64 matches the precision-sweep treatment of the rest of the
67
+ * solver path.
68
+ */
69
+ const scratch_support_a = new Float64Array(3);
70
+ const scratch_support_b = new Float64Array(3);
@@ -30,7 +30,7 @@
30
30
  * - Tends to converge in 5–15 iterations on typical inputs vs. EPA's
31
31
  * 32+ on smooth pairs.
32
32
  *
33
- * **Output convention matches EPA** ({@link expanding_polytope_algorithm}):
33
+ * **Output convention matches the EPA penetration query** ({@link gjk_epa_penetration}'s MTV form):
34
34
  * `result[result_offset .. result_offset+2]` is the MTV vector —
35
35
  * direction is "from A's surface into B" (i.e. the direction you'd
36
36
  * translate B by to separate the shapes), magnitude is the depth.
@@ -1 +1 @@
1
- {"version":3,"file":"mpr.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/gjk/mpr.js"],"names":[],"mappings":"AA4CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,4BANW,YAAY,iBACZ,MAAM,6CAGJ,OAAO,CAuPnB"}
1
+ {"version":3,"file":"mpr.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/gjk/mpr.js"],"names":[],"mappings":"AAsDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,4BANW,YAAY,iBACZ,MAAM,6CAGJ,OAAO,CA+PnB"}