@ignifx/physics 0.8.0 → 0.10.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 +18 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -160
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/skills/physics/SKILL.md +10 -9
package/dist/index.d.ts
CHANGED
|
@@ -404,17 +404,25 @@ interface TriggerEvent {
|
|
|
404
404
|
readonly self: Entity;
|
|
405
405
|
}
|
|
406
406
|
/**
|
|
407
|
-
* What a script's `onCollisionEnter`/`onCollisionStay`/`onCollisionExit` is handed.
|
|
407
|
+
* What a script's `onCollisionEnter`/`onCollisionStay`/`onCollisionExit` is handed. Both entities in
|
|
408
|
+
* a contact receive it, each with the other one as `other`.
|
|
408
409
|
*
|
|
409
|
-
* @
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```ts
|
|
412
|
+
* class Crate extends Script implements ScriptCallbacks {
|
|
413
|
+
* static typeId = "mygame/Crate";
|
|
414
|
+
* onCollisionEnter(collision: Collision): void {
|
|
415
|
+
* if (collision.other?.tags.has("projectile") === true) {
|
|
416
|
+
* this.entity.destroy();
|
|
417
|
+
* }
|
|
418
|
+
* }
|
|
419
|
+
* }
|
|
420
|
+
* ```
|
|
413
421
|
*
|
|
414
422
|
* @public
|
|
415
423
|
*/
|
|
416
424
|
interface Collision {
|
|
417
|
-
/** The entity that was hit, or `null` when
|
|
425
|
+
/** The entity that was hit, or `null` when its body is not an entity's (a character controller's capsule). */
|
|
418
426
|
readonly other: Entity | null;
|
|
419
427
|
/** The other entity's first collider, or `null`. */
|
|
420
428
|
readonly otherCollider: Collider | null;
|
|
@@ -422,7 +430,7 @@ interface Collision {
|
|
|
422
430
|
readonly self: Entity;
|
|
423
431
|
/** The contacts of this event. Pooled; valid only during the callback. */
|
|
424
432
|
readonly contacts: readonly ContactPoint[];
|
|
425
|
-
/**
|
|
433
|
+
/** This body's velocity minus the other's at the contact, or `null` when `other` is `null`. */
|
|
426
434
|
readonly relativeVelocity: Vec3Like | null;
|
|
427
435
|
}
|
|
428
436
|
/**
|
|
@@ -1038,8 +1046,6 @@ export declare const PhysicsErrorCode: {
|
|
|
1038
1046
|
readonly colliderGeometryUnavailable: "IGX-0906";
|
|
1039
1047
|
/** A physics body was built for an entity that has a parent, whose node pose is not world space. */
|
|
1040
1048
|
readonly bodyOnChildEntity: "IGX-0907";
|
|
1041
|
-
/** The ADR-0013 collision drain refused to bind because Babylon Lite's internals moved. */
|
|
1042
|
-
readonly internalDrainUnavailable: "IGX-0908";
|
|
1043
1049
|
};
|
|
1044
1050
|
/**
|
|
1045
1051
|
* The union of the codes the `PhysicsErrorCode` table declares.
|
|
@@ -1267,18 +1273,6 @@ interface QueryTarget {
|
|
|
1267
1273
|
* Everything here is `@internal`; the public surface is `PhysicsService`, `Rigidbody`, the
|
|
1268
1274
|
* colliders, and `CharacterController`.
|
|
1269
1275
|
*/
|
|
1270
|
-
/**
|
|
1271
|
-
* How collision events learn which bodies took part (`09-physics.md` §4, ADR-0013).
|
|
1272
|
-
*
|
|
1273
|
-
* @public
|
|
1274
|
-
*/
|
|
1275
|
-
export declare const COLLISION_IDENTITY_MODES: readonly ["upstream", "internal"];
|
|
1276
|
-
/**
|
|
1277
|
-
* The union of {@link COLLISION_IDENTITY_MODES}.
|
|
1278
|
-
*
|
|
1279
|
-
* @public
|
|
1280
|
-
*/
|
|
1281
|
-
type CollisionIdentityMode = (typeof COLLISION_IDENTITY_MODES)[number];
|
|
1282
1276
|
/** What the extension hands the runtime. */
|
|
1283
1277
|
interface PhysicsRuntimeOptions {
|
|
1284
1278
|
/** The extension registration surface; the physics kernel hooks live on it. */
|
|
@@ -1289,8 +1283,6 @@ interface PhysicsRuntimeOptions {
|
|
|
1289
1283
|
readonly simulation: SimulationHandles;
|
|
1290
1284
|
/** The Havok world. */
|
|
1291
1285
|
readonly world: LitePhysicsWorld;
|
|
1292
|
-
/** Which collision-identity path to use. */
|
|
1293
|
-
readonly collisionIdentities: CollisionIdentityMode;
|
|
1294
1286
|
/** The `physics` diagnostics group. */
|
|
1295
1287
|
readonly counters: DiagnosticsGroup;
|
|
1296
1288
|
}
|
|
@@ -1316,9 +1308,8 @@ declare class PhysicsRuntime {
|
|
|
1316
1308
|
/**
|
|
1317
1309
|
* Builds the runtime, applies the world settings, and registers the event drains.
|
|
1318
1310
|
*
|
|
1319
|
-
* @param options - The context, settings, scene, world,
|
|
1320
|
-
* @throws IgnifxError with code `IGX-0905` when the collision matrix names an unknown layer
|
|
1321
|
-
* `IGX-0908` when the internal drain does not recognise this Babylon Lite build.
|
|
1311
|
+
* @param options - The context, settings, scene, world, and counters.
|
|
1312
|
+
* @throws IgnifxError with code `IGX-0905` when the collision matrix names an unknown layer.
|
|
1322
1313
|
*/
|
|
1323
1314
|
constructor(options: PhysicsRuntimeOptions);
|
|
1324
1315
|
/**
|
|
@@ -1735,12 +1726,6 @@ export declare class PhysicsService {
|
|
|
1735
1726
|
* @public
|
|
1736
1727
|
*/
|
|
1737
1728
|
interface PhysicsOptions {
|
|
1738
|
-
/**
|
|
1739
|
-
* How collision callbacks learn which bodies took part (ADR-0013). `"upstream"` is the default and
|
|
1740
|
-
* delivers contacts with `other === null`, because `@babylonjs/lite@1.27.0` reports no identities;
|
|
1741
|
-
* `"internal"` opts into the waived adapter-internal drain that recovers them.
|
|
1742
|
-
*/
|
|
1743
|
-
readonly collisionIdentities?: CollisionIdentityMode;
|
|
1744
1729
|
/** An already-instantiated Havok module, which skips loading entirely. */
|
|
1745
1730
|
readonly havok?: unknown;
|
|
1746
1731
|
/** The `HavokPhysics.wasm` bytes, for a host that reads them itself. */
|
|
@@ -1793,5 +1778,5 @@ export declare const physics: (options?: PhysicsOptions) => Extension;
|
|
|
1793
1778
|
*/
|
|
1794
1779
|
export declare function describeSchemas(): Readonly<Record<string, SchemaDescription>>;
|
|
1795
1780
|
//#endregion
|
|
1796
|
-
export type { BodyType, CapsuleDirection, CharacterCollision, Collision, CollisionEventMode,
|
|
1781
|
+
export type { BodyType, CapsuleDirection, CharacterCollision, Collision, CollisionEventMode, ContactPoint, FreezeRotation, InterpolationMode, KinematicSyncMode, PhysicsDebugViewer, PhysicsErrorOptions, PhysicsLiteHandles, PhysicsMaterialValues, PhysicsOptions, PhysicsSettings, QueryOptions, QueryShape, RaycastHit, RigidbodyLiteHandles, ShapeCastHit, ShapeCastOptions, SupportStateName, TriggerEvent, VelocityLimitSettings };
|
|
1797
1782
|
//# sourceMappingURL=index.d.ts.map
|
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;;;;;;;;;;;EAcA;;;;;;;EAUA,gBAAgB,UAAU,wBAAwB;;;;;;;;;;;WAczC,YAAY,OAAO,kBAAkB,OAAO,UAAU,MAAM,gBAAgB;;;;;;;;;;WAW5E,iBAAiB,OAAO,UAAU,KAAK;;;;;;;;;;;;;;;;;UC3GjC;;WAEN,OAAO;;WAEP,QAAQ;;WAER;;;;;;;;;;;;;;;;;;;UAoBM;;WAEN,OAAO;;WAEP,eAAe;;WAEf,MAAM
|
|
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;;;;;;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;;;;;;EA+BtB;;EAKA;;;;;;;;;MA6BI;;;;;;;;;;;;;;UCpYW;;WAEN;;WAEA,aAAa;;;YAIZ;;aAEC,SAAS;;;;;;;;;;;;;;;;qBAqBT,UAAU,UAAU,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;wBCzCpC,mBAAmB,SAAS,eAAe"}
|
package/dist/index.js
CHANGED
|
@@ -462,9 +462,7 @@ const PhysicsErrorCode = {
|
|
|
462
462
|
/** A `MeshCollider` has no geometry to build a shape from. */
|
|
463
463
|
colliderGeometryUnavailable: "IGX-0906",
|
|
464
464
|
/** A physics body was built for an entity that has a parent, whose node pose is not world space. */
|
|
465
|
-
bodyOnChildEntity: "IGX-0907"
|
|
466
|
-
/** The ADR-0013 collision drain refused to bind because Babylon Lite's internals moved. */
|
|
467
|
-
internalDrainUnavailable: "IGX-0908"
|
|
465
|
+
bodyOnChildEntity: "IGX-0907"
|
|
468
466
|
};
|
|
469
467
|
/**
|
|
470
468
|
* The one-line message template of every code, as `ExtensionContext.registerErrorCodes` wants it.
|
|
@@ -479,8 +477,7 @@ const PHYSICS_ERROR_MESSAGES = Object.freeze({
|
|
|
479
477
|
"IGX-0904": "{file} is not an ignifx.physicsmaterial document this build can read.",
|
|
480
478
|
"IGX-0905": "physics.collisionMatrix names the layer {layer}, which the project does not declare.",
|
|
481
479
|
"IGX-0906": "{entity} has a MeshCollider with no geometry to build a shape from.",
|
|
482
|
-
"IGX-0907": "{entity} carries a physics body but is not a root entity; Havok writes its local pose."
|
|
483
|
-
"IGX-0908": "The adapter-internal collision drain does not recognise Babylon Lite {version}."
|
|
480
|
+
"IGX-0907": "{entity} carries a physics body but is not a root entity; Havok writes its local pose."
|
|
484
481
|
});
|
|
485
482
|
/**
|
|
486
483
|
* Builds an `IgnifxError` carrying one of this package's codes.
|
|
@@ -1354,8 +1351,14 @@ function onTriggerEvents(world, sink) {
|
|
|
1354
1351
|
});
|
|
1355
1352
|
}
|
|
1356
1353
|
/**
|
|
1357
|
-
* Registers the
|
|
1358
|
-
*
|
|
1354
|
+
* Registers the collision drain (`onPhysicsCollision`, `index.d.ts` 9315). Each
|
|
1355
|
+
* `PhysicsCollisionInfo` (10030) names both bodies as `collider` and `collidedAgainst`, and they are
|
|
1356
|
+
* resolved to nodes the same way the trigger drain resolves `bodyA`/`bodyB`. Lite skips an event
|
|
1357
|
+
* whose bodies it no longer tracks (`lib/physics/havok-collision.js:47-52`), so both are present.
|
|
1358
|
+
*
|
|
1359
|
+
* @remarks
|
|
1360
|
+
* `colliderIndex` and `collidedAgainstIndex` are thin-instance indices. ignifx never creates
|
|
1361
|
+
* thin-instance bodies, so they are always `0` and are ignored.
|
|
1359
1362
|
*
|
|
1360
1363
|
* @param world - The world handle.
|
|
1361
1364
|
* @param sink - Called once per collision event.
|
|
@@ -1369,8 +1372,8 @@ function onCollisionEvents(world, sink) {
|
|
|
1369
1372
|
point: info.point,
|
|
1370
1373
|
normal: info.normal,
|
|
1371
1374
|
impulse: info.impulse,
|
|
1372
|
-
nodeA:
|
|
1373
|
-
nodeB:
|
|
1375
|
+
nodeA: info.collider.node,
|
|
1376
|
+
nodeB: info.collidedAgainst.node
|
|
1374
1377
|
});
|
|
1375
1378
|
});
|
|
1376
1379
|
}
|
|
@@ -2245,127 +2248,8 @@ function toSupportState(value) {
|
|
|
2245
2248
|
return value === SupportState.sliding ? SupportState.sliding : SupportState.unsupported;
|
|
2246
2249
|
}
|
|
2247
2250
|
//#endregion
|
|
2248
|
-
//#region src/lite/internal/collision-drain.ts
|
|
2249
|
-
/** Lite's `offA`: where the first contact's slots begin. */
|
|
2250
|
-
const OFFSET_A = 2;
|
|
2251
|
-
/** Lite's `offB`: where the second contact's slots begin. */
|
|
2252
|
-
const OFFSET_B = 18;
|
|
2253
|
-
/** The Babylon Lite version this drain was written and tested against. */
|
|
2254
|
-
const PINNED_LITE_VERSION = "1.27.0";
|
|
2255
|
-
/**
|
|
2256
|
-
* Reports whether a world exposes the internals this drain reads.
|
|
2257
|
-
*
|
|
2258
|
-
* @param world - The Havok world handle.
|
|
2259
|
-
* @returns `true` when every field the drain needs is present and of the expected kind.
|
|
2260
|
-
*
|
|
2261
|
-
* @internal
|
|
2262
|
-
*/
|
|
2263
|
-
function probeCollisionLayout(world) {
|
|
2264
|
-
const internals = asWorldInternals(world);
|
|
2265
|
-
const havok = internals._hknp;
|
|
2266
|
-
if (havok === void 0 || internals._hkWorld === void 0 || !Array.isArray(internals._bodies)) return false;
|
|
2267
|
-
if (typeof havok.HP_World_GetCollisionEvents !== "function") return false;
|
|
2268
|
-
if (typeof havok.HP_World_GetNextCollisionEvent !== "function") return false;
|
|
2269
|
-
const started = havok.EventType["COLLISION_STARTED"];
|
|
2270
|
-
const continued = havok.EventType["COLLISION_CONTINUED"];
|
|
2271
|
-
return typeof started?.value === "number" && typeof continued?.value === "number";
|
|
2272
|
-
}
|
|
2273
|
-
/**
|
|
2274
|
-
* Registers the internal drain on a world's post-step hook.
|
|
2275
|
-
*
|
|
2276
|
-
* @param world - The Havok world handle.
|
|
2277
|
-
* @param sink - Called once per collision event, with both nodes resolved.
|
|
2278
|
-
* @throws IgnifxError with code `IGX-0908` when {@link probeCollisionLayout} says the internals
|
|
2279
|
-
* moved, which is what makes a Babylon Lite upgrade fail loudly rather than silently.
|
|
2280
|
-
*
|
|
2281
|
-
* @internal
|
|
2282
|
-
*/
|
|
2283
|
-
function drainCollisionsWithBodies(world, sink) {
|
|
2284
|
-
if (!probeCollisionLayout(world)) throw physicsError(PhysicsErrorCode.internalDrainUnavailable, "physics({ collisionIdentities: \"internal\" }) needs Babylon Lite's Havok internals, which this version does not expose.", {
|
|
2285
|
-
context: { version: PINNED_LITE_VERSION },
|
|
2286
|
-
hint: "Pin @babylonjs/lite to 1.27.0, or use the default collisionIdentities: \"upstream\"."
|
|
2287
|
-
});
|
|
2288
|
-
const internals = asWorldInternals(world);
|
|
2289
|
-
const havok = internals._hknp;
|
|
2290
|
-
const native = internals._hkWorld;
|
|
2291
|
-
if (havok === void 0 || native === void 0) return;
|
|
2292
|
-
const startedValue = havok.EventType["COLLISION_STARTED"]?.value ?? -1;
|
|
2293
|
-
const continuedValue = havok.EventType["COLLISION_CONTINUED"]?.value ?? -1;
|
|
2294
|
-
afterStep(world, () => {
|
|
2295
|
-
let address = havok.HP_World_GetCollisionEvents(native)[1];
|
|
2296
|
-
while (address !== 0) {
|
|
2297
|
-
const ints = new Int32Array(havok.HEAPU8.buffer, address);
|
|
2298
|
-
const floats = new Float32Array(havok.HEAPU8.buffer, address);
|
|
2299
|
-
const type = ints[0] ?? -1;
|
|
2300
|
-
sink({
|
|
2301
|
-
phase: type === startedValue ? 0 : type === continuedValue ? 1 : 2,
|
|
2302
|
-
point: {
|
|
2303
|
-
x: floats[10] ?? 0,
|
|
2304
|
-
y: floats[11] ?? 0,
|
|
2305
|
-
z: floats[12] ?? 0
|
|
2306
|
-
},
|
|
2307
|
-
normal: {
|
|
2308
|
-
x: floats[13] ?? 0,
|
|
2309
|
-
y: floats[14] ?? 0,
|
|
2310
|
-
z: floats[15] ?? 0
|
|
2311
|
-
},
|
|
2312
|
-
impulse: floats[34] ?? 0,
|
|
2313
|
-
nodeA: nodeById(internals, ints[OFFSET_A] ?? 0),
|
|
2314
|
-
nodeB: nodeById(internals, ints[OFFSET_B] ?? 0)
|
|
2315
|
-
});
|
|
2316
|
-
address = havok.HP_World_GetNextCollisionEvent(native, address);
|
|
2317
|
-
}
|
|
2318
|
-
});
|
|
2319
|
-
}
|
|
2320
|
-
/**
|
|
2321
|
-
* Resolves a native body id to the node Lite bound it to, the same linear scan Lite's own
|
|
2322
|
-
* `findBodyById` performs (`lib/physics/havok-trigger.js`, `havok-queries.js`).
|
|
2323
|
-
*
|
|
2324
|
-
* @param internals - The world internals.
|
|
2325
|
-
* @param id - The native body id from the event buffer.
|
|
2326
|
-
* @returns The node, or `null` when the body is no longer tracked.
|
|
2327
|
-
*/
|
|
2328
|
-
function nodeById(internals, id) {
|
|
2329
|
-
const bodies = internals._bodies ?? [];
|
|
2330
|
-
for (let index = 0; index < bodies.length; index += 1) {
|
|
2331
|
-
const body = bodies[index];
|
|
2332
|
-
const native = body?._hkBody?.[0];
|
|
2333
|
-
if (native === id) return body?.node ?? null;
|
|
2334
|
-
if (typeof native === "bigint" && native === BigInt(id)) return body?.node ?? null;
|
|
2335
|
-
}
|
|
2336
|
-
return null;
|
|
2337
|
-
}
|
|
2338
|
-
/**
|
|
2339
|
-
* Views a Lite world as the internal record this drain reads.
|
|
2340
|
-
*
|
|
2341
|
-
* @remarks
|
|
2342
|
-
* The waived boundary crossing of ADR-0013, in one expression. It needs no assertion: Lite declares
|
|
2343
|
-
* `PhysicsWorld` as an empty interface and every field below is optional, so the view is structural
|
|
2344
|
-
* — and {@link probeCollisionLayout} is what makes reading it safe.
|
|
2345
|
-
*
|
|
2346
|
-
* @param world - The opaque handle.
|
|
2347
|
-
* @returns The same object, typed.
|
|
2348
|
-
*/
|
|
2349
|
-
function asWorldInternals(world) {
|
|
2350
|
-
return world;
|
|
2351
|
-
}
|
|
2352
|
-
//#endregion
|
|
2353
2251
|
//#region src/runtime/runtime.ts
|
|
2354
2252
|
/**
|
|
2355
|
-
* The per-app physics runtime: the Havok world, the bodies, the character controllers, the event
|
|
2356
|
-
* drains, and the three things the systems ask it to do each frame — restore, step, interpolate
|
|
2357
|
-
* (`docs/architecture/09-physics.md` §1).
|
|
2358
|
-
*
|
|
2359
|
-
* Everything here is `@internal`; the public surface is `PhysicsService`, `Rigidbody`, the
|
|
2360
|
-
* colliders, and `CharacterController`.
|
|
2361
|
-
*/
|
|
2362
|
-
/**
|
|
2363
|
-
* How collision events learn which bodies took part (`09-physics.md` §4, ADR-0013).
|
|
2364
|
-
*
|
|
2365
|
-
* @public
|
|
2366
|
-
*/
|
|
2367
|
-
const COLLISION_IDENTITY_MODES = ["upstream", "internal"];
|
|
2368
|
-
/**
|
|
2369
2253
|
* The counters `09-physics.md` §9 and the plan's diagnostics deliverable name.
|
|
2370
2254
|
*
|
|
2371
2255
|
* @public
|
|
@@ -2401,7 +2285,6 @@ var PhysicsRuntime = class {
|
|
|
2401
2285
|
#settings;
|
|
2402
2286
|
#simulation;
|
|
2403
2287
|
#world;
|
|
2404
|
-
#identities;
|
|
2405
2288
|
#counters;
|
|
2406
2289
|
#records = [];
|
|
2407
2290
|
#byEntity = /* @__PURE__ */ new Map();
|
|
@@ -2440,16 +2323,14 @@ var PhysicsRuntime = class {
|
|
|
2440
2323
|
/**
|
|
2441
2324
|
* Builds the runtime, applies the world settings, and registers the event drains.
|
|
2442
2325
|
*
|
|
2443
|
-
* @param options - The context, settings, scene, world,
|
|
2444
|
-
* @throws IgnifxError with code `IGX-0905` when the collision matrix names an unknown layer
|
|
2445
|
-
* `IGX-0908` when the internal drain does not recognise this Babylon Lite build.
|
|
2326
|
+
* @param options - The context, settings, scene, world, and counters.
|
|
2327
|
+
* @throws IgnifxError with code `IGX-0905` when the collision matrix names an unknown layer.
|
|
2446
2328
|
*/
|
|
2447
2329
|
constructor(options) {
|
|
2448
2330
|
this.#ctx = options.ctx;
|
|
2449
2331
|
this.#settings = options.settings;
|
|
2450
2332
|
this.#simulation = options.simulation;
|
|
2451
2333
|
this.#world = options.world;
|
|
2452
|
-
this.#identities = options.collisionIdentities;
|
|
2453
2334
|
this.#counters = options.counters;
|
|
2454
2335
|
this.#contacts.push(this.#contactPoint);
|
|
2455
2336
|
setGravity(this.#world, this.#settings.gravity);
|
|
@@ -2462,10 +2343,7 @@ var PhysicsRuntime = class {
|
|
|
2462
2343
|
onTriggerEvents(this.#world, (record) => {
|
|
2463
2344
|
this.#bufferTrigger(record);
|
|
2464
2345
|
});
|
|
2465
|
-
|
|
2466
|
-
this.#bufferContact(record);
|
|
2467
|
-
});
|
|
2468
|
-
else onCollisionEvents(this.#world, (record) => {
|
|
2346
|
+
onCollisionEvents(this.#world, (record) => {
|
|
2469
2347
|
this.#bufferContact(record);
|
|
2470
2348
|
});
|
|
2471
2349
|
afterStep(this.#world, () => {});
|
|
@@ -3321,7 +3199,7 @@ var PhysicsRuntime = class {
|
|
|
3321
3199
|
/**
|
|
3322
3200
|
* Buffers a collision event.
|
|
3323
3201
|
*
|
|
3324
|
-
* @param event - What the
|
|
3202
|
+
* @param event - What the collision drain reported.
|
|
3325
3203
|
*/
|
|
3326
3204
|
#bufferContact(event) {
|
|
3327
3205
|
const slot = this.#contactSlot(this.#contactCount);
|
|
@@ -3409,28 +3287,11 @@ var PhysicsRuntime = class {
|
|
|
3409
3287
|
const slot = this.#contactSlots[index];
|
|
3410
3288
|
if (slot === void 0) continue;
|
|
3411
3289
|
const kind = contactCallback(slot.phase);
|
|
3412
|
-
if (slot.first === null && slot.second === null) {
|
|
3413
|
-
this.#broadcastContact(slot, kind);
|
|
3414
|
-
continue;
|
|
3415
|
-
}
|
|
3416
3290
|
this.#deliverContact(slot, slot.first, slot.second, kind);
|
|
3417
3291
|
this.#deliverContact(slot, slot.second, slot.first, kind);
|
|
3418
3292
|
}
|
|
3419
3293
|
}
|
|
3420
3294
|
/**
|
|
3421
|
-
* Delivers one collision to every entity that opted into collision events — the only thing that
|
|
3422
|
-
* can be done in `"upstream"` mode, where Lite reports no identities at all (`09-physics.md` §4).
|
|
3423
|
-
*
|
|
3424
|
-
* @param slot - The buffered contact.
|
|
3425
|
-
* @param kind - Which callback to deliver.
|
|
3426
|
-
*/
|
|
3427
|
-
#broadcastContact(slot, kind) {
|
|
3428
|
-
for (let index = 0; index < this.#records.length; index += 1) {
|
|
3429
|
-
const record = this.#records[index];
|
|
3430
|
-
if (record !== void 0 && record.collisionEvents) this.#deliverContact(slot, record, null, kind);
|
|
3431
|
-
}
|
|
3432
|
-
}
|
|
3433
|
-
/**
|
|
3434
3295
|
* Delivers one collision to one entity.
|
|
3435
3296
|
*
|
|
3436
3297
|
* @param slot - The buffered contact.
|
|
@@ -4489,15 +4350,18 @@ const physics = defineExtension((options = {}) => {
|
|
|
4489
4350
|
ctx.defineAppProperty("physics", () => service);
|
|
4490
4351
|
ctx.registerSystem(new PhysicsRestoreSystem(host), {
|
|
4491
4352
|
phase: Phase.FixedUpdate,
|
|
4492
|
-
order: PHYSICS_RESTORE_ORDER
|
|
4353
|
+
order: PHYSICS_RESTORE_ORDER,
|
|
4354
|
+
editMode: "skip"
|
|
4493
4355
|
});
|
|
4494
4356
|
ctx.registerSystem(new PhysicsStepSystem(host), {
|
|
4495
4357
|
phase: Phase.FixedUpdate,
|
|
4496
|
-
order: 100
|
|
4358
|
+
order: 100,
|
|
4359
|
+
editMode: "skip"
|
|
4497
4360
|
});
|
|
4498
4361
|
ctx.registerSystem(new PhysicsInterpolationSystem(host), {
|
|
4499
4362
|
phase: Phase.Update,
|
|
4500
|
-
order: PHYSICS_INTERPOLATE_ORDER
|
|
4363
|
+
order: PHYSICS_INTERPOLATE_ORDER,
|
|
4364
|
+
editMode: "skip"
|
|
4501
4365
|
});
|
|
4502
4366
|
},
|
|
4503
4367
|
async onStart(app) {
|
|
@@ -4523,7 +4387,6 @@ const physics = defineExtension((options = {}) => {
|
|
|
4523
4387
|
settings,
|
|
4524
4388
|
simulation,
|
|
4525
4389
|
world,
|
|
4526
|
-
collisionIdentities: options.collisionIdentities ?? "upstream",
|
|
4527
4390
|
counters
|
|
4528
4391
|
});
|
|
4529
4392
|
ctx.setSimulationScene(simulation.scene);
|
|
@@ -4626,6 +4489,6 @@ function describeSchemas() {
|
|
|
4626
4489
|
};
|
|
4627
4490
|
}
|
|
4628
4491
|
//#endregion
|
|
4629
|
-
export { BODY_TYPES, BoxCollider, CAPSULE_DIRECTIONS, COLLISION_EVENT_MODES,
|
|
4492
|
+
export { BODY_TYPES, BoxCollider, CAPSULE_DIRECTIONS, COLLISION_EVENT_MODES, CapsuleCollider, CharacterController, Collider, CylinderCollider, HAVOK_WASM_AUTO, HeightfieldCollider, INTERPOLATION_MODES, KINEMATIC_SYNC_MODES, MeshCollider, PHYSICS_DIAGNOSTICS_COUNTERS, PHYSICS_DIAGNOSTICS_GROUP, PHYSICS_ERROR_MESSAGES, PHYSICS_MATERIAL_ASSET_TYPE, PHYSICS_MATERIAL_FILE_EXTENSION, PHYSICS_MATERIAL_FILE_FORMAT, PHYSICS_MATERIAL_FORMAT_VERSION, PHYSICS_SETTINGS_SECTION, PhysicsErrorCode, PhysicsMaterial, PhysicsService, Rigidbody, SUPPORT_STATES, SphereCollider, colliderFields, createPhysicsMaterialLoader, defaultPhysicsSettings, describePhysicsMaterialFileFormat, describeSchemas, parsePhysicsMaterial, physics, physicsError, physicsSettingsSchema };
|
|
4630
4493
|
|
|
4631
4494
|
//# sourceMappingURL=index.js.map
|