@codexo/exojs-physics 0.18.0 → 0.19.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.
Files changed (68) hide show
  1. package/README.md +52 -58
  2. package/dist/esm/Aabb.d.ts.map +1 -1
  3. package/dist/esm/Collider.d.ts.map +1 -1
  4. package/dist/esm/Collider.js +9 -0
  5. package/dist/esm/Collider.js.map +1 -1
  6. package/dist/esm/ContactGraph.d.ts +23 -3
  7. package/dist/esm/ContactGraph.d.ts.map +1 -1
  8. package/dist/esm/ContactGraph.js +45 -4
  9. package/dist/esm/ContactGraph.js.map +1 -1
  10. package/dist/esm/PhysicsBody.d.ts.map +1 -1
  11. package/dist/esm/PhysicsBody.js +32 -0
  12. package/dist/esm/PhysicsBody.js.map +1 -1
  13. package/dist/esm/PhysicsBodyComponent.d.ts +45 -0
  14. package/dist/esm/PhysicsBodyComponent.d.ts.map +1 -0
  15. package/dist/esm/PhysicsBodyComponent.js +77 -0
  16. package/dist/esm/PhysicsBodyComponent.js.map +1 -0
  17. package/dist/esm/PhysicsWorld.d.ts +49 -5
  18. package/dist/esm/PhysicsWorld.d.ts.map +1 -1
  19. package/dist/esm/PhysicsWorld.js +111 -46
  20. package/dist/esm/PhysicsWorld.js.map +1 -1
  21. package/dist/esm/TimeStepper.d.ts.map +1 -1
  22. package/dist/esm/backend/NativePhysicsBackend.d.ts.map +1 -1
  23. package/dist/esm/binding/BindingRegistry.d.ts.map +1 -1
  24. package/dist/esm/binding/PhysicsBinding.d.ts +6 -2
  25. package/dist/esm/binding/PhysicsBinding.d.ts.map +1 -1
  26. package/dist/esm/binding/PhysicsBinding.js +8 -4
  27. package/dist/esm/binding/PhysicsBinding.js.map +1 -1
  28. package/dist/esm/binding/nodeWorldTransform.d.ts +18 -0
  29. package/dist/esm/binding/nodeWorldTransform.d.ts.map +1 -0
  30. package/dist/esm/binding/nodeWorldTransform.js +41 -0
  31. package/dist/esm/binding/nodeWorldTransform.js.map +1 -0
  32. package/dist/esm/broadphase/AabbTreeBroadPhase.d.ts.map +1 -1
  33. package/dist/esm/collision/Manifold.d.ts.map +1 -1
  34. package/dist/esm/collision/dispatch.d.ts.map +1 -1
  35. package/dist/esm/collision/narrowphase.d.ts.map +1 -1
  36. package/dist/esm/collision/segments.d.ts.map +1 -1
  37. package/dist/esm/collision/sweep.d.ts.map +1 -1
  38. package/dist/esm/debug/PhysicsDebugDraw.d.ts.map +1 -1
  39. package/dist/esm/debug/PhysicsDebugDraw.js +13 -11
  40. package/dist/esm/debug/PhysicsDebugDraw.js.map +1 -1
  41. package/dist/esm/index.js +2 -1
  42. package/dist/esm/joints/DistanceJoint.d.ts.map +1 -1
  43. package/dist/esm/joints/Joint.d.ts.map +1 -1
  44. package/dist/esm/joints/MouseJoint.d.ts.map +1 -1
  45. package/dist/esm/joints/PrismaticJoint.d.ts.map +1 -1
  46. package/dist/esm/joints/RevoluteJoint.d.ts.map +1 -1
  47. package/dist/esm/joints/WeldJoint.d.ts.map +1 -1
  48. package/dist/esm/joints/WheelJoint.d.ts.map +1 -1
  49. package/dist/esm/math.d.ts.map +1 -1
  50. package/dist/esm/physicsBuildInfo.js +2 -2
  51. package/dist/esm/public.d.ts +1 -0
  52. package/dist/esm/public.d.ts.map +1 -1
  53. package/dist/esm/query/QueryEngine.d.ts.map +1 -1
  54. package/dist/esm/shapes/BoxShape.d.ts.map +1 -1
  55. package/dist/esm/shapes/CapsuleShape.d.ts +1 -1
  56. package/dist/esm/shapes/CapsuleShape.d.ts.map +1 -1
  57. package/dist/esm/shapes/ChainShape.d.ts +1 -1
  58. package/dist/esm/shapes/ChainShape.d.ts.map +1 -1
  59. package/dist/esm/shapes/CircleShape.d.ts +1 -1
  60. package/dist/esm/shapes/CircleShape.d.ts.map +1 -1
  61. package/dist/esm/shapes/PolygonShape.d.ts +1 -1
  62. package/dist/esm/shapes/PolygonShape.d.ts.map +1 -1
  63. package/dist/esm/shapes/SegmentShape.d.ts +1 -1
  64. package/dist/esm/shapes/SegmentShape.d.ts.map +1 -1
  65. package/dist/esm/shapes/convexParts.d.ts.map +1 -1
  66. package/dist/esm/solver/ContactSolver.d.ts.map +1 -1
  67. package/dist/esm/types.d.ts.map +1 -1
  68. package/package.json +5 -5
package/README.md CHANGED
@@ -1,84 +1,78 @@
1
1
  # @codexo/exojs-physics
2
2
 
