@woosh/meep-engine 2.153.0 → 2.155.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 (107) 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/core/geom/vec3/v3_array_copy.d.ts +3 -3
  6. package/src/core/geom/vec3/v3_array_copy.d.ts.map +1 -1
  7. package/src/core/geom/vec3/v3_array_copy.js +2 -2
  8. package/src/core/geom/vec3/v3_cross.d.ts +17 -0
  9. package/src/core/geom/vec3/v3_cross.d.ts.map +1 -0
  10. package/src/core/geom/vec3/v3_cross.js +20 -0
  11. package/src/core/geom/vec3/v3_subtract.d.ts +16 -0
  12. package/src/core/geom/vec3/v3_subtract.d.ts.map +1 -0
  13. package/src/core/geom/vec3/v3_subtract.js +19 -0
  14. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts.map +1 -1
  15. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +8 -0
  16. package/src/engine/graphics/ecs/trail2d/Trail2D.d.ts +4 -0
  17. package/src/engine/graphics/ecs/trail2d/Trail2D.d.ts.map +1 -1
  18. package/src/engine/graphics/ecs/trail2d/Trail2D.js +21 -0
  19. package/src/engine/physics/PLAN.md +4 -4
  20. package/src/engine/physics/body/BodyStorage.d.ts +3 -1
  21. package/src/engine/physics/body/BodyStorage.d.ts.map +1 -1
  22. package/src/engine/physics/body/BodyStorage.js +452 -450
  23. package/src/engine/physics/body/SolverBodyState.d.ts.map +1 -1
  24. package/src/engine/physics/body/SolverBodyState.js +6 -5
  25. package/src/engine/physics/broadphase/generate_pairs.d.ts.map +1 -1
  26. package/src/engine/physics/broadphase/generate_pairs.js +9 -1
  27. package/src/engine/physics/ccd/linear_sweep.d.ts.map +1 -1
  28. package/src/engine/physics/ccd/linear_sweep.js +237 -238
  29. package/src/engine/physics/computeInterceptPoint.d.ts.map +1 -1
  30. package/src/engine/physics/computeInterceptPoint.js +8 -3
  31. package/src/engine/physics/contact/ManifoldStore.d.ts +0 -16
  32. package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -1
  33. package/src/engine/physics/contact/ManifoldStore.js +1 -38
  34. package/src/engine/physics/ecs/BodyKind.d.ts +3 -2
  35. package/src/engine/physics/ecs/BodyKind.d.ts.map +1 -1
  36. package/src/engine/physics/ecs/BodyKind.js +25 -24
  37. package/src/engine/physics/ecs/PhysicsEvents.d.ts +4 -5
  38. package/src/engine/physics/ecs/PhysicsEvents.d.ts.map +1 -1
  39. package/src/engine/physics/ecs/PhysicsEvents.js +15 -16
  40. package/src/engine/physics/ecs/PhysicsSystem.d.ts +5 -30
  41. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  42. package/src/engine/physics/ecs/PhysicsSystem.js +13 -45
  43. package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts.map +1 -1
  44. package/src/engine/physics/ecs/RigidBodySerializationAdapter.js +85 -81
  45. package/src/engine/physics/ecs/is_sensor.d.ts +18 -0
  46. package/src/engine/physics/ecs/is_sensor.d.ts.map +1 -0
  47. package/src/engine/physics/ecs/is_sensor.js +27 -0
  48. package/src/engine/physics/events/ContactEventBuffer.d.ts +2 -1
  49. package/src/engine/physics/events/ContactEventBuffer.d.ts.map +1 -1
  50. package/src/engine/physics/events/ContactEventBuffer.js +84 -83
  51. package/src/engine/physics/gjk/gjk.d.ts +0 -26
  52. package/src/engine/physics/gjk/gjk.d.ts.map +1 -1
  53. package/src/engine/physics/gjk/gjk.js +3 -52
  54. package/src/engine/physics/gjk/gjk_epa_penetration.d.ts +20 -0
  55. package/src/engine/physics/gjk/gjk_epa_penetration.d.ts.map +1 -0
  56. package/src/engine/physics/gjk/gjk_epa_penetration.js +548 -0
  57. package/src/engine/physics/gjk/minkowski_support.d.ts +4 -9
  58. package/src/engine/physics/gjk/minkowski_support.d.ts.map +1 -1
  59. package/src/engine/physics/gjk/minkowski_support.js +70 -75
  60. package/src/engine/physics/gjk/mpr.d.ts +1 -1
  61. package/src/engine/physics/gjk/mpr.d.ts.map +1 -1
  62. package/src/engine/physics/gjk/mpr.js +362 -344
  63. package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -1
  64. package/src/engine/physics/island/IslandBuilder.js +431 -428
  65. package/src/engine/physics/narrowphase/box_box_manifold.d.ts.map +1 -1
  66. package/src/engine/physics/narrowphase/box_box_manifold.js +4 -81
  67. package/src/engine/physics/narrowphase/box_triangle_contact.d.ts.map +1 -1
  68. package/src/engine/physics/narrowphase/box_triangle_contact.js +4 -39
  69. package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -1
  70. package/src/engine/physics/narrowphase/capsule_contacts.js +459 -462
  71. package/src/engine/physics/narrowphase/clip_against_axis_uv.d.ts.map +1 -1
  72. package/src/engine/physics/narrowphase/clip_against_axis_uv.js +4 -1
  73. package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts +83 -0
  74. package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts.map +1 -0
  75. package/src/engine/physics/narrowphase/convex_convex_manifold.js +425 -0
  76. package/src/engine/physics/narrowphase/convex_decomposition.d.ts +32 -0
  77. package/src/engine/physics/narrowphase/convex_decomposition.d.ts.map +1 -0
  78. package/src/engine/physics/narrowphase/convex_decomposition.js +293 -0
  79. package/src/engine/physics/narrowphase/mesh_convex_hull.d.ts +41 -0
  80. package/src/engine/physics/narrowphase/mesh_convex_hull.d.ts.map +1 -0
  81. package/src/engine/physics/narrowphase/mesh_convex_hull.js +106 -0
  82. package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.d.ts +8 -0
  83. package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.d.ts.map +1 -0
  84. package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.js +117 -0
  85. package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -1
  86. package/src/engine/physics/narrowphase/narrowphase_step.js +105 -102
  87. package/src/engine/physics/narrowphase/reduce_manifold_contacts.d.ts +29 -0
  88. package/src/engine/physics/narrowphase/reduce_manifold_contacts.d.ts.map +1 -0
  89. package/src/engine/physics/narrowphase/reduce_manifold_contacts.js +69 -0
  90. package/src/engine/physics/narrowphase/refine_ray_concave.d.ts.map +1 -1
  91. package/src/engine/physics/narrowphase/refine_ray_concave.js +152 -145
  92. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -1
  93. package/src/engine/physics/narrowphase/sphere_box_contact.js +132 -123
  94. package/src/engine/physics/queries/overlap_shape.d.ts.map +1 -1
  95. package/src/engine/physics/queries/overlap_shape.js +16 -17
  96. package/src/engine/physics/queries/raycast.d.ts +5 -0
  97. package/src/engine/physics/queries/raycast.d.ts.map +1 -1
  98. package/src/engine/physics/queries/raycast.js +16 -8
  99. package/src/engine/physics/queries/shape_cast.d.ts.map +1 -1
  100. package/src/engine/physics/queries/shape_cast.js +13 -7
  101. package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -1
  102. package/src/engine/physics/solver/solve_contacts.js +8 -11
  103. package/src/engine/physics/vehicle/RaycastVehicle.d.ts.map +1 -1
  104. package/src/engine/physics/vehicle/RaycastVehicle.js +339 -333
  105. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts +0 -13
  106. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +0 -1
  107. package/src/engine/physics/gjk/expanding_polytope_algorithm.js +0 -399
