@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
|
@@ -119,14 +119,6 @@ export class ManifoldStore {
|
|
|
119
119
|
this.__data = new Float64Array(this.__capacity * SLOT_DATA_STRIDE);
|
|
120
120
|
this.__meta = new Uint32Array(this.__capacity * SLOT_META_STRIDE);
|
|
121
121
|
|
|
122
|
-
// Per-slot cached GJK separating-axis seed (3 floats / slot).
|
|
123
|
-
// Hot-path GJK callers thread `slot_axis_buffer` +
|
|
124
|
-
// `slot_axis_offset(slot)` into `gjk_with_axis(...)` so the
|
|
125
|
-
// cached axis seeds the next frame's iteration. Initialised to
|
|
126
|
-
// zeros — the `gjk_with_axis` guard catches that and uses
|
|
127
|
-
// (1, 0, 0) as the cold-start fallback.
|
|
128
|
-
this.__slot_axis = new Float64Array(this.__capacity * 3);
|
|
129
|
-
|
|
130
122
|
this.__pair_index = new PairUint32Map(this.__capacity * 2);
|
|
131
123
|
|
|
132
124
|
// Dense list of currently-allocated slot ids + reverse map.
|
|
@@ -188,13 +180,6 @@ export class ManifoldStore {
|
|
|
188
180
|
// impulses don't leak across pair identities.
|
|
189
181
|
const data_off = slot * SLOT_DATA_STRIDE;
|
|
190
182
|
this.__data.fill(0, data_off, data_off + SLOT_DATA_STRIDE);
|
|
191
|
-
// Zero the cached GJK axis. A stale axis from a previously
|
|
192
|
-
// released pair would mislead `gjk_with_axis` on this fresh
|
|
193
|
-
// pair; resetting to (0, 0, 0) hits the cold-start guard.
|
|
194
|
-
const axis_off = slot * 3;
|
|
195
|
-
this.__slot_axis[axis_off] = 0;
|
|
196
|
-
this.__slot_axis[axis_off + 1] = 0;
|
|
197
|
-
this.__slot_axis[axis_off + 2] = 0;
|
|
198
183
|
|
|
199
184
|
this.__pair_index.set(idA, idB, slot);
|
|
200
185
|
}
|
|
@@ -447,27 +432,6 @@ export class ManifoldStore {
|
|
|
447
432
|
return this.__data;
|
|
448
433
|
}
|
|
449
434
|
|
|
450
|
-
/**
|
|
451
|
-
* Per-slot cached GJK separating axis buffer. Hot-path GJK callers
|
|
452
|
-
* pass this together with {@link slot_axis_offset} to
|
|
453
|
-
* `gjk_with_axis(...)` so the cached axis seeds the next iteration.
|
|
454
|
-
* Buffer identity is stable until grow.
|
|
455
|
-
* @returns {Float64Array}
|
|
456
|
-
*/
|
|
457
|
-
get slot_axis_buffer() {
|
|
458
|
-
return this.__slot_axis;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Float offset into {@link slot_axis_buffer} where this slot's
|
|
463
|
-
* cached axis lives (3 floats: x, y, z).
|
|
464
|
-
* @param {number} slot
|
|
465
|
-
* @returns {number}
|
|
466
|
-
*/
|
|
467
|
-
slot_axis_offset(slot) {
|
|
468
|
-
return slot * 3;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
435
|
/**
|
|
472
436
|
* Word offset into {@link data_buffer} where the first contact of `slot`
|
|
473
437
|
* begins. Subsequent contacts within the slot are at
|
|
@@ -494,7 +458,7 @@ export class ManifoldStore {
|
|
|
494
458
|
const was_touched = (packed & FLAG_TOUCHED) !== 0;
|
|
495
459
|
// Roll touched → prev_touched, clear touched.
|
|
496
460
|
if (was_touched) {
|
|
497
|
-
packed
|
|
461
|
+
packed |= FLAG_PREV_TOUCHED; // single-bit mask: clear-then-set is just set
|
|
498
462
|
packed &= ~FLAG_TOUCHED;
|
|
499
463
|
// Reset grace.
|
|
500
464
|
packed &= ~(GRACE_MASK << GRACE_SHIFT);
|
|
@@ -578,7 +542,6 @@ export class ManifoldStore {
|
|
|
578
542
|
|
|
579
543
|
this.__data = grow_f64(this.__data, SLOT_DATA_STRIDE);
|
|
580
544
|
this.__meta = grow_u32(this.__meta, SLOT_META_STRIDE);
|
|
581
|
-
this.__slot_axis = grow_f64(this.__slot_axis, 3);
|
|
582
545
|
|
|
583
546
|
const next_live = new Uint32Array(new_capacity);
|
|
584
547
|
next_live.set(this.__live_slots);
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
* is derived by the system from the per-step delta so dynamic neighbours respond
|
|
11
11
|
* correctly.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* These are plain enum ordinals compared by identity (`=== BodyKind.Dynamic`),
|
|
14
|
+
* NOT a bitmask: Static is 0 (can't participate in a mask) and the values are
|
|
15
|
+
* not bit-distinct (KinematicPosition 3 === Dynamic 1 | KinematicVelocity 2).
|
|
15
16
|
*/
|
|
16
17
|
export type BodyKind = number;
|
|
17
18
|
export namespace BodyKind {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BodyKind.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ecs/BodyKind.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BodyKind.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ecs/BodyKind.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;uBAiBU,MAAM"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kind of a rigid body. Determines how the body participates in the simulation:
|
|
3
|
-
* - {@link BodyKind.Static}: never moves. Has infinite mass. Ideal for level geometry.
|
|
4
|
-
* Stored in the static broadphase tree.
|
|
5
|
-
* - {@link BodyKind.Dynamic}: integrated under forces, gravity and contact impulses. The
|
|
6
|
-
* common case for game-play objects.
|
|
7
|
-
* - {@link BodyKind.KinematicVelocity}: driven externally by velocity. Pushes Dynamic
|
|
8
|
-
* bodies but is not pushed back. Mass effectively infinite for the solver.
|
|
9
|
-
* - {@link BodyKind.KinematicPosition}: driven externally by direct pose writes. Velocity
|
|
10
|
-
* is derived by the system from the per-step delta so dynamic neighbours respond
|
|
11
|
-
* correctly.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Kind of a rigid body. Determines how the body participates in the simulation:
|
|
3
|
+
* - {@link BodyKind.Static}: never moves. Has infinite mass. Ideal for level geometry.
|
|
4
|
+
* Stored in the static broadphase tree.
|
|
5
|
+
* - {@link BodyKind.Dynamic}: integrated under forces, gravity and contact impulses. The
|
|
6
|
+
* common case for game-play objects.
|
|
7
|
+
* - {@link BodyKind.KinematicVelocity}: driven externally by velocity. Pushes Dynamic
|
|
8
|
+
* bodies but is not pushed back. Mass effectively infinite for the solver.
|
|
9
|
+
* - {@link BodyKind.KinematicPosition}: driven externally by direct pose writes. Velocity
|
|
10
|
+
* is derived by the system from the per-step delta so dynamic neighbours respond
|
|
11
|
+
* correctly.
|
|
12
|
+
*
|
|
13
|
+
* These are plain enum ordinals compared by identity (`=== BodyKind.Dynamic`),
|
|
14
|
+
* NOT a bitmask: Static is 0 (can't participate in a mask) and the values are
|
|
15
|
+
* not bit-distinct (KinematicPosition 3 === Dynamic 1 | KinematicVelocity 2).
|
|
16
|
+
*
|
|
17
|
+
* @readonly
|
|
18
|
+
* @enum {number}
|
|
19
|
+
*/
|
|
20
|
+
export const BodyKind = {
|
|
21
|
+
Static: 0,
|
|
22
|
+
Dynamic: 1,
|
|
23
|
+
KinematicVelocity: 2,
|
|
24
|
+
KinematicPosition: 3,
|
|
25
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Entity-level event names emitted by {@link PhysicsSystem } via
|
|
3
|
-
* `
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* {@link PhysicsSystemonContactBegin }, etc., for global listeners.
|
|
3
|
+
* `dataset.sendEvent(entity, name, payload)` — once for each entity of a
|
|
4
|
+
* contacting pair. This is the only contact-event path; subscribe per entity
|
|
5
|
+
* with `dataset.addEntityEventListener(entity, name, …)`. The payload is
|
|
6
|
+
* **only valid for the dispatch** — copy any field you need to retain.
|
|
8
7
|
*/
|
|
9
8
|
export type PhysicsEvents = string;
|
|
10
9
|
export namespace PhysicsEvents {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhysicsEvents.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ecs/PhysicsEvents.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PhysicsEvents.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ecs/PhysicsEvents.js"],"names":[],"mappings":";;;;;;;4BAQU,MAAM"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Entity-level event names emitted by {@link PhysicsSystem} via
|
|
3
|
-
* `
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Entity-level event names emitted by {@link PhysicsSystem} via
|
|
3
|
+
* `dataset.sendEvent(entity, name, payload)` — once for each entity of a
|
|
4
|
+
* contacting pair. This is the only contact-event path; subscribe per entity
|
|
5
|
+
* with `dataset.addEntityEventListener(entity, name, …)`. The payload is
|
|
6
|
+
* **only valid for the dispatch** — copy any field you need to retain.
|
|
7
|
+
*
|
|
8
|
+
* @readonly
|
|
9
|
+
* @enum {string}
|
|
10
|
+
*/
|
|
11
|
+
export const PhysicsEvents = {
|
|
12
|
+
ContactBegin: '@ecd-component-RigidBody/contact-begin',
|
|
13
|
+
ContactStay: '@ecd-component-RigidBody/contact-stay',
|
|
14
|
+
ContactEnd: '@ecd-component-RigidBody/contact-end',
|
|
15
|
+
};
|
|
@@ -121,24 +121,6 @@ export class PhysicsSystem extends System<any, any, any, any, any> {
|
|
|
121
121
|
* @type {Vector3}
|
|
122
122
|
*/
|
|
123
123
|
readonly gravity: Vector3;
|
|
124
|
-
/**
|
|
125
|
-
* Emitted at end-of-step for newly established contact pairs.
|
|
126
|
-
* @readonly
|
|
127
|
-
* @type {Signal}
|
|
128
|
-
*/
|
|
129
|
-
readonly onContactBegin: Signal;
|
|
130
|
-
/**
|
|
131
|
-
* Emitted at end-of-step for contact pairs that persisted from the previous step.
|
|
132
|
-
* @readonly
|
|
133
|
-
* @type {Signal}
|
|
134
|
-
*/
|
|
135
|
-
readonly onContactStay: Signal;
|
|
136
|
-
/**
|
|
137
|
-
* Emitted at end-of-step for contact pairs that disappeared.
|
|
138
|
-
* @readonly
|
|
139
|
-
* @type {Signal}
|
|
140
|
-
*/
|
|
141
|
-
readonly onContactEnd: Signal;
|
|
142
124
|
/**
|
|
143
125
|
* Optional global contact filter. Called for each surviving broadphase
|
|
144
126
|
* pair; returning `false` discards the pair.
|
|
@@ -655,13 +637,6 @@ export class PhysicsSystem extends System<any, any, any, any, any> {
|
|
|
655
637
|
z: number;
|
|
656
638
|
w: number;
|
|
657
639
|
}, output: Uint32Array | number[], output_offset: number, filter?: (entity: number, collider: Collider) => boolean): number;
|
|
658
|
-
/**
|
|
659
|
-
* Run one simulation step. v1 pipeline: integrate velocity → integrate
|
|
660
|
-
* position → refit broadphase AABBs. Narrowphase, solver, islands and
|
|
661
|
-
* contact-event emission land in subsequent slices.
|
|
662
|
-
*
|
|
663
|
-
* @param {number} dt
|
|
664
|
-
*/
|
|
665
640
|
/**
|
|
666
641
|
* Wake any sleeping body that appears in this step's broadphase pair list.
|
|
667
642
|
* A pair means the BVH AABBs overlap — even if the sleeper hasn't moved,
|
|
@@ -709,10 +684,11 @@ export class PhysicsSystem extends System<any, any, any, any, any> {
|
|
|
709
684
|
*/
|
|
710
685
|
private __sleep_test;
|
|
711
686
|
/**
|
|
712
|
-
* Dispatch every buffered contact event
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
687
|
+
* Dispatch every buffered contact event to the entities involved, via the
|
|
688
|
+
* dataset's per-entity event channel — `dataset.sendEvent(entity, name,
|
|
689
|
+
* payload)`, once for each of the pair's entities. This is the only
|
|
690
|
+
* contact-event path: a system with no dataset attached has nowhere to
|
|
691
|
+
* deliver and emits nothing.
|
|
716
692
|
*
|
|
717
693
|
* Payload is a reused scratch object; listeners must copy anything they
|
|
718
694
|
* intend to retain past the listener body.
|
|
@@ -760,7 +736,6 @@ import { ContactEventBuffer } from "../events/ContactEventBuffer.js";
|
|
|
760
736
|
import { IslandBuilder } from "../island/IslandBuilder.js";
|
|
761
737
|
import { SolverBodyState } from "../body/SolverBodyState.js";
|
|
762
738
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
763
|
-
import Signal from "../../../core/events/signal/Signal.js";
|
|
764
739
|
import { BodyKind } from "./BodyKind.js";
|
|
765
740
|
import { RigidBodyFlags } from "./RigidBodyFlags.js";
|
|
766
741
|
export { BodyKind, RigidBodyFlags };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhysicsSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ecs/PhysicsSystem.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PhysicsSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ecs/PhysicsSystem.js"],"names":[],"mappings":"AAkEA;;;;;;;;;;;;;;;;GAgBG;AACH;IAEI,cAwPC;IArPG,sDAA0C;IAE1C,kKAIC;IAED;;;OAGG;IACH,kBAHU,WAAW,CAGW;IAEhC;;OAEG;IACH,WAFU,GAAG,CAEa;IAE1B;;OAEG;IACH,YAFU,GAAG,CAEc;IAE3B;;;;OAIG;IACH,oBAHU,aAAa,CAGa;IAEpC;;;;OAIG;IACH,OAFU,QAAQ,CAES;IAE3B;;;;OAIG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1
1
|
import { assert } from "../../../core/assert.js";
|
|
2
2
|
import { BinaryBuffer } from "../../../core/binary/BinaryBuffer.js";
|
|
3
3
|
import { BVH } from "../../../core/bvh2/bvh3/BVH.js";
|
|
4
|
-
import Signal from "../../../core/events/signal/Signal.js";
|
|
5
4
|
import { returnTrue } from "../../../core/function/returnTrue.js";
|
|
6
5
|
import { aabb3_transform_oriented } from "../../../core/geom/3d/aabb/aabb3_transform_oriented.js";
|
|
7
6
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
@@ -219,27 +218,6 @@ export class PhysicsSystem extends System {
|
|
|
219
218
|
*/
|
|
220
219
|
this.gravity = new Vector3(0, -9.81, 0);
|
|
221
220
|
|
|
222
|
-
/**
|
|
223
|
-
* Emitted at end-of-step for newly established contact pairs.
|
|
224
|
-
* @readonly
|
|
225
|
-
* @type {Signal}
|
|
226
|
-
*/
|
|
227
|
-
this.onContactBegin = new Signal();
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Emitted at end-of-step for contact pairs that persisted from the previous step.
|
|
231
|
-
* @readonly
|
|
232
|
-
* @type {Signal}
|
|
233
|
-
*/
|
|
234
|
-
this.onContactStay = new Signal();
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Emitted at end-of-step for contact pairs that disappeared.
|
|
238
|
-
* @readonly
|
|
239
|
-
* @type {Signal}
|
|
240
|
-
*/
|
|
241
|
-
this.onContactEnd = new Signal();
|
|
242
|
-
|
|
243
221
|
/**
|
|
244
222
|
* Optional global contact filter. Called for each surviving broadphase
|
|
245
223
|
* pair; returning `false` discards the pair.
|
|
@@ -1133,13 +1111,6 @@ export class PhysicsSystem extends System {
|
|
|
1133
1111
|
return overlap_shape_query(this, shape, position, rotation, output, output_offset, filter);
|
|
1134
1112
|
}
|
|
1135
1113
|
|
|
1136
|
-
/**
|
|
1137
|
-
* Run one simulation step. v1 pipeline: integrate velocity → integrate
|
|
1138
|
-
* position → refit broadphase AABBs. Narrowphase, solver, islands and
|
|
1139
|
-
* contact-event emission land in subsequent slices.
|
|
1140
|
-
*
|
|
1141
|
-
* @param {number} dt
|
|
1142
|
-
*/
|
|
1143
1114
|
/**
|
|
1144
1115
|
* Wake any sleeping body that appears in this step's broadphase pair list.
|
|
1145
1116
|
* A pair means the BVH AABBs overlap — even if the sleeper hasn't moved,
|
|
@@ -1291,10 +1262,11 @@ export class PhysicsSystem extends System {
|
|
|
1291
1262
|
}
|
|
1292
1263
|
|
|
1293
1264
|
/**
|
|
1294
|
-
* Dispatch every buffered contact event
|
|
1295
|
-
*
|
|
1296
|
-
*
|
|
1297
|
-
*
|
|
1265
|
+
* Dispatch every buffered contact event to the entities involved, via the
|
|
1266
|
+
* dataset's per-entity event channel — `dataset.sendEvent(entity, name,
|
|
1267
|
+
* payload)`, once for each of the pair's entities. This is the only
|
|
1268
|
+
* contact-event path: a system with no dataset attached has nowhere to
|
|
1269
|
+
* deliver and emits nothing.
|
|
1298
1270
|
*
|
|
1299
1271
|
* Payload is a reused scratch object; listeners must copy anything they
|
|
1300
1272
|
* intend to retain past the listener body.
|
|
@@ -1308,6 +1280,10 @@ export class PhysicsSystem extends System {
|
|
|
1308
1280
|
const ecd = (this.entityManager !== null && this.entityManager !== undefined)
|
|
1309
1281
|
? this.entityManager.dataset
|
|
1310
1282
|
: null;
|
|
1283
|
+
// No dataset → nowhere to deliver. The buffer is cleared by
|
|
1284
|
+
// diff_manifolds each step regardless, so nothing leaks.
|
|
1285
|
+
if (ecd === null || ecd === undefined) return;
|
|
1286
|
+
|
|
1311
1287
|
const manifolds = this.manifolds;
|
|
1312
1288
|
const data = manifolds.data_buffer;
|
|
1313
1289
|
|
|
@@ -1324,8 +1300,8 @@ export class PhysicsSystem extends System {
|
|
|
1324
1300
|
const slot_off = manifolds.slot_data_offset(slot);
|
|
1325
1301
|
const has_contact = manifolds.contact_count(slot) > 0;
|
|
1326
1302
|
|
|
1327
|
-
// Scratch payload —
|
|
1328
|
-
//
|
|
1303
|
+
// Scratch payload — write the point/normal components by index to
|
|
1304
|
+
// skip the Vector3 change-signal dispatch (nothing observes them).
|
|
1329
1305
|
const pt = payload.point;
|
|
1330
1306
|
const nm = payload.normal;
|
|
1331
1307
|
if (has_contact) {
|
|
@@ -1351,24 +1327,16 @@ export class PhysicsSystem extends System {
|
|
|
1351
1327
|
payload.entityB = entB;
|
|
1352
1328
|
|
|
1353
1329
|
let event_name;
|
|
1354
|
-
let signal;
|
|
1355
1330
|
if (kind === ContactEventKind.Begin) {
|
|
1356
1331
|
event_name = PhysicsEvents.ContactBegin;
|
|
1357
|
-
signal = this.onContactBegin;
|
|
1358
1332
|
} else if (kind === ContactEventKind.Stay) {
|
|
1359
1333
|
event_name = PhysicsEvents.ContactStay;
|
|
1360
|
-
signal = this.onContactStay;
|
|
1361
1334
|
} else {
|
|
1362
1335
|
event_name = PhysicsEvents.ContactEnd;
|
|
1363
|
-
signal = this.onContactEnd;
|
|
1364
1336
|
}
|
|
1365
1337
|
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
if (ecd !== null && ecd !== undefined) {
|
|
1369
|
-
if (entA >= 0) ecd.sendEvent(entA, event_name, payload);
|
|
1370
|
-
if (entB >= 0) ecd.sendEvent(entB, event_name, payload);
|
|
1371
|
-
}
|
|
1338
|
+
if (entA >= 0) ecd.sendEvent(entA, event_name, payload);
|
|
1339
|
+
if (entB >= 0) ecd.sendEvent(entB, event_name, payload);
|
|
1372
1340
|
}
|
|
1373
1341
|
}
|
|
1374
1342
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RigidBodySerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ecs/RigidBodySerializationAdapter.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH;;IAEI,wBAAkB;IAClB,gBAAY;IAEZ;;;;OAIG;IACH,uCAFW,SAAS,QA0BnB;IAED;;;;OAIG;IACH,yCAFW,SAAS,
|
|
1
|
+
{"version":3,"file":"RigidBodySerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ecs/RigidBodySerializationAdapter.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH;;IAEI,wBAAkB;IAClB,gBAAY;IAEZ;;;;OAIG;IACH,uCAFW,SAAS,QA0BnB;IAED;;;;OAIG;IACH,yCAFW,SAAS,QAiCnB;CACJ;gDApF+C,6DAA6D;0BACnF,gBAAgB"}
|
|
@@ -1,81 +1,85 @@
|
|
|
1
|
-
import { BinaryClassSerializationAdapter } from "../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
-
import { RigidBody } from "./RigidBody.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Binary serialization for {@link RigidBody}.
|
|
6
|
-
*
|
|
7
|
-
* Only the configurable / persistent fields are written. Transient runtime state
|
|
8
|
-
* (`_bodyId`, `sleepState`, accumulated force/torque) is owned by the
|
|
9
|
-
* {@link PhysicsSystem} and recomputed on link — serialising it would tie the
|
|
10
|
-
* stream to a particular world instance.
|
|
11
|
-
*/
|
|
12
|
-
export class RigidBodySerializationAdapter extends BinaryClassSerializationAdapter {
|
|
13
|
-
|
|
14
|
-
klass = RigidBody;
|
|
15
|
-
version = 0;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @param {BinaryBuffer} buffer
|
|
20
|
-
* @param {RigidBody} value
|
|
21
|
-
*/
|
|
22
|
-
serialize(buffer, value) {
|
|
23
|
-
buffer.writeUint8(value.kind);
|
|
24
|
-
|
|
25
|
-
buffer.writeFloat64(value.linearVelocity.x);
|
|
26
|
-
buffer.writeFloat64(value.linearVelocity.y);
|
|
27
|
-
buffer.writeFloat64(value.linearVelocity.z);
|
|
28
|
-
|
|
29
|
-
buffer.writeFloat64(value.angularVelocity.x);
|
|
30
|
-
buffer.writeFloat64(value.angularVelocity.y);
|
|
31
|
-
buffer.writeFloat64(value.angularVelocity.z);
|
|
32
|
-
|
|
33
|
-
buffer.writeFloat64(value.mass);
|
|
34
|
-
|
|
35
|
-
buffer.writeFloat64(value.inverseInertiaLocal.x);
|
|
36
|
-
buffer.writeFloat64(value.inverseInertiaLocal.y);
|
|
37
|
-
buffer.writeFloat64(value.inverseInertiaLocal.z);
|
|
38
|
-
|
|
39
|
-
buffer.writeFloat64(value.linearDamping);
|
|
40
|
-
buffer.writeFloat64(value.angularDamping);
|
|
41
|
-
buffer.writeFloat64(value.gravityScale);
|
|
42
|
-
|
|
43
|
-
buffer.writeUint32(value.layer >>> 0);
|
|
44
|
-
buffer.writeUint32(value.mask >>> 0);
|
|
45
|
-
buffer.writeUint32(value.flags >>> 0);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {BinaryBuffer} buffer
|
|
51
|
-
* @param {RigidBody} value
|
|
52
|
-
*/
|
|
53
|
-
deserialize(buffer, value) {
|
|
54
|
-
value.kind = buffer.readUint8();
|
|
55
|
-
|
|
56
|
-
const lvx = buffer.readFloat64();
|
|
57
|
-
const lvy = buffer.readFloat64();
|
|
58
|
-
const lvz = buffer.readFloat64();
|
|
59
|
-
value.linearVelocity.set(lvx, lvy, lvz);
|
|
60
|
-
|
|
61
|
-
const avx = buffer.readFloat64();
|
|
62
|
-
const avy = buffer.readFloat64();
|
|
63
|
-
const avz = buffer.readFloat64();
|
|
64
|
-
value.angularVelocity.set(avx, avy, avz);
|
|
65
|
-
|
|
66
|
-
value.mass = buffer.readFloat64();
|
|
67
|
-
|
|
68
|
-
const iix = buffer.readFloat64();
|
|
69
|
-
const iiy = buffer.readFloat64();
|
|
70
|
-
const iiz = buffer.readFloat64();
|
|
71
|
-
value.inverseInertiaLocal.set(iix, iiy, iiz);
|
|
72
|
-
|
|
73
|
-
value.linearDamping = buffer.readFloat64();
|
|
74
|
-
value.angularDamping = buffer.readFloat64();
|
|
75
|
-
value.gravityScale = buffer.readFloat64();
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
1
|
+
import { BinaryClassSerializationAdapter } from "../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
+
import { RigidBody } from "./RigidBody.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Binary serialization for {@link RigidBody}.
|
|
6
|
+
*
|
|
7
|
+
* Only the configurable / persistent fields are written. Transient runtime state
|
|
8
|
+
* (`_bodyId`, `sleepState`, accumulated force/torque) is owned by the
|
|
9
|
+
* {@link PhysicsSystem} and recomputed on link — serialising it would tie the
|
|
10
|
+
* stream to a particular world instance.
|
|
11
|
+
*/
|
|
12
|
+
export class RigidBodySerializationAdapter extends BinaryClassSerializationAdapter {
|
|
13
|
+
|
|
14
|
+
klass = RigidBody;
|
|
15
|
+
version = 0;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {BinaryBuffer} buffer
|
|
20
|
+
* @param {RigidBody} value
|
|
21
|
+
*/
|
|
22
|
+
serialize(buffer, value) {
|
|
23
|
+
buffer.writeUint8(value.kind);
|
|
24
|
+
|
|
25
|
+
buffer.writeFloat64(value.linearVelocity.x);
|
|
26
|
+
buffer.writeFloat64(value.linearVelocity.y);
|
|
27
|
+
buffer.writeFloat64(value.linearVelocity.z);
|
|
28
|
+
|
|
29
|
+
buffer.writeFloat64(value.angularVelocity.x);
|
|
30
|
+
buffer.writeFloat64(value.angularVelocity.y);
|
|
31
|
+
buffer.writeFloat64(value.angularVelocity.z);
|
|
32
|
+
|
|
33
|
+
buffer.writeFloat64(value.mass);
|
|
34
|
+
|
|
35
|
+
buffer.writeFloat64(value.inverseInertiaLocal.x);
|
|
36
|
+
buffer.writeFloat64(value.inverseInertiaLocal.y);
|
|
37
|
+
buffer.writeFloat64(value.inverseInertiaLocal.z);
|
|
38
|
+
|
|
39
|
+
buffer.writeFloat64(value.linearDamping);
|
|
40
|
+
buffer.writeFloat64(value.angularDamping);
|
|
41
|
+
buffer.writeFloat64(value.gravityScale);
|
|
42
|
+
|
|
43
|
+
buffer.writeUint32(value.layer >>> 0);
|
|
44
|
+
buffer.writeUint32(value.mask >>> 0);
|
|
45
|
+
buffer.writeUint32(value.flags >>> 0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* @param {BinaryBuffer} buffer
|
|
51
|
+
* @param {RigidBody} value
|
|
52
|
+
*/
|
|
53
|
+
deserialize(buffer, value) {
|
|
54
|
+
value.kind = buffer.readUint8();
|
|
55
|
+
|
|
56
|
+
const lvx = buffer.readFloat64();
|
|
57
|
+
const lvy = buffer.readFloat64();
|
|
58
|
+
const lvz = buffer.readFloat64();
|
|
59
|
+
value.linearVelocity.set(lvx, lvy, lvz);
|
|
60
|
+
|
|
61
|
+
const avx = buffer.readFloat64();
|
|
62
|
+
const avy = buffer.readFloat64();
|
|
63
|
+
const avz = buffer.readFloat64();
|
|
64
|
+
value.angularVelocity.set(avx, avy, avz);
|
|
65
|
+
|
|
66
|
+
value.mass = buffer.readFloat64();
|
|
67
|
+
|
|
68
|
+
const iix = buffer.readFloat64();
|
|
69
|
+
const iiy = buffer.readFloat64();
|
|
70
|
+
const iiz = buffer.readFloat64();
|
|
71
|
+
value.inverseInertiaLocal.set(iix, iiy, iiz);
|
|
72
|
+
|
|
73
|
+
value.linearDamping = buffer.readFloat64();
|
|
74
|
+
value.angularDamping = buffer.readFloat64();
|
|
75
|
+
value.gravityScale = buffer.readFloat64();
|
|
76
|
+
|
|
77
|
+
// `| 0` back to the signed int32 in-memory form the fields use (e.g. the
|
|
78
|
+
// default mask is `0xFFFFFFFF | 0 === -1`). Reading the raw unsigned value
|
|
79
|
+
// would make a round-tripped body compare unequal to a fresh one under
|
|
80
|
+
// RigidBody.equals()'s strict ===, denting reset-to-snapshot determinism.
|
|
81
|
+
value.layer = buffer.readUint32() | 0;
|
|
82
|
+
value.mask = buffer.readUint32() | 0;
|
|
83
|
+
value.flags = buffer.readUint32() | 0;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a body presents as a **sensor** (trigger): either the body carries
|
|
3
|
+
* {@link RigidBodyFlags.IsSensor} or its collider carries
|
|
4
|
+
* {@link ColliderFlags.IsSensor}. A sensor still generates overlap / contact
|
|
5
|
+
* events (Begin/Stay/End) but applies no impulse, and is not a solid surface —
|
|
6
|
+
* the contact solver skips its impulse, the island builder excludes it from
|
|
7
|
+
* sleep islands, and {@link raycast} passes straight through it.
|
|
8
|
+
*
|
|
9
|
+
* Single source of truth for the "is this a sensor" question across the
|
|
10
|
+
* physics engine. Callers holding both sides of a pair OR the two results.
|
|
11
|
+
*
|
|
12
|
+
* @param {RigidBody} rb the body
|
|
13
|
+
* @param {Collider|null} collider the body's (primary) collider, or `null`
|
|
14
|
+
* when the body has none — then only the body flag matters.
|
|
15
|
+
* @returns {boolean}
|
|
16
|
+
*/
|
|
17
|
+
export function is_sensor(rb: RigidBody, collider: Collider | null): boolean;
|
|
18
|
+
//# sourceMappingURL=is_sensor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is_sensor.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ecs/is_sensor.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AACH,mDAJW,WAAS,IAAI,GAEX,OAAO,CASnB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ColliderFlags } from "./ColliderFlags.js";
|
|
2
|
+
import { RigidBodyFlags } from "./RigidBodyFlags.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Whether a body presents as a **sensor** (trigger): either the body carries
|
|
6
|
+
* {@link RigidBodyFlags.IsSensor} or its collider carries
|
|
7
|
+
* {@link ColliderFlags.IsSensor}. A sensor still generates overlap / contact
|
|
8
|
+
* events (Begin/Stay/End) but applies no impulse, and is not a solid surface —
|
|
9
|
+
* the contact solver skips its impulse, the island builder excludes it from
|
|
10
|
+
* sleep islands, and {@link raycast} passes straight through it.
|
|
11
|
+
*
|
|
12
|
+
* Single source of truth for the "is this a sensor" question across the
|
|
13
|
+
* physics engine. Callers holding both sides of a pair OR the two results.
|
|
14
|
+
*
|
|
15
|
+
* @param {RigidBody} rb the body
|
|
16
|
+
* @param {Collider|null} collider the body's (primary) collider, or `null`
|
|
17
|
+
* when the body has none — then only the body flag matters.
|
|
18
|
+
* @returns {boolean}
|
|
19
|
+
*/
|
|
20
|
+
export function is_sensor(rb, collider) {
|
|
21
|
+
if ((rb.flags & RigidBodyFlags.IsSensor) !== 0) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return collider !== null && collider !== undefined
|
|
26
|
+
&& (collider.flags & ColliderFlags.IsSensor) !== 0;
|
|
27
|
+
}
|
|
@@ -11,7 +11,8 @@ export namespace ContactEventKind {
|
|
|
11
11
|
* Append-only buffer of contact events produced during one fixedUpdate, ready
|
|
12
12
|
* to be dispatched (and then cleared) at end-of-step.
|
|
13
13
|
*
|
|
14
|
-
* Storage is flat
|
|
14
|
+
* Storage is flat Int32Array (signed: entity ids may legitimately be -1 for a
|
|
15
|
+
* stale body after free) — keeping the metadata side allocation-free; the
|
|
15
16
|
* actual contact payload (normal, depth, world point) is read on demand from
|
|
16
17
|
* the {@link ManifoldStore} by the dispatch code.
|
|
17
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContactEventBuffer.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/events/ContactEventBuffer.js"],"names":[],"mappings":";;;+BAGU,MAAM;;;;;;AAoBhB
|
|
1
|
+
{"version":3,"file":"ContactEventBuffer.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/events/ContactEventBuffer.js"],"names":[],"mappings":";;;+BAGU,MAAM;;;;;;AAoBhB;;;;;;;;;;;GAWG;AACH;IACI;;OAEG;IACH,+BAFW,MAAM,EAOhB;IAJG,mBAA+C;IAC/C,gBAAgB;IAEhB,mBAA4D;IAGhE;;OAEG;IACH,oBAEC;IAED,cAEC;IAED;;;;;OAKG;IACH,WALW,gBAAgB,GAAC,MAAM,WACvB,MAAM,WACN,MAAM,QACN,MAAM,QAgBhB;IAED,wBAAoD;IACpD,2BAA2D;IAC3D,2BAA2D;IAC3D,wBAAwD;CAC3D"}
|