@ignifx/physics 0.7.0 → 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 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
- /** The collider on that entity, or `null` when the entity has none registered any more. */
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
- /** The entity the swept shape hit, or `null` when the bounds index cannot identify it. */
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 registered body whose world bounding box intersects the query shape's. It is conservative
1623
- * — a body whose box overlaps but whose shape does not is listed.
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 body creation order. The array is reused between calls.
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[];
@@ -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;;WA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,WAAW;;;;;EAiB7B;;;;;;;;;;;;;;;cCvtBW;;EAEX,SAAS;;;;;;;;;;UCqBM;;WAEN,OAAO;;WAEP,iBAAiB;;;;;;;UAQX;;;;;EAKf;;;;;;;;;;;;;;;qBAgBW;;;;;;;;;;;EAgCX,YAAY,KAAK,KAAK,MAAM,aAAa,UAAU;;;;;;MAa/C,WAAW;;;;;;MASX,QAAQ,OAAO;;;;;;MAUf,eAAe;;;;;;MASf,QAAQ;;;;;;;;;;;EAcZ,QACE,QAAQ,UACR,WAAW,UACX,sBACA,UAAU,eACT;;;;;;;;;;;;;;;;;;;;;EA6DH,UAAU,OAAO,YAAY,MAAM,UAAU,IAAI,UAAU,UAAU,mBAAmB;;;;;;;;;;;;;;;;;;EAsDxF,QAAQ,OAAO,YAAY,UAAU,UAAU,WAAW,MAAM,UAAU,wBAAwB;;;;;;;;;;;;EA8BlG,kBAAkB,OAAO,YAAY,UAAU,UAAU,qBAAqB,UAAU;;;;;;EAuBxF,sBAAsB;;;;;;EA+BtB;;EAKA;;;;;;;;;MA6BI;;;;;;;;;;;;;;UCzVW;;;;;;WAMN,sBAAsB;;WAEtB;;WAEA,aAAa;;;YAIZ;;aAEC,SAAS;;;;;;;;;;;;;;;;qBAqBT,UAAU,UAAU,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;wBChDpC,mBAAmB,SAAS,eAAe"}
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;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;;;;;;;;;;;;;;;EAwDxF,QAAQ,OAAO,YAAY,UAAU,UAAU,WAAW,MAAM,UAAU,wBAAwB;;;;;;;;;;;;EAoClG,kBAAkB,OAAO,YAAY,UAAU,UAAU,qBAAqB,UAAU;;;;;;EAuBxF,sBAAsB;;;;;;EA+BtB;;EAKA;;;;;;;;;MA6BI;;;;;;;;;;;;;;UCnYW;;;;;;WAMN,sBAAsB;;WAEtB;;WAEA,aAAa;;;YAIZ;;aAEC,SAAS;;;;;;;;;;;;;;;;qBAqBT,UAAU,UAAU,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;wBChDpC,mBAAmB,SAAS,eAAe"}
package/dist/index.js CHANGED
@@ -2141,6 +2141,18 @@ function controllerBody(controller) {
2141
2141
  return controller.getBody();
2142
2142
  }
2143
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
+ /**
2144
2156
  * Reads the controller's resolved position.
2145
2157
  *
2146
2158
  * @param controller - The controller.
@@ -2396,6 +2408,7 @@ var PhysicsRuntime = class {
2396
2408
  #byNode = /* @__PURE__ */ new Map();
2397
2409
  #dirty = /* @__PURE__ */ new Set();
2398
2410
  #controllers = [];
2411
+ #controllersByNode = /* @__PURE__ */ new Map();
2399
2412
  #dirtyControllers = /* @__PURE__ */ new Set();
2400
2413
  #collideMasks = new Int32Array(LAYER_COUNT).fill(-1);
2401
2414
  #triggerSlots = [];
