@ignifx/physics 0.6.1 → 0.8.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/dist/index.d.ts +64 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +160 -50
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/skills/physics/SKILL.md +12 -3
package/dist/index.d.ts
CHANGED
|
@@ -1091,7 +1091,8 @@ export declare function physicsError(code: PhysicsErrorCode, message: string, op
|
|
|
1091
1091
|
/**
|
|
1092
1092
|
* Raycasts return backend body identities. Shape casts use backend hit geometry and the local
|
|
1093
1093
|
* body-bounds index for identity; overlaps use that index entirely. Shape-cast identities and
|
|
1094
|
-
* overlap results are bounds-accurate, not exact shape intersections.
|
|
1094
|
+
* overlap results are bounds-accurate, not exact shape intersections. Every query can hit a
|
|
1095
|
+
* `Rigidbody`, a collider-only static body, or a `CharacterController` capsule.
|
|
1095
1096
|
*/
|
|
1096
1097
|
/**
|
|
1097
1098
|
* Options every query accepts.
|
|
@@ -1153,9 +1154,12 @@ type QueryShape = {
|
|
|
1153
1154
|
* @public
|
|
1154
1155
|
*/
|
|
1155
1156
|
interface RaycastHit {
|
|
1156
|
-
/** The entity that was hit. */
|
|
1157
|
+
/** The entity that was hit: a body's entity, or a `CharacterController`'s entity for its capsule. */
|
|
1157
1158
|
readonly entity: Entity;
|
|
1158
|
-
/**
|
|
1159
|
+
/**
|
|
1160
|
+
* The collider on that entity, or `null` for a `CharacterController` capsule or an entity with no
|
|
1161
|
+
* collider registered any more.
|
|
1162
|
+
*/
|
|
1159
1163
|
readonly collider: Collider | null;
|
|
1160
1164
|
/** The world-space contact point. */
|
|
1161
1165
|
readonly point: Vec3Like;
|
|
@@ -1172,9 +1176,12 @@ interface RaycastHit {
|
|
|
1172
1176
|
* @public
|
|
1173
1177
|
*/
|
|
1174
1178
|
interface ShapeCastHit {
|
|
1175
|
-
/**
|
|
1179
|
+
/**
|
|
1180
|
+
* The entity the swept shape hit — a `CharacterController`'s entity for its capsule — or `null`
|
|
1181
|
+
* when the bounds index cannot identify it or `layerMask` excludes it.
|
|
1182
|
+
*/
|
|
1176
1183
|
readonly entity: Entity | null;
|
|
1177
|
-
/** The collider on that entity, or `null
|
|
1184
|
+
/** The collider on that entity, or `null`, which is always the case for a capsule. */
|
|
1178
1185
|
readonly collider: Collider | null;
|
|
1179
1186
|
/** The world-space contact point on the hit body. */
|
|
1180
1187
|
readonly point: Vec3Like;
|
|
@@ -1232,6 +1239,24 @@ interface BodyRecord {
|
|
|
1232
1239
|
/** Signal connections the record owns, dropped when it is torn down. */
|
|
1233
1240
|
disconnects: Disconnect[];
|
|
1234
1241
|
}
|
|
1242
|
+
/**
|
|
1243
|
+
* What a query can resolve a hit to: a {@link BodyRecord}, or a `CharacterController`'s capsule,
|
|
1244
|
+
* which is a Havok body the runtime keeps with its controllers rather than its body records.
|
|
1245
|
+
*
|
|
1246
|
+
* @internal
|
|
1247
|
+
*/
|
|
1248
|
+
interface QueryTarget {
|
|
1249
|
+
/** The entity a hit is reported against. */
|
|
1250
|
+
readonly entity: Entity;
|
|
1251
|
+
/** The colliders that make up the body; empty for a character capsule. */
|
|
1252
|
+
readonly colliders: readonly Collider[];
|
|
1253
|
+
/** The layer queries filter by; a runtime `entity.layer` change lands on the next fixed step. */
|
|
1254
|
+
readonly layer: number;
|
|
1255
|
+
/** The centre of the world bounding box, as of the last fixed step. */
|
|
1256
|
+
readonly currentPosition: Vec3;
|
|
1257
|
+
/** Half the world bounding box. */
|
|
1258
|
+
readonly halfExtents: Vec3;
|
|
1259
|
+
}
|
|
1235
1260
|
//#endregion
|
|
1236
1261
|
//#region src/runtime/runtime.d.ts
|
|
1237
1262
|
/**
|
|
@@ -1388,6 +1413,27 @@ declare class PhysicsRuntime {
|
|
|
1388
1413
|
* @returns The record, or `null`.
|
|
1389
1414
|
*/
|
|
1390
1415
|
recordOfNode(node: LiteSceneNode | null): BodyRecord | null;
|
|
1416
|
+
/**
|
|
1417
|
+
* What a query hit on a Lite node: a body record, or a character controller's capsule.
|
|
1418
|
+
*
|
|
1419
|
+
* @param node - The node of the body that was hit.
|
|
1420
|
+
* @returns The target, or `null` when the node belongs to neither.
|
|
1421
|
+
*/
|
|
1422
|
+
targetOfNode(node: LiteSceneNode | null): QueryTarget | null;
|
|
1423
|
+
/**
|
|
1424
|
+
* How many entries the query index holds: every body record, then every character controller.
|
|
1425
|
+
*
|
|
1426
|
+
* @returns The count.
|
|
1427
|
+
*/
|
|
1428
|
+
get queryTargetCount(): number;
|
|
1429
|
+
/**
|
|
1430
|
+
* One entry of the query index. Bodies come first and controllers after, each in creation order,
|
|
1431
|
+
* so `overlap` lists them in a stable order (`09-physics.md` §8).
|
|
1432
|
+
*
|
|
1433
|
+
* @param index - An index below {@link PhysicsRuntime.queryTargetCount}.
|
|
1434
|
+
* @returns The target, or `undefined` past the end.
|
|
1435
|
+
*/
|
|
1436
|
+
queryTargetAt(index: number): QueryTarget | undefined;
|
|
1391
1437
|
/** Counts one query for the diagnostics group. */
|
|
1392
1438
|
countQuery(): void;
|
|
1393
1439
|
/**
|
|
@@ -1584,6 +1630,11 @@ export declare class PhysicsService {
|
|
|
1584
1630
|
/**
|
|
1585
1631
|
* Casts a ray and returns the first entity it hits (`09-physics.md` §5).
|
|
1586
1632
|
*
|
|
1633
|
+
* @remarks
|
|
1634
|
+
* The ray hits `Rigidbody` and collider-only bodies and `CharacterController` capsules. A capsule
|
|
1635
|
+
* hit reports the character's entity with `collider: null`. A ray passes through a capsule when
|
|
1636
|
+
* `layerMask` leaves out the character's layer, or when the ray starts inside it.
|
|
1637
|
+
*
|
|
1587
1638
|
* @param origin - The world-space origin.
|
|
1588
1639
|
* @param direction - The direction; it is normalised for you.
|
|
1589
1640
|
* @param maxDistance - How far to travel; defaults to 10 km.
|
|
@@ -1597,7 +1648,9 @@ export declare class PhysicsService {
|
|
|
1597
1648
|
*
|
|
1598
1649
|
* @remarks
|
|
1599
1650
|
* Lite's `shapeCast` reports no body (`index.d.ts` 11497), so `entity` is resolved against the
|
|
1600
|
-
* extension's body-bounds index and is bounds-accurate rather than shape-accurate.
|
|
1651
|
+
* extension's body-bounds index and is bounds-accurate rather than shape-accurate. The index holds
|
|
1652
|
+
* every `Rigidbody` and collider-only body and every `CharacterController` capsule; a capsule
|
|
1653
|
+
* contact reports the character's entity with `collider: null`.
|
|
1601
1654
|
*
|
|
1602
1655
|
* The sweep itself cannot be filtered by layer — Lite's `ShapeCastQuery` carries no collision
|
|
1603
1656
|
* masks — so a body outside `layerMask` still stops the sweep; it is merely reported with
|
|
@@ -1619,15 +1672,17 @@ export declare class PhysicsService {
|
|
|
1619
1672
|
* @remarks
|
|
1620
1673
|
* Lite's `shapeProximity` reports one hit and no identity (`index.d.ts` 11540,
|
|
1621
1674
|
* `lib/physics/havok-queries.js:7`), so this is answered from the extension's own bounds index:
|
|
1622
|
-
* every
|
|
1623
|
-
* — a body whose box overlaps but whose shape
|
|
1675
|
+
* every `Rigidbody`, collider-only body and `CharacterController` capsule whose world bounding box
|
|
1676
|
+
* intersects the query shape's. It is conservative — a body whose box overlaps but whose shape
|
|
1677
|
+
* does not is listed.
|
|
1624
1678
|
*
|
|
1625
1679
|
* @param shape - The query shape.
|
|
1626
1680
|
* @param position - Its world position.
|
|
1627
1681
|
* @param rotation - Its world rotation; accepted for forward compatibility and currently unused,
|
|
1628
1682
|
* because the bounds test is axis-aligned.
|
|
1629
1683
|
* @param options - Layer mask and trigger behaviour.
|
|
1630
|
-
* @returns The overlapping entities, in
|
|
1684
|
+
* @returns The overlapping entities, each once: bodies in creation order, then characters in
|
|
1685
|
+
* creation order. The array is reused between calls.
|
|
1631
1686
|
* @throws IgnifxError with code `IGX-0902` in development when no fixed step has run yet.
|
|
1632
1687
|
*/
|
|
1633
1688
|
overlap(shape: QueryShape, position: Vec3Like, rotation?: Quat, options?: QueryOptions): readonly Entity[];
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/settings.ts","../src/material.ts","../src/lite/havok.ts","../src/components/collider.ts","../src/events.ts","../src/components/rigidbody.ts","../src/components/character-controller.ts","../src/components/colliders.ts","../src/errors.ts","../src/queries.ts","../src/runtime/body-record.ts","../src/runtime/runtime.ts","../src/runtime/host.ts","../src/service.ts","../src/extension.ts","../src/schemas.ts"],"mappings":";;;;;;;;;;;;;;qBAea;;;;;;qBAOA;;;;;;;UAQI;;WAEN;;WAEA;;WAEA;;;;;;;;UASM;;WAEN;;WAEA;;;;;;;;;;;;;;;;;;;UAoBM;;WAEN,SAAS;;;;;WAKT,iBAAiB,SAAS;;WAE1B,iBAAiB;;WAEjB,gBAAgB;;WAEhB;;WAEA;;;;;;;;;;;;;wBA8BK,yBAAyB;;;;;;;;wBAyBzB,0BAA0B;;;;;;;;;;;;;qBC5H7B;;;;;;qBAOA;;;;;;qBAOA;;;;;;qBAOA;;;;;;;;;;;;;qBAcA,2BAA2B;;SAE/B;;WAGE;;WAGA;;WAGA;;WAGA;;;;;;;;EAST,YAAY,cAAc,QAAQ;;;;;;;;;;;;;SAmB3B,WAAW,cAAc,QAAQ,QAAQ,yBAAyB;;;;;;;;;wBAiB3D,+BAA+B,YAAY;;;;;;;;;;;wBAqB3C,qBAAqB,iBAAiB,UAAU,YAAY;;;;;;;;;wBAgC5D,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KC9FzC,mBAAmB;;;;;;;KAQnB,kBAAkB;;;;;;KAOlB,mBAAmB;;;;;;;cAQlB;;WAEX;;WAEA;;WAEA;;;;;;;KAQU,qBAAqB,yBAAyB;;UA0EzC;;WAEN,QAAQ;;WAER,OAAO;;;;;;;;;;;;;;;;wBCnKF,kBAAkB;;;;;;;8BAsBZ,iBAAiB,qBAAqB;;SAEnD;;EAGP,QAAgB;;EAGhB;;EAGA,UAAkB,YAAY;;EAG9B,gBAAwB;;EAGxB;;;;EAKA;;EAMA;;EAKA;;;;;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B,QAAQ,UAAU,MAAM,gBAAgB;;;;;;;;EAY7E,iBAAiB,QAAQ,UAAU,KAAK;;;;;;;;;;;;;qBAkD7B,4BAA4B;;SAEhC;;SAGA,QAAQ;EAEf;EAEA;EAEA;EAEA,MAAc;;EAGd;;;;;;;;EAYA,YAAY,OAAO,kBAAkB,OAAO,WAAW;;;;;;;EAgCvD,iBAAiB,OAAO,UAAU,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;qBCzY5B;;WAEX;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;YAQU,2BAA2B,+BAA+B;;;;;;;qBAQzD,wBAAwB,SAAS;;;;;;;UAiB7B;;WAEN,UAAU;;WAEV;;WAEA;;;;;;;;;;;;;;;;;;;wBAoBK,aAAa,MAAM,kBAAkB,iBAAiB,UAAU,sBAAsB
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/settings.ts","../src/material.ts","../src/lite/havok.ts","../src/components/collider.ts","../src/events.ts","../src/components/rigidbody.ts","../src/components/character-controller.ts","../src/components/colliders.ts","../src/errors.ts","../src/queries.ts","../src/runtime/body-record.ts","../src/runtime/runtime.ts","../src/runtime/host.ts","../src/service.ts","../src/extension.ts","../src/schemas.ts"],"mappings":";;;;;;;;;;;;;;qBAea;;;;;;qBAOA;;;;;;;UAQI;;WAEN;;WAEA;;WAEA;;;;;;;;UASM;;WAEN;;WAEA;;;;;;;;;;;;;;;;;;;UAoBM;;WAEN,SAAS;;;;;WAKT,iBAAiB,SAAS;;WAE1B,iBAAiB;;WAEjB,gBAAgB;;WAEhB;;WAEA;;;;;;;;;;;;;wBA8BK,yBAAyB;;;;;;;;wBAyBzB,0BAA0B;;;;;;;;;;;;;qBC5H7B;;;;;;qBAOA;;;;;;qBAOA;;;;;;qBAOA;;;;;;;;;;;;;qBAcA,2BAA2B;;SAE/B;;WAGE;;WAGA;;WAGA;;WAGA;;;;;;;;EAST,YAAY,cAAc,QAAQ;;;;;;;;;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qBAqBT,UAAU,UAAU,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;wBChDpC,mBAAmB,SAAS,eAAe"}
|
package/dist/index.js
CHANGED
|
@@ -2097,20 +2097,33 @@ function moveController(controller, displacement) {
|
|
|
2097
2097
|
/**
|
|
2098
2098
|
* Probes the surface under the character without moving it.
|
|
2099
2099
|
*
|
|
2100
|
+
* @remarks
|
|
2101
|
+
* `checkSupport` wants a **unit** direction. It classifies by `1 - dot(slide, direction)²` against
|
|
2102
|
+
* `maxSlopeCosine²` (`lib/physics/character-controller.js`, `checkSupport`), which is `cos²` of the
|
|
2103
|
+
* slope only when `direction` has length 1. Passed raw gravity (length 9.81), the term fell below
|
|
2104
|
+
* the limit on any incline steeper than 4° to 5°, so every walkable slope read as `SLIDING` and
|
|
2105
|
+
* `isGrounded` was false on it (fixed 2026-10-14). Zero gravity probes straight down.
|
|
2106
|
+
*
|
|
2100
2107
|
* @param controller - The controller.
|
|
2101
2108
|
* @param deltaSeconds - The fixed step.
|
|
2102
|
-
* @param gravity - The probe direction, normally gravity.
|
|
2109
|
+
* @param gravity - The probe direction, normally gravity; only its direction is used.
|
|
2103
2110
|
* @param groundNormal - Written with the averaged supporting normal.
|
|
2104
2111
|
* @returns The support classification.
|
|
2105
2112
|
*
|
|
2106
2113
|
* @internal
|
|
2107
2114
|
*/
|
|
2108
2115
|
function probeSupport(controller, deltaSeconds, gravity, groundNormal) {
|
|
2109
|
-
const
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2116
|
+
const length = Math.hypot(gravity.x, gravity.y, gravity.z);
|
|
2117
|
+
const direction = length > 0 ? {
|
|
2118
|
+
x: gravity.x / length,
|
|
2119
|
+
y: gravity.y / length,
|
|
2120
|
+
z: gravity.z / length
|
|
2121
|
+
} : {
|
|
2122
|
+
x: 0,
|
|
2123
|
+
y: -1,
|
|
2124
|
+
z: 0
|
|
2125
|
+
};
|
|
2126
|
+
const surface = controller.checkSupport(deltaSeconds, direction);
|
|
2114
2127
|
const normal = surface.averageSurfaceNormal;
|
|
2115
2128
|
groundNormal.set(normal.x, normal.y, normal.z);
|
|
2116
2129
|
return toSupportState(surface.supportedState);
|
|
@@ -2128,6 +2141,18 @@ function controllerBody(controller) {
|
|
|
2128
2141
|
return controller.getBody();
|
|
2129
2142
|
}
|
|
2130
2143
|
/**
|
|
2144
|
+
* The node of a controller's capsule body. Lite creates it for the controller, separate from the
|
|
2145
|
+
* entity's node, so it is what a ray hit on the capsule reports (`RaycastResult.body.node`).
|
|
2146
|
+
*
|
|
2147
|
+
* @param controller - The controller.
|
|
2148
|
+
* @returns The capsule body's node.
|
|
2149
|
+
*
|
|
2150
|
+
* @internal
|
|
2151
|
+
*/
|
|
2152
|
+
function controllerNode(controller) {
|
|
2153
|
+
return controller.getBody().node;
|
|
2154
|
+
}
|
|
2155
|
+
/**
|
|
2131
2156
|
* Reads the controller's resolved position.
|
|
2132
2157
|
*
|
|
2133
2158
|
* @param controller - The controller.
|
|
@@ -2383,6 +2408,7 @@ var PhysicsRuntime = class {
|
|
|
2383
2408
|
#byNode = /* @__PURE__ */ new Map();
|
|
2384
2409
|
#dirty = /* @__PURE__ */ new Set();
|
|
2385
2410
|
#controllers = [];
|
|
2411
|
+
#controllersByNode = /* @__PURE__ */ new Map();
|
|
2386
2412
|
#dirtyControllers = /* @__PURE__ */ new Set();
|
|
2387
2413
|
#collideMasks = new Int32Array(LAYER_COUNT).fill(-1);
|
|
2388
2414
|
#triggerSlots = [];
|
|
@@ -2604,6 +2630,35 @@ var PhysicsRuntime = class {
|
|
|
2604
2630
|
recordOfNode(node) {
|
|
2605
2631
|
return node === null ? null : this.#byNode.get(node) ?? null;
|
|
2606
2632
|
}
|
|
2633
|
+
/**
|
|
2634
|
+
* What a query hit on a Lite node: a body record, or a character controller's capsule.
|
|
2635
|
+
*
|
|
2636
|
+
* @param node - The node of the body that was hit.
|
|
2637
|
+
* @returns The target, or `null` when the node belongs to neither.
|
|
2638
|
+
*/
|
|
2639
|
+
targetOfNode(node) {
|
|
2640
|
+
if (node === null) return null;
|
|
2641
|
+
return this.#byNode.get(node) ?? this.#controllersByNode.get(node) ?? null;
|
|
2642
|
+
}
|
|
2643
|
+
/**
|
|
2644
|
+
* How many entries the query index holds: every body record, then every character controller.
|
|
2645
|
+
*
|
|
2646
|
+
* @returns The count.
|
|
2647
|
+
*/
|
|
2648
|
+
get queryTargetCount() {
|
|
2649
|
+
return this.#records.length + this.#controllers.length;
|
|
2650
|
+
}
|
|
2651
|
+
/**
|
|
2652
|
+
* One entry of the query index. Bodies come first and controllers after, each in creation order,
|
|
2653
|
+
* so `overlap` lists them in a stable order (`09-physics.md` §8).
|
|
2654
|
+
*
|
|
2655
|
+
* @param index - An index below {@link PhysicsRuntime.queryTargetCount}.
|
|
2656
|
+
* @returns The target, or `undefined` past the end.
|
|
2657
|
+
*/
|
|
2658
|
+
queryTargetAt(index) {
|
|
2659
|
+
const bodies = this.#records.length;
|
|
2660
|
+
return index < bodies ? this.#records[index] : this.#controllers[index - bodies];
|
|
2661
|
+
}
|
|
2607
2662
|
/** Counts one query for the diagnostics group. */
|
|
2608
2663
|
countQuery() {
|
|
2609
2664
|
this.#queries += 1;
|
|
@@ -2728,7 +2783,10 @@ var PhysicsRuntime = class {
|
|
|
2728
2783
|
*/
|
|
2729
2784
|
resizeController(component, preserveFeet) {
|
|
2730
2785
|
const record = this.#controllerOf(component);
|
|
2731
|
-
if (record !== null)
|
|
2786
|
+
if (record !== null) {
|
|
2787
|
+
resizeController(record.controller, component.height, component.radius, preserveFeet);
|
|
2788
|
+
capsuleHalfExtents(component.height, component.radius, record.halfExtents);
|
|
2789
|
+
}
|
|
2732
2790
|
}
|
|
2733
2791
|
/**
|
|
2734
2792
|
* Teleports a controller and resets its interpolation history.
|
|
@@ -2762,6 +2820,7 @@ var PhysicsRuntime = class {
|
|
|
2762
2820
|
record.disconnect();
|
|
2763
2821
|
disposeController(record.controller);
|
|
2764
2822
|
this.#controllers.splice(index, 1);
|
|
2823
|
+
this.#controllersByNode.delete(record.node);
|
|
2765
2824
|
return;
|
|
2766
2825
|
}
|
|
2767
2826
|
}
|
|
@@ -2781,6 +2840,7 @@ var PhysicsRuntime = class {
|
|
|
2781
2840
|
}
|
|
2782
2841
|
}
|
|
2783
2842
|
this.#controllers.length = 0;
|
|
2843
|
+
this.#controllersByNode.clear();
|
|
2784
2844
|
for (let index = this.#records.length - 1; index >= 0; index -= 1) {
|
|
2785
2845
|
const record = this.#records[index];
|
|
2786
2846
|
if (record !== void 0) this.#teardown(record);
|
|
@@ -3114,6 +3174,10 @@ var PhysicsRuntime = class {
|
|
|
3114
3174
|
if (record === void 0 || record.entity.layer === record.layer) continue;
|
|
3115
3175
|
this.markDirty(record.entity);
|
|
3116
3176
|
}
|
|
3177
|
+
for (let index = 0; index < this.#controllers.length; index += 1) {
|
|
3178
|
+
const record = this.#controllers[index];
|
|
3179
|
+
if (record !== void 0) record.layer = record.entity.layer;
|
|
3180
|
+
}
|
|
3117
3181
|
}
|
|
3118
3182
|
/**
|
|
3119
3183
|
* Snapshots every body's authoritative pose and reports implicit-static bodies that moved.
|
|
@@ -3200,6 +3264,11 @@ var PhysicsRuntime = class {
|
|
|
3200
3264
|
const record = {
|
|
3201
3265
|
component,
|
|
3202
3266
|
controller,
|
|
3267
|
+
node: controllerNode(controller),
|
|
3268
|
+
entity: component.entity,
|
|
3269
|
+
colliders: NO_COLLIDERS,
|
|
3270
|
+
layer: component.entity.layer,
|
|
3271
|
+
halfExtents: capsuleHalfExtents(component.height, component.radius, new Vec3()),
|
|
3203
3272
|
previousPosition: centre.clone(),
|
|
3204
3273
|
currentPosition: centre.clone(),
|
|
3205
3274
|
interpolate: this.#settings.interpolation && component.interpolation === "interpolate",
|
|
@@ -3209,6 +3278,7 @@ var PhysicsRuntime = class {
|
|
|
3209
3278
|
this.#reportPush(record, push);
|
|
3210
3279
|
});
|
|
3211
3280
|
this.#controllers.push(record);
|
|
3281
|
+
this.#controllersByNode.set(record.node, record);
|
|
3212
3282
|
}
|
|
3213
3283
|
/**
|
|
3214
3284
|
* Turns one Lite push event into a `CharacterCollision`.
|
|
@@ -3417,6 +3487,21 @@ var PhysicsRuntime = class {
|
|
|
3417
3487
|
};
|
|
3418
3488
|
/** Lite's own `characterStrength` default, which `pushStrength: 1` reproduces (`index.d.ts` 8320). */
|
|
3419
3489
|
const DEFAULT_CHARACTER_STRENGTH = 1e38;
|
|
3490
|
+
/** The collider list of a character capsule, which is built from the controller, not from colliders. */
|
|
3491
|
+
const NO_COLLIDERS = Object.freeze([]);
|
|
3492
|
+
/**
|
|
3493
|
+
* The half-extents of a controller capsule's bounding box. Lite places the capsule's segment ends at
|
|
3494
|
+
* `±(height / 2 - radius)` (`createPhysicsCharacterController`), and the capsule does not scale with
|
|
3495
|
+
* the entity.
|
|
3496
|
+
*
|
|
3497
|
+
* @param height - The capsule's total height.
|
|
3498
|
+
* @param radius - Its radius.
|
|
3499
|
+
* @param out - The vector to write.
|
|
3500
|
+
* @returns `out`.
|
|
3501
|
+
*/
|
|
3502
|
+
function capsuleHalfExtents(height, radius, out) {
|
|
3503
|
+
return out.set(radius, Math.abs(height / 2 - radius) + radius, radius);
|
|
3504
|
+
}
|
|
3420
3505
|
/**
|
|
3421
3506
|
* The colliders that make up an entity's body: every enabled `Collider` on the entity itself.
|
|
3422
3507
|
*
|
|
@@ -3815,6 +3900,8 @@ function bodyNodeOf(body) {
|
|
|
3815
3900
|
*/
|
|
3816
3901
|
/** How far a ray travels when the caller names no distance, in metres. */
|
|
3817
3902
|
const DEFAULT_RAY_DISTANCE = 1e4;
|
|
3903
|
+
/** How far past a skipped character capsule's surface a ray resumes, in metres. */
|
|
3904
|
+
const RAY_RESUME_DISTANCE = .001;
|
|
3818
3905
|
/** How much slack the bounds index allows when it resolves a sweep contact to an entity. */
|
|
3819
3906
|
const BOUNDS_EPSILON = .001;
|
|
3820
3907
|
/** Every bit set: the mask a query uses when the caller names no layers. */
|
|
@@ -3848,6 +3935,7 @@ var PhysicsService = class {
|
|
|
3848
3935
|
};
|
|
3849
3936
|
#point = new Vec3();
|
|
3850
3937
|
#normal = new Vec3();
|
|
3938
|
+
#rayFrom = new Vec3();
|
|
3851
3939
|
#overlapExtents = new Vec3();
|
|
3852
3940
|
#overlapResults = [];
|
|
3853
3941
|
#debugViewer;
|
|
@@ -3907,6 +3995,11 @@ var PhysicsService = class {
|
|
|
3907
3995
|
/**
|
|
3908
3996
|
* Casts a ray and returns the first entity it hits (`09-physics.md` §5).
|
|
3909
3997
|
*
|
|
3998
|
+
* @remarks
|
|
3999
|
+
* The ray hits `Rigidbody` and collider-only bodies and `CharacterController` capsules. A capsule
|
|
4000
|
+
* hit reports the character's entity with `collider: null`. A ray passes through a capsule when
|
|
4001
|
+
* `layerMask` leaves out the character's layer, or when the ray starts inside it.
|
|
4002
|
+
*
|
|
3910
4003
|
* @param origin - The world-space origin.
|
|
3911
4004
|
* @param direction - The direction; it is normalised for you.
|
|
3912
4005
|
* @param maxDistance - How far to travel; defaults to 10 km.
|
|
@@ -3916,7 +4009,8 @@ var PhysicsService = class {
|
|
|
3916
4009
|
*/
|
|
3917
4010
|
raycast(origin, direction, maxDistance = DEFAULT_RAY_DISTANCE, options) {
|
|
3918
4011
|
this.#requireStep("raycast");
|
|
3919
|
-
this.#rt()
|
|
4012
|
+
const runtime = this.#rt();
|
|
4013
|
+
runtime.countQuery();
|
|
3920
4014
|
const length = Math.hypot(direction.x, direction.y, direction.z);
|
|
3921
4015
|
if (length === 0) return null;
|
|
3922
4016
|
const scale = maxDistance / length;
|
|
@@ -3925,25 +4019,36 @@ var PhysicsService = class {
|
|
|
3925
4019
|
y: origin.y + direction.y * scale,
|
|
3926
4020
|
z: origin.z + direction.z * scale
|
|
3927
4021
|
};
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
4022
|
+
const from = this.#rayFrom.set(origin.x, origin.y, origin.z);
|
|
4023
|
+
let travelled = 0;
|
|
4024
|
+
for (let pass = 0; pass <= runtime.queryTargetCount; pass += 1) {
|
|
4025
|
+
castRay(runtime.world, from, to, ALL_LAYERS, maskOf(options), options?.hitTriggers === true, this.#point, this.#normal, this.#rayResult);
|
|
4026
|
+
if (!this.#rayResult.hit) return null;
|
|
4027
|
+
const target = runtime.targetOfNode(this.#rayResult.node);
|
|
4028
|
+
if (target === null) return null;
|
|
4029
|
+
if (this.#accepts(target, options)) return {
|
|
4030
|
+
entity: target.entity,
|
|
4031
|
+
collider: target.colliders[0] ?? null,
|
|
4032
|
+
point: this.#point.clone(),
|
|
4033
|
+
normal: this.#normal.clone(),
|
|
4034
|
+
distance: travelled + this.#rayResult.distance,
|
|
4035
|
+
triangleIndex: this.#rayResult.triangleIndex
|
|
4036
|
+
};
|
|
4037
|
+
travelled += this.#rayResult.distance + RAY_RESUME_DISTANCE;
|
|
4038
|
+
if (travelled >= maxDistance) return null;
|
|
4039
|
+
const step = RAY_RESUME_DISTANCE / length;
|
|
4040
|
+
from.set(this.#point.x + direction.x * step, this.#point.y + direction.y * step, this.#point.z + direction.z * step);
|
|
4041
|
+
}
|
|
4042
|
+
return null;
|
|
3940
4043
|
}
|
|
3941
4044
|
/**
|
|
3942
4045
|
* Sweeps a shape and returns the first contact (`09-physics.md` §5).
|
|
3943
4046
|
*
|
|
3944
4047
|
* @remarks
|
|
3945
4048
|
* Lite's `shapeCast` reports no body (`index.d.ts` 11497), so `entity` is resolved against the
|
|
3946
|
-
* extension's body-bounds index and is bounds-accurate rather than shape-accurate.
|
|
4049
|
+
* extension's body-bounds index and is bounds-accurate rather than shape-accurate. The index holds
|
|
4050
|
+
* every `Rigidbody` and collider-only body and every `CharacterController` capsule; a capsule
|
|
4051
|
+
* contact reports the character's entity with `collider: null`.
|
|
3947
4052
|
*
|
|
3948
4053
|
* The sweep itself cannot be filtered by layer — Lite's `ShapeCastQuery` carries no collision
|
|
3949
4054
|
* masks — so a body outside `layerMask` still stops the sweep; it is merely reported with
|
|
@@ -3970,11 +4075,11 @@ var PhysicsService = class {
|
|
|
3970
4075
|
destroyShape(this.#rt().world, handle);
|
|
3971
4076
|
}
|
|
3972
4077
|
if (!this.#sweepResult.hit) return null;
|
|
3973
|
-
const
|
|
4078
|
+
const target = this.#targetAt(this.#point, options, ignored);
|
|
3974
4079
|
const distance = Math.hypot(to.x - from.x, to.y - from.y, to.z - from.z) * this.#sweepResult.fraction;
|
|
3975
4080
|
return {
|
|
3976
|
-
entity:
|
|
3977
|
-
collider:
|
|
4081
|
+
entity: target?.entity ?? null,
|
|
4082
|
+
collider: target?.colliders[0] ?? null,
|
|
3978
4083
|
point: this.#point.clone(),
|
|
3979
4084
|
normal: this.#normal.clone(),
|
|
3980
4085
|
fraction: this.#sweepResult.fraction,
|
|
@@ -3987,29 +4092,33 @@ var PhysicsService = class {
|
|
|
3987
4092
|
* @remarks
|
|
3988
4093
|
* Lite's `shapeProximity` reports one hit and no identity (`index.d.ts` 11540,
|
|
3989
4094
|
* `lib/physics/havok-queries.js:7`), so this is answered from the extension's own bounds index:
|
|
3990
|
-
* every
|
|
3991
|
-
* — a body whose box overlaps but whose shape
|
|
4095
|
+
* every `Rigidbody`, collider-only body and `CharacterController` capsule whose world bounding box
|
|
4096
|
+
* intersects the query shape's. It is conservative — a body whose box overlaps but whose shape
|
|
4097
|
+
* does not is listed.
|
|
3992
4098
|
*
|
|
3993
4099
|
* @param shape - The query shape.
|
|
3994
4100
|
* @param position - Its world position.
|
|
3995
4101
|
* @param rotation - Its world rotation; accepted for forward compatibility and currently unused,
|
|
3996
4102
|
* because the bounds test is axis-aligned.
|
|
3997
4103
|
* @param options - Layer mask and trigger behaviour.
|
|
3998
|
-
* @returns The overlapping entities, in
|
|
4104
|
+
* @returns The overlapping entities, each once: bodies in creation order, then characters in
|
|
4105
|
+
* creation order. The array is reused between calls.
|
|
3999
4106
|
* @throws IgnifxError with code `IGX-0902` in development when no fixed step has run yet.
|
|
4000
4107
|
*/
|
|
4001
4108
|
overlap(shape, position, rotation, options) {
|
|
4002
4109
|
this.#requireStep("overlap");
|
|
4003
|
-
this.#rt()
|
|
4110
|
+
const runtime = this.#rt();
|
|
4111
|
+
runtime.countQuery();
|
|
4004
4112
|
queryHalfExtents(shape, this.#overlapExtents);
|
|
4005
|
-
this.#overlapResults
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
if (
|
|
4113
|
+
const results = this.#overlapResults;
|
|
4114
|
+
results.length = 0;
|
|
4115
|
+
const count = runtime.queryTargetCount;
|
|
4116
|
+
for (let index = 0; index < count; index += 1) {
|
|
4117
|
+
const target = runtime.queryTargetAt(index);
|
|
4118
|
+
if (target === void 0 || !this.#accepts(target, options)) continue;
|
|
4119
|
+
if (boxesOverlap(position, this.#overlapExtents, target.currentPosition, target.halfExtents) && !results.includes(target.entity)) results.push(target.entity);
|
|
4011
4120
|
}
|
|
4012
|
-
return
|
|
4121
|
+
return results;
|
|
4013
4122
|
}
|
|
4014
4123
|
/**
|
|
4015
4124
|
* How far the nearest body is from a positioned shape, which is the one thing Lite's
|
|
@@ -4147,36 +4256,37 @@ var PhysicsService = class {
|
|
|
4147
4256
|
* @param options - Layer mask and trigger behaviour.
|
|
4148
4257
|
* @param ignored - The entity the sweep was told to pass through, which can therefore not be the
|
|
4149
4258
|
* one it hit.
|
|
4150
|
-
* @returns The
|
|
4259
|
+
* @returns The body or capsule, or `null`.
|
|
4151
4260
|
*/
|
|
4152
|
-
#
|
|
4153
|
-
const
|
|
4261
|
+
#targetAt(point, options, ignored = null) {
|
|
4262
|
+
const runtime = this.#rt();
|
|
4263
|
+
const count = runtime.queryTargetCount;
|
|
4154
4264
|
let best = null;
|
|
4155
4265
|
let bestDistance = Number.POSITIVE_INFINITY;
|
|
4156
|
-
for (let index = 0; index <
|
|
4157
|
-
const
|
|
4158
|
-
if (
|
|
4159
|
-
const centre =
|
|
4160
|
-
const extents =
|
|
4266
|
+
for (let index = 0; index < count; index += 1) {
|
|
4267
|
+
const target = runtime.queryTargetAt(index);
|
|
4268
|
+
if (target === void 0 || target.entity === ignored || !this.#accepts(target, options)) continue;
|
|
4269
|
+
const centre = target.currentPosition;
|
|
4270
|
+
const extents = target.halfExtents;
|
|
4161
4271
|
if (Math.abs(point.x - centre.x) > extents.x + BOUNDS_EPSILON || Math.abs(point.y - centre.y) > extents.y + BOUNDS_EPSILON || Math.abs(point.z - centre.z) > extents.z + BOUNDS_EPSILON) continue;
|
|
4162
4272
|
const distance = Math.hypot(point.x - centre.x, point.y - centre.y, point.z - centre.z);
|
|
4163
4273
|
if (distance < bestDistance) {
|
|
4164
4274
|
bestDistance = distance;
|
|
4165
|
-
best =
|
|
4275
|
+
best = target;
|
|
4166
4276
|
}
|
|
4167
4277
|
}
|
|
4168
4278
|
return best;
|
|
4169
4279
|
}
|
|
4170
4280
|
/**
|
|
4171
|
-
* Whether a body passes a query's layer and trigger filters.
|
|
4281
|
+
* Whether a body or capsule passes a query's layer and trigger filters.
|
|
4172
4282
|
*
|
|
4173
|
-
* @param
|
|
4283
|
+
* @param target - The body or capsule.
|
|
4174
4284
|
* @param options - The query options.
|
|
4175
|
-
* @returns `true` when
|
|
4285
|
+
* @returns `true` when it may be reported.
|
|
4176
4286
|
*/
|
|
4177
|
-
#accepts(
|
|
4178
|
-
if ((maskOf(options) & 1 <<
|
|
4179
|
-
return options?.hitTriggers === true || !allTriggers(
|
|
4287
|
+
#accepts(target, options) {
|
|
4288
|
+
if ((maskOf(options) & 1 << target.layer) === 0) return false;
|
|
4289
|
+
return options?.hitTriggers === true || !allTriggers(target.colliders);
|
|
4180
4290
|
}
|
|
4181
4291
|
};
|
|
4182
4292
|
/**
|