@vworlds/vecs-physics 1.0.25 → 1.0.27
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/adapter/{state.d.ts → engine.d.ts} +13 -10
- package/adapter/{state.js → engine.js} +23 -30
- package/adapter/engine.js.map +1 -0
- package/adapter/queries.d.ts +68 -0
- package/adapter/queries.js +145 -0
- package/adapter/queries.js.map +1 -0
- package/adapter/runtime.d.ts +4 -0
- package/adapter/runtime.js +20 -0
- package/adapter/runtime.js.map +1 -1
- package/components/body.js +5 -2
- package/components/body.js.map +1 -1
- package/components/geometry.d.ts +21 -6
- package/components/geometry.js +47 -9
- package/components/geometry.js.map +1 -1
- package/components/material.d.ts +5 -0
- package/components/material.js +5 -0
- package/components/material.js.map +1 -1
- package/index.d.ts +4 -2
- package/index.js +5 -3
- package/index.js.map +1 -1
- package/module.js +32 -19
- package/module.js.map +1 -1
- package/package.json +2 -2
- package/systems/chain_lifecycle.d.ts +6 -0
- package/systems/chain_lifecycle.js +102 -0
- package/systems/chain_lifecycle.js.map +1 -0
- package/systems/debug.d.ts +4 -5
- package/systems/debug.js +26 -24
- package/systems/debug.js.map +1 -1
- package/systems/event_opt_in_sync.d.ts +3 -3
- package/systems/event_opt_in_sync.js +53 -25
- package/systems/event_opt_in_sync.js.map +1 -1
- package/systems/events.d.ts +3 -3
- package/systems/events.js +36 -34
- package/systems/events.js.map +1 -1
- package/systems/forces.d.ts +3 -3
- package/systems/forces.js +30 -21
- package/systems/forces.js.map +1 -1
- package/systems/impulse_accumulate.d.ts +4 -4
- package/systems/impulse_accumulate.js +32 -28
- package/systems/impulse_accumulate.js.map +1 -1
- package/systems/impulse_zero.d.ts +3 -3
- package/systems/impulse_zero.js +6 -4
- package/systems/impulse_zero.js.map +1 -1
- package/systems/index.d.ts +3 -4
- package/systems/index.js +42 -48
- package/systems/index.js.map +1 -1
- package/systems/kinematic.d.ts +3 -3
- package/systems/kinematic.js +33 -33
- package/systems/kinematic.js.map +1 -1
- package/systems/lifecycle.d.ts +3 -3
- package/systems/lifecycle.js +58 -36
- package/systems/lifecycle.js.map +1 -1
- package/systems/mass_recompute.d.ts +3 -3
- package/systems/mass_recompute.js +21 -19
- package/systems/mass_recompute.js.map +1 -1
- package/systems/material_filter_sync.d.ts +3 -3
- package/systems/material_filter_sync.js +64 -29
- package/systems/material_filter_sync.js.map +1 -1
- package/systems/pose_sync_in.d.ts +3 -3
- package/systems/pose_sync_in.js +47 -20
- package/systems/pose_sync_in.js.map +1 -1
- package/systems/pose_sync_out.d.ts +3 -3
- package/systems/pose_sync_out.js +8 -6
- package/systems/pose_sync_out.js.map +1 -1
- package/systems/shape_lifecycle.d.ts +31 -4
- package/systems/shape_lifecycle.js +93 -145
- package/systems/shape_lifecycle.js.map +1 -1
- package/systems/shape_pose_sync.d.ts +3 -3
- package/systems/shape_pose_sync.js +35 -10
- package/systems/shape_pose_sync.js.map +1 -1
- package/systems/shape_predicates.d.ts +12 -0
- package/systems/shape_predicates.js +5 -0
- package/systems/shape_predicates.js.map +1 -0
- package/systems/step.d.ts +3 -3
- package/systems/step.js +7 -5
- package/systems/step.js.map +1 -1
- package/util/resolve_body.d.ts +2 -2
- package/util/resolve_body.js +5 -9
- package/util/resolve_body.js.map +1 -1
- package/util/warn.d.ts +1 -1
- package/util/warn.js +2 -1
- package/util/warn.js.map +1 -1
- package/adapter/state.js.map +0 -1
|
@@ -1,40 +1,68 @@
|
|
|
1
|
+
import { ChildOf, Iter } from "@vworlds/vecs";
|
|
2
|
+
import { Body } from "../components/body.js";
|
|
3
|
+
import { Chain, SingleShape } from "../components/geometry.js";
|
|
1
4
|
import { ContactEvents, HitEvents, SensorEvents } from "../components/events.js";
|
|
2
|
-
|
|
5
|
+
import { Detectable } from "../components/material.js";
|
|
6
|
+
import { PhysicsSystemTag } from "../adapter/engine.js";
|
|
7
|
+
import { recreateChainForEntity } from "./chain_lifecycle.js";
|
|
8
|
+
import { chainWithBodyParent } from "./shape_predicates.js";
|
|
9
|
+
export function installEventOptInSync(world, engine, phase) {
|
|
10
|
+
world.component(ContactEvents).onAdd((entity) => setEventFlag(engine, entity, "contact", true));
|
|
3
11
|
world
|
|
4
12
|
.component(ContactEvents)
|
|
5
|
-
.
|
|
6
|
-
world
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.
|
|
14
|
-
.onRemove((entity) => setEventFlag(state, entity.eid, "sensor", false));
|
|
15
|
-
return world
|
|
16
|
-
.system("PhysicsEventOptInSync")
|
|
13
|
+
.onRemove((entity) => setEventFlag(engine, entity, "contact", false));
|
|
14
|
+
world.component(HitEvents).onAdd((entity) => setEventFlag(engine, entity, "hit", true));
|
|
15
|
+
world.component(HitEvents).onRemove((entity) => setEventFlag(engine, entity, "hit", false));
|
|
16
|
+
// Sensor detection: enable if SensorEvents OR Detectable is present.
|
|
17
|
+
// Query only single b2Shape geometries; chains have no runtime sensor-event
|
|
18
|
+
// setter and are recreated by the chain opt-in system below.
|
|
19
|
+
const sensorSystem = world
|
|
20
|
+
.system("PhysicsEventOptInSync:Sensor")
|
|
21
|
+
.with({ all: [SingleShape, { any: [SensorEvents, Detectable] }] })
|
|
17
22
|
.phase(phase)
|
|
18
|
-
.
|
|
19
|
-
|
|
23
|
+
.enter([SingleShape], (_e, [shape]) => {
|
|
24
|
+
const shapeId = shape._shapeId;
|
|
25
|
+
if (shapeId !== undefined) {
|
|
26
|
+
engine.box2d.b2Shape_EnableSensorEvents(shapeId, true);
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
.exit([SingleShape], (_e, [shape]) => {
|
|
30
|
+
const shapeId = shape._shapeId;
|
|
31
|
+
if (shapeId !== undefined) {
|
|
32
|
+
engine.box2d.b2Shape_EnableSensorEvents(shapeId, false);
|
|
33
|
+
}
|
|
20
34
|
});
|
|
35
|
+
sensorSystem.entity.add(PhysicsSystemTag);
|
|
36
|
+
const chainSensorSystem = world
|
|
37
|
+
.system("PhysicsEventOptInSync:ChainSensor")
|
|
38
|
+
.with({ all: [Chain, { any: [SensorEvents, Detectable] }] }, chainWithBodyParent)
|
|
39
|
+
.phase(phase)
|
|
40
|
+
.enter(Iter, [Chain, { target: [ChildOf, [Body]] }], (it, [chain, body]) => {
|
|
41
|
+
recreateChainForEntity(engine, it.entity, it.src[1], body, chain);
|
|
42
|
+
})
|
|
43
|
+
.exit((entity) => {
|
|
44
|
+
const chain = entity.get(Chain);
|
|
45
|
+
const parent = entity.parent;
|
|
46
|
+
recreateChainForEntity(engine, entity, parent, parent?.get(Body), chain);
|
|
47
|
+
});
|
|
48
|
+
chainSensorSystem.entity.add(PhysicsSystemTag);
|
|
21
49
|
}
|
|
22
|
-
function setEventFlag(
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
|
|
50
|
+
function setEventFlag(engine, entity, flag, enabled) {
|
|
51
|
+
const shape = entity.get(SingleShape);
|
|
52
|
+
if (shape !== undefined) {
|
|
53
|
+
const shapeId = shape._shapeId;
|
|
54
|
+
if (shapeId !== undefined) {
|
|
55
|
+
applyEventFlag(engine, shapeId, flag, enabled);
|
|
56
|
+
}
|
|
26
57
|
}
|
|
27
58
|
}
|
|
28
|
-
function applyEventFlag(
|
|
59
|
+
function applyEventFlag(engine, shapeId, flag, enabled) {
|
|
29
60
|
switch (flag) {
|
|
30
61
|
case "contact":
|
|
31
|
-
|
|
62
|
+
engine.box2d.b2Shape_EnableContactEvents(shapeId, enabled);
|
|
32
63
|
break;
|
|
33
64
|
case "hit":
|
|
34
|
-
|
|
35
|
-
break;
|
|
36
|
-
case "sensor":
|
|
37
|
-
state.box2d.b2Shape_EnableSensorEvents(shapeId, enabled);
|
|
65
|
+
engine.box2d.b2Shape_EnableHitEvents(shapeId, enabled);
|
|
38
66
|
break;
|
|
39
67
|
}
|
|
40
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event_opt_in_sync.js","sourceRoot":"","sources":["../../../../src/systems/event_opt_in_sync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event_opt_in_sync.js","sourceRoot":"","sources":["../../../../src/systems/event_opt_in_sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAA2B,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAsC,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAI5D,MAAM,UAAU,qBAAqB,CAAC,KAAY,EAAE,MAAqB,EAAE,KAAa;IACtF,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAChG,KAAK;SACF,SAAS,CAAC,aAAa,CAAC;SACxB,QAAQ,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAExE,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IACxF,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,EAA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AA2B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC3D,MAAM;QACR,KAAK,KAAK;YACR,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACvD,MAAM;IACV,CAAC;AACH,CAAC"}
|
package/systems/events.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type Entity, type
|
|
2
|
-
import { type
|
|
3
|
-
export declare function installEvents(world: World,
|
|
1
|
+
import { type Entity, type World } from "@vworlds/vecs";
|
|
2
|
+
import { type PhysicsEngine } from "../adapter/engine.js";
|
|
3
|
+
export declare function installEvents(world: World, engine: PhysicsEngine, phase: Entity): void;
|
package/systems/events.js
CHANGED
|
@@ -1,46 +1,48 @@
|
|
|
1
1
|
import { ContactEvents, HitEvents, SensorEvents } from "../components/events.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { PhysicsSystemTag } from "../adapter/engine.js";
|
|
3
|
+
export function installEvents(world, engine, phase) {
|
|
4
|
+
const system = world
|
|
4
5
|
.system("PhysicsEvents")
|
|
5
6
|
.phase(phase)
|
|
6
7
|
.run(() => {
|
|
7
8
|
const touchedContact = new Set();
|
|
8
9
|
const touchedSensor = new Set();
|
|
9
10
|
const touchedHit = new Set();
|
|
10
|
-
publishContactAndHitEvents(world,
|
|
11
|
-
publishSensorEvents(world,
|
|
11
|
+
publishContactAndHitEvents(world, engine, touchedContact, touchedHit);
|
|
12
|
+
publishSensorEvents(world, engine, touchedSensor);
|
|
12
13
|
markModified(world, touchedContact, ContactEvents);
|
|
13
14
|
markModified(world, touchedSensor, SensorEvents);
|
|
14
15
|
markModified(world, touchedHit, HitEvents);
|
|
15
|
-
clearUntouchedContactEvents(world,
|
|
16
|
-
clearUntouchedSensorEvents(world,
|
|
17
|
-
clearUntouchedHitEvents(world,
|
|
18
|
-
// Store touched sets on
|
|
19
|
-
|
|
16
|
+
clearUntouchedContactEvents(world, engine.prevTouchedContact, touchedContact);
|
|
17
|
+
clearUntouchedSensorEvents(world, engine.prevTouchedSensor, touchedSensor);
|
|
18
|
+
clearUntouchedHitEvents(world, engine.prevTouchedHit, touchedHit);
|
|
19
|
+
// Store touched sets on engine for the next step's clear pass.
|
|
20
|
+
engine.prevTouchedContact.clear();
|
|
20
21
|
for (const eid of touchedContact) {
|
|
21
|
-
|
|
22
|
+
engine.prevTouchedContact.add(eid);
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
engine.prevTouchedSensor.clear();
|
|
24
25
|
for (const eid of touchedSensor) {
|
|
25
|
-
|
|
26
|
+
engine.prevTouchedSensor.add(eid);
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
engine.prevTouchedHit.clear();
|
|
28
29
|
for (const eid of touchedHit) {
|
|
29
|
-
|
|
30
|
+
engine.prevTouchedHit.add(eid);
|
|
30
31
|
}
|
|
31
32
|
});
|
|
33
|
+
system.entity.add(PhysicsSystemTag);
|
|
32
34
|
}
|
|
33
35
|
// Contact begin/end and hit events all come from a single
|
|
34
36
|
// `b2World_GetContactEvents` poll, so fetch the event block once per step and
|
|
35
|
-
// fan begin/end into `touchedContact` and hits into `touchedHit` (
|
|
37
|
+
// fan begin/end into `touchedContact` and hits into `touchedHit` (ARCHITECTURE.md ->
|
|
36
38
|
// PhysicsEvents: "poll once per step").
|
|
37
|
-
function publishContactAndHitEvents(world,
|
|
38
|
-
const events =
|
|
39
|
+
function publishContactAndHitEvents(world, engine, touchedContact, touchedHit) {
|
|
40
|
+
const events = engine.box2d.b2World_GetContactEvents(engine.worldId);
|
|
39
41
|
try {
|
|
40
42
|
for (let i = 0; i < events.beginCount; i++) {
|
|
41
43
|
const event = events.GetBeginEvent(i);
|
|
42
44
|
try {
|
|
43
|
-
emitContactEvent(world,
|
|
45
|
+
emitContactEvent(world, engine, touchedContact, event, "begin");
|
|
44
46
|
}
|
|
45
47
|
finally {
|
|
46
48
|
deleteIfPresent(event);
|
|
@@ -48,12 +50,12 @@ function publishContactAndHitEvents(world, state, touchedContact, touchedHit) {
|
|
|
48
50
|
}
|
|
49
51
|
for (let i = 0; i < events.endCount; i++) {
|
|
50
52
|
const event = events.GetEndEvent(i);
|
|
51
|
-
emitContactEvent(world,
|
|
53
|
+
emitContactEvent(world, engine, touchedContact, event, "end");
|
|
52
54
|
}
|
|
53
55
|
for (let i = 0; i < events.hitCount; i++) {
|
|
54
56
|
const event = events.GetHitEvent(i);
|
|
55
57
|
try {
|
|
56
|
-
emitHitEvent(world,
|
|
58
|
+
emitHitEvent(world, engine, touchedHit, event);
|
|
57
59
|
}
|
|
58
60
|
finally {
|
|
59
61
|
event.delete();
|
|
@@ -64,32 +66,32 @@ function publishContactAndHitEvents(world, state, touchedContact, touchedHit) {
|
|
|
64
66
|
events.delete();
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
|
-
function publishSensorEvents(world,
|
|
68
|
-
const events =
|
|
69
|
+
function publishSensorEvents(world, engine, touched) {
|
|
70
|
+
const events = engine.box2d.b2World_GetSensorEvents(engine.worldId);
|
|
69
71
|
try {
|
|
70
72
|
for (let i = 0; i < events.beginCount; i++) {
|
|
71
|
-
emitSensorEvent(world,
|
|
73
|
+
emitSensorEvent(world, engine, touched, events.GetBeginEvent(i), "begin");
|
|
72
74
|
}
|
|
73
75
|
for (let i = 0; i < events.endCount; i++) {
|
|
74
|
-
emitSensorEvent(world,
|
|
76
|
+
emitSensorEvent(world, engine, touched, events.GetEndEvent(i), "end");
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
finally {
|
|
78
80
|
events.delete();
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
|
-
function emitContactEvent(world,
|
|
82
|
-
const entityA = getLiveEntity(world,
|
|
83
|
-
const entityB = getLiveEntity(world,
|
|
83
|
+
function emitContactEvent(world, engine, touched, event, kind) {
|
|
84
|
+
const entityA = getLiveEntity(world, engine.entityByShapeIndex.get(event.shapeIdA.index1));
|
|
85
|
+
const entityB = getLiveEntity(world, engine.entityByShapeIndex.get(event.shapeIdB.index1));
|
|
84
86
|
if (entityA === undefined || entityB === undefined) {
|
|
85
87
|
return;
|
|
86
88
|
}
|
|
87
89
|
emitContactToEntity(touched, entityA, entityB, kind);
|
|
88
90
|
emitContactToEntity(touched, entityB, entityA, kind);
|
|
89
91
|
}
|
|
90
|
-
function emitSensorEvent(world,
|
|
91
|
-
const sensor = getLiveEntity(world,
|
|
92
|
-
const visitor = getLiveEntity(world,
|
|
92
|
+
function emitSensorEvent(world, engine, touched, event, kind) {
|
|
93
|
+
const sensor = getLiveEntity(world, engine.entityByShapeIndex.get(event.sensorShapeId.index1));
|
|
94
|
+
const visitor = getLiveEntity(world, engine.entityByShapeIndex.get(event.visitorShapeId.index1));
|
|
93
95
|
if (sensor === undefined || visitor === undefined) {
|
|
94
96
|
return;
|
|
95
97
|
}
|
|
@@ -109,9 +111,9 @@ function emitSensorEvent(world, state, touched, event, kind) {
|
|
|
109
111
|
events.end.push({ other: visitor });
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
|
-
function emitHitEvent(world,
|
|
113
|
-
const entityA = getLiveEntity(world,
|
|
114
|
-
const entityB = getLiveEntity(world,
|
|
114
|
+
function emitHitEvent(world, engine, touched, event) {
|
|
115
|
+
const entityA = getLiveEntity(world, engine.entityByShapeIndex.get(event.shapeIdA.index1));
|
|
116
|
+
const entityB = getLiveEntity(world, engine.entityByShapeIndex.get(event.shapeIdB.index1));
|
|
115
117
|
if (entityA === undefined || entityB === undefined) {
|
|
116
118
|
return;
|
|
117
119
|
}
|
|
@@ -207,6 +209,6 @@ function deleteIfPresent(value) {
|
|
|
207
209
|
value.delete?.();
|
|
208
210
|
}
|
|
209
211
|
function isDestroyed(entity) {
|
|
210
|
-
return entity.
|
|
212
|
+
return entity.destroyed;
|
|
211
213
|
}
|
|
212
214
|
//# sourceMappingURL=events.js.map
|
package/systems/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../src/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B,EAAE,CAAC;QACzC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,YAAY,CAA6B,CAAC;QACxF,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YACxB,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAC9B,KAAY,EACZ,iBAA2B,EAC3B,OAAiB;IAEjB,KAAK,MAAM,QAAQ,IAAI,iBAAiB,EAAE,CAAC;QACzC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,SAAS,CAA0B,CAAC;QAClF,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,KAA8B;IACrD,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;AACnB,CAAC;AAED,SAAS,WAAW,CAAC,MAAc;IACjC,OAAO,MAAM,CAAC,SAAS,CAAC;AAC1B,CAAC"}
|
package/systems/forces.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type Entity, type
|
|
2
|
-
import { type
|
|
3
|
-
export declare function installForceGather(world: World,
|
|
1
|
+
import { type Entity, type World } from "@vworlds/vecs";
|
|
2
|
+
import { type PhysicsEngine } from "../adapter/engine.js";
|
|
3
|
+
export declare function installForceGather(world: World, engine: PhysicsEngine, phase: Entity): void;
|
package/systems/forces.js
CHANGED
|
@@ -1,26 +1,35 @@
|
|
|
1
|
+
import { ChildOf } from "@vworlds/vecs";
|
|
2
|
+
import { Body } from "../components/body.js";
|
|
1
3
|
import { Force, Torque } from "../components/force.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { scr_b2Vec2 } from "../adapter/runtime.js";
|
|
5
|
+
import { PhysicsSystemTag } from "../adapter/engine.js";
|
|
6
|
+
const forceTargetPredicate = { any: [Body, { parent: Body }] };
|
|
7
|
+
export function installForceGather(world, engine, phase) {
|
|
8
|
+
const forceSystem = world
|
|
9
|
+
.system("PhysicsForceGather:Force")
|
|
10
|
+
.with(Force, forceTargetPredicate)
|
|
11
|
+
.phase(phase);
|
|
12
|
+
forceSystem.entity.add(PhysicsSystemTag);
|
|
13
|
+
forceSystem.each([Force, Body, { target: [ChildOf, [Body]] }], (_entity, [force, body, parentBody]) => {
|
|
14
|
+
const bodyId = body?._bodyId ?? parentBody?._bodyId;
|
|
15
|
+
if (bodyId === undefined) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const vec = scr_b2Vec2[0];
|
|
19
|
+
vec.Set(force.x, force.y);
|
|
20
|
+
engine.box2d.b2Body_ApplyForceToCenter(bodyId, vec, force.wake);
|
|
21
|
+
});
|
|
22
|
+
const torqueSystem = world
|
|
23
|
+
.system("PhysicsForceGather:Torque")
|
|
24
|
+
.with(Torque, forceTargetPredicate)
|
|
7
25
|
.phase(phase)
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const force = entity.get(Force);
|
|
15
|
-
if (force !== undefined) {
|
|
16
|
-
state.scratchVec2.Set(force.x, force.y);
|
|
17
|
-
state.box2d.b2Body_ApplyForceToCenter(bodyId, state.scratchVec2, force.wake);
|
|
18
|
-
}
|
|
19
|
-
const torque = entity.get(Torque);
|
|
20
|
-
if (torque !== undefined) {
|
|
21
|
-
state.box2d.b2Body_ApplyTorque(bodyId, torque.value, torque.wake);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
26
|
+
.each([Torque, Body, { target: [ChildOf, [Body]] }], (_entity, [torque, body, parentBody]) => {
|
|
27
|
+
const bodyId = body?._bodyId ?? parentBody?._bodyId;
|
|
28
|
+
if (bodyId === undefined) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
engine.box2d.b2Body_ApplyTorque(bodyId, torque.value, torque.wake);
|
|
24
32
|
});
|
|
33
|
+
torqueSystem.entity.add(PhysicsSystemTag);
|
|
25
34
|
}
|
|
26
35
|
//# sourceMappingURL=forces.js.map
|
package/systems/forces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forces.js","sourceRoot":"","sources":["../../../../src/systems/forces.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"forces.js","sourceRoot":"","sources":["../../../../src/systems/forces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAsB,MAAM,sBAAsB,CAAC;AAE5E,MAAM,oBAAoB,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAW,CAAC;AAExE,MAAM,UAAU,kBAAkB,CAAC,KAAY,EAAE,MAAqB,EAAE,KAAa;IACnF,MAAM,WAAW,GAAG,KAAK;SACtB,MAAM,CAAC,0BAA0B,CAAC;SAClC,IAAI,CAAC,KAAK,EAAE,oBAAoB,CAAC;SACjC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChB,WAAW,CA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AC,CAAC;IACrE,CAAC,CAAC,CAAC;IACL,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Entity, type
|
|
2
|
-
import { type
|
|
3
|
-
export declare function installImpulseAccumulate(world: World,
|
|
4
|
-
export declare function registerImpulseHooks(world: World,
|
|
1
|
+
import { type Entity, type World } from "@vworlds/vecs";
|
|
2
|
+
import { type PhysicsEngine } from "../adapter/engine.js";
|
|
3
|
+
export declare function installImpulseAccumulate(world: World, engine: PhysicsEngine, phase: Entity): void;
|
|
4
|
+
export declare function registerImpulseHooks(world: World, engine: PhysicsEngine): void;
|
|
@@ -1,69 +1,73 @@
|
|
|
1
1
|
import { AngularImpulse, Impulse } from "../components/force.js";
|
|
2
|
+
import { scr_b2Vec2 } from "../adapter/runtime.js";
|
|
3
|
+
import { PhysicsSystemTag } from "../adapter/engine.js";
|
|
2
4
|
import { resolveBodyId } from "../util/resolve_body.js";
|
|
3
|
-
export function installImpulseAccumulate(world,
|
|
4
|
-
|
|
5
|
+
export function installImpulseAccumulate(world, engine, phase) {
|
|
6
|
+
const system = world
|
|
5
7
|
.system("PhysicsImpulseAccumulate")
|
|
6
8
|
.phase(phase)
|
|
7
9
|
.run(() => {
|
|
8
|
-
drainLinearImpulses(
|
|
9
|
-
drainAngularImpulses(
|
|
10
|
+
drainLinearImpulses(engine);
|
|
11
|
+
drainAngularImpulses(engine);
|
|
10
12
|
});
|
|
13
|
+
system.entity.add(PhysicsSystemTag);
|
|
11
14
|
}
|
|
12
|
-
export function registerImpulseHooks(world,
|
|
15
|
+
export function registerImpulseHooks(world, engine) {
|
|
13
16
|
world.component(Impulse).onSet((entity, impulse) => {
|
|
14
|
-
const bodyId = resolveBodyId(entity
|
|
17
|
+
const bodyId = resolveBodyId(entity);
|
|
15
18
|
if (bodyId === undefined) {
|
|
16
19
|
return;
|
|
17
20
|
}
|
|
18
|
-
|
|
19
|
-
const accumulator = getLinearAccumulator(
|
|
21
|
+
engine.impulseEntitiesThisStep.add(entity.eid);
|
|
22
|
+
const accumulator = getLinearAccumulator(engine, bodyId);
|
|
20
23
|
accumulator.x += impulse.x;
|
|
21
24
|
accumulator.y += impulse.y;
|
|
22
25
|
accumulator.wake || (accumulator.wake = impulse.wake);
|
|
23
26
|
});
|
|
24
27
|
world.component(AngularImpulse).onSet((entity, impulse) => {
|
|
25
|
-
const bodyId = resolveBodyId(entity
|
|
28
|
+
const bodyId = resolveBodyId(entity);
|
|
26
29
|
if (bodyId === undefined) {
|
|
27
30
|
return;
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
const accumulator = getAngularAccumulator(
|
|
32
|
+
engine.impulseEntitiesThisStep.add(entity.eid);
|
|
33
|
+
const accumulator = getAngularAccumulator(engine, bodyId);
|
|
31
34
|
accumulator.value += impulse.value;
|
|
32
35
|
accumulator.wake || (accumulator.wake = impulse.wake);
|
|
33
36
|
});
|
|
34
37
|
}
|
|
35
|
-
function drainLinearImpulses(
|
|
36
|
-
for (const [bodyId, impulse] of
|
|
37
|
-
if (!
|
|
38
|
+
function drainLinearImpulses(engine) {
|
|
39
|
+
for (const [bodyId, impulse] of engine.pendingLinearImpulse) {
|
|
40
|
+
if (!engine.entityByBodyIndex.has(bodyId.index1)) {
|
|
38
41
|
continue;
|
|
39
42
|
}
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
const vec = scr_b2Vec2[0];
|
|
44
|
+
vec.Set(impulse.x, impulse.y);
|
|
45
|
+
engine.box2d.b2Body_ApplyLinearImpulseToCenter(bodyId, vec, impulse.wake);
|
|
42
46
|
}
|
|
43
|
-
|
|
47
|
+
engine.pendingLinearImpulse.clear();
|
|
44
48
|
}
|
|
45
|
-
function drainAngularImpulses(
|
|
46
|
-
for (const [bodyId, impulse] of
|
|
47
|
-
if (!
|
|
49
|
+
function drainAngularImpulses(engine) {
|
|
50
|
+
for (const [bodyId, impulse] of engine.pendingAngularImpulse) {
|
|
51
|
+
if (!engine.entityByBodyIndex.has(bodyId.index1)) {
|
|
48
52
|
continue;
|
|
49
53
|
}
|
|
50
|
-
|
|
54
|
+
engine.box2d.b2Body_ApplyAngularImpulse(bodyId, impulse.value, impulse.wake);
|
|
51
55
|
}
|
|
52
|
-
|
|
56
|
+
engine.pendingAngularImpulse.clear();
|
|
53
57
|
}
|
|
54
|
-
function getLinearAccumulator(
|
|
55
|
-
let accumulator =
|
|
58
|
+
function getLinearAccumulator(engine, bodyId) {
|
|
59
|
+
let accumulator = engine.pendingLinearImpulse.get(bodyId);
|
|
56
60
|
if (accumulator === undefined) {
|
|
57
61
|
accumulator = { x: 0, y: 0, wake: false };
|
|
58
|
-
|
|
62
|
+
engine.pendingLinearImpulse.set(bodyId, accumulator);
|
|
59
63
|
}
|
|
60
64
|
return accumulator;
|
|
61
65
|
}
|
|
62
|
-
function getAngularAccumulator(
|
|
63
|
-
let accumulator =
|
|
66
|
+
function getAngularAccumulator(engine, bodyId) {
|
|
67
|
+
let accumulator = engine.pendingAngularImpulse.get(bodyId);
|
|
64
68
|
if (accumulator === undefined) {
|
|
65
69
|
accumulator = { value: 0, wake: false };
|
|
66
|
-
|
|
70
|
+
engine.pendingAngularImpulse.set(bodyId, accumulator);
|
|
67
71
|
}
|
|
68
72
|
return accumulator;
|
|
69
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impulse_accumulate.js","sourceRoot":"","sources":["../../../../src/systems/impulse_accumulate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"impulse_accumulate.js","sourceRoot":"","sources":["../../../../src/systems/impulse_accumulate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,E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,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E,CAAC;IACD,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;AACvC,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAqB,EAAE,MAAgB;IACnE,IAAI,WAAW,GAAG,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1D,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,WAAW,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC1C,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAqB,EAAE,MAAgB;IACpE,IAAI,WAAW,GAAG,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3D,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,WAAW,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACxC,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type Entity, type
|
|
2
|
-
import { type
|
|
3
|
-
export declare function installImpulseZero(world: World,
|
|
1
|
+
import { type Entity, type World } from "@vworlds/vecs";
|
|
2
|
+
import { type PhysicsEngine } from "../adapter/engine.js";
|
|
3
|
+
export declare function installImpulseZero(world: World, engine: PhysicsEngine, phase: Entity): void;
|
package/systems/impulse_zero.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { AngularImpulse, Impulse } from "../components/force.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { PhysicsSystemTag } from "../adapter/engine.js";
|
|
3
|
+
export function installImpulseZero(world, engine, phase) {
|
|
4
|
+
const system = world
|
|
4
5
|
.system("PhysicsImpulseZero")
|
|
5
6
|
.phase(phase)
|
|
6
7
|
.run(() => {
|
|
7
|
-
for (const eid of
|
|
8
|
+
for (const eid of engine.impulseEntitiesThisStep) {
|
|
8
9
|
const entity = world.getEntity(eid);
|
|
9
10
|
if (entity === undefined) {
|
|
10
11
|
continue;
|
|
@@ -19,7 +20,8 @@ export function installImpulseZero(world, state, phase) {
|
|
|
19
20
|
ai.value = 0;
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
engine.impulseEntitiesThisStep.clear();
|
|
23
24
|
});
|
|
25
|
+
system.entity.add(PhysicsSystemTag);
|
|
24
26
|
}
|
|
25
27
|
//# sourceMappingURL=impulse_zero.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impulse_zero.js","sourceRoot":"","sources":["../../../../src/systems/impulse_zero.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"impulse_zero.js","sourceRoot":"","sources":["../../../../src/systems/impulse_zero.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAsB,MAAM,sBAAsB,CAAC;AAE5E,MAAM,UAAU,kBAAkB,CAAC,KAAY,EAAE,MAAqB,EAAE,KAAa;IACnF,MAAM,MAAM,GAAG,KAAK;SACjB,MAAM,CAAC,oBAAoB,CAAC;SAC5B,KAAK,CAAC,KAAK,CAAC;SACZ,GAAG,CAAC,GAAG,EAAE;QACR,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,uBAAuB,EAAE,CAAC;YACjD,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACpC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,SAAS;YACX,CAAC;YAED,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAwB,CAAC;YACvD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;gBACV,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;YACZ,CAAC;YAED,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAA+B,CAAC;YACpE,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;gBACrB,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC;YACf,CAAC;QACH,CAAC;QAED,MAAM,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;IACL,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AACtC,CAAC"}
|
package/systems/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Entity, type World } from "@vworlds/vecs";
|
|
2
|
-
import { type
|
|
2
|
+
import { type PhysicsEngine } from "../adapter/engine.js";
|
|
3
3
|
/** The three phases the physics systems split across. */
|
|
4
4
|
export interface PhysicsPhases {
|
|
5
5
|
preStep: Entity;
|
|
@@ -11,6 +11,5 @@ export interface PhysicsSystemsOptions {
|
|
|
11
11
|
/** Install `PhysicsDebugValidation` when `true`. Default `false`. */
|
|
12
12
|
debug?: boolean;
|
|
13
13
|
}
|
|
14
|
-
/** Register every physics system into `world`, bound to `
|
|
15
|
-
|
|
16
|
-
export declare function registerPhysicsSystems(world: World, state: PhysicsState, phases: PhysicsPhases, opts?: PhysicsSystemsOptions): void;
|
|
14
|
+
/** Register every physics system into `world`, bound to `engine`. */
|
|
15
|
+
export declare function registerPhysicsSystems(world: World, engine: PhysicsEngine, phases: PhysicsPhases, opts?: PhysicsSystemsOptions): void;
|