@@ -1,83 +1,84 @@
1
- /**
2
- * Event kinds emitted by the manifold diff pass.
3
- * @readonly
4
- * @enum {number}
5
- */
6
- export const ContactEventKind = {
7
- Begin: 0,
8
- Stay: 1,
9
- End: 2,
10
- };
11
-
12
- const DEFAULT_INITIAL_CAPACITY = 32;
13
-
14
- /**
15
- * Per-event stride in the Uint32 backing array:
16
- * 0 : kind (ContactEventKind)
17
- * 1 : entityA
18
- * 2 : entityB
19
- * 3 : slot
20
- * @type {number}
21
- */
22
- const EVENT_STRIDE = 4;
23
-
24
- /**
25
- * Append-only buffer of contact events produced during one fixedUpdate, ready
26
- * to be dispatched (and then cleared) at end-of-step.
27
- *
28
- * Storage is flat Uint32Array keeping the metadata side allocation-free; the
29
- * actual contact payload (normal, depth, world point) is read on demand from
30
- * the {@link ManifoldStore} by the dispatch code.
31
- *
32
- * @author Alex Goldring
33
- * @copyright Company Named Limited (c) 2026
34
- */
35
- export class ContactEventBuffer {
36
- /**
37
- * @param {number} [initial_capacity] events
38
- */
39
- constructor(initial_capacity = DEFAULT_INITIAL_CAPACITY) {
40
- this.__capacity = Math.max(1, initial_capacity);
41
- this.__count = 0;
42
- // Int32 so entity ids may legitimately store -1 (stale body after free).
43
- this.__data = new Int32Array(this.__capacity * EVENT_STRIDE);
44
- }
45
-
46
- /**
47
- * @returns {number}
48
- */
49
- get count() {
50
- return this.__count;
51
- }
52
-
53
- clear() {
54
- this.__count = 0;
55
- }
56
-
57
- /**
58
- * @param {ContactEventKind|number} kind
59
- * @param {number} entityA
60
- * @param {number} entityB
61
- * @param {number} slot manifold slot id
62
- */
63
- push(kind, entityA, entityB, slot) {
64
- if (this.__count === this.__capacity) {
65
- const new_cap = this.__capacity << 1;
66
- const next = new Int32Array(new_cap * EVENT_STRIDE);
67
- next.set(this.__data);
68
- this.__data = next;
69
- this.__capacity = new_cap;
70
- }
71
- const off = this.__count * EVENT_STRIDE;
72
- this.__data[off] = kind;
73
- this.__data[off + 1] = entityA;
74
- this.__data[off + 2] = entityB;
75
- this.__data[off + 3] = slot;
76
- this.__count++;
77
- }
78
-
79
- kind_at(i) { return this.__data[i * EVENT_STRIDE]; }
80
- entityA_at(i) { return this.__data[i * EVENT_STRIDE + 1]; }
81
- entityB_at(i) { return this.__data[i * EVENT_STRIDE + 2]; }
82
- slot_at(i) { return this.__data[i * EVENT_STRIDE + 3]; }
83
- }
1
+ /**
2
+ * Event kinds emitted by the manifold diff pass.
3
+ * @readonly
4
+ * @enum {number}
5
+ */
6
+ export const ContactEventKind = {
7
+ Begin: 0,
8
+ Stay: 1,
9
+ End: 2,
10
+ };
11
+
12
+ const DEFAULT_INITIAL_CAPACITY = 32;
13
+
14
+ /**
15
+ * Per-event stride in the Int32 backing array:
16
+ * 0 : kind (ContactEventKind)
17
+ * 1 : entityA
18
+ * 2 : entityB
19
+ * 3 : slot
20
+ * @type {number}
21
+ */
22
+ const EVENT_STRIDE = 4;
23
+
24
+ /**
25
+ * Append-only buffer of contact events produced during one fixedUpdate, ready
26
+ * to be dispatched (and then cleared) at end-of-step.
27
+ *
28
+ * Storage is flat Int32Array (signed: entity ids may legitimately be -1 for a
29
+ * stale body after free) keeping the metadata side allocation-free; the
30
+ * actual contact payload (normal, depth, world point) is read on demand from
31
+ * the {@link ManifoldStore} by the dispatch code.
32
+ *
33
+ * @author Alex Goldring
34
+ * @copyright Company Named Limited (c) 2026
35
+ */
36
+ export class ContactEventBuffer {
37
+ /**
38
+ * @param {number} [initial_capacity] events
39
+ */
40
+ constructor(initial_capacity = DEFAULT_INITIAL_CAPACITY) {
41
+ this.__capacity = Math.max(1, initial_capacity);
42
+ this.__count = 0;
43
+ // Int32 so entity ids may legitimately store -1 (stale body after free).
44
+ this.__data = new Int32Array(this.__capacity * EVENT_STRIDE);
45
+ }
46
+
47
+ /**
48
+ * @returns {number}
49
+ */
50
+ get count() {
51
+ return this.__count;
52
+ }
53
+
54
+ clear() {
55
+ this.__count = 0;
56
+ }
57
+
58
+ /**
59
+ * @param {ContactEventKind|number} kind
60
+ * @param {number} entityA
61
+ * @param {number} entityB
62
+ * @param {number} slot manifold slot id
63
+ */
64
+ push(kind, entityA, entityB, slot) {
65
+ if (this.__count === this.__capacity) {
66
+ const new_cap = this.__capacity << 1;
67
+ const next = new Int32Array(new_cap * EVENT_STRIDE);
68
+ next.set(this.__data);
69
+ this.__data = next;
70
+ this.__capacity = new_cap;
71
+ }
72
+ const off = this.__count * EVENT_STRIDE;
73
+ this.__data[off] = kind;
74
+ this.__data[off + 1] = entityA;
75
+ this.__data[off + 2] = entityB;
76
+ this.__data[off + 3] = slot;
77
+ this.__count++;
78
+ }
79
+
80
+ kind_at(i) { return this.__data[i * EVENT_STRIDE]; }
81
+ entityA_at(i) { return this.__data[i * EVENT_STRIDE + 1]; }
82
+ entityB_at(i) { return this.__data[i * EVENT_STRIDE + 2]; }
83
+ slot_at(i) { return this.__data[i * EVENT_STRIDE + 3]; }
84
+ }
@@ -13,30 +13,4 @@
13
13
  * @returns {boolean} true if the shapes intersect