3
- Native 2D **rigid-body** runtime for [ExoJS](https://github.com/Exoridus/ExoJS).
3
+ A TypeScript 2D rigid-body runtime for ExoJS: bodies, colliders, joints, sensors, contact policy, spatial queries, and scene-node binding.
4
4
 
5
- Zero production dependencies, ESM-only, version-locked with the core engine. It ships a fixed-step world with a warm-started **TGS-Soft** solver: shapes, colliders, bodies, a dynamic-AABB broad phase, a manifold-generating narrow phase, joints, sleeping islands, continuous collision for fast bodies, a per-contact modifier, collision filters, sensors, events, spatial queries, scene-node binding with interpolation, and a debug overlay.
6
-
7
- > **Library, not an extension.** Physics contributes no renderer or asset bindings, so there is no `/register` entry. Construct a `PhysicsWorld` directly. `@codexo/exojs` is a peer dependency.
5
+ Use it for simulated motion and collision response. Core's geometric queries are sufficient for simpler hit tests and overlaps. This package contributes no application extension descriptor: construct a `PhysicsWorld` and give it a scene or another explicit owner.
8
6
 
9
7
  ## Install
10
8
 
11
9
  ```sh
12
- npm install @codexo/exojs @codexo/exojs-physics
10
+ npm install --save-exact @codexo/exojs @codexo/exojs-physics
13
11
  ```
14
12
 
15
- ## Quick start
13
+ Core is a peer dependency. Keep the packages on a compatible release line.
14
+
15
+ ## Start a scene-owned world
16
16
 
17
17
  ```ts
18
- import { Scene, type Seconds, Vector } from '@codexo/exojs';
19
- import { BoxShape, CircleShape, Collider, PhysicsBody, PhysicsWorld } from '@codexo/exojs-physics';
20
-
21
- class GameScene extends Scene {
22
- private readonly world = new PhysicsWorld({ gravity: new Vector(0, 980) });
23
-
24
- public override onStart(): void {
25
- // Construct bodies/colliders freely, then hand them to the world: `add`
26
- // assigns ids, registers the colliders and aggregates the mass model.
27
- // Static ground (an explicit static body + box collider).
28
- this.world.add(
29
- new PhysicsBody({ type: 'static', position: new Vector(400, 600), colliders: [new Collider({ shape: new BoxShape(800, 32), friction: 0.9 })] }),
18
+ import { Scene, SystemOrder } from '@codexo/exojs';
19
+ import { BoxShape, Collider, PhysicsBody, PhysicsWorld } from '@codexo/exojs-physics';
20
+
21
+ export class GameScene extends Scene {
22
+ override init(): void {
23
+ const world = new PhysicsWorld({ gravity: { x: 0, y: 980 } });
24
+
25
+ this.systems.add(world, { order: SystemOrder.Physics });
26
+ world.add(
27
+ new PhysicsBody({
28
+ type: 'static',
29
+ position: { x: 400, y: 560 },
30
+ colliders: [new Collider({ shape: new BoxShape(700, 32) })],
31
+ }),
32
+ );
33
+ world.add(
34
+ new PhysicsBody({
35
+ type: 'dynamic',
36
+ position: { x: 400, y: 100 },
37
+ colliders: [new Collider({ shape: new BoxShape(40, 40) })],
38
+ }),
30
39
  );
31
-
32
- // A kinematic platform you move yourself. Attach more colliders any time.
33
- const platform = new PhysicsBody({ type: 'kinematic', position: new Vector(200, 400) });
34
- platform.addCollider(new Collider({ shape: new BoxShape(120, 16) }));
35
- this.world.add(platform);
36
-
37
- // A sensor trigger.
38
- const triggerCollider = new Collider({ shape: new CircleShape(40), isSensor: true });
39
- this.world.add(new PhysicsBody({ type: 'static', position: new Vector(600, 500), colliders: [triggerCollider] }));
40
- this.world.onSensorEnter.add(({ sensor }) => {
41
- if (sensor === triggerCollider) console.log('entered the trigger');
42
- });
43
- }
44
-
45
- public override update(delta: Seconds): void {
46
- this.world.step(delta); // fixed-step detection + events + binding
47
40
  }
48
41
  }
49
42
  ```
50
43
 
51
- ## What it does
44
+ The scene registry drives and destroys this world. The snippet creates simulation only; bodies do not draw themselves. Use `world.attach(node, definition)` or `world.bind(body, node)` to connect visible nodes, and render them from the scene's `draw` hook. The [Physics guide](https://exoridus.github.io/ExoJS/en/guide/physics/physics-basics/) supplies a complete, asset-free falling-box application.
45
+
46
+ ## Bodies owned by nodes
47
+
48
+ `PhysicsBodyComponent` gives a node a body that follows the node's lifecycle: it joins the world while the node is active in a scene, leaves it with its state kept when the component is disabled, the node is removed or reparented, or its scene is retained, and is destroyed with the node.
49
+
50
+ ```ts
51
+ import { Graphics } from '@codexo/exojs';
52
+ import { CircleShape, PhysicsBodyComponent, PhysicsWorld } from '@codexo/exojs-physics';
53
+
54
+ const world = new PhysicsWorld({ gravity: { x: 0, y: 980 } });
55
+ const ball = new Graphics();
56
+ const physics = ball.addComponent(new PhysicsBodyComponent(world, { colliders: [{ shape: new CircleShape(12) }] }));
57
+
58
+ physics.body.applyImpulse(0, -300);
59
+ ```
60
+
61
+ Component-managed bodies do not support joints yet. `world.remove(body)` takes any body out of the simulation without destroying it; `world.add(body)` puts it back.
52
62
 
53
- | Area | API |
54
- | -------------------- | --------------------------------------------------------------------------------------------------------------------------- |
55
- | World | `PhysicsWorld`, `step`, `gravity`, `timeStepper`, `destroy` |
56
- | Bodies | `new PhysicsBody` + `world.add` (`dynamic`/`static`/`kinematic`), `setTransform`, mass/inertia from colliders |
57
- | Colliders | `new Collider` + `body.addCollider` / `colliders: [...]`, density/friction/restitution, `isSensor`, filter, offset |
58
- | Attach | `world.attach(node, def)` — body + collider + `bind` in one call |
59
- | Shapes | solid: `CircleShape`, `CapsuleShape`, `PolygonShape` (convex-validated), `BoxShape`; boundary: `SegmentShape`, `ChainShape` |
60
- | Concave outlines | `toConvexPolygonShapes(vertices)` — one possibly-concave outline into the convex `PolygonShape`s for a single body |
61
- | Dynamics | fixed-step TGS-Soft solver, gravity, forces/impulses, friction/restitution, sleeping islands |
62
- | Joints | `DistanceJoint`, `RevoluteJoint`, `PrismaticJoint`, `WheelJoint`, `WeldJoint`, `MouseJoint` |
63
- | Continuous collision | `body.isBullet` — exact translational shape cast of the whole shape, not just its centre |
64
- | Contact policy | `world.contactModifier` — per-contact material/enable decisions (one-way platforms, conditional friction) |
65
- | Filtering | `CollisionFilter` (category/mask/group), `shouldCollide` |
66
- | Events | `onCollisionStart` / `onCollisionEnd` / `onSensorEnter` / `onSensorExit` — immutable snapshots |
67
- | Queries | `queryPoint`, `queryAabb` (+ `out` / `forEachAabbHit`), `rayCast`, `rayCastAll`, `overlapShape` |
68
- | Binding | `bind(body, node)` — node tracks the body's position each step |
69
- | Debug | `@codexo/exojs-physics/debug` → `PhysicsDebugDraw` (shapes/AABBs/contacts/normals/centres/broad-phase/joints) |
63
+ ## Important boundaries
70
64
 
71
- Building a level out of a tilemap? `@codexo/exojs-tilemap-physics` turns `@codexo/exojs-tilemap` collision geometry into static bodies and keeps them in sync with streamed chunks.
65
+ Choose one stepping clock. A world registered in `scene.systems` is stepped by the host; do not also call `step()`. An independently hosted world can use `step(frameDeltaSeconds)` and its own accumulator.
72
66
 
73
- ## Determinism & non-goals
67
+ Physics angles use radians and clockwise-positive screen rotation. Scene-node rotation uses degrees with the opposite screen sign; the built-in binding performs the conversion. Interpolation affects bound-node presentation, not the number of collision steps.
74
68
 
75
- Stepping is fully **caller-driven** and uses a fixed timestep with an accumulator (`world.step(frameDeltaSeconds)`); the same build replays a scene identically given the same inputs. There are **no rollback/lockstep determinism guarantees across builds or machines** (floating-point reality). The package is single-threaded and 2D only — no workers, GPU, 3D, soft bodies, fluids or vehicles.
69
+ Continuous collision covers supported translational shape casts, not unrestricted rotational sweeping. Boundary-only geometry is not a solid dynamic mass. Fixed timesteps do not promise cross-build or cross-machine lockstep determinism, and performance depends on the actual contacts, shapes, and workload.
76
70
 
77
- `step()` owns its own fixed-timestep accumulator, so you can drive it from either the engine's `Scene.fixedUpdate` (already a constant-rate hook — the idiomatic choice) or straight from `Scene.update`'s raw, variable per-frame delta; either way `step` converts whatever it's given into the right number of fixed sub-steps. See the "Stepping the world" section of the [physics guide](https://exoridus.github.io/ExoJS/en/guide/physics/physics-basics/) for the details and an interpolation note (`world.timeStepper.alpha`).
71
+ For tilemap collision, use [`@codexo/exojs-tilemap-physics`](https://github.com/Exoridus/ExoJS/tree/next/packages/exojs-tilemap-physics). For diagnostic drawing, use the package's `@codexo/exojs-physics/debug` entry point.
78
72
 
79
- **Broad-phase scale.** Collision detection uses a dynamic AABB tree (Box2D-style), incrementally updated across steps: a collider whose AABB stays within its stored margin is never reinserted, so the dominant cost tracks how much actually moved rather than the total live collider count (there's still a cheap linear pass over all live colliders each step). Scales to tens of thousands of simultaneously-live colliders.
73
+ ## Documentation
80
74
 
81
- **Solid and boundary geometry.** `CircleShape`, `CapsuleShape`, `PolygonShape` and `BoxShape` enclose an area and carry mass; `SegmentShape` and `ChainShape` are boundaries with no interior, so they contribute collision only and a `dynamic` body needs at least one solid collider alongside them. A chain is one authored collider that the engine solves edge by edge with shared-vertex adjacency, so a body slides across a seam without snagging. Two boundaries never collide with each other, and a boundary is never the _moving_ operand of a continuous shape cast — level structure is swept against, not swept.
75
+ [Physics guide](https://exoridus.github.io/ExoJS/en/guide/physics/physics-basics/) · [Joints and contact behavior](https://exoridus.github.io/ExoJS/en/guide/physics/joints-and-dynamics/) · [PhysicsWorld API](https://exoridus.github.io/ExoJS/en/api/physics-world/) · [Drag and Throw playground](https://exoridus.github.io/ExoJS/en/playground/?example=physics/sprite-follows-body)
82
76
 
83
77
  ## License
84
78
 
@@ -1 +1 @@
1
- {"version":3,"file":"Aabb.d.ts","sourceRoot":"","sources":["../../src/Aabb.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,+CAA+C;AAC/C,eAAO,MAAM,UAAU,QAAO,QAAoD,CAAC;AAEnF,2EAA2E;AAC3E,eAAO,MAAM,WAAW,GAAI,GAAG,QAAQ,EAAE,GAAG,QAAQ,KAAG,OAAuF,CAAC;AAE/I,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,GAAI,MAAM,QAAQ,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,OAA+E,CAAC;AAEzJ,+DAA+D;AAC/D,eAAO,MAAM,UAAU,GAAI,MAAM,QAAQ,EAAE,QAAQ,MAAM,KAAG,QAO3D,CAAC"}
1
+ {"version":3,"file":"Aabb.d.ts","sourceRoot":"","sources":["../../src/Aabb.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,+CAA+C;AAC/C,eAAO,MAAM,UAAU,QAAO,QAAoD,CAAC;AAEnF,2EAA2E;AAC3E,eAAO,MAAM,WAAW,MAAO,QAAQ,KAAK,QAAQ,KAAG,OAAuF,CAAC;AAE/I,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,SAAU,QAAQ,KAAK,MAAM,KAAK,MAAM,KAAG,OAA+E,CAAC;AAEzJ,+DAA+D;AAC/D,eAAO,MAAM,UAAU,SAAU,QAAQ,UAAU,MAAM,KAAG,QAO3D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Collider.d.ts","sourceRoot":"","sources":["../../src/Collider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAoB/C,2CAA2C;AAC3C,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,KAAK,EAAE,QAAQ,CAAC;IAChB,oGAAoG;IACpG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iGAAiG;IACjG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sFAAsF;IACtF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oEAAoE;IACpE,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACl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,CAAC,QAAQ,CAAC,CAEpC;IAED,iFAAiF;IACjF,IAAW,cAAc,IAAI,QAAQ,CAAC,SAAS,CAAC,CAE/C;IAED,qEAAqE;IACrE,IAAW,cAAc,IAAI,QAAQ,CAAC,SAAS,CAAC,CAE/C;IAED,qEAAqE;IACrE,IAAW,WAAW,IAAI,QAAQ,CAAC,SAAS,CAAC,CAE5C;IAED,yFAAyF;IACzF,IAAW,aAAa,IAAI,SAAS,MAAM,EAAE,CAE5C;IAED,gGAAgG;IAChG,IAAW,YAAY,IAAI,SAAS,MAAM,EAAE,CAE3C;IAmBD,iEAAiE;IACjE,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED;;;;OAIG;IACI,WAAW,CAAC,aAAa,EAAE,SAAS,GAAG,IAAI,CAwBjD;IAED;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAwBzB,gFAAgF;IAChF,OAAO,CAAC,kBAAkB;IAS1B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAgD3B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;CA+BzB"}
@@ -233,6 +233,15 @@ var Collider = class Collider {
233
233
  this._id = id;
234
234
  }
235
235
  /**
236
+ * @internal - forget the ids this collider and its chain edges held in the
237
+ * world they left. The body link stays: the collider still belongs to its
238
+ * body, which may join a world again.
239
+ */
240
+ _detachFromWorld() {
241
+ this._id = -1;
242
+ if (this._chainEdges !== null) for (const edge of this._chainEdges) edge._id = -1;
243
+ }
244
+ /**
236
245
  * Fan a chain out into one proxy per edge. Each proxy carries the chain's own
237
246
  * local placement, so it needs no transform of its own, and its shape carries
238
247
  * the adjacency that keeps a body from snagging at a shared vertex.
@@ -1 +1 @@
1
- {"version":3,"file":"Collider.js","names":[],"sources":["../../src/Collider.ts"],"sourcesContent":["import type { AabbLike, PointLike } from '@codexo/exojs';\n\nimport { createAabb } from './Aabb';\nimport type { Transform } from './math';\nimport { applyRotation, applyTransform, composeTransforms, createTransform } from './math';\nimport type { PhysicsBody } from './PhysicsBody';\nimport type { AnyShape } from './shapes/AnyShape';\nimport type { ChainShape } from './shapes/ChainShape';\nimport type { CollisionFilter } from './types';\nimport { resolveFilter } from './types';\n\n/** Number of world-space vertices a shape kind caches on its collider. */\nconst worldVertexCount = (shape: AnyShape): number => {\n switch (shape.type) {\n case 'polygon':\n return shape.count;\n case 'capsule':\n case 'segment':\n // Two endpoints. Both are a two-vertex ring, with and without a radius.\n return 2;\n case 'circle':\n case 'chain':\n // A chain caches nothing of its own: its geometry lives on the per-edge\n // child proxies, and its AABB is the union of theirs.\n return 0;\n }\n};\n\n/** Construction options for a collider. */\nexport interface ColliderOptions {\n /** The collision geometry. */\n shape: AnyShape;\n /** Density (mass per px²) for the owning body's mass; ignored for static/kinematic. Default `1`. */\n density?: number;\n /** Coulomb friction coefficient (used by the solver once dynamics ship). Default `0.2`. */\n friction?: number;\n /** Restitution / bounciness in `[0, 1]` (used by the solver once dynamics ship). Default `0`. */\n restitution?: number;\n /** When `true`, generates overlap events but no contact response. Default `false`. */\n isSensor?: boolean;\n /** Category/mask/group filter; partials merge over the defaults. */\n filter?: Partial<CollisionFilter>;\n /** Body-local offset of the shape origin. Default `(0, 0)`. */\n offset?: Readonly<PointLike>;\n /** Body-local rotation of the shape in radians (compound colliders). Default `0`. */\n rotation?: number;\n}\n\n/**\n * Geometry attached to a {@link PhysicsBody}: a {@link Shape} plus a body-local\n * offset/rotation, material (friction/restitution/density) and a collision\n * filter. A body may own several colliders (compound). The collider also caches\n * its world-space geometry - refreshed by {@link synchronize} - which the broad\n * phase, narrow phase and queries read directly.\n *\n * Material fields and the filter are mutable; the shape and local placement are\n * immutable (rebuild the collider to change geometry).\n */\nexport class Collider {\n /** Stable id, assigned when the owning body joins a world (`-1` until then). */\n public readonly shape: AnyShape;\n public readonly offsetX: number;\n public readonly offsetY: number;\n public readonly localRotation: number;\n\n public density: number;\n public friction: number;\n public restitution: number;\n public isSensor: boolean;\n public readonly filter: CollisionFilter;\n\n private _id = -1;\n private _body: PhysicsBody | null = null;\n private readonly _chainEdges: readonly Collider[] | null;\n private _chainParent: Collider | null = null;\n private readonly _localTransform: Transform;\n private readonly _worldTransform: Transform = createTransform();\n private readonly _aabb: AabbLike = createAabb();\n private readonly _worldCenter: PointLike = { x: 0, y: 0 };\n // Reused per-vertex scratch for synchronize()'s polygon transform loop so a\n // collider sync allocates nothing. Instance-private: never held across the\n // call, never aliased between colliders.\n private readonly _syncScratch: PointLike = { x: 0, y: 0 };\n private readonly _worldVertices: number[];\n private readonly _worldNormals: number[];\n\n private _destroyed = false;\n\n /**\n * @internal - proxy id in the physics world's broad-phase spatial tree; `-1`\n * when not inserted. Like `PhysicsBody._islandIndex`/`_sleepTime`, this is a\n * single-owner slot: exactly ONE `AabbTreeBroadPhase` may track this collider\n * at a time (in production, the world's own broad phase for the collider's\n * whole lifetime). A second broad phase over the same collider would clobber\n * this value and corrupt the first's tree - never do that.\n */\n public _treeProxy = -1;\n\n /**\n * @internal - whether {@link aabb} has changed since the owning broad phase\n * last looked at it. Set by every write to the AABB ({@link synchronize} is\n * the only one) and cleared when the broad phase has taken the new box, so a\n * resting collider costs nothing to re-sync. Single-owner like\n * {@link _treeProxy}, and for the same reason.\n */\n public _treeDirty = true;\n\n public constructor(options: ColliderOptions) {\n const density = options.density ?? 1;\n\n if (!Number.isFinite(density) || density < 0) {\n throw new RangeError(`Collider: density must be a non-negative finite number, received ${density}.`);\n }\n\n this.shape = options.shape;\n this.offsetX = options.offset?.x ?? 0;\n this.offsetY = options.offset?.y ?? 0;\n this.localRotation = options.rotation ?? 0;\n this.density = density;\n this.friction = options.friction ?? 0.2;\n this.restitution = options.restitution ?? 0;\n this.isSensor = options.isSensor ?? false;\n this.filter = resolveFilter(options.filter);\n this._localTransform = createTransform(this.offsetX, this.offsetY, this.localRotation);\n\n const vertexCount = worldVertexCount(this.shape);\n\n this._worldVertices = new Array<number>(vertexCount * 2).fill(0);\n this._worldNormals = new Array<number>(vertexCount * 2).fill(0);\n this._chainEdges = this.shape.type === 'chain' ? this._buildChainEdges(this.shape) : null;\n }\n\n /** Stable id, assigned when the owning body joins a world via `world.add()`; `-1` until then. */\n public get id(): number {\n return this._id;\n }\n\n /**\n * The body this collider belongs to. `null` until the collider has been added\n * to a body that has joined a world (free-standing colliders have no body yet).\n */\n public get body(): PhysicsBody {\n if (this._body === null) {\n throw new Error('Collider: this collider has not been attached to a body in a world yet.');\n }\n\n return this._body;\n }\n\n /** The collider's world AABB (valid after the latest {@link synchronize}). */\n public get aabb(): Readonly<AabbLike> {\n return this._aabb;\n }\n\n /** The collider's world transform (offset/rotation composed with the body's). */\n public get worldTransform(): Readonly<Transform> {\n return this._worldTransform;\n }\n\n /** The collider's body-local transform (offset + local rotation). */\n public get localTransform(): Readonly<Transform> {\n return this._localTransform;\n }\n\n /** World-space circle centre (only meaningful for circle shapes). */\n public get worldCenter(): Readonly<PointLike> {\n return this._worldCenter;\n }\n\n /** World-space polygon vertices `[x0, y0, ...]` (only meaningful for polygon shapes). */\n public get worldVertices(): readonly number[] {\n return this._worldVertices;\n }\n\n /** World-space polygon outward normals `[x0, y0, ...]` (only meaningful for polygon shapes). */\n public get worldNormals(): readonly number[] {\n return this._worldNormals;\n }\n\n /**\n * @internal - the engine-owned edge proxies a chain collider fans out into,\n * one per chain edge; `null` for every other shape. They are what the broad\n * phase, the narrow phase and the solver see, so a chain contact reuses the\n * one-manifold-per-pair model unchanged. They are never part of\n * `body.colliders`, `world.colliders` or any query result - the authored\n * collider is the public identity of every contact they produce.\n */\n public get chainEdges(): readonly Collider[] | null {\n return this._chainEdges;\n }\n\n /** @internal - the authored chain collider this edge proxy belongs to; `null` for an authored collider. */\n public get chainParent(): Collider | null {\n return this._chainParent;\n }\n\n /** `true` after the owning world has destroyed this collider. */\n public get destroyed(): boolean {\n return this._destroyed;\n }\n\n /**\n * Recompute the cached world geometry from the body's transform. Called by the\n * body on `setTransform`, on collider creation, and by the world before each\n * detection pass.\n */\n public synchronize(bodyTransform: Transform): void {\n const world = composeTransforms(bodyTransform, this._localTransform, this._worldTransform);\n\n this._treeDirty = true;\n\n switch (this.shape.type) {\n case 'circle':\n this._synchronizeCircle(world, this.shape.radius);\n break;\n case 'capsule':\n // A capsule is a two-vertex ring plus a radius, so it rides the polygon\n // path and only the AABB inflation differs.\n this._synchronizePolygon(world, this.shape.vertices, this.shape.normals, 2, this.shape.radius);\n break;\n case 'segment':\n this._synchronizePolygon(world, this.shape.vertices, this.shape.normals, 2, 0);\n break;\n case 'polygon':\n this._synchronizePolygon(world, this.shape.vertices, this.shape.normals, this.shape.count, 0);\n break;\n case 'chain':\n this._synchronizeChain(bodyTransform);\n break;\n }\n }\n\n /**\n * A chain's world geometry is its edge proxies': each of them shares the\n * chain's local placement and syncs its own two endpoints, and the chain's own\n * AABB is their union. Nothing is transformed twice, and no proxy is rebuilt.\n */\n private _synchronizeChain(bodyTransform: Transform): void {\n const edges = this._chainEdges!;\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const edge of edges) {\n edge.synchronize(bodyTransform);\n\n const aabb = edge.aabb;\n\n minX = aabb.minX < minX ? aabb.minX : minX;\n minY = aabb.minY < minY ? aabb.minY : minY;\n maxX = aabb.maxX > maxX ? aabb.maxX : maxX;\n maxY = aabb.maxY > maxY ? aabb.maxY : maxY;\n }\n\n this._aabb.minX = minX;\n this._aabb.minY = minY;\n this._aabb.maxX = maxX;\n this._aabb.maxY = maxY;\n }\n\n /** A circle is its transformed centre; the local vertex buffers stay unused. */\n private _synchronizeCircle(world: Transform, radius: number): void {\n this._worldCenter.x = world.x;\n this._worldCenter.y = world.y;\n this._aabb.minX = world.x - radius;\n this._aabb.minY = world.y - radius;\n this._aabb.maxX = world.x + radius;\n this._aabb.maxY = world.y + radius;\n }\n\n /**\n * Transform a local vertex/normal ring into the world buffers and take the\n * AABB while doing it. `radius` inflates the box for a rounded outline (a\n * capsule's spine); it is `0` for a plain polygon.\n */\n private _synchronizePolygon(world: Transform, local: readonly number[], normals: readonly number[], count: number, radius: number): void {\n const out = this._syncScratch;\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (let i = 0; i < count; i++) {\n applyTransform(world, local[i * 2]!, local[i * 2 + 1]!, out);\n this._worldVertices[i * 2] = out.x;\n this._worldVertices[i * 2 + 1] = out.y;\n minX = out.x < minX ? out.x : minX;\n minY = out.y < minY ? out.y : minY;\n maxX = out.x > maxX ? out.x : maxX;\n maxY = out.y > maxY ? out.y : maxY;\n\n applyRotation(world, normals[i * 2]!, normals[i * 2 + 1]!, out);\n this._worldNormals[i * 2] = out.x;\n this._worldNormals[i * 2 + 1] = out.y;\n }\n\n this._aabb.minX = minX - radius;\n this._aabb.minY = minY - radius;\n this._aabb.maxX = maxX + radius;\n this._aabb.maxY = maxY + radius;\n }\n\n /** @internal - bind this collider to its body and id (called when the body joins a world). */\n public _attach(body: PhysicsBody, id: number): void {\n this._body = body;\n this._id = id;\n }\n\n /**\n * Fan a chain out into one proxy per edge. Each proxy carries the chain's own\n * local placement, so it needs no transform of its own, and its shape carries\n * the adjacency that keeps a body from snagging at a shared vertex.\n */\n private _buildChainEdges(chain: ChainShape): readonly Collider[] {\n const edges: Collider[] = [];\n\n for (const edgeShape of chain.edges) {\n const edge = new Collider({\n shape: edgeShape,\n offset: { x: this.offsetX, y: this.offsetY },\n rotation: this.localRotation,\n // Material, filter and sensor flag stay mutable on the authored collider\n // and are read from there per pass, so copying them here would only add a\n // second, staler source of truth.\n density: 0,\n });\n\n edge._chainParent = this;\n edges.push(edge);\n }\n\n return edges;\n }\n\n /** @internal - mark destroyed (called by the world). */\n public _markDestroyed(): void {\n this._destroyed = true;\n\n if (this._chainEdges !== null) {\n for (const edge of this._chainEdges) {\n edge._destroyed = true;\n }\n }\n }\n}\n\n/**\n * The authored collider a contact, query hit or sweep target belongs to: the\n * collider itself, or the chain it is an engine-owned edge proxy of. Every\n * public identity - events, query results, the contact modifier - goes through\n * this, so a solver-side partition never reaches a caller.\n *\n * @internal\n */\nexport const authoredCollider = (collider: Collider): Collider => collider.chainParent ?? collider;\n"],"mappings":";;;;;;AAYA,MAAM,oBAAoB,UAA4B;CACpD,QAAQ,MAAM,MAAd;EACE,KAAK,WACH,OAAO,MAAM;EACf,KAAK;EACL,KAAK,WAEH,OAAO;EACT,KAAK;EACL,KAAK,SAGH,OAAO;CACX;AACF;;;;;;;;;;;AAgCA,IAAa,WAAb,MAAa,SAAS;;CAEpB,AAAgB;CAChB,AAAgB;CAChB,AAAgB;CAChB,AAAgB;CAEhB,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAgB;CAEhB,AAAQ,MAAM;CACd,AAAQ,QAA4B;CACpC,AAAiB;CACjB,AAAQ,eAAgC;CACxC,AAAiB;CACjB,AAAiB,kBAA6B,gBAAgB;CAC9D,AAAiB,QAAkB,WAAW;CAC9C,AAAiB,eAA0B;EAAE,GAAG;EAAG,GAAG;CAAE;CAIxD,AAAiB,eAA0B;EAAE,GAAG;EAAG,GAAG;CAAE;CACxD,AAAiB;CACjB,AAAiB;CAEjB,AAAQ,aAAa;;;;;;;;;CAUrB,AAAO,aAAa;;;;;;;;CASpB,AAAO,aAAa;CAEpB,AAAO,YAAY,SAA0B;EAC3C,MAAM,UAAU,QAAQ,WAAW;EAEnC,IAAI,CAAC,OAAO,SAAS,OAAO,KAAK,UAAU,GACzC,MAAM,IAAI,WAAW,oEAAoE,QAAQ,EAAE;EAGrG,KAAK,QAAQ,QAAQ;EACrB,KAAK,UAAU,QAAQ,QAAQ,KAAK;EACpC,KAAK,UAAU,QAAQ,QAAQ,KAAK;EACpC,KAAK,gBAAgB,QAAQ,YAAY;EACzC,KAAK,UAAU;EACf,KAAK,WAAW,QAAQ,YAAY;EACpC,KAAK,cAAc,QAAQ,eAAe;EAC1C,KAAK,WAAW,QAAQ,YAAY;EACpC,KAAK,SAAS,cAAc,QAAQ,MAAM;EAC1C,KAAK,kBAAkB,gBAAgB,KAAK,SAAS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,IAAI,KAAK,IAAI;GACrC,OAAO,IAAI,IAAI,OAAO,IAAI,IAAI;GAC9B,OAAO,IAAI,IAAI,OAAO,IAAI,IAAI;GAC9B,OAAO,IAAI,IAAI,OAAO,IAAI,IAAI;GAC9B,OAAO,IAAI,IAAI,OAAO,IAAI,IAAI;GAE9B,cAAc,OAAO,QAAQ,IAAI,IAAK,QAAQ,IAAI,IAAI,IAAK,GAAG;GAC9D,KAAK,cAAc,IAAI,KAAK,IAAI;GAChC,KAAK,cAAc,IAAI,IAAI,KAAK,IAAI;EACtC;EAEA,KAAK,MAAM,OAAO,OAAO;EACzB,KAAK,MAAM,OAAO,OAAO;EACzB,KAAK,MAAM,OAAO,OAAO;EACzB,KAAK,MAAM,OAAO,OAAO;CAC3B;;CAGA,AAAO,QAAQ,MAAmB,IAAkB;EAClD,KAAK,QAAQ;EACb,KAAK,MAAM;CACb;;;;;;CAOA,AAAQ,iBAAiB,OAAwC;EAC/D,MAAM,QAAoB,CAAC;EAE3B,KAAK,MAAM,aAAa,MAAM,OAAO;GACnC,MAAM,OAAO,IAAI,SAAS;IACxB,OAAO;IACP,QAAQ;KAAE,GAAG,KAAK;KAAS,GAAG,KAAK;IAAQ;IAC3C,UAAU,KAAK;IAIf,SAAS;GACX,CAAC;GAED,KAAK,eAAe;GACpB,MAAM,KAAK,IAAI;EACjB;EAEA,OAAO;CACT;;CAGA,AAAO,iBAAuB;EAC5B,KAAK,aAAa;EAElB,IAAI,KAAK,gBAAgB,MACvB,KAAK,MAAM,QAAQ,KAAK,aACtB,KAAK,aAAa;CAGxB;AACF;;;;;;;;;AAUA,MAAa,oBAAoB,aAAiC,SAAS,eAAe"}
1
+ {"version":3,"file":"Collider.js","names":[],"sources":["../../src/Collider.ts"],"sourcesContent":["import type { AabbLike, PointLike } from '@codexo/exojs';\n\nimport { createAabb } from './Aabb';\nimport type { Transform } from './math';\nimport { applyRotation, applyTransform, composeTransforms, createTransform } from './math';\nimport type { PhysicsBody } from './PhysicsBody';\nimport type { AnyShape } from './shapes/AnyShape';\nimport type { ChainShape } from './shapes/ChainShape';\nimport type { CollisionFilter } from './types';\nimport { resolveFilter } from './types';\n\n/** Number of world-space vertices a shape kind caches on its collider. */\nconst worldVertexCount = (shape: AnyShape): number => {\n switch (shape.type) {\n case 'polygon':\n return shape.count;\n case 'capsule':\n case 'segment':\n // Two endpoints. Both are a two-vertex ring, with and without a radius.\n return 2;\n case 'circle':\n case 'chain':\n // A chain caches nothing of its own: its geometry lives on the per-edge\n // child proxies, and its AABB is the union of theirs.\n return 0;\n }\n};\n\n/** Construction options for a collider. */\nexport interface ColliderOptions {\n /** The collision geometry. */\n shape: AnyShape;\n /** Density (mass per px²) for the owning body's mass; ignored for static/kinematic. Default `1`. */\n density?: number;\n /** Coulomb friction coefficient (used by the solver once dynamics ship). Default `0.2`. */\n friction?: number;\n /** Restitution / bounciness in `[0, 1]` (used by the solver once dynamics ship). Default `0`. */\n restitution?: number;\n /** When `true`, generates overlap events but no contact response. Default `false`. */\n isSensor?: boolean;\n /** Category/mask/group filter; partials merge over the defaults. */\n filter?: Partial<CollisionFilter>;\n /** Body-local offset of the shape origin. Default `(0, 0)`. */\n offset?: Readonly<PointLike>;\n /** Body-local rotation of the shape in radians (compound colliders). Default `0`. */\n rotation?: number;\n}\n\n/**\n * Geometry attached to a {@link PhysicsBody}: a {@link Shape} plus a body-local\n * offset/rotation, material (friction/restitution/density) and a collision\n * filter. A body may own several colliders (compound). The collider also caches\n * its world-space geometry - refreshed by {@link synchronize} - which the broad\n * phase, narrow phase and queries read directly.\n *\n * Material fields and the filter are mutable; the shape and local placement are\n * immutable (rebuild the collider to change geometry).\n */\nexport class Collider {\n /** Stable id, assigned when the owning body joins a world (`-1` until then). */\n public readonly shape: AnyShape;\n public readonly offsetX: number;\n public readonly offsetY: number;\n public readonly localRotation: number;\n\n public density: number;\n public friction: number;\n public restitution: number;\n public isSensor: boolean;\n public readonly filter: CollisionFilter;\n\n private _id = -1;\n private _body: PhysicsBody | null = null;\n private readonly _chainEdges: readonly Collider[] | null;\n private _chainParent: Collider | null = null;\n private readonly _localTransform: Transform;\n private readonly _worldTransform: Transform = createTransform();\n private readonly _aabb: AabbLike = createAabb();\n private readonly _worldCenter: PointLike = { x: 0, y: 0 };\n // Reused per-vertex scratch for synchronize()'s polygon transform loop so a\n // collider sync allocates nothing. Instance-private: never held across the\n // call, never aliased between colliders.\n private readonly _syncScratch: PointLike = { x: 0, y: 0 };\n private readonly _worldVertices: number[];\n private readonly _worldNormals: number[];\n\n private _destroyed = false;\n\n /**\n * @internal - proxy id in the physics world's broad-phase spatial tree; `-1`\n * when not inserted. Like `PhysicsBody._islandIndex`/`_sleepTime`, this is a\n * single-owner slot: exactly ONE `AabbTreeBroadPhase` may track this collider\n * at a time (in production, the world's own broad phase for the collider's\n * whole lifetime). A second broad phase over the same collider would clobber\n * this value and corrupt the first's tree - never do that.\n */\n public _treeProxy = -1;\n\n /**\n * @internal - whether {@link aabb} has changed since the owning broad phase\n * last looked at it. Set by every write to the AABB ({@link synchronize} is\n * the only one) and cleared when the broad phase has taken the new box, so a\n * resting collider costs nothing to re-sync. Single-owner like\n * {@link _treeProxy}, and for the same reason.\n */\n public _treeDirty = true;\n\n public constructor(options: ColliderOptions) {\n const density = options.density ?? 1;\n\n if (!Number.isFinite(density) || density < 0) {\n throw new RangeError(`Collider: density must be a non-negative finite number, received ${density}.`);\n }\n\n this.shape = options.shape;\n this.offsetX = options.offset?.x ?? 0;\n this.offsetY = options.offset?.y ?? 0;\n this.localRotation = options.rotation ?? 0;\n this.density = density;\n this.friction = options.friction ?? 0.2;\n this.restitution = options.restitution ?? 0;\n this.isSensor = options.isSensor ?? false;\n this.filter = resolveFilter(options.filter);\n this._localTransform = createTransform(this.offsetX, this.offsetY, this.localRotation);\n\n const vertexCount = worldVertexCount(this.shape);\n\n this._worldVertices = new Array<number>(vertexCount * 2).fill(0);\n this._worldNormals = new Array<number>(vertexCount * 2).fill(0);\n this._chainEdges = this.shape.type === 'chain' ? this._buildChainEdges(this.shape) : null;\n }\n\n /** Stable id, assigned when the owning body joins a world via `world.add()`; `-1` until then. */\n public get id(): number {\n return this._id;\n }\n\n /**\n * The body this collider belongs to. `null` until the collider has been added\n * to a body that has joined a world (free-standing colliders have no body yet).\n */\n public get body(): PhysicsBody {\n if (this._body === null) {\n throw new Error('Collider: this collider has not been attached to a body in a world yet.');\n }\n\n return this._body;\n }\n\n /** The collider's world AABB (valid after the latest {@link synchronize}). */\n public get aabb(): Readonly<AabbLike> {\n return this._aabb;\n }\n\n /** The collider's world transform (offset/rotation composed with the body's). */\n public get worldTransform(): Readonly<Transform> {\n return this._worldTransform;\n }\n\n /** The collider's body-local transform (offset + local rotation). */\n public get localTransform(): Readonly<Transform> {\n return this._localTransform;\n }\n\n /** World-space circle centre (only meaningful for circle shapes). */\n public get worldCenter(): Readonly<PointLike> {\n return this._worldCenter;\n }\n\n /** World-space polygon vertices `[x0, y0, ...]` (only meaningful for polygon shapes). */\n public get worldVertices(): readonly number[] {\n return this._worldVertices;\n }\n\n /** World-space polygon outward normals `[x0, y0, ...]` (only meaningful for polygon shapes). */\n public get worldNormals(): readonly number[] {\n return this._worldNormals;\n }\n\n /**\n * @internal - the engine-owned edge proxies a chain collider fans out into,\n * one per chain edge; `null` for every other shape. They are what the broad\n * phase, the narrow phase and the solver see, so a chain contact reuses the\n * one-manifold-per-pair model unchanged. They are never part of\n * `body.colliders`, `world.colliders` or any query result - the authored\n * collider is the public identity of every contact they produce.\n */\n public get chainEdges(): readonly Collider[] | null {\n return this._chainEdges;\n }\n\n /** @internal - the authored chain collider this edge proxy belongs to; `null` for an authored collider. */\n public get chainParent(): Collider | null {\n return this._chainParent;\n }\n\n /** `true` after the owning world has destroyed this collider. */\n public get destroyed(): boolean {\n return this._destroyed;\n }\n\n /**\n * Recompute the cached world geometry from the body's transform. Called by the\n * body on `setTransform`, on collider creation, and by the world before each\n * detection pass.\n */\n public synchronize(bodyTransform: Transform): void {\n const world = composeTransforms(bodyTransform, this._localTransform, this._worldTransform);\n\n this._treeDirty = true;\n\n switch (this.shape.type) {\n case 'circle':\n this._synchronizeCircle(world, this.shape.radius);\n break;\n case 'capsule':\n // A capsule is a two-vertex ring plus a radius, so it rides the polygon\n // path and only the AABB inflation differs.\n this._synchronizePolygon(world, this.shape.vertices, this.shape.normals, 2, this.shape.radius);\n break;\n case 'segment':\n this._synchronizePolygon(world, this.shape.vertices, this.shape.normals, 2, 0);\n break;\n case 'polygon':\n this._synchronizePolygon(world, this.shape.vertices, this.shape.normals, this.shape.count, 0);\n break;\n case 'chain':\n this._synchronizeChain(bodyTransform);\n break;\n }\n }\n\n /**\n * A chain's world geometry is its edge proxies': each of them shares the\n * chain's local placement and syncs its own two endpoints, and the chain's own\n * AABB is their union. Nothing is transformed twice, and no proxy is rebuilt.\n */\n private _synchronizeChain(bodyTransform: Transform): void {\n const edges = this._chainEdges!;\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const edge of edges) {\n edge.synchronize(bodyTransform);\n\n const aabb = edge.aabb;\n\n minX = aabb.minX < minX ? aabb.minX : minX;\n minY = aabb.minY < minY ? aabb.minY : minY;\n maxX = aabb.maxX > maxX ? aabb.maxX : maxX;\n maxY = aabb.maxY > maxY ? aabb.maxY : maxY;\n }\n\n this._aabb.minX = minX;\n this._aabb.minY = minY;\n this._aabb.maxX = maxX;\n this._aabb.maxY = maxY;\n }\n\n /** A circle is its transformed centre; the local vertex buffers stay unused. */\n private _synchronizeCircle(world: Transform, radius: number): void {\n this._worldCenter.x = world.x;\n this._worldCenter.y = world.y;\n this._aabb.minX = world.x - radius;\n this._aabb.minY = world.y - radius;\n this._aabb.maxX = world.x + radius;\n this._aabb.maxY = world.y + radius;\n }\n\n /**\n * Transform a local vertex/normal ring into the world buffers and take the\n * AABB while doing it. `radius` inflates the box for a rounded outline (a\n * capsule's spine); it is `0` for a plain polygon.\n */\n private _synchronizePolygon(world: Transform, local: readonly number[], normals: readonly number[], count: number, radius: number): void {\n const out = this._syncScratch;\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (let i = 0; i < count; i++) {\n applyTransform(world, local[i * 2]!, local[i * 2 + 1]!, out);\n this._worldVertices[i * 2] = out.x;\n this._worldVertices[i * 2 + 1] = out.y;\n minX = out.x < minX ? out.x : minX;\n minY = out.y < minY ? out.y : minY;\n maxX = out.x > maxX ? out.x : maxX;\n maxY = out.y > maxY ? out.y : maxY;\n\n applyRotation(world, normals[i * 2]!, normals[i * 2 + 1]!, out);\n this._worldNormals[i * 2] = out.x;\n this._worldNormals[i * 2 + 1] = out.y;\n }\n\n this._aabb.minX = minX - radius;\n this._aabb.minY = minY - radius;\n this._aabb.maxX = maxX + radius;\n this._aabb.maxY = maxY + radius;\n }\n\n /** @internal - bind this collider to its body and id (called when the body joins a world). */\n public _attach(body: PhysicsBody, id: number): void {\n this._body = body;\n this._id = id;\n }\n\n /**\n * @internal - forget the ids this collider and its chain edges held in the\n * world they left. The body link stays: the collider still belongs to its\n * body, which may join a world again.\n */\n public _detachFromWorld(): void {\n this._id = -1;\n\n if (this._chainEdges !== null) {\n for (const edge of this._chainEdges) {\n edge._id = -1;\n }\n }\n }\n\n /**\n * Fan a chain out into one proxy per edge. Each proxy carries the chain's own\n * local placement, so it needs no transform of its own, and its shape carries\n * the adjacency that keeps a body from snagging at a shared vertex.\n */\n private _buildChainEdges(chain: ChainShape): readonly Collider[] {\n const edges: Collider[] = [];\n\n for (const edgeShape of chain.edges) {\n const edge = new Collider({\n shape: edgeShape,\n offset: { x: this.offsetX, y: this.offsetY },\n rotation: this.localRotation,\n // Material, filter and sensor flag stay mutable on the authored collider\n // and are read from there per pass, so copying them here would only add a\n // second, staler source of truth.\n density: 0,\n });\n\n edge._chainParent = this;\n edges.push(edge);\n }\n\n return edges;\n }\n\n /** @internal - mark destroyed (called by the world). */\n public _markDestroyed(): void {\n this._destroyed = true;\n\n if (this._chainEdges !== null) {\n for (const edge of this._chainEdges) {\n edge._destroyed = true;\n }\n }\n }\n}\n\n/**\n * The authored collider a contact, query hit or sweep target belongs to: the\n * collider itself, or the chain it is an engine-owned edge proxy of. Every\n * public identity - events, query results, the contact modifier - goes through\n * this, so a solver-side partition never reaches a caller.\n *\n * @internal\n */\nexport const authoredCollider = (collider: Collider): Collider => collider.chainParent ?? collider;\n"],"mappings":";;;;;;AAYA,MAAM,oBAAoB,UAA4B;CACpD,QAAQ,MAAM,MAAd;EACE,KAAK,WACH,OAAO,MAAM;EACf,KAAK;EACL,KAAK,WAEH,OAAO;EACT,KAAK;EACL,KAAK,SAGH,OAAO;CACX;AACF;;;;;;;;;;;AAgCA,IAAa,WAAb,MAAa,SAAS;;CAEpB,AAAgB;CAChB,AAAgB;CAChB,AAAgB;CAChB,AAAgB;CAEhB,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAgB;CAEhB,AAAQ,MAAM;CACd,AAAQ,QAA4B;CACpC,AAAiB;CACjB,AAAQ,eAAgC;CACxC,AAAiB;CACjB,AAAiB,kBAA6B,gBAAgB;CAC9D,AAAiB,QAAkB,WAAW;CAC9C,AAAiB,eAA0B;EAAE,GAAG;EAAG,GAAG;CAAE;CAIxD,AAAiB,eAA0B;EAAE,GAAG;EAAG,GAAG;CAAE;CACxD,AAAiB;CACjB,AAAiB;CAEjB,AAAQ,aAAa;;;;;;;;;CAUrB,AAAO,aAAa;;;;;;;;CASpB,AAAO,aAAa;CAEpB,AAAO,YAAY,SAA0B;EAC3C,MAAM,UAAU,QAAQ,WAAW;EAEnC,IAAI,CAAC,OAAO,SAAS,OAAO,KAAK,UAAU,GACzC,MAAM,IAAI,WAAW,oEAAoE,QAAQ,EAAE;EAGrG,KAAK,QAAQ,QAAQ;EACrB,KAAK,UAAU,QAAQ,QAAQ,KAAK;EACpC,KAAK,UAAU,QAAQ,QAAQ,KAAK;EACpC,KAAK,gBAAgB,QAAQ,YAAY;EACzC,KAAK,UAAU;EACf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M,QAAQ,KAAK,aACtB,KAAK,aAAa;CAGxB;AACF;;;;;;;;;AAUA,MAAa,oBAAoB,aAAiC,SAAS,eAAe"}
@@ -75,6 +75,14 @@ export declare class ContactGraph {
75
75
  readonly sensorEnter: SensorEvent[];
76
76
  /** Immutable sensor-exit snapshots produced by the latest {@link update}. */
77
77
  readonly sensorExit: SensorEvent[];
78
+ /**
79
+ * End snapshots of touching solid pairs whose collider left the world
80
+ * between detection passes. {@link update} keeps them; the world dispatches
81
+ * them ahead of the next pass's events, then calls {@link clearRemovalEnds}.
82
+ */
83
+ readonly removalCollisionEnd: CollisionEvent[];
84
+ /** Sensor counterpart of {@link removalCollisionEnd}. */
85
+ readonly removalSensorExit: SensorEvent[];
78
86
  /** Touching solid contacts this pass, in deterministic order - consumed by the solver. */
79
87
  readonly solidContacts: ContactRecord[];
80
88
  /**
@@ -91,6 +99,8 @@ export declare class ContactGraph {
91
99
  private readonly _records;
92
100
  private readonly _authoredPairs;
93
101
  private readonly _modifierContext;
102
+ private _sealedCollisionEnds;
103
+ private _sealedSensorExits;
94
104
  /** Touching pairs currently tracked (for debug draw). */
95
105
  get recordCount(): number;
96
106
  /** Diff this pass's candidate pairs against the persistent set, collecting events + solid contacts. */
@@ -104,11 +114,21 @@ export declare class ContactGraph {
104
114
  */
105
115
  applyModifier(modifier: ContactModifier): void;
106
116
  /**
107
- * Remove every record referencing `collider` (called when a collider is
108
- * destroyed). Passing an authored chain collider also drops the records of
109
- * every edge proxy it owns.
117
+ * Remove every record referencing `collider` (called when a collider leaves
118
+ * the world). Passing an authored chain collider also drops the records of
119
+ * every edge proxy it owns. A touching pair queues one end snapshot per
120
+ * authored pair into the removal buffers.
110
121
  */
111
122
  removeCollider(collider: Collider): void;
123
+ /**
124
+ * Sort the removal ends queued since the previous seal by collider ids, the
125
+ * order {@link update} gives its own events. Called once per removal while
126
+ * the removed colliders still carry the ids they were detected under, since
127
+ * a non-destructive removal resets them afterwards.
128
+ */
129
+ sealRemovalEnds(): void;
130
+ /** Forget the removal ends once they have been dispatched. */
131
+ clearRemovalEnds(): void;
112
132
  /** Drop all records (world reset/destroy). */
113
133
  clear(): void;
114
134
  private _emitBegin;
@@ -1 +1 @@
1
- {"version":3,"file":"ContactGraph.d.ts","sourceRoot":"","sources":["../../src/ContactGraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAgB,WAAW,EAAE,MAAM,UAAU,CAAC;AAI1E;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC;IACrB,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC;IACrB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,uFAAuF;IACvF,QAAQ,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,wFAAwF;IACxF,QAAQ,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,2EAA2E;IAC3E,QAAQ,CA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AED,8CAA8C;IACvC,KAAK,IAAI,IAAI,CAInB;IAED,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,QAAQ;IAYhB;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAa3B,0FAA0F;IAC1F,OAAO,CAAC,oBAAoB;IAmB5B;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;CASxB"}
@@ -31,6 +31,14 @@ var ContactGraph = class {
31
31
  sensorEnter = [];
32
32
  /** Immutable sensor-exit snapshots produced by the latest {@link update}. */
33
33
  sensorExit = [];
34
+ /**
35
+ * End snapshots of touching solid pairs whose collider left the world
36
+ * between detection passes. {@link update} keeps them; the world dispatches
37
+ * them ahead of the next pass's events, then calls {@link clearRemovalEnds}.
38
+ */
39
+ removalCollisionEnd = [];
40
+ /** Sensor counterpart of {@link removalCollisionEnd}. */
41
+ removalSensorExit = [];
34
42
  /** Touching solid contacts this pass, in deterministic order - consumed by the solver. */
35
43
  solidContacts = [];
36
44
  /**
@@ -47,6 +55,8 @@ var ContactGraph = class {
47
55
  _records = /* @__PURE__ */ new Map();
48
56
  _authoredPairs = /* @__PURE__ */ new Map();
49
57
  _modifierContext = new MutableContactModifierContext();
58
+ _sealedCollisionEnds = 0;
59
+ _sealedSensorExits = 0;
50
60
  /** Touching pairs currently tracked (for debug draw). */
51
61
  get recordCount() {
52
62
  return this._records.size;
@@ -126,20 +136,44 @@ var ContactGraph = class {
126
136
  }
127
137
  }
128
138
  /**
129
- * Remove every record referencing `collider` (called when a collider is
130
- * destroyed). Passing an authored chain collider also drops the records of
131
- * every edge proxy it owns.
139
+ * Remove every record referencing `collider` (called when a collider leaves
140
+ * the world). Passing an authored chain collider also drops the records of
141
+ * every edge proxy it owns. A touching pair queues one end snapshot per
142
+ * authored pair into the removal buffers.
132
143
  */
133
144
  removeCollider(collider) {
134
145
  for (const [key, record] of this._records) if (record.a === collider || record.b === collider || record.ownerA === collider || record.ownerB === collider) {
135
- if (record.touching) this._releaseAuthoredPair(record);
146
+ if (record.touching && this._releaseAuthoredPair(record)) {
147
+ if (record.isSensor) this.removalSensorExit.push(makeSensorEvent(record.ownerA, record.ownerB));
148
+ else this.removalCollisionEnd.push(makeEndEvent(record.ownerA, record.ownerB));
149
+ }
136
150
  this._records.delete(key);
137
151
  }
138
152
  }
153
+ /**
154
+ * Sort the removal ends queued since the previous seal by collider ids, the
155
+ * order {@link update} gives its own events. Called once per removal while
156
+ * the removed colliders still carry the ids they were detected under, since
157
+ * a non-destructive removal resets them afterwards.
158
+ */
159
+ sealRemovalEnds() {
160
+ sortTail(this.removalCollisionEnd, this._sealedCollisionEnds, byColliderPair);
161
+ sortTail(this.removalSensorExit, this._sealedSensorExits, bySensorPair);
162
+ this._sealedCollisionEnds = this.removalCollisionEnd.length;
163
+ this._sealedSensorExits = this.removalSensorExit.length;
164
+ }
165
+ /** Forget the removal ends once they have been dispatched. */
166
+ clearRemovalEnds() {
167
+ this.removalCollisionEnd.length = 0;
168
+ this.removalSensorExit.length = 0;
169
+ this._sealedCollisionEnds = 0;
170
+ this._sealedSensorExits = 0;
171
+ }
139
172
  /** Drop all records (world reset/destroy). */
140
173
  clear() {
141
174
  this._records.clear();
142
175
  this._authoredPairs.clear();
176
+ this.clearRemovalEnds();
143
177
  }
144
178
  _emitBegin(record) {
145
179
  if (!this._retainAuthoredPair(record)) return;
@@ -336,6 +370,13 @@ const makeSensorEvent = (a, b) => {
336
370
  const byColliderPair = (x, y) => x.colliderA.id - y.colliderA.id || x.colliderB.id - y.colliderB.id;
337
371
  const bySensorPair = (x, y) => x.sensor.id - y.sensor.id || x.other.id - y.other.id;
338
372
  const byRecordPair = (x, y) => x.a.id - y.a.id || x.b.id - y.b.id;
373
+ /** Sort `items[from..]` in place. Removal is not a per-step path, so the splice is acceptable. */
374
+ const sortTail = (items, from, compare) => {
375
+ if (items.length - from < 2) return;
376
+ const tail = items.splice(from);
377
+ tail.sort(compare);
378
+ items.push(...tail);
379
+ };
339
380
 
340
381
  //#endregion
341
382
  export { ContactGraph, bodyPairKey, pairKey, pairKeyStride };
@@ -1 +1 @@
1
- {"version":3,"file":"ContactGraph.js","names":[],"sources":["../../src/ContactGraph.ts"],"sourcesContent":["import type { CandidatePair } from './broadphase/BroadPhase';\nimport type { Collider } from './Collider';\nimport { authoredCollider } from './Collider';\nimport { Manifold } from './collision/Manifold';\nimport { collide, testOverlap } from './collision/narrowphase';\nimport type { ContactModifier } from './ContactModifier';\nimport { MutableContactModifierContext } from './ContactModifier';\nimport type { CollisionEvent, ContactPoint, SensorEvent } from './events';\nimport { sortInPlace } from './sort';\nimport { shouldCollide } from './types';\n\n/**\n * Persistent per-pair contact state. For solid contacts it carries a manifold\n * reused across passes plus the accumulated normal/tangent impulses (warm-start\n * cache), keyed by manifold-point feature ids. Consumed by the {@link ContactSolver}.\n */\nexport interface ContactRecord {\n readonly a: Collider;\n readonly b: Collider;\n /**\n * Authored collider behind {@link a} - itself, unless `a` is an engine-owned\n * chain edge proxy, in which case it is the chain collider the caller made.\n * Solver identity is the proxy pair; public identity is the authored pair.\n */\n readonly ownerA: Collider;\n readonly ownerB: Collider;\n readonly isSensor: boolean;\n touching: boolean;\n seen: boolean;\n /**\n * Per-step solver participation. Re-derived to `true` for every touching solid\n * contact each pass, then optionally cleared by the world's `ContactModifier`.\n */\n enabled: boolean;\n /** Per-step Coulomb friction, re-derived from the two colliders each pass. */\n friction: number;\n /** Per-step restitution, re-derived from the two colliders each pass. */\n restitution: number;\n /** Persistent manifold (solid contacts), refreshed each pass by the narrow phase. */\n readonly manifold: Manifold;\n /** Accumulated normal impulse per contact point, carried across steps (warm-start). */\n readonly normalImpulse: [number, number];\n /** Accumulated tangent impulse per contact point, carried across steps (warm-start). */\n readonly tangentImpulse: [number, number];\n /** Feature ids the cached impulses belong to (for warm-start matching). */\n readonly pointIds: [number, number];\n /**\n * Penetration each point carried on the previous detection pass, matched by\n * feature id the same way the impulse cache is, or `-1` where the point is new\n * and has no history. The difference against the manifold's current\n * penetration is how much the last solve actually moved the overlap, which is\n * what separates a contact the push-out is still working off from one that has\n * reached the depth its load holds it at.\n */\n readonly previousPenetration: [number, number];\n /** Penetration per point as of this pass, kept so the next pass can form that difference. */\n readonly pointPenetration: [number, number];\n}\n\n/**\n * The persistent contact set. Each detection pass it diffs the currently\n * touching collider pairs against the previous pass and produces immutable\n * begin/end (and sensor enter/exit) event snapshots. Duplicate begin/end churn\n * is suppressed by the persistent records, and the produced event arrays are\n * sorted by collider id for deterministic dispatch.\n *\n * Touching solid contacts are also collected into {@link solidContacts} (with a\n * warm-start impulse cache) for the dynamics solver. The graph holds no\n * module-level state - each world owns one.\n *\n * Records are keyed on the pair the solver sees, which for a chain collider is\n * one of its edge proxies. Events are not: a body touching several edges of one\n * chain is one authored contact, so the graph reference-counts the authored pair\n * behind its records and emits begin/end only on the first and last of them.\n */\nexport class ContactGraph {\n /** Immutable solid-contact begin snapshots produced by the latest {@link update}. */\n public readonly collisionStart: CollisionEvent[] = [];\n /** Immutable solid-contact end snapshots produced by the latest {@link update}. */\n public readonly collisionEnd: CollisionEvent[] = [];\n /** Immutable sensor-enter snapshots produced by the latest {@link update}. */\n public readonly sensorEnter: SensorEvent[] = [];\n /** Immutable sensor-exit snapshots produced by the latest {@link update}. */\n public readonly sensorExit: SensorEvent[] = [];\n /** Touching solid contacts this pass, in deterministic order - consumed by the solver. */\n public readonly solidContacts: ContactRecord[] = [];\n\n // Integer pair-keys (`(a.id << 16) | b.id`, a.id < b.id guaranteed by the broad\n // phase) - cheaper than string keys on the per-step solver hot path.\n /**\n * Body pairs a joint has taken out of collision, keyed by\n * {@link bodyPairKey} and reference-counted by the world; `null` until a world\n * hands its own map over.\n *\n * Consulted here rather than in the solver because the cheapest contact is\n * the one the narrow phase never computes: a chain of N links otherwise pays\n * for N-1 manifolds, warm-start slots and event records per step that nothing\n * is allowed to act on.\n */\n private _uncollidablePairs: ReadonlyMap<number, number> | null = null;\n\n private readonly _records = new Map<number, ContactRecord>();\n // Live solver contacts per authored collider pair. Only pairs whose records\n // are engine-owned proxies appear here; everything else emits directly.\n private readonly _authoredPairs = new Map<number, number>();\n private readonly _modifierContext = new MutableContactModifierContext();\n\n /** Touching pairs currently tracked (for debug draw). */\n public get recordCount(): number {\n return this._records.size;\n }\n\n /** @internal - adopt the world's joint-filtered body pairs; see {@link _uncollidablePairs}. */\n public _useUncollidablePairs(pairs: ReadonlyMap<number, number>): void {\n this._uncollidablePairs = pairs;\n }\n\n /** Diff this pass's candidate pairs against the persistent set, collecting events + solid contacts. */\n public update(pairs: readonly CandidatePair[]): void {\n this.collisionStart.length = 0;\n this.collisionEnd.length = 0;\n this.sensorEnter.length = 0;\n this.sensorExit.length = 0;\n this.solidContacts.length = 0;\n\n this._records.forEach(resetSeen);\n\n for (const pair of pairs) {\n const a = pair.a;\n const b = pair.b;\n\n // Material, filter and sensor flag live on the authored collider; an edge\n // proxy carries none of its own, so a chain stays one collider to configure.\n const ownerA = authoredCollider(a);\n const ownerB = authoredCollider(b);\n\n if (!shouldCollide(ownerA.filter, ownerB.filter)) {\n continue;\n }\n\n // Checked against the size first so a world without such a joint pays one\n // property read per pair rather than a map lookup.\n if (this._uncollidablePairs !== null && this._uncollidablePairs.size > 0 && this._uncollidablePairs.has(bodyPairKey(ownerA.body.id, ownerB.body.id))) {\n continue;\n }\n\n const isSensor = ownerA.isSensor || ownerB.isSensor;\n const key = pairKey(a.id, b.id);\n const existing = this._records.get(key);\n const record = existing ?? createRecord(a, b, ownerA, ownerB, isSensor);\n const touching = isSensor ? testOverlap(a, b) : collide(a, b, record.manifold);\n\n if (touching) {\n record.seen = true;\n\n if (existing === undefined) {\n this._records.set(key, record);\n }\n\n if (!record.touching) {\n record.touching = true;\n this._emitBegin(record);\n }\n\n if (!isSensor) {\n // Per-step controls start from the collider-derived defaults every\n // pass, so a modifier that skipped a contact last step does not leak\n // into this one.\n record.enabled = true;\n record.friction = Math.sqrt(ownerA.friction * ownerB.friction);\n record.restitution = Math.max(ownerA.restitution, ownerB.restitution);\n warmStartMatch(record);\n this.solidContacts.push(record);\n }\n } else if (existing !== undefined) {\n if (record.touching) {\n this._emitEnd(record);\n }\n\n this._records.delete(key);\n }\n }\n\n // Pairs that left the broad phase entirely while touching → fire end. forEach\n // + thisArg is the allocation-free iteration (for...of allocates an entry tuple\n // per record each step); the thisArg binds `this`, so unbound-method is a\n // false positive here.\n // eslint-disable-next-line @typescript-eslint/unbound-method -- the thisArg above binds it\n this._records.forEach(this._removeIfUnseen, this);\n\n sortInPlace(this.collisionStart, byColliderPair);\n sortInPlace(this.collisionEnd, byColliderPair);\n sortInPlace(this.sensorEnter, bySensorPair);\n sortInPlace(this.sensorExit, bySensorPair);\n sortInPlace(this.solidContacts, byRecordPair);\n }\n\n /**\n * Run `modifier` over every touching solid contact of this pass. Called after\n * detection and before island building, so a contact the modifier disables\n * neither reaches the solver nor couples its two bodies into one sleeping\n * island. A disabled contact's warm-start cache is dropped, so re-enabling it\n * later starts from zero instead of releasing a stale impulse.\n */\n public applyModifier(modifier: ContactModifier): void {\n const context = this._modifierContext;\n\n for (const record of this.solidContacts) {\n context.bind(record);\n modifier(context);\n context.flush(record);\n\n if (!record.enabled) {\n record.normalImpulse[0] = 0;\n record.normalImpulse[1] = 0;\n record.tangentImpulse[0] = 0;\n record.tangentImpulse[1] = 0;\n record.pointIds[0] = 0;\n record.pointIds[1] = 0;\n // Same reasoning for the penetration history: a contact that carried no\n // impulse this step did not move its overlap, so the next pass must read\n // the point as new rather than as one whose push-out has converged.\n record.pointPenetration[0] = -1;\n record.pointPenetration[1] = -1;\n }\n }\n }\n\n /**\n * Remove every record referencing `collider` (called when a collider is\n * destroyed). Passing an authored chain collider also drops the records of\n * every edge proxy it owns.\n */\n public removeCollider(collider: Collider): void {\n for (const [key, record] of this._records) {\n if (record.a === collider || record.b === collider || record.ownerA === collider || record.ownerB === collider) {\n if (record.touching) {\n this._releaseAuthoredPair(record);\n }\n\n this._records.delete(key);\n }\n }\n }\n\n /** Drop all records (world reset/destroy). */\n public clear(): void {\n this._records.clear();\n this._authoredPairs.clear();\n }\n\n private _emitBegin(record: ContactRecord): void {\n if (!this._retainAuthoredPair(record)) {\n return;\n }\n\n if (record.isSensor) {\n this.sensorEnter.push(makeSensorEvent(record.ownerA, record.ownerB));\n } else {\n this.collisionStart.push(makeCollisionEvent(record.ownerA, record.ownerB, record.manifold));\n }\n }\n\n private _emitEnd(record: ContactRecord): void {\n if (!this._releaseAuthoredPair(record)) {\n return;\n }\n\n if (record.isSensor) {\n this.sensorExit.push(makeSensorEvent(record.ownerA, record.ownerB));\n } else {\n this.collisionEnd.push(makeEndEvent(record.ownerA, record.ownerB));\n }\n }\n\n /**\n * Count one more solver contact against the authored pair, reporting whether\n * it is the first - the only one that may emit a begin event. A record whose\n * colliders are the authored ones needs no counting at all, so a world without\n * chains never touches the map.\n */\n private _retainAuthoredPair(record: ContactRecord): boolean {\n if (record.a === record.ownerA && record.b === record.ownerB) {\n return true;\n }\n\n const key = authoredPairKey(record);\n const count = this._authoredPairs.get(key) ?? 0;\n\n this._authoredPairs.set(key, count + 1);\n\n return count === 0;\n }\n\n /** Counterpart of {@link _retainAuthoredPair}: `true` on the last contact of the pair. */\n private _releaseAuthoredPair(record: ContactRecord): boolean {\n if (record.a === record.ownerA && record.b === record.ownerB) {\n return true;\n }\n\n const key = authoredPairKey(record);\n const count = (this._authoredPairs.get(key) ?? 1) - 1;\n\n if (count <= 0) {\n this._authoredPairs.delete(key);\n\n return true;\n }\n\n this._authoredPairs.set(key, count);\n\n return false;\n }\n\n /**\n * `Map.forEach` callback (its `this` bound via the forEach thisArg) - drops a\n * record the latest pass did not see, firing an end event if it was touching.\n * A method reference + thisArg keeps the per-step iteration allocation-free,\n * unlike `for (const [key, record] of map)` which allocates an entry tuple per\n * record (~1000/step). Deleting the current entry during forEach is safe.\n */\n private _removeIfUnseen(record: ContactRecord, key: number): void {\n if (!record.seen) {\n if (record.touching) {\n this._emitEnd(record);\n }\n\n this._records.delete(key);\n }\n }\n}\n\n/** `Map.forEach` callback - clears the per-pass `seen` flag (no iterator allocation). */\nconst resetSeen = (record: ContactRecord): void => {\n record.seen = false;\n};\n\n/**\n * Stride for packing two collider ids into one pair key. Multiplying by this\n * (rather than a 32-bit `<<`) keeps the key collision-free up to ~67M (2^26)\n * ids per world, within JS's 2^53 safe-integer range.\n * @internal\n */\nexport const pairKeyStride = 0x4000000; // 2^26\n\n/**\n * Integer key for an unordered collider pair (`aId < bId` is guaranteed by the\n * broad phase). The previous `(aId << 16) | bId` silently collided once any id\n * reached 65536, because JS bitwise operators wrap at 32 bits.\n * @internal\n */\nexport const pairKey = (aId: number, bId: number): number => aId * pairKeyStride + bId;\n\n/**\n * Integer key for an unordered BODY pair, which unlike a collider pair arrives\n * in no guaranteed order.\n * @internal\n */\nexport const bodyPairKey = (aId: number, bId: number): number => (aId < bId ? pairKey(aId, bId) : pairKey(bId, aId));\n\nconst authoredPairKey = (record: ContactRecord): number => {\n const first = record.ownerA.id;\n const second = record.ownerB.id;\n\n return first < second ? pairKey(first, second) : pairKey(second, first);\n};\n\nconst createRecord = (a: Collider, b: Collider, ownerA: Collider, ownerB: Collider, isSensor: boolean): ContactRecord => ({\n a,\n b,\n ownerA,\n ownerB,\n isSensor,\n touching: false,\n seen: true,\n enabled: true,\n friction: 0,\n restitution: 0,\n manifold: new Manifold(),\n normalImpulse: [0, 0],\n tangentImpulse: [0, 0],\n pointIds: [0, 0],\n previousPenetration: [-1, -1],\n pointPenetration: [-1, -1],\n});\n\n/**\n * Map the previously accumulated impulses onto the new manifold points by feature\n * id (warm-starting), and carry each point's previous penetration across the same\n * match. Unmatched points start at zero impulse and at no penetration history;\n * the cache is re-keyed to the new ids. Runs after `collide` has refreshed\n * `record.manifold`.\n */\nconst warmStartMatch = (record: ContactRecord): void => {\n const manifold = record.manifold;\n const pn0 = record.normalImpulse[0];\n const pn1 = record.normalImpulse[1];\n const pt0 = record.tangentImpulse[0];\n const pt1 = record.tangentImpulse[1];\n const pd0 = record.pointPenetration[0];\n const pd1 = record.pointPenetration[1];\n const pid0 = record.pointIds[0];\n const pid1 = record.pointIds[1];\n\n for (let i = 0; i < 2; i++) {\n if (i < manifold.pointCount) {\n // i ∈ {0,1} and within pointCount, so the manifold point exists.\n const point = i === 0 ? manifold.points[0] : manifold.points[1];\n const id = point.id;\n let normal = 0;\n let tangent = 0;\n let previous = -1;\n\n if (id === pid0) {\n normal = pn0;\n tangent = pt0;\n previous = pd0;\n } else if (id === pid1) {\n normal = pn1;\n tangent = pt1;\n previous = pd1;\n }\n\n record.normalImpulse[i] = normal;\n record.tangentImpulse[i] = tangent;\n record.previousPenetration[i] = previous;\n record.pointPenetration[i] = point.penetration;\n record.pointIds[i] = id;\n } else {\n record.normalImpulse[i] = 0;\n record.tangentImpulse[i] = 0;\n record.previousPenetration[i] = -1;\n record.pointPenetration[i] = -1;\n record.pointIds[i] = 0;\n }\n }\n};\n\nconst makeCollisionEvent = (a: Collider, b: Collider, manifold: Manifold): CollisionEvent => {\n const points: ContactPoint[] = [];\n\n for (let i = 0; i < manifold.pointCount; i++) {\n // i in 0..pointCount-1 and pointCount ≤ 2, so the manifold point exists.\n const p = i === 0 ? manifold.points[0] : manifold.points[1];\n\n points.push(Object.freeze({ x: p.x, y: p.y, penetration: p.penetration }));\n }\n\n return Object.freeze({\n bodyA: a.body,\n bodyB: b.body,\n colliderA: a,\n colliderB: b,\n normal: Object.freeze({ x: manifold.normalX, y: manifold.normalY }),\n points: Object.freeze(points),\n });\n};\n\nconst makeEndEvent = (a: Collider, b: Collider): CollisionEvent =>\n Object.freeze({\n bodyA: a.body,\n bodyB: b.body,\n colliderA: a,\n colliderB: b,\n normal: Object.freeze({ x: 0, y: 0 }),\n points: Object.freeze([] as ContactPoint[]),\n });\n\nconst makeSensorEvent = (a: Collider, b: Collider): SensorEvent => {\n let sensor: Collider;\n let other: Collider;\n\n if (a.isSensor && b.isSensor) {\n sensor = a.id < b.id ? a : b;\n other = sensor === a ? b : a;\n } else if (a.isSensor) {\n sensor = a;\n other = b;\n } else {\n sensor = b;\n other = a;\n }\n\n return Object.freeze({ sensor, other });\n};\n\nconst byColliderPair = (x: CollisionEvent, y: CollisionEvent): number => x.colliderA.id - y.colliderA.id || x.colliderB.id - y.colliderB.id;\n\nconst bySensorPair = (x: SensorEvent, y: SensorEvent): number => x.sensor.id - y.sensor.id || x.other.id - y.other.id;\n\nconst byRecordPair = (x: ContactRecord, y: ContactRecord): number => x.a.id - y.a.id || x.b.id - y.b.id;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2EA,IAAa,eAAb,MAA0B;;CAExB,AAAgB,iBAAmC,CAAC;;CAEpD,AAAgB,eAAiC,CAAC;;CAElD,AAAgB,cAA6B,CAAC;;CAE9C,AAAgB,aAA4B,CAAC;;CAE7C,AAAgB,gBAAiC,CAAC;;;;;;;;;;;CAclD,AAAQ,qBAAyD;CAEjE,AAAiB,2BAAW,IAAI,IAA2B;CAG3D,AAAiB,iCAAiB,IAAI,IAAoB;CAC1D,AAAiB,mBAAmB,IAAI,8BAA8B;;CAGtE,IAAW,cAAsB;EAC/B,OAAO,KAAK,SAAS;CACvB;;CAGA,AAAO,sBAAsB,OAA0C;EACrE,KAAK,qBAAqB;CAC5B;;CAGA,AAAO,OAAO,OAAuC;EACnD,KAAK,eAAe,SAAS;EAC7B,KAAK,aAAa,SAAS;EAC3B,KAAK,YAAY,SAAS;EAC1B,KAAK,WAAW,SAAS;EACzB,KAAK,cAAc,SAAS;EAE5B,KAAK,SAAS,QAAQ,SAAS;EAE/B,KAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,IAAI,KAAK;GACf,MAAM,IAAI,KAAK;GAIf,MAAM,SAAS,iBAAiB,CAAC;GACjC,MAAM,SAAS,iBAAiB,CAAC;GAEjC,IAAI,CAAC,cAAc,OAAO,QAAQ,OAAO,MAAM,GAC7C;GAKF,IAAI,KAAK,uBAAuB,QAAQ,KAAK,mBAAmB,OAAO,KAAK,KAAK,mBAAmB,IAAI,YAAY,OAAO,KAAK,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AW;EACX,WAAW;EACX,QAAQ,OAAO,OAAO;GAAE,GAAG,SAAS;GAAS,GAAG,SAAS;EAAQ,CAAC;EAClE,QAAQ,OAAO,OAAO,MAAM;CAC9B,CAAC;AACH;AAEA,MAAM,gBAAgB,GAAa,MACjC,OAAO,OAAO;CACZ,OAAO,EAAE;CACT,OAAO,EAAE;CACT,WAAW;CACX,WAAW;CACX,QAAQ,OAAO,OAAO;EAAE,GAAG;EAAG,GAAG;CAAE,CAAC;CACpC,QAAQ,OAAO,OAAO,CAAC,CAAmB;AAC5C,CAAC;AAEH,MAAM,mBAAmB,GAAa,MAA6B;CACjE,IAAI;CACJ,IAAI;CAEJ,IAAI,EAAE,YAAY,EAAE,UAAU;EAC5B,SAAS,EAAE,KAAK,EAAE,KAAK,IAAI;EAC3B,QAAQ,WAAW,IAAI,IAAI;CAC7B,OAAO,IAAI,EAAE,UAAU;EACrB,SAAS;EACT,QAAQ;CACV,OAAO;EACL,SAAS;EACT,QAAQ;CACV;CAEA,OAAO,OAAO,OAAO;EAAE;EAAQ;CAAM,CAAC;AACxC;AAEA,MAAM,kBAAkB,GAAmB,MAA8B,EAAE,UAAU,KAAK,EAAE,UAAU,MAAM,EAAE,UAAU,KAAK,EAAE,UAAU;AAEzI,MAAM,gBAAgB,GAAgB,MAA2B,EAAE,OAAO,KAAK,EAAE,OAAO,MAAM,EAAE,MAAM,KAAK,EAAE,MAAM;AAEnH,MAAM,gBAAgB,GAAkB,MAA6B,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE"}
1
+ {"version":3,"file":"ContactGraph.js","names":[],"sources":["../../src/ContactGraph.ts"],"sourcesContent":["import type { CandidatePair } from './broadphase/BroadPhase';\nimport type { Collider } from './Collider';\nimport { authoredCollider } from './Collider';\nimport { Manifold } from './collision/Manifold';\nimport { collide, testOverlap } from './collision/narrowphase';\nimport type { ContactModifier } from './ContactModifier';\nimport { MutableContactModifierContext } from './ContactModifier';\nimport type { CollisionEvent, ContactPoint, SensorEvent } from './events';\nimport { sortInPlace } from './sort';\nimport { shouldCollide } from './types';\n\n/**\n * Persistent per-pair contact state. For solid contacts it carries a manifold\n * reused across passes plus the accumulated normal/tangent impulses (warm-start\n * cache), keyed by manifold-point feature ids. Consumed by the {@link ContactSolver}.\n */\nexport interface ContactRecord {\n readonly a: Collider;\n readonly b: Collider;\n /**\n * Authored collider behind {@link a} - itself, unless `a` is an engine-owned\n * chain edge proxy, in which case it is the chain collider the caller made.\n * Solver identity is the proxy pair; public identity is the authored pair.\n */\n readonly ownerA: Collider;\n readonly ownerB: Collider;\n readonly isSensor: boolean;\n touching: boolean;\n seen: boolean;\n /**\n * Per-step solver participation. Re-derived to `true` for every touching solid\n * contact each pass, then optionally cleared by the world's `ContactModifier`.\n */\n enabled: boolean;\n /** Per-step Coulomb friction, re-derived from the two colliders each pass. */\n friction: number;\n /** Per-step restitution, re-derived from the two colliders each pass. */\n restitution: number;\n /** Persistent manifold (solid contacts), refreshed each pass by the narrow phase. */\n readonly manifold: Manifold;\n /** Accumulated normal impulse per contact point, carried across steps (warm-start). */\n readonly normalImpulse: [number, number];\n /** Accumulated tangent impulse per contact point, carried across steps (warm-start). */\n readonly tangentImpulse: [number, number];\n /** Feature ids the cached impulses belong to (for warm-start matching). */\n readonly pointIds: [number, number];\n /**\n * Penetration each point carried on the previous detection pass, matched by\n * feature id the same way the impulse cache is, or `-1` where the point is new\n * and has no history. The difference against the manifold's current\n * penetration is how much the last solve actually moved the overlap, which is\n * what separates a contact the push-out is still working off from one that has\n * reached the depth its load holds it at.\n */\n readonly previousPenetration: [number, number];\n /** Penetration per point as of this pass, kept so the next pass can form that difference. */\n readonly pointPenetration: [number, number];\n}\n\n/**\n * The persistent contact set. Each detection pass it diffs the currently\n * touching collider pairs against the previous pass and produces immutable\n * begin/end (and sensor enter/exit) event snapshots. Duplicate begin/end churn\n * is suppressed by the persistent records, and the produced event arrays are\n * sorted by collider id for deterministic dispatch.\n *\n * Touching solid contacts are also collected into {@link solidContacts} (with a\n * warm-start impulse cache) for the dynamics solver. The graph holds no\n * module-level state - each world owns one.\n *\n * Records are keyed on the pair the solver sees, which for a chain collider is\n * one of its edge proxies. Events are not: a body touching several edges of one\n * chain is one authored contact, so the graph reference-counts the authored pair\n * behind its records and emits begin/end only on the first and last of them.\n */\nexport class ContactGraph {\n /** Immutable solid-contact begin snapshots produced by the latest {@link update}. */\n public readonly collisionStart: CollisionEvent[] = [];\n /** Immutable solid-contact end snapshots produced by the latest {@link update}. */\n public readonly collisionEnd: CollisionEvent[] = [];\n /** Immutable sensor-enter snapshots produced by the latest {@link update}. */\n public readonly sensorEnter: SensorEvent[] = [];\n /** Immutable sensor-exit snapshots produced by the latest {@link update}. */\n public readonly sensorExit: SensorEvent[] = [];\n /**\n * End snapshots of touching solid pairs whose collider left the world\n * between detection passes. {@link update} keeps them; the world dispatches\n * them ahead of the next pass's events, then calls {@link clearRemovalEnds}.\n */\n public readonly removalCollisionEnd: CollisionEvent[] = [];\n /** Sensor counterpart of {@link removalCollisionEnd}. */\n public readonly removalSensorExit: SensorEvent[] = [];\n /** Touching solid contacts this pass, in deterministic order - consumed by the solver. */\n public readonly solidContacts: ContactRecord[] = [];\n\n // Integer pair-keys (`(a.id << 16) | b.id`, a.id < b.id guaranteed by the broad\n // phase) - cheaper than string keys on the per-step solver hot path.\n /**\n * Body pairs a joint has taken out of collision, keyed by\n * {@link bodyPairKey} and reference-counted by the world; `null` until a world\n * hands its own map over.\n *\n * Consulted here rather than in the solver because the cheapest contact is\n * the one the narrow phase never computes: a chain of N links otherwise pays\n * for N-1 manifolds, warm-start slots and event records per step that nothing\n * is allowed to act on.\n */\n private _uncollidablePairs: ReadonlyMap<number, number> | null = null;\n\n private readonly _records = new Map<number, ContactRecord>();\n // Live solver contacts per authored collider pair. Only pairs whose records\n // are engine-owned proxies appear here; everything else emits directly.\n private readonly _authoredPairs = new Map<number, number>();\n private readonly _modifierContext = new MutableContactModifierContext();\n // How much of each removal buffer is already sorted; see sealRemovalEnds.\n private _sealedCollisionEnds = 0;\n private _sealedSensorExits = 0;\n\n /** Touching pairs currently tracked (for debug draw). */\n public get recordCount(): number {\n return this._records.size;\n }\n\n /** @internal - adopt the world's joint-filtered body pairs; see {@link _uncollidablePairs}. */\n public _useUncollidablePairs(pairs: ReadonlyMap<number, number>): void {\n this._uncollidablePairs = pairs;\n }\n\n /** Diff this pass's candidate pairs against the persistent set, collecting events + solid contacts. */\n public update(pairs: readonly CandidatePair[]): void {\n this.collisionStart.length = 0;\n this.collisionEnd.length = 0;\n this.sensorEnter.length = 0;\n this.sensorExit.length = 0;\n this.solidContacts.length = 0;\n\n this._records.forEach(resetSeen);\n\n for (const pair of pairs) {\n const a = pair.a;\n const b = pair.b;\n\n // Material, filter and sensor flag live on the authored collider; an edge\n // proxy carries none of its own, so a chain stays one collider to configure.\n const ownerA = authoredCollider(a);\n const ownerB = authoredCollider(b);\n\n if (!shouldCollide(ownerA.filter, ownerB.filter)) {\n continue;\n }\n\n // Checked against the size first so a world without such a joint pays one\n // property read per pair rather than a map lookup.\n if (this._uncollidablePairs !== null && this._uncollidablePairs.size > 0 && this._uncollidablePairs.has(bodyPairKey(ownerA.body.id, ownerB.body.id))) {\n continue;\n }\n\n const isSensor = ownerA.isSensor || ownerB.isSensor;\n const key = pairKey(a.id, b.id);\n const existing = this._records.get(key);\n const record = existing ?? createRecord(a, b, ownerA, ownerB, isSensor);\n const touching = isSensor ? testOverlap(a, b) : collide(a, b, record.manifold);\n\n if (touching) {\n record.seen = true;\n\n if (existing === undefined) {\n this._records.set(key, record);\n }\n\n if (!record.touching) {\n record.touching = true;\n this._emitBegin(record);\n }\n\n if (!isSensor) {\n // Per-step controls start from the collider-derived defaults every\n // pass, so a modifier that skipped a contact last step does not leak\n // into this one.\n record.enabled = true;\n record.friction = Math.sqrt(ownerA.friction * ownerB.friction);\n record.restitution = Math.max(ownerA.restitution, ownerB.restitution);\n warmStartMatch(record);\n this.solidContacts.push(record);\n }\n } else if (existing !== undefined) {\n if (record.touching) {\n this._emitEnd(record);\n }\n\n this._records.delete(key);\n }\n }\n\n // Pairs that left the broad phase entirely while touching → fire end. forEach\n // + thisArg is the allocation-free iteration (for...of allocates an entry tuple\n // per record each step); the thisArg binds `this`, so unbound-method is a\n // false positive here.\n // eslint-disable-next-line @typescript-eslint/unbound-method -- the thisArg above binds it\n this._records.forEach(this._removeIfUnseen, this);\n\n sortInPlace(this.collisionStart, byColliderPair);\n sortInPlace(this.collisionEnd, byColliderPair);\n sortInPlace(this.sensorEnter, bySensorPair);\n sortInPlace(this.sensorExit, bySensorPair);\n sortInPlace(this.solidContacts, byRecordPair);\n }\n\n /**\n * Run `modifier` over every touching solid contact of this pass. Called after\n * detection and before island building, so a contact the modifier disables\n * neither reaches the solver nor couples its two bodies into one sleeping\n * island. A disabled contact's warm-start cache is dropped, so re-enabling it\n * later starts from zero instead of releasing a stale impulse.\n */\n public applyModifier(modifier: ContactModifier): void {\n const context = this._modifierContext;\n\n for (const record of this.solidContacts) {\n context.bind(record);\n modifier(context);\n context.flush(record);\n\n if (!record.enabled) {\n record.normalImpulse[0] = 0;\n record.normalImpulse[1] = 0;\n record.tangentImpulse[0] = 0;\n record.tangentImpulse[1] = 0;\n record.pointIds[0] = 0;\n record.pointIds[1] = 0;\n // Same reasoning for the penetration history: a contact that carried no\n // impulse this step did not move its overlap, so the next pass must read\n // the point as new rather than as one whose push-out has converged.\n record.pointPenetration[0] = -1;\n record.pointPenetration[1] = -1;\n }\n }\n }\n\n /**\n * Remove every record referencing `collider` (called when a collider leaves\n * the world). Passing an authored chain collider also drops the records of\n * every edge proxy it owns. A touching pair queues one end snapshot per\n * authored pair into the removal buffers.\n */\n public removeCollider(collider: Collider): void {\n for (const [key, record] of this._records) {\n if (record.a === collider || record.b === collider || record.ownerA === collider || record.ownerB === collider) {\n if (record.touching && this._releaseAuthoredPair(record)) {\n if (record.isSensor) {\n this.removalSensorExit.push(makeSensorEvent(record.ownerA, record.ownerB));\n } else {\n this.removalCollisionEnd.push(makeEndEvent(record.ownerA, record.ownerB));\n }\n }\n\n this._records.delete(key);\n }\n }\n }\n\n /**\n * Sort the removal ends queued since the previous seal by collider ids, the\n * order {@link update} gives its own events. Called once per removal while\n * the removed colliders still carry the ids they were detected under, since\n * a non-destructive removal resets them afterwards.\n */\n public sealRemovalEnds(): void {\n sortTail(this.removalCollisionEnd, this._sealedCollisionEnds, byColliderPair);\n sortTail(this.removalSensorExit, this._sealedSensorExits, bySensorPair);\n this._sealedCollisionEnds = this.removalCollisionEnd.length;\n this._sealedSensorExits = this.removalSensorExit.length;\n }\n\n /** Forget the removal ends once they have been dispatched. */\n public clearRemovalEnds(): void {\n this.removalCollisionEnd.length = 0;\n this.removalSensorExit.length = 0;\n this._sealedCollisionEnds = 0;\n this._sealedSensorExits = 0;\n }\n\n /** Drop all records (world reset/destroy). */\n public clear(): void {\n this._records.clear();\n this._authoredPairs.clear();\n this.clearRemovalEnds();\n }\n\n private _emitBegin(record: ContactRecord): void {\n if (!this._retainAuthoredPair(record)) {\n return;\n }\n\n if (record.isSensor) {\n this.sensorEnter.push(makeSensorEvent(record.ownerA, record.ownerB));\n } else {\n this.collisionStart.push(makeCollisionEvent(record.ownerA, record.ownerB, record.manifold));\n }\n }\n\n private _emitEnd(record: ContactRecord): void {\n if (!this._releaseAuthoredPair(record)) {\n return;\n }\n\n if (record.isSensor) {\n this.sensorExit.push(makeSensorEvent(record.ownerA, record.ownerB));\n } else {\n this.collisionEnd.push(makeEndEvent(record.ownerA, record.ownerB));\n }\n }\n\n /**\n * Count one more solver contact against the authored pair, reporting whether\n * it is the first - the only one that may emit a begin event. A record whose\n * colliders are the authored ones needs no counting at all, so a world without\n * chains never touches the map.\n */\n private _retainAuthoredPair(record: ContactRecord): boolean {\n if (record.a === record.ownerA && record.b === record.ownerB) {\n return true;\n }\n\n const key = authoredPairKey(record);\n const count = this._authoredPairs.get(key) ?? 0;\n\n this._authoredPairs.set(key, count + 1);\n\n return count === 0;\n }\n\n /** Counterpart of {@link _retainAuthoredPair}: `true` on the last contact of the pair. */\n private _releaseAuthoredPair(record: ContactRecord): boolean {\n if (record.a === record.ownerA && record.b === record.ownerB) {\n return true;\n }\n\n const key = authoredPairKey(record);\n const count = (this._authoredPairs.get(key) ?? 1) - 1;\n\n if (count <= 0) {\n this._authoredPairs.delete(key);\n\n return true;\n }\n\n this._authoredPairs.set(key, count);\n\n return false;\n }\n\n /**\n * `Map.forEach` callback (its `this` bound via the forEach thisArg) - drops a\n * record the latest pass did not see, firing an end event if it was touching.\n * A method reference + thisArg keeps the per-step iteration allocation-free,\n * unlike `for (const [key, record] of map)` which allocates an entry tuple per\n * record (~1000/step). Deleting the current entry during forEach is safe.\n */\n private _removeIfUnseen(record: ContactRecord, key: number): void {\n if (!record.seen) {\n if (record.touching) {\n this._emitEnd(record);\n }\n\n this._records.delete(key);\n }\n }\n}\n\n/** `Map.forEach` callback - clears the per-pass `seen` flag (no iterator allocation). */\nconst resetSeen = (record: ContactRecord): void => {\n record.seen = false;\n};\n\n/**\n * Stride for packing two collider ids into one pair key. Multiplying by this\n * (rather than a 32-bit `<<`) keeps the key collision-free up to ~67M (2^26)\n * ids per world, within JS's 2^53 safe-integer range.\n * @internal\n */\nexport const pairKeyStride = 0x4000000; // 2^26\n\n/**\n * Integer key for an unordered collider pair (`aId < bId` is guaranteed by the\n * broad phase). The previous `(aId << 16) | bId` silently collided once any id\n * reached 65536, because JS bitwise operators wrap at 32 bits.\n * @internal\n */\nexport const pairKey = (aId: number, bId: number): number => aId * pairKeyStride + bId;\n\n/**\n * Integer key for an unordered BODY pair, which unlike a collider pair arrives\n * in no guaranteed order.\n * @internal\n */\nexport const bodyPairKey = (aId: number, bId: number): number => (aId < bId ? pairKey(aId, bId) : pairKey(bId, aId));\n\nconst authoredPairKey = (record: ContactRecord): number => {\n const first = record.ownerA.id;\n const second = record.ownerB.id;\n\n return first < second ? pairKey(first, second) : pairKey(second, first);\n};\n\nconst createRecord = (a: Collider, b: Collider, ownerA: Collider, ownerB: Collider, isSensor: boolean): ContactRecord => ({\n a,\n b,\n ownerA,\n ownerB,\n isSensor,\n touching: false,\n seen: true,\n enabled: true,\n friction: 0,\n restitution: 0,\n manifold: new Manifold(),\n normalImpulse: [0, 0],\n tangentImpulse: [0, 0],\n pointIds: [0, 0],\n previousPenetration: [-1, -1],\n pointPenetration: [-1, -1],\n});\n\n/**\n * Map the previously accumulated impulses onto the new manifold points by feature\n * id (warm-starting), and carry each point's previous penetration across the same\n * match. Unmatched points start at zero impulse and at no penetration history;\n * the cache is re-keyed to the new ids. Runs after `collide` has refreshed\n * `record.manifold`.\n */\nconst warmStartMatch = (record: ContactRecord): void => {\n const manifold = record.manifold;\n const pn0 = record.normalImpulse[0];\n const pn1 = record.normalImpulse[1];\n const pt0 = record.tangentImpulse[0];\n const pt1 = record.tangentImpulse[1];\n const pd0 = record.pointPenetration[0];\n const pd1 = record.pointPenetration[1];\n const pid0 = record.pointIds[0];\n const pid1 = record.pointIds[1];\n\n for (let i = 0; i < 2; i++) {\n if (i < manifold.pointCount) {\n // i ∈ {0,1} and within pointCount, so the manifold point exists.\n const point = i === 0 ? manifold.points[0] : manifold.points[1];\n const id = point.id;\n let normal = 0;\n let tangent = 0;\n let previous = -1;\n\n if (id === pid0) {\n normal = pn0;\n tangent = pt0;\n previous = pd0;\n } else if (id === pid1) {\n normal = pn1;\n tangent = pt1;\n previous = pd1;\n }\n\n record.normalImpulse[i] = normal;\n record.tangentImpulse[i] = tangent;\n record.previousPenetration[i] = previous;\n record.pointPenetration[i] = point.penetration;\n record.pointIds[i] = id;\n } else {\n record.normalImpulse[i] = 0;\n record.tangentImpulse[i] = 0;\n record.previousPenetration[i] = -1;\n record.pointPenetration[i] = -1;\n record.pointIds[i] = 0;\n }\n }\n};\n\nconst makeCollisionEvent = (a: Collider, b: Collider, manifold: Manifold): CollisionEvent => {\n const points: ContactPoint[] = [];\n\n for (let i = 0; i < manifold.pointCount; i++) {\n // i in 0..pointCount-1 and pointCount ≤ 2, so the manifold point exists.\n const p = i === 0 ? manifold.points[0] : manifold.points[1];\n\n points.push(Object.freeze({ x: p.x, y: p.y, penetration: p.penetration }));\n }\n\n return Object.freeze({\n bodyA: a.body,\n bodyB: b.body,\n colliderA: a,\n colliderB: b,\n normal: Object.freeze({ x: manifold.normalX, y: manifold.normalY }),\n points: Object.freeze(points),\n });\n};\n\nconst makeEndEvent = (a: Collider, b: Collider): CollisionEvent =>\n Object.freeze({\n bodyA: a.body,\n bodyB: b.body,\n colliderA: a,\n colliderB: b,\n normal: Object.freeze({ x: 0, y: 0 }),\n points: Object.freeze([] as ContactPoint[]),\n });\n\nconst makeSensorEvent = (a: Collider, b: Collider): SensorEvent => {\n let sensor: Collider;\n let other: Collider;\n\n if (a.isSensor && b.isSensor) {\n sensor = a.id < b.id ? a : b;\n other = sensor === a ? b : a;\n } else if (a.isSensor) {\n sensor = a;\n other = b;\n } else {\n sensor = b;\n other = a;\n }\n\n return Object.freeze({ sensor, other });\n};\n\nconst byColliderPair = (x: CollisionEvent, y: CollisionEvent): number => x.colliderA.id - y.colliderA.id || x.colliderB.id - y.colliderB.id;\n\nconst bySensorPair = (x: SensorEvent, y: SensorEvent): number => x.sensor.id - y.sensor.id || x.other.id - y.other.id;\n\nconst byRecordPair = (x: ContactRecord, y: ContactRecord): number => x.a.id - y.a.id || x.b.id - y.b.id;\n\n/** Sort `items[from..]` in place. Removal is not a per-step path, so the splice is acceptable. */\nconst sortTail = <T>(items: T[], from: number, compare: (x: T, y: T) => number): void => {\n if (items.length - from < 2) {\n return;\n }\n\n const tail = items.splice(from);\n\n tail.sort(compare);\n items.push(...tail);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2EA,IAAa,eAAb,MAA0B;;CAExB,AAAgB,iBAAmC,CAAC;;CAEpD,AAAgB,eAAiC,CAAC;;CAElD,AAAgB,cAA6B,CAAC;;CAE9C,AAAgB,aAA4B,CAAC;;;;;;CAM7C,AAAgB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