@@ -2617,6 +2630,35 @@ var PhysicsRuntime = class {
2617
2630
  recordOfNode(node) {
2618
2631
  return node === null ? null : this.#byNode.get(node) ?? null;
2619
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
+ }
2620
2662
  /** Counts one query for the diagnostics group. */
2621
2663
  countQuery() {
2622
2664
  this.#queries += 1;
@@ -2741,7 +2783,10 @@ var PhysicsRuntime = class {
2741
2783
  */
2742
2784
  resizeController(component, preserveFeet) {
2743
2785
  const record = this.#controllerOf(component);
2744
- if (record !== null) resizeController(record.controller, component.height, component.radius, preserveFeet);
2786
+ if (record !== null) {
2787
+ resizeController(record.controller, component.height, component.radius, preserveFeet);
2788
+ capsuleHalfExtents(component.height, component.radius, record.halfExtents);
2789
+ }
2745
2790
  }
2746
2791
  /**
2747
2792
  * Teleports a controller and resets its interpolation history.
@@ -2775,6 +2820,7 @@ var PhysicsRuntime = class {
2775
2820
  record.disconnect();
2776
2821
  disposeController(record.controller);
2777
2822
  this.#controllers.splice(index, 1);
2823
+ this.#controllersByNode.delete(record.node);
2778
2824
  return;
2779
2825
  }
2780
2826
  }
@@ -2794,6 +2840,7 @@ var PhysicsRuntime = class {
2794
2840
  }
2795
2841
  }
2796
2842
  this.#controllers.length = 0;
2843
+ this.#controllersByNode.clear();
2797
2844
  for (let index = this.#records.length - 1; index >= 0; index -= 1) {
2798
2845
  const record = this.#records[index];
2799
2846
  if (record !== void 0) this.#teardown(record);
@@ -3127,6 +3174,10 @@ var PhysicsRuntime = class {
3127
3174
  if (record === void 0 || record.entity.layer === record.layer) continue;
3128
3175
  this.markDirty(record.entity);
3129
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
+ }
3130
3181
  }
3131
3182
  /**
3132
3183
  * Snapshots every body's authoritative pose and reports implicit-static bodies that moved.
@@ -3213,6 +3264,11 @@ var PhysicsRuntime = class {
3213
3264
  const record = {
3214
3265
  component,
3215
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()),
3216
3272
  previousPosition: centre.clone(),
3217
3273
  currentPosition: centre.clone(),
3218
3274
  interpolate: this.#settings.interpolation && component.interpolation === "interpolate",
@@ -3222,6 +3278,7 @@ var PhysicsRuntime = class {
3222
3278
  this.#reportPush(record, push);
3223
3279
  });
3224
3280
  this.#controllers.push(record);
3281
+ this.#controllersByNode.set(record.node, record);
3225
3282
  }
3226
3283
  /**
3227
3284
  * Turns one Lite push event into a `CharacterCollision`.
@@ -3430,6 +3487,21 @@ var PhysicsRuntime = class {
3430
3487
  };
3431
3488
  /** Lite's own `characterStrength` default, which `pushStrength: 1` reproduces (`index.d.ts` 8320). */
3432
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
+ }
3433
3505
  /**
3434
3506
  * The colliders that make up an entity's body: every enabled `Collider` on the entity itself.
3435
3507
  *
@@ -3828,6 +3900,8 @@ function bodyNodeOf(body) {
3828
3900
  */
3829
3901
  /** How far a ray travels when the caller names no distance, in metres. */
3830
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;
3831
3905
  /** How much slack the bounds index allows when it resolves a sweep contact to an entity. */
3832
3906
  const BOUNDS_EPSILON = .001;
3833
3907
  /** Every bit set: the mask a query uses when the caller names no layers. */
@@ -3861,6 +3935,7 @@ var PhysicsService = class {
3861
3935
  };
3862
3936
  #point = new Vec3();
3863
3937
  #normal = new Vec3();
3938
+ #rayFrom = new Vec3();
3864
3939
  #overlapExtents = new Vec3();
3865
3940
  #overlapResults = [];
3866
3941
  #debugViewer;
@@ -3920,6 +3995,11 @@ var PhysicsService = class {
3920
3995
  /**
3921
3996
  * Casts a ray and returns the first entity it hits (`09-physics.md` §5).
3922
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
+ *
3923
4003
  * @param origin - The world-space origin.
3924
4004
  * @param direction - The direction; it is normalised for you.
3925
4005
  * @param maxDistance - How far to travel; defaults to 10 km.
@@ -3929,7 +4009,8 @@ var PhysicsService = class {
3929
4009
  */
3930
4010
  raycast(origin, direction, maxDistance = DEFAULT_RAY_DISTANCE, options) {
3931
4011
  this.#requireStep("raycast");
3932
- this.#rt().countQuery();
4012
+ const runtime = this.#rt();
4013
+ runtime.countQuery();
3933
4014
  const length = Math.hypot(direction.x, direction.y, direction.z);
3934
4015
  if (length === 0) return null;
3935
4016
  const scale = maxDistance / length;
@@ -3938,25 +4019,36 @@ var PhysicsService = class {
3938
4019
  y: origin.y + direction.y * scale,
3939
4020
  z: origin.z + direction.z * scale
3940
4021
  };
3941
- castRay(this.#rt().world, origin, to, ALL_LAYERS, maskOf(options), options?.hitTriggers === true, this.#point, this.#normal, this.#rayResult);
3942
- if (!this.#rayResult.hit) return null;
3943
- const record = this.#rt().recordOfNode(this.#rayResult.node);
3944
- if (record === null) return null;
3945
- return {
3946
- entity: record.entity,
3947
- collider: record.colliders[0] ?? null,
3948
- point: this.#point.clone(),
3949
- normal: this.#normal.clone(),
3950
- distance: this.#rayResult.distance,
3951
- triangleIndex: this.#rayResult.triangleIndex
3952
- };
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;
3953
4043
  }
3954
4044
  /**
3955
4045
  * Sweeps a shape and returns the first contact (`09-physics.md` §5).
3956
4046
  *
3957
4047
  * @remarks
3958
4048
  * Lite's `shapeCast` reports no body (`index.d.ts` 11497), so `entity` is resolved against the
3959
- * 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`.
3960
4052
  *
3961
4053
  * The sweep itself cannot be filtered by layer — Lite's `ShapeCastQuery` carries no collision
3962
4054
  * masks — so a body outside `layerMask` still stops the sweep; it is merely reported with
@@ -3983,11 +4075,11 @@ var PhysicsService = class {
3983
4075
  destroyShape(this.#rt().world, handle);
3984
4076
  }
3985
4077
  if (!this.#sweepResult.hit) return null;
3986
- const record = this.#recordAt(this.#point, options, ignored);
4078
+ const target = this.#targetAt(this.#point, options, ignored);
3987
4079
  const distance = Math.hypot(to.x - from.x, to.y - from.y, to.z - from.z) * this.#sweepResult.fraction;
3988
4080
  return {
3989
- entity: record?.entity ?? null,
3990
- collider: record?.colliders[0] ?? null,
4081
+ entity: target?.entity ?? null,
4082
+ collider: target?.colliders[0] ?? null,
3991
4083
  point: this.#point.clone(),
3992
4084
  normal: this.#normal.clone(),
3993
4085
  fraction: this.#sweepResult.fraction,
@@ -4000,29 +4092,33 @@ var PhysicsService = class {
4000
4092
  * @remarks
4001
4093
  * Lite's `shapeProximity` reports one hit and no identity (`index.d.ts` 11540,
4002
4094
  * `lib/physics/havok-queries.js:7`), so this is answered from the extension's own bounds index:
4003
- * every registered body whose world bounding box intersects the query shape's. It is conservative
4004
- * — a body whose box overlaps but whose shape does not is listed.
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.
4005
4098
  *
4006
4099
  * @param shape - The query shape.
4007
4100
  * @param position - Its world position.
4008
4101
  * @param rotation - Its world rotation; accepted for forward compatibility and currently unused,
4009
4102
  * because the bounds test is axis-aligned.
4010
4103
  * @param options - Layer mask and trigger behaviour.
4011
- * @returns The overlapping entities, in body creation order. The array is reused between calls.
4104
+ * @returns The overlapping entities, each once: bodies in creation order, then characters in
4105
+ * creation order. The array is reused between calls.
4012
4106
  * @throws IgnifxError with code `IGX-0902` in development when no fixed step has run yet.
4013
4107
  */
4014
4108
  overlap(shape, position, rotation, options) {
4015
4109
  this.#requireStep("overlap");
4016
- this.#rt().countQuery();
4110
+ const runtime = this.#rt();
4111
+ runtime.countQuery();
4017
4112
  queryHalfExtents(shape, this.#overlapExtents);
4018
- this.#overlapResults.length = 0;
4019
- const records = this.#rt().records;
4020
- for (let index = 0; index < records.length; index += 1) {
4021
- const record = records[index];
4022
- if (record === void 0 || !this.#accepts(record, options)) continue;
4023
- if (boxesOverlap(position, this.#overlapExtents, record.currentPosition, record.halfExtents)) this.#overlapResults.push(record.entity);
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);
4024
4120
  }
4025
- return this.#overlapResults;
4121
+ return results;
4026
4122
  }
4027
4123
  /**
4028
4124
  * How far the nearest body is from a positioned shape, which is the one thing Lite's
@@ -4160,36 +4256,37 @@ var PhysicsService = class {
4160
4256
  * @param options - Layer mask and trigger behaviour.
4161
4257
  * @param ignored - The entity the sweep was told to pass through, which can therefore not be the
4162
4258
  * one it hit.
4163
- * @returns The record, or `null`.
4259
+ * @returns The body or capsule, or `null`.
4164
4260
  */
4165
- #recordAt(point, options, ignored = null) {
4166
- const records = this.#rt().records;
4261
+ #targetAt(point, options, ignored = null) {
4262
+ const runtime = this.#rt();
4263
+ const count = runtime.queryTargetCount;
4167
4264
  let best = null;
4168
4265
  let bestDistance = Number.POSITIVE_INFINITY;
4169
- for (let index = 0; index < records.length; index += 1) {
4170
- const record = records[index];
4171
- if (record === void 0 || record.entity === ignored || !this.#accepts(record, options)) continue;
4172
- const centre = record.currentPosition;
4173
- const extents = record.halfExtents;
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;
4174
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;
4175
4272
  const distance = Math.hypot(point.x - centre.x, point.y - centre.y, point.z - centre.z);
4176
4273
  if (distance < bestDistance) {
4177
4274
  bestDistance = distance;
4178
- best = record;
4275
+ best = target;
4179
4276
  }
4180
4277
  }
4181
4278
  return best;
4182
4279
  }
4183
4280
  /**
4184
- * 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.
4185
4282
  *
4186
- * @param record - The body.
4283
+ * @param target - The body or capsule.
4187
4284
  * @param options - The query options.
4188
- * @returns `true` when the body may be reported.
4285
+ * @returns `true` when it may be reported.
4189
4286
  */
4190
- #accepts(record, options) {
4191
- if ((maskOf(options) & 1 << record.layer) === 0) return false;
4192
- return options?.hitTriggers === true || !allTriggers(record.colliders);
4287
+ #accepts(target, options) {
4288
+ if ((maskOf(options) & 1 << target.layer) === 0) return false;
4289
+ return options?.hitTriggers === true || !allTriggers(target.colliders);
4193
4290
  }
4194
4291
  };
4195
4292
  /**