14
14
  */
15
15
  export function gjk(simplex: number[] | Float64Array, shape_a: AbstractShape3D, shape_b: AbstractShape3D): boolean;
16
- /**
17
- * Separating-axis-cached variant of {@link gjk}. The 3 floats at
18
- * `axis_buffer[axis_offset..+2]` are used as the initial search
19
- * direction (seed) AND are overwritten with the final search direction
20
- * on exit. The narrowphase keeps a per-manifold-slot cache of these
21
- * three floats so quiescent contacts converge in 1–2 iterations next
22
- * frame instead of ~6–10 from a cold `(1, 0, 0)` start (Bullet's
23
- * `m_cachedSeparatingAxis` and Jolt's `ioV` use the same pattern).
24
- *
25
- * The same primitive doubles as a separating-axis cache for the
26
- * "no-overlap" path: when GJK returns false, the final direction is
27
- * roughly the separating axis, and next frame's first iteration
28
- * detects separation immediately.
29
- *
30
- * Writeback is automatic — `gjk_core` mutates a `subarray` view of
31
- * `axis_buffer`, so on return `axis_buffer[axis_offset..+2]` holds the
32
- * final direction. No try/finally needed.
33
- *
34
- * @param {number[]|Float64Array} simplex
35
- * @param {AbstractShape3D} shape_a
36
- * @param {AbstractShape3D} shape_b
37
- * @param {Float64Array} axis_buffer
38
- * @param {number} axis_offset
39
- * @returns {boolean}
40
- */
41
- export function gjk_with_axis(simplex: number[] | Float64Array, shape_a: AbstractShape3D, shape_b: AbstractShape3D, axis_buffer: Float64Array, axis_offset: number): boolean;
42
16
  //# sourceMappingURL=gjk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gjk.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/gjk/gjk.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;GAaG;AACH,6BALW,MAAM,EAAE,GAAC,YAAY,uDAGnB,OAAO,CAWnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,uCAPW,MAAM,EAAE,GAAC,YAAY,mEAGrB,YAAY,eACZ,MAAM,GACJ,OAAO,CAqBnB"}
