@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.
- package/package.json +1 -1
- package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts +112 -0
- package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts.map +1 -0
- package/src/core/geom/3d/shape/ConvexHullShape3D.js +325 -0
- package/src/engine/graphics/ecs/trail2d/Trail2D.d.ts +4 -0
- package/src/engine/graphics/ecs/trail2d/Trail2D.d.ts.map +1 -1
- package/src/engine/graphics/ecs/trail2d/Trail2D.js +21 -0
- package/src/engine/physics/PLAN.md +4 -4
- package/src/engine/physics/body/BodyStorage.d.ts +3 -1
- package/src/engine/physics/body/BodyStorage.d.ts.map +1 -1
- package/src/engine/physics/body/BodyStorage.js +452 -450
- package/src/engine/physics/body/SolverBodyState.d.ts.map +1 -1
- package/src/engine/physics/body/SolverBodyState.js +6 -5
- package/src/engine/physics/broadphase/generate_pairs.d.ts.map +1 -1
- package/src/engine/physics/broadphase/generate_pairs.js +9 -1
- package/src/engine/physics/ccd/linear_sweep.d.ts.map +1 -1
- package/src/engine/physics/ccd/linear_sweep.js +237 -238
- package/src/engine/physics/computeInterceptPoint.d.ts.map +1 -1
- package/src/engine/physics/computeInterceptPoint.js +8 -3
- package/src/engine/physics/contact/ManifoldStore.d.ts +0 -16
- package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -1
- package/src/engine/physics/contact/ManifoldStore.js +1 -38
- package/src/engine/physics/ecs/BodyKind.d.ts +3 -2
- package/src/engine/physics/ecs/BodyKind.d.ts.map +1 -1
- package/src/engine/physics/ecs/BodyKind.js +25 -24
- package/src/engine/physics/ecs/PhysicsEvents.d.ts +4 -5
- package/src/engine/physics/ecs/PhysicsEvents.d.ts.map +1 -1
- package/src/engine/physics/ecs/PhysicsEvents.js +15 -16
- package/src/engine/physics/ecs/PhysicsSystem.d.ts +5 -30
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
- package/src/engine/physics/ecs/PhysicsSystem.js +13 -45
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts.map +1 -1
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.js +85 -81
- package/src/engine/physics/ecs/is_sensor.d.ts +18 -0
- package/src/engine/physics/ecs/is_sensor.d.ts.map +1 -0
- package/src/engine/physics/ecs/is_sensor.js +27 -0
- package/src/engine/physics/events/ContactEventBuffer.d.ts +2 -1
- package/src/engine/physics/events/ContactEventBuffer.d.ts.map +1 -1
- package/src/engine/physics/events/ContactEventBuffer.js +84 -83
- package/src/engine/physics/gjk/gjk.d.ts +0 -26
- package/src/engine/physics/gjk/gjk.d.ts.map +1 -1
- package/src/engine/physics/gjk/gjk.js +3 -52
- package/src/engine/physics/gjk/gjk_epa_penetration.d.ts +16 -0
- package/src/engine/physics/gjk/gjk_epa_penetration.d.ts.map +1 -0
- package/src/engine/physics/gjk/gjk_epa_penetration.js +255 -0
- package/src/engine/physics/gjk/minkowski_support.d.ts +4 -9
- package/src/engine/physics/gjk/minkowski_support.d.ts.map +1 -1
- package/src/engine/physics/gjk/minkowski_support.js +70 -75
- package/src/engine/physics/gjk/mpr.d.ts +1 -1
- package/src/engine/physics/gjk/mpr.d.ts.map +1 -1
- package/src/engine/physics/gjk/mpr.js +362 -344
- package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -1
- package/src/engine/physics/island/IslandBuilder.js +431 -428
- package/src/engine/physics/narrowphase/box_box_manifold.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/box_box_manifold.js +4 -81
- package/src/engine/physics/narrowphase/box_triangle_contact.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/box_triangle_contact.js +4 -39
- package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/capsule_contacts.js +459 -462
- package/src/engine/physics/narrowphase/clip_against_axis_uv.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/clip_against_axis_uv.js +4 -1
- package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts +83 -0
- package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/convex_convex_manifold.js +425 -0
- package/src/engine/physics/narrowphase/convex_decomposition.d.ts +32 -0
- package/src/engine/physics/narrowphase/convex_decomposition.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/convex_decomposition.js +293 -0
- package/src/engine/physics/narrowphase/mesh_convex_hull.d.ts +41 -0
- package/src/engine/physics/narrowphase/mesh_convex_hull.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/mesh_convex_hull.js +106 -0
- package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.d.ts +8 -0
- package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.js +117 -0
- package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/narrowphase_step.js +105 -102
- package/src/engine/physics/narrowphase/reduce_manifold_contacts.d.ts +29 -0
- package/src/engine/physics/narrowphase/reduce_manifold_contacts.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/reduce_manifold_contacts.js +69 -0
- package/src/engine/physics/narrowphase/refine_ray_concave.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/refine_ray_concave.js +152 -145
- package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/sphere_box_contact.js +132 -123
- package/src/engine/physics/queries/overlap_shape.d.ts.map +1 -1
- package/src/engine/physics/queries/overlap_shape.js +16 -17
- package/src/engine/physics/queries/raycast.d.ts +5 -0
- package/src/engine/physics/queries/raycast.d.ts.map +1 -1
- package/src/engine/physics/queries/raycast.js +16 -8
- package/src/engine/physics/queries/shape_cast.d.ts.map +1 -1
- package/src/engine/physics/queries/shape_cast.js +13 -7
- package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -1
- package/src/engine/physics/solver/solve_contacts.js +8 -11
- package/src/engine/physics/vehicle/RaycastVehicle.d.ts.map +1 -1
- package/src/engine/physics/vehicle/RaycastVehicle.js +339 -333
- package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts +0 -13
- package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +0 -1
- 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:
|
|
21
|
-
* support inline rather than calling this
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {number}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
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
|
|
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":"
|
|
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"}
|