1
+ {"version":3,"file":"gjk.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/gjk/gjk.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;GAaG;AACH,6BALW,MAAM,EAAE,GAAC,YAAY,uDAGnB,OAAO,CAWnB"}
@@ -40,60 +40,11 @@ export function gjk(simplex, shape_a, shape_b) {
40
40
  return gjk_core(simplex, shape_a, shape_b, scratch_dir);
41
41
  }
42
42
 
43
- /**
44
- * Separating-axis-cached variant of {@link gjk}. The 3 floats at
45
- * `axis_buffer[axis_offset..+2]` are used as the initial search
46
- * direction (seed) AND are overwritten with the final search direction
47
- * on exit. The narrowphase keeps a per-manifold-slot cache of these
48
- * three floats so quiescent contacts converge in 1–2 iterations next
49
- * frame instead of ~6–10 from a cold `(1, 0, 0)` start (Bullet's
50
- * `m_cachedSeparatingAxis` and Jolt's `ioV` use the same pattern).
51
- *
52
- * The same primitive doubles as a separating-axis cache for the
53
- * "no-overlap" path: when GJK returns false, the final direction is
54
- * roughly the separating axis, and next frame's first iteration
55
- * detects separation immediately.
56
- *
57
- * Writeback is automatic — `gjk_core` mutates a `subarray` view of
58
- * `axis_buffer`, so on return `axis_buffer[axis_offset..+2]` holds the
59
- * final direction. No try/finally needed.
60
- *
61
- * @param {number[]|Float64Array} simplex
62
- * @param {AbstractShape3D} shape_a
63
- * @param {AbstractShape3D} shape_b
64
- * @param {Float64Array} axis_buffer
65
- * @param {number} axis_offset
66
- * @returns {boolean}
67
- */
68
- export function gjk_with_axis(simplex, shape_a, shape_b, axis_buffer, axis_offset) {
69
- // Subarray view: zero-copy in V8 once the JIT realises both views
70
- // back the same buffer; the in-place writes inside gjk_core
71
- // propagate to axis_buffer automatically.
72
- const dir_view = axis_buffer.subarray(axis_offset, axis_offset + 3);
73
-
74
- // Guard against a stale or degenerate cached axis. A zero vector
75
- // (first-frame initial state, or a stuck cache) and NaN / Inf
76
- // would crash the first support-point query; the (1, 0, 0)
77
- // fallback is the cold-start default.
78
- const x = dir_view[0], y = dir_view[1], z = dir_view[2];
79
- if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z)
80
- || (x === 0 && y === 0 && z === 0)) {
81
- dir_view[0] = 1;
82
- dir_view[1] = 0;
83
- dir_view[2] = 0;
84
- }
85
-
86
- return gjk_core(simplex, shape_a, shape_b, dir_view);
87
- }
88
-
89
43
  /**
90
44
  * Core GJK routine — parameterised on the search-direction buffer.
91
- * The caller seeds `dir[0..2]` with an initial direction (typically
92
- * `(1, 0, 0)` for cold starts or a cached separating axis from a
93
- * previous frame), and on return `dir` holds the FINAL search
94
- * direction the algorithm settled on. The narrowphase separating-
95
- * axis cache (P2.1) uses this to thread per-manifold axes through
96
- * `gjk_with_axis` without a try/finally writeback dance.
45
+ * The caller seeds `dir[0..2]` with an initial direction (`(1, 0, 0)`
46
+ * for the {@link gjk} cold-start wrapper), and on return `dir` holds the
47
+ * FINAL search direction the algorithm settled on.
97
48
  *
98
49
  * @param {number[]|Float64Array} simplex
99
50
  * @param {AbstractShape3D} shape_a
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Penetration depth + normal between two convex support providers at world pose.
3
+ * Writes the unit separation normal (B→A) into `out` and returns the depth
4
+ * (positive on overlap, 0 if separated — `out` untouched on 0).
5
+ *
6
+ * @param {Float64Array|number[]} out destination for the unit normal, length ≥ 3
7
+ * @param {SupportProvider} A world-space support provider (e.g. PosedShape)
8
+ * @param {SupportProvider} B world-space support provider (e.g. PosedShape)
9
+ * @returns {number} penetration depth, or 0 if separated
10
+ */
11
+ export function gjk_epa_penetration(out: Float64Array | number[], A: SupportProvider, B: SupportProvider): number;
12
+ /**
13
+ * A convex shape exposing a world-space support mapping: `support(out, off, dx,
14
+ * dy, dz)` writes the farthest point of the shape in direction `(dx, dy, dz)`
15
+ * into `out[off..off+2]` (e.g. {@link PosedShape }).
16
+ */
17
+ export type SupportProvider = {
18
+ support: (arg0: Float64Array, arg1: number, arg2: number, arg3: number, arg4: number) => void;
19
+ };
20
+ //# sourceMappingURL=gjk_epa_penetration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gjk_epa_penetration.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/gjk/gjk_epa_penetration.js"],"names":[],"mappings":"AAmhBA;;;;;;;;;GASG;AACH,yCALW,YAAY,GAAC,MAAM,EAAE,KACrB,eAAe,KACf,eAAe,GACb,MAAM,CAQlB;;;;;;8BAndY;IAAE,OAAO,SAAW,YAAY,QAAE,MAAM,QAAE,MAAM,QAAE,MAAM,QAAE,MAAM,KAAG,IAAI,CAAA;CAAE"}