@codexo/exojs-physics 0.19.0 → 0.20.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 (207) hide show
  1. package/README.md +8 -73
  2. package/{dist/esm/debug/index.d.ts → debug.d.ts} +1 -2
  3. package/debug.js +1 -0
  4. package/index.d.ts +1 -0
  5. package/index.js +1 -0
  6. package/package.json +17 -23
  7. package/dist/esm/Aabb.d.ts +0 -10
  8. package/dist/esm/Aabb.d.ts.map +0 -1
  9. package/dist/esm/Aabb.js +0 -16
  10. package/dist/esm/Aabb.js.map +0 -1
  11. package/dist/esm/Collider.d.ts +0 -107
  12. package/dist/esm/Collider.d.ts.map +0 -1
  13. package/dist/esm/Collider.js +0 -284
  14. package/dist/esm/Collider.js.map +0 -1
  15. package/dist/esm/ContactGraph.d.ts +0 -154
  16. package/dist/esm/ContactGraph.d.ts.map +0 -1
  17. package/dist/esm/ContactGraph.js +0 -383
  18. package/dist/esm/ContactGraph.js.map +0 -1
  19. package/dist/esm/ContactModifier.d.ts +0 -62
  20. package/dist/esm/ContactModifier.d.ts.map +0 -1
  21. package/dist/esm/ContactModifier.js +0 -49
  22. package/dist/esm/ContactModifier.js.map +0 -1
  23. package/dist/esm/PhysicsBody.d.ts +0 -186
  24. package/dist/esm/PhysicsBody.d.ts.map +0 -1
  25. package/dist/esm/PhysicsBody.js +0 -526
  26. package/dist/esm/PhysicsBody.js.map +0 -1
  27. package/dist/esm/PhysicsBodyComponent.d.ts +0 -45
  28. package/dist/esm/PhysicsBodyComponent.d.ts.map +0 -1
  29. package/dist/esm/PhysicsBodyComponent.js +0 -77
  30. package/dist/esm/PhysicsBodyComponent.js.map +0 -1
  31. package/dist/esm/PhysicsWorld.d.ts +0 -567
  32. package/dist/esm/PhysicsWorld.d.ts.map +0 -1
  33. package/dist/esm/PhysicsWorld.js +0 -1096
  34. package/dist/esm/PhysicsWorld.js.map +0 -1
  35. package/dist/esm/TimeStepper.d.ts +0 -40
  36. package/dist/esm/TimeStepper.d.ts.map +0 -1
  37. package/dist/esm/TimeStepper.js +0 -59
  38. package/dist/esm/TimeStepper.js.map +0 -1
  39. package/dist/esm/backend/NativePhysicsBackend.d.ts +0 -28
  40. package/dist/esm/backend/NativePhysicsBackend.d.ts.map +0 -1
  41. package/dist/esm/backend/NativePhysicsBackend.js +0 -52
  42. package/dist/esm/backend/NativePhysicsBackend.js.map +0 -1
  43. package/dist/esm/backend/PhysicsBackend.d.ts +0 -38
  44. package/dist/esm/backend/PhysicsBackend.d.ts.map +0 -1
  45. package/dist/esm/binding/BindingRegistry.d.ts +0 -48
  46. package/dist/esm/binding/BindingRegistry.d.ts.map +0 -1
  47. package/dist/esm/binding/BindingRegistry.js +0 -81
  48. package/dist/esm/binding/BindingRegistry.js.map +0 -1
  49. package/dist/esm/binding/PhysicsBinding.d.ts +0 -37
  50. package/dist/esm/binding/PhysicsBinding.d.ts.map +0 -1
  51. package/dist/esm/binding/PhysicsBinding.js +0 -54
  52. package/dist/esm/binding/PhysicsBinding.js.map +0 -1
  53. package/dist/esm/binding/nodeWorldTransform.d.ts +0 -18
  54. package/dist/esm/binding/nodeWorldTransform.d.ts.map +0 -1
  55. package/dist/esm/binding/nodeWorldTransform.js +0 -41
  56. package/dist/esm/binding/nodeWorldTransform.js.map +0 -1
  57. package/dist/esm/broadphase/AabbTreeBroadPhase.d.ts +0 -84
  58. package/dist/esm/broadphase/AabbTreeBroadPhase.d.ts.map +0 -1
  59. package/dist/esm/broadphase/AabbTreeBroadPhase.js +0 -183
  60. package/dist/esm/broadphase/AabbTreeBroadPhase.js.map +0 -1
  61. package/dist/esm/broadphase/BroadPhase.d.ts +0 -25
  62. package/dist/esm/broadphase/BroadPhase.d.ts.map +0 -1
  63. package/dist/esm/broadphase/index.d.ts +0 -3
  64. package/dist/esm/broadphase/index.d.ts.map +0 -1
  65. package/dist/esm/collision/CollisionProxy.d.ts +0 -15
  66. package/dist/esm/collision/CollisionProxy.d.ts.map +0 -1
  67. package/dist/esm/collision/Manifold.d.ts +0 -34
  68. package/dist/esm/collision/Manifold.d.ts.map +0 -1
  69. package/dist/esm/collision/Manifold.js +0 -37
  70. package/dist/esm/collision/Manifold.js.map +0 -1
  71. package/dist/esm/collision/chainAdjacency.d.ts +0 -2
  72. package/dist/esm/collision/chainAdjacency.d.ts.map +0 -1
  73. package/dist/esm/collision/chainAdjacency.js +0 -44
  74. package/dist/esm/collision/chainAdjacency.js.map +0 -1
  75. package/dist/esm/collision/dispatch.d.ts +0 -35
  76. package/dist/esm/collision/dispatch.d.ts.map +0 -1
  77. package/dist/esm/collision/dispatch.js +0 -58
  78. package/dist/esm/collision/dispatch.js.map +0 -1
  79. package/dist/esm/collision/index.d.ts +0 -5
  80. package/dist/esm/collision/index.d.ts.map +0 -1
  81. package/dist/esm/collision/narrowphase.d.ts +0 -17
  82. package/dist/esm/collision/narrowphase.d.ts.map +0 -1
  83. package/dist/esm/collision/narrowphase.js +0 -555
  84. package/dist/esm/collision/narrowphase.js.map +0 -1
  85. package/dist/esm/collision/segments.d.ts +0 -19
  86. package/dist/esm/collision/segments.d.ts.map +0 -1
  87. package/dist/esm/collision/segments.js +0 -36
  88. package/dist/esm/collision/segments.js.map +0 -1
  89. package/dist/esm/collision/sweep.d.ts +0 -35
  90. package/dist/esm/collision/sweep.d.ts.map +0 -1
  91. package/dist/esm/collision/sweep.js +0 -437
  92. package/dist/esm/collision/sweep.js.map +0 -1
  93. package/dist/esm/debug/PhysicsDebugDraw.d.ts +0 -72
  94. package/dist/esm/debug/PhysicsDebugDraw.d.ts.map +0 -1
  95. package/dist/esm/debug/PhysicsDebugDraw.js +0 -239
  96. package/dist/esm/debug/PhysicsDebugDraw.js.map +0 -1
  97. package/dist/esm/debug/index.d.ts.map +0 -1
  98. package/dist/esm/debug/index.js +0 -3
  99. package/dist/esm/events.d.ts +0 -36
  100. package/dist/esm/events.d.ts.map +0 -1
  101. package/dist/esm/index.d.ts +0 -2
  102. package/dist/esm/index.d.ts.map +0 -1
  103. package/dist/esm/index.js +0 -25
  104. package/dist/esm/joints/DistanceJoint.d.ts +0 -70
  105. package/dist/esm/joints/DistanceJoint.d.ts.map +0 -1
  106. package/dist/esm/joints/DistanceJoint.js +0 -167
  107. package/dist/esm/joints/DistanceJoint.js.map +0 -1
  108. package/dist/esm/joints/Joint.d.ts +0 -76
  109. package/dist/esm/joints/Joint.d.ts.map +0 -1
  110. package/dist/esm/joints/Joint.js +0 -62
  111. package/dist/esm/joints/Joint.js.map +0 -1
  112. package/dist/esm/joints/MouseJoint.d.ts +0 -55
  113. package/dist/esm/joints/MouseJoint.d.ts.map +0 -1
  114. package/dist/esm/joints/MouseJoint.js +0 -139
  115. package/dist/esm/joints/MouseJoint.js.map +0 -1
  116. package/dist/esm/joints/PrismaticJoint.d.ts +0 -84
  117. package/dist/esm/joints/PrismaticJoint.d.ts.map +0 -1
  118. package/dist/esm/joints/PrismaticJoint.js +0 -218
  119. package/dist/esm/joints/PrismaticJoint.js.map +0 -1
  120. package/dist/esm/joints/RevoluteJoint.d.ts +0 -77
  121. package/dist/esm/joints/RevoluteJoint.d.ts.map +0 -1
  122. package/dist/esm/joints/RevoluteJoint.js +0 -204
  123. package/dist/esm/joints/RevoluteJoint.js.map +0 -1
  124. package/dist/esm/joints/WeldJoint.d.ts +0 -60
  125. package/dist/esm/joints/WeldJoint.d.ts.map +0 -1
  126. package/dist/esm/joints/WeldJoint.js +0 -166
  127. package/dist/esm/joints/WeldJoint.js.map +0 -1
  128. package/dist/esm/joints/WheelJoint.d.ts +0 -91
  129. package/dist/esm/joints/WheelJoint.d.ts.map +0 -1
  130. package/dist/esm/joints/WheelJoint.js +0 -235
  131. package/dist/esm/joints/WheelJoint.js.map +0 -1
  132. package/dist/esm/math.d.ts +0 -29
  133. package/dist/esm/math.d.ts.map +0 -1
  134. package/dist/esm/math.js +0 -60
  135. package/dist/esm/math.js.map +0 -1
  136. package/dist/esm/physicsBuildInfo.d.ts +0 -16
  137. package/dist/esm/physicsBuildInfo.d.ts.map +0 -1
  138. package/dist/esm/physicsBuildInfo.js +0 -10
  139. package/dist/esm/physicsBuildInfo.js.map +0 -1
  140. package/dist/esm/public.d.ts +0 -34
  141. package/dist/esm/public.d.ts.map +0 -1
  142. package/dist/esm/query/QueryEngine.d.ts +0 -95
  143. package/dist/esm/query/QueryEngine.d.ts.map +0 -1
  144. package/dist/esm/query/QueryEngine.js +0 -512
  145. package/dist/esm/query/QueryEngine.js.map +0 -1
  146. package/dist/esm/query/SpatialIndex.d.ts +0 -34
  147. package/dist/esm/query/SpatialIndex.d.ts.map +0 -1
  148. package/dist/esm/shapes/AnyShape.d.ts +0 -14
  149. package/dist/esm/shapes/AnyShape.d.ts.map +0 -1
  150. package/dist/esm/shapes/BoxShape.d.ts +0 -12
  151. package/dist/esm/shapes/BoxShape.d.ts.map +0 -1
  152. package/dist/esm/shapes/BoxShape.js +0 -41
  153. package/dist/esm/shapes/BoxShape.js.map +0 -1
  154. package/dist/esm/shapes/CapsuleShape.d.ts +0 -30
  155. package/dist/esm/shapes/CapsuleShape.d.ts.map +0 -1
  156. package/dist/esm/shapes/CapsuleShape.js +0 -88
  157. package/dist/esm/shapes/CapsuleShape.js.map +0 -1
  158. package/dist/esm/shapes/ChainEdgeShape.d.ts +0 -2
  159. package/dist/esm/shapes/ChainEdgeShape.d.ts.map +0 -1
  160. package/dist/esm/shapes/ChainEdgeShape.js +0 -66
  161. package/dist/esm/shapes/ChainEdgeShape.js.map +0 -1
  162. package/dist/esm/shapes/ChainShape.d.ts +0 -46
  163. package/dist/esm/shapes/ChainShape.d.ts.map +0 -1
  164. package/dist/esm/shapes/ChainShape.js +0 -85
  165. package/dist/esm/shapes/ChainShape.js.map +0 -1
  166. package/dist/esm/shapes/CircleShape.d.ts +0 -14
  167. package/dist/esm/shapes/CircleShape.d.ts.map +0 -1
  168. package/dist/esm/shapes/CircleShape.js +0 -31
  169. package/dist/esm/shapes/CircleShape.js.map +0 -1
  170. package/dist/esm/shapes/PolygonShape.d.ts +0 -24
  171. package/dist/esm/shapes/PolygonShape.d.ts.map +0 -1
  172. package/dist/esm/shapes/PolygonShape.js +0 -153
  173. package/dist/esm/shapes/PolygonShape.js.map +0 -1
  174. package/dist/esm/shapes/SegmentShape.d.ts +0 -31
  175. package/dist/esm/shapes/SegmentShape.d.ts.map +0 -1
  176. package/dist/esm/shapes/SegmentShape.js +0 -62
  177. package/dist/esm/shapes/SegmentShape.js.map +0 -1
  178. package/dist/esm/shapes/Shape.d.ts +0 -37
  179. package/dist/esm/shapes/Shape.d.ts.map +0 -1
  180. package/dist/esm/shapes/Shape.js +0 -15
  181. package/dist/esm/shapes/Shape.js.map +0 -1
  182. package/dist/esm/shapes/convexParts.d.ts +0 -21
  183. package/dist/esm/shapes/convexParts.d.ts.map +0 -1
  184. package/dist/esm/shapes/convexParts.js +0 -26
  185. package/dist/esm/shapes/convexParts.js.map +0 -1
  186. package/dist/esm/shapes/decompose.d.ts +0 -2
  187. package/dist/esm/shapes/decompose.d.ts.map +0 -1
  188. package/dist/esm/shapes/decompose.js +0 -272
  189. package/dist/esm/shapes/decompose.js.map +0 -1
  190. package/dist/esm/shapes/index.d.ts +0 -9
  191. package/dist/esm/shapes/index.d.ts.map +0 -1
  192. package/dist/esm/solver/ContactSolver.d.ts +0 -94
  193. package/dist/esm/solver/ContactSolver.d.ts.map +0 -1
  194. package/dist/esm/solver/ContactSolver.js +0 -457
  195. package/dist/esm/solver/ContactSolver.js.map +0 -1
  196. package/dist/esm/solver/tolerances.d.ts +0 -2
  197. package/dist/esm/solver/tolerances.d.ts.map +0 -1
  198. package/dist/esm/solver/tolerances.js +0 -36
  199. package/dist/esm/solver/tolerances.js.map +0 -1
  200. package/dist/esm/sort.d.ts +0 -2
  201. package/dist/esm/sort.d.ts.map +0 -1
  202. package/dist/esm/sort.js +0 -44
  203. package/dist/esm/sort.js.map +0 -1
  204. package/dist/esm/types.d.ts +0 -35
  205. package/dist/esm/types.d.ts.map +0 -1
  206. package/dist/esm/types.js +0 -26
  207. package/dist/esm/types.js.map +0 -1
@@ -1,154 +0,0 @@
1
- import type { CandidatePair } from './broadphase/BroadPhase';
2
- import type { Collider } from './Collider';
3
- import { Manifold } from './collision/Manifold';
4
- import type { ContactModifier } from './ContactModifier';
5
- import type { CollisionEvent, SensorEvent } from './events';
6
- /**
7
- * Persistent per-pair contact state. For solid contacts it carries a manifold
8
- * reused across passes plus the accumulated normal/tangent impulses (warm-start
9
- * cache), keyed by manifold-point feature ids. Consumed by the {@link ContactSolver}.
10
- */
11
- export interface ContactRecord {
12
- readonly a: Collider;
13
- readonly b: Collider;
14
- /**
15
- * Authored collider behind {@link a} - itself, unless `a` is an engine-owned
16
- * chain edge proxy, in which case it is the chain collider the caller made.
17
- * Solver identity is the proxy pair; public identity is the authored pair.
18
- */
19
- readonly ownerA: Collider;
20
- readonly ownerB: Collider;
21
- readonly isSensor: boolean;
22
- touching: boolean;
23
- seen: boolean;
24
- /**
25
- * Per-step solver participation. Re-derived to `true` for every touching solid
26
- * contact each pass, then optionally cleared by the world's `ContactModifier`.
27
- */
28
- enabled: boolean;
29
- /** Per-step Coulomb friction, re-derived from the two colliders each pass. */
30
- friction: number;
31
- /** Per-step restitution, re-derived from the two colliders each pass. */
32
- restitution: number;
33
- /** Persistent manifold (solid contacts), refreshed each pass by the narrow phase. */
34
- readonly manifold: Manifold;
35
- /** Accumulated normal impulse per contact point, carried across steps (warm-start). */
36
- readonly normalImpulse: [number, number];
37
- /** Accumulated tangent impulse per contact point, carried across steps (warm-start). */
38
- readonly tangentImpulse: [number, number];
39
- /** Feature ids the cached impulses belong to (for warm-start matching). */
40
- readonly pointIds: [number, number];
41
- /**
42
- * Penetration each point carried on the previous detection pass, matched by
43
- * feature id the same way the impulse cache is, or `-1` where the point is new
44
- * and has no history. The difference against the manifold's current
45
- * penetration is how much the last solve actually moved the overlap, which is
46
- * what separates a contact the push-out is still working off from one that has
47
- * reached the depth its load holds it at.
48
- */
49
- readonly previousPenetration: [number, number];
50
- /** Penetration per point as of this pass, kept so the next pass can form that difference. */
51
- readonly pointPenetration: [number, number];
52
- }
53
- /**
54
- * The persistent contact set. Each detection pass it diffs the currently
55
- * touching collider pairs against the previous pass and produces immutable
56
- * begin/end (and sensor enter/exit) event snapshots. Duplicate begin/end churn
57
- * is suppressed by the persistent records, and the produced event arrays are
58
- * sorted by collider id for deterministic dispatch.
59
- *
60
- * Touching solid contacts are also collected into {@link solidContacts} (with a
61
- * warm-start impulse cache) for the dynamics solver. The graph holds no
62
- * module-level state - each world owns one.
63
- *
64
- * Records are keyed on the pair the solver sees, which for a chain collider is
65
- * one of its edge proxies. Events are not: a body touching several edges of one
66
- * chain is one authored contact, so the graph reference-counts the authored pair
67
- * behind its records and emits begin/end only on the first and last of them.
68
- */
69
- export declare class ContactGraph {
70
- /** Immutable solid-contact begin snapshots produced by the latest {@link update}. */
71
- readonly collisionStart: CollisionEvent[];
72
- /** Immutable solid-contact end snapshots produced by the latest {@link update}. */
73
- readonly collisionEnd: CollisionEvent[];
74
- /** Immutable sensor-enter snapshots produced by the latest {@link update}. */
75
- readonly sensorEnter: SensorEvent[];
76
- /** Immutable sensor-exit snapshots produced by the latest {@link update}. */
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[];
86
- /** Touching solid contacts this pass, in deterministic order - consumed by the solver. */
87
- readonly solidContacts: ContactRecord[];
88
- /**
89
- * Body pairs a joint has taken out of collision, keyed by
90
- * {@link bodyPairKey} and reference-counted by the world; `null` until a world
91
- * hands its own map over.
92
- *
93
- * Consulted here rather than in the solver because the cheapest contact is
94
- * the one the narrow phase never computes: a chain of N links otherwise pays
95
- * for N-1 manifolds, warm-start slots and event records per step that nothing
96
- * is allowed to act on.
97
- */
98
- private _uncollidablePairs;
99
- private readonly _records;
100
- private readonly _authoredPairs;
101
- private readonly _modifierContext;
102
- private _sealedCollisionEnds;
103
- private _sealedSensorExits;
104
- /** Touching pairs currently tracked (for debug draw). */
105
- get recordCount(): number;
106
- /** Diff this pass's candidate pairs against the persistent set, collecting events + solid contacts. */
107
- update(pairs: readonly CandidatePair[]): void;
108
- /**
109
- * Run `modifier` over every touching solid contact of this pass. Called after
110
- * detection and before island building, so a contact the modifier disables
111
- * neither reaches the solver nor couples its two bodies into one sleeping
112
- * island. A disabled contact's warm-start cache is dropped, so re-enabling it
113
- * later starts from zero instead of releasing a stale impulse.
114
- */
115
- applyModifier(modifier: ContactModifier): void;
116
- /**
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.
121
- */
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;
132
- /** Drop all records (world reset/destroy). */
133
- clear(): void;
134
- private _emitBegin;
135
- private _emitEnd;
136
- /**
137
- * Count one more solver contact against the authored pair, reporting whether
138
- * it is the first - the only one that may emit a begin event. A record whose
139
- * colliders are the authored ones needs no counting at all, so a world without
140
- * chains never touches the map.
141
- */
142
- private _retainAuthoredPair;
143
- /** Counterpart of {@link _retainAuthoredPair}: `true` on the last contact of the pair. */
144
- private _releaseAuthoredPair;
145
- /**
146
- * `Map.forEach` callback (its `this` bound via the forEach thisArg) - drops a
147
- * record the latest pass did not see, firing an end event if it was touching.
148
- * A method reference + thisArg keeps the per-step iteration allocation-free,
149
- * unlike `for (const [key, record] of map)` which allocates an entry tuple per
150
- * record (~1000/step). Deleting the current entry during forEach is safe.
151
- */
152
- private _removeIfUnseen;
153
- }
154
- //# sourceMappingURL=ContactGraph.d.ts.map
@@ -1 +0,0 @@
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,CAA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9C;IAED;;;;;OAKG;IACI,eAAe,IAAI,IAAI,CAK7B;IAED,8DAA8D;IACvD,gBAAgB,IAAI,IAAI,CAK9B;IAED,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"}
@@ -1,383 +0,0 @@
1
- import { shouldCollide } from "./types.js";
2
- import { authoredCollider } from "./Collider.js";
3
- import { Manifold } from "./collision/Manifold.js";
4
- import { collide, testOverlap } from "./collision/narrowphase.js";
5
- import { MutableContactModifierContext } from "./ContactModifier.js";
6
- import { sortInPlace } from "./sort.js";
7
-
8
- //#region src/ContactGraph.ts
9
- /**
10
- * The persistent contact set. Each detection pass it diffs the currently
11
- * touching collider pairs against the previous pass and produces immutable
12
- * begin/end (and sensor enter/exit) event snapshots. Duplicate begin/end churn
13
- * is suppressed by the persistent records, and the produced event arrays are
14
- * sorted by collider id for deterministic dispatch.
15
- *
16
- * Touching solid contacts are also collected into {@link solidContacts} (with a
17
- * warm-start impulse cache) for the dynamics solver. The graph holds no
18
- * module-level state - each world owns one.
19
- *
20
- * Records are keyed on the pair the solver sees, which for a chain collider is
21
- * one of its edge proxies. Events are not: a body touching several edges of one
22
- * chain is one authored contact, so the graph reference-counts the authored pair
23
- * behind its records and emits begin/end only on the first and last of them.
24
- */
25
- var ContactGraph = class {
26
- /** Immutable solid-contact begin snapshots produced by the latest {@link update}. */
27
- collisionStart = [];
28
- /** Immutable solid-contact end snapshots produced by the latest {@link update}. */
29
- collisionEnd = [];
30
- /** Immutable sensor-enter snapshots produced by the latest {@link update}. */
31
- sensorEnter = [];
32
- /** Immutable sensor-exit snapshots produced by the latest {@link update}. */
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 = [];
42
- /** Touching solid contacts this pass, in deterministic order - consumed by the solver. */
43
- solidContacts = [];
44
- /**
45
- * Body pairs a joint has taken out of collision, keyed by
46
- * {@link bodyPairKey} and reference-counted by the world; `null` until a world
47
- * hands its own map over.
48
- *
49
- * Consulted here rather than in the solver because the cheapest contact is
50
- * the one the narrow phase never computes: a chain of N links otherwise pays
51
- * for N-1 manifolds, warm-start slots and event records per step that nothing
52
- * is allowed to act on.
53
- */
54
- _uncollidablePairs = null;
55
- _records = /* @__PURE__ */ new Map();
56
- _authoredPairs = /* @__PURE__ */ new Map();
57
- _modifierContext = new MutableContactModifierContext();
58
- _sealedCollisionEnds = 0;
59
- _sealedSensorExits = 0;
60
- /** Touching pairs currently tracked (for debug draw). */
61
- get recordCount() {
62
- return this._records.size;
63
- }
64
- /** @internal - adopt the world's joint-filtered body pairs; see {@link _uncollidablePairs}. */
65
- _useUncollidablePairs(pairs) {
66
- this._uncollidablePairs = pairs;
67
- }
68
- /** Diff this pass's candidate pairs against the persistent set, collecting events + solid contacts. */
69
- update(pairs) {
70
- this.collisionStart.length = 0;
71
- this.collisionEnd.length = 0;
72
- this.sensorEnter.length = 0;
73
- this.sensorExit.length = 0;
74
- this.solidContacts.length = 0;
75
- this._records.forEach(resetSeen);
76
- for (const pair of pairs) {
77
- const a = pair.a;
78
- const b = pair.b;
79
- const ownerA = authoredCollider(a);
80
- const ownerB = authoredCollider(b);
81
- if (!shouldCollide(ownerA.filter, ownerB.filter)) continue;
82
- if (this._uncollidablePairs !== null && this._uncollidablePairs.size > 0 && this._uncollidablePairs.has(bodyPairKey(ownerA.body.id, ownerB.body.id))) continue;
83
- const isSensor = ownerA.isSensor || ownerB.isSensor;
84
- const key = pairKey(a.id, b.id);
85
- const existing = this._records.get(key);
86
- const record = existing ?? createRecord(a, b, ownerA, ownerB, isSensor);
87
- if (isSensor ? testOverlap(a, b) : collide(a, b, record.manifold)) {
88
- record.seen = true;
89
- if (existing === void 0) this._records.set(key, record);
90
- if (!record.touching) {
91
- record.touching = true;
92
- this._emitBegin(record);
93
- }
94
- if (!isSensor) {
95
- record.enabled = true;
96
- record.friction = Math.sqrt(ownerA.friction * ownerB.friction);
97
- record.restitution = Math.max(ownerA.restitution, ownerB.restitution);
98
- warmStartMatch(record);
99
- this.solidContacts.push(record);
100
- }
101
- } else if (existing !== void 0) {
102
- if (record.touching) this._emitEnd(record);
103
- this._records.delete(key);
104
- }
105
- }
106
- this._records.forEach(this._removeIfUnseen, this);
107
- sortInPlace(this.collisionStart, byColliderPair);
108
- sortInPlace(this.collisionEnd, byColliderPair);
109
- sortInPlace(this.sensorEnter, bySensorPair);
110
- sortInPlace(this.sensorExit, bySensorPair);
111
- sortInPlace(this.solidContacts, byRecordPair);
112
- }
113
- /**
114
- * Run `modifier` over every touching solid contact of this pass. Called after
115
- * detection and before island building, so a contact the modifier disables
116
- * neither reaches the solver nor couples its two bodies into one sleeping
117
- * island. A disabled contact's warm-start cache is dropped, so re-enabling it
118
- * later starts from zero instead of releasing a stale impulse.
119
- */
120
- applyModifier(modifier) {
121
- const context = this._modifierContext;
122
- for (const record of this.solidContacts) {
123
- context.bind(record);
124
- modifier(context);
125
- context.flush(record);
126
- if (!record.enabled) {
127
- record.normalImpulse[0] = 0;
128
- record.normalImpulse[1] = 0;
129
- record.tangentImpulse[0] = 0;
130
- record.tangentImpulse[1] = 0;
131
- record.pointIds[0] = 0;
132
- record.pointIds[1] = 0;
133
- record.pointPenetration[0] = -1;
134
- record.pointPenetration[1] = -1;
135
- }
136
- }
137
- }
138
- /**
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.
143
- */
144
- removeCollider(collider) {
145
- for (const [key, record] of this._records) if (record.a === collider || record.b === collider || record.ownerA === collider || record.ownerB === collider) {
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
- }
150
- this._records.delete(key);
151
- }
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
- }
172
- /** Drop all records (world reset/destroy). */
173
- clear() {
174
- this._records.clear();
175
- this._authoredPairs.clear();
176
- this.clearRemovalEnds();
177
- }
178
- _emitBegin(record) {
179
- if (!this._retainAuthoredPair(record)) return;
180
- if (record.isSensor) this.sensorEnter.push(makeSensorEvent(record.ownerA, record.ownerB));
181
- else this.collisionStart.push(makeCollisionEvent(record.ownerA, record.ownerB, record.manifold));
182
- }
183
- _emitEnd(record) {
184
- if (!this._releaseAuthoredPair(record)) return;
185
- if (record.isSensor) this.sensorExit.push(makeSensorEvent(record.ownerA, record.ownerB));
186
- else this.collisionEnd.push(makeEndEvent(record.ownerA, record.ownerB));
187
- }
188
- /**
189
- * Count one more solver contact against the authored pair, reporting whether
190
- * it is the first - the only one that may emit a begin event. A record whose
191
- * colliders are the authored ones needs no counting at all, so a world without
192
- * chains never touches the map.
193
- */
194
- _retainAuthoredPair(record) {
195
- if (record.a === record.ownerA && record.b === record.ownerB) return true;
196
- const key = authoredPairKey(record);
197
- const count = this._authoredPairs.get(key) ?? 0;
198
- this._authoredPairs.set(key, count + 1);
199
- return count === 0;
200
- }
201
- /** Counterpart of {@link _retainAuthoredPair}: `true` on the last contact of the pair. */
202
- _releaseAuthoredPair(record) {
203
- if (record.a === record.ownerA && record.b === record.ownerB) return true;
204
- const key = authoredPairKey(record);
205
- const count = (this._authoredPairs.get(key) ?? 1) - 1;
206
- if (count <= 0) {
207
- this._authoredPairs.delete(key);
208
- return true;
209
- }
210
- this._authoredPairs.set(key, count);
211
- return false;
212
- }
213
- /**
214
- * `Map.forEach` callback (its `this` bound via the forEach thisArg) - drops a
215
- * record the latest pass did not see, firing an end event if it was touching.
216
- * A method reference + thisArg keeps the per-step iteration allocation-free,
217
- * unlike `for (const [key, record] of map)` which allocates an entry tuple per
218
- * record (~1000/step). Deleting the current entry during forEach is safe.
219
- */
220
- _removeIfUnseen(record, key) {
221
- if (!record.seen) {
222
- if (record.touching) this._emitEnd(record);
223
- this._records.delete(key);
224
- }
225
- }
226
- };
227
- /** `Map.forEach` callback - clears the per-pass `seen` flag (no iterator allocation). */
228
- const resetSeen = (record) => {
229
- record.seen = false;
230
- };
231
- /**
232
- * Stride for packing two collider ids into one pair key. Multiplying by this
233
- * (rather than a 32-bit `<<`) keeps the key collision-free up to ~67M (2^26)
234
- * ids per world, within JS's 2^53 safe-integer range.
235
- * @internal
236
- */
237
- const pairKeyStride = 67108864;
238
- /**
239
- * Integer key for an unordered collider pair (`aId < bId` is guaranteed by the
240
- * broad phase). The previous `(aId << 16) | bId` silently collided once any id
241
- * reached 65536, because JS bitwise operators wrap at 32 bits.
242
- * @internal
243
- */
244
- const pairKey = (aId, bId) => aId * pairKeyStride + bId;
245
- /**
246
- * Integer key for an unordered BODY pair, which unlike a collider pair arrives
247
- * in no guaranteed order.
248
- * @internal
249
- */
250
- const bodyPairKey = (aId, bId) => aId < bId ? pairKey(aId, bId) : pairKey(bId, aId);
251
- const authoredPairKey = (record) => {
252
- const first = record.ownerA.id;
253
- const second = record.ownerB.id;
254
- return first < second ? pairKey(first, second) : pairKey(second, first);
255
- };
256
- const createRecord = (a, b, ownerA, ownerB, isSensor) => ({
257
- a,
258
- b,
259
- ownerA,
260
- ownerB,
261
- isSensor,
262
- touching: false,
263
- seen: true,
264
- enabled: true,
265
- friction: 0,
266
- restitution: 0,
267
- manifold: new Manifold(),
268
- normalImpulse: [0, 0],
269
- tangentImpulse: [0, 0],
270
- pointIds: [0, 0],
271
- previousPenetration: [-1, -1],
272
- pointPenetration: [-1, -1]
273
- });
274
- /**
275
- * Map the previously accumulated impulses onto the new manifold points by feature
276
- * id (warm-starting), and carry each point's previous penetration across the same
277
- * match. Unmatched points start at zero impulse and at no penetration history;
278
- * the cache is re-keyed to the new ids. Runs after `collide` has refreshed
279
- * `record.manifold`.
280
- */
281
- const warmStartMatch = (record) => {
282
- const manifold = record.manifold;
283
- const pn0 = record.normalImpulse[0];
284
- const pn1 = record.normalImpulse[1];
285
- const pt0 = record.tangentImpulse[0];
286
- const pt1 = record.tangentImpulse[1];
287
- const pd0 = record.pointPenetration[0];
288
- const pd1 = record.pointPenetration[1];
289
- const pid0 = record.pointIds[0];
290
- const pid1 = record.pointIds[1];
291
- for (let i = 0; i < 2; i++) if (i < manifold.pointCount) {
292
- const point = i === 0 ? manifold.points[0] : manifold.points[1];
293
- const id = point.id;
294
- let normal = 0;
295
- let tangent = 0;
296
- let previous = -1;
297
- if (id === pid0) {
298
- normal = pn0;
299
- tangent = pt0;
300
- previous = pd0;
301
- } else if (id === pid1) {
302
- normal = pn1;
303
- tangent = pt1;
304
- previous = pd1;
305
- }
306
- record.normalImpulse[i] = normal;
307
- record.tangentImpulse[i] = tangent;
308
- record.previousPenetration[i] = previous;
309
- record.pointPenetration[i] = point.penetration;
310
- record.pointIds[i] = id;
311
- } else {
312
- record.normalImpulse[i] = 0;
313
- record.tangentImpulse[i] = 0;
314
- record.previousPenetration[i] = -1;
315
- record.pointPenetration[i] = -1;
316
- record.pointIds[i] = 0;
317
- }
318
- };
319
- const makeCollisionEvent = (a, b, manifold) => {
320
- const points = [];
321
- for (let i = 0; i < manifold.pointCount; i++) {
322
- const p = i === 0 ? manifold.points[0] : manifold.points[1];
323
- points.push(Object.freeze({
324
- x: p.x,
325
- y: p.y,
326
- penetration: p.penetration
327
- }));
328
- }
329
- return Object.freeze({
330
- bodyA: a.body,
331
- bodyB: b.body,
332
- colliderA: a,
333
- colliderB: b,
334
- normal: Object.freeze({
335
- x: manifold.normalX,
336
- y: manifold.normalY
337
- }),
338
- points: Object.freeze(points)
339
- });
340
- };
341
- const makeEndEvent = (a, b) => Object.freeze({
342
- bodyA: a.body,
343
- bodyB: b.body,
344
- colliderA: a,
345
- colliderB: b,
346
- normal: Object.freeze({
347
- x: 0,
348
- y: 0
349
- }),
350
- points: Object.freeze([])
351
- });
352
- const makeSensorEvent = (a, b) => {
353
- let sensor;
354
- let other;
355
- if (a.isSensor && b.isSensor) {
356
- sensor = a.id < b.id ? a : b;
357
- other = sensor === a ? b : a;
358
- } else if (a.isSensor) {
359
- sensor = a;
360
- other = b;
361
- } else {
362
- sensor = b;
363
- other = a;
364
- }
365
- return Object.freeze({
366
- sensor,
367
- other
368
- });
369
- };
370
- const byColliderPair = (x, y) => x.colliderA.id - y.colliderA.id || x.colliderB.id - y.colliderB.id;
371
- const bySensorPair = (x, y) => x.sensor.id - y.sensor.id || x.other.id - y.other.id;
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
- };
380
-
381
- //#endregion
382
- export { ContactGraph, bodyPairKey, pairKey, pairKeyStride };
383
- //# sourceMappingURL=ContactGraph.js.map
@@ -1 +0,0 @@
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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K,EAAE,OAAO,MAAM,EAAE,MAAM,KAAK,EAAE,MAAM;AAEnH,MAAM,gBAAgB,GAAkB,MAA6B,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE;;AAGrG,MAAM,YAAe,OAAY,MAAc,YAA0C;CACvF,IAAI,MAAM,SAAS,OAAO,GACxB;CAGF,MAAM,OAAO,MAAM,OAAO,IAAI;CAE9B,KAAK,KAAK,OAAO;CACjB,MAAM,KAAK,GAAG,IAAI;AACpB"}
@@ -1,62 +0,0 @@
1
- import type { Collider } from './Collider';
2
- import type { PhysicsBody } from './PhysicsBody';
3
- /**
4
- * A solid contact as the world's {@link ContactModifier} sees it: the pair that
5
- * produced it, the contact normal, and the three per-step controls the modifier
6
- * may change. Everything else is read-only.
7
- *
8
- * The object is reused for every contact and is only valid for the duration of
9
- * the callback - read what you need, write the controls, do not retain it.
10
- *
11
- * Writing a control affects this step only; the values are re-derived from the
12
- * two colliders before the modifier runs again.
13
- *
14
- * A chain collider is solved per edge, so a body touching several edges of one
15
- * chain reaches the modifier once per edge, each time with the same authored
16
- * collider pair. Decide from the contact's own normal and penetration rather
17
- * than from the pair's identity if that distinction matters.
18
- */
19
- export interface ContactModifierContext {
20
- readonly colliderA: Collider;
21
- readonly colliderB: Collider;
22
- readonly bodyA: PhysicsBody;
23
- readonly bodyB: PhysicsBody;
24
- /** X of the unit contact normal, pointing from A towards B. */
25
- readonly normalX: number;
26
- /** Y of the unit contact normal, pointing from A towards B. */
27
- readonly normalY: number;
28
- /** Manifold points backing this contact: `1` for a vertex/face hit, `2` for a face/face hit. */
29
- readonly pointCount: number;
30
- /** Deepest penetration across the manifold points, in px. */
31
- readonly maxPenetration: number;
32
- /**
33
- * Set to `false` to skip this contact in the solver for this step. The
34
- * contact stays geometrically touching, so `collisionStart`/`collisionEnd`
35
- * still describe the real geometry; it just applies no impulse, and it does
36
- * not join the two bodies into one sleeping island. Its warm-start impulses
37
- * are dropped while it is disabled, so re-enabling it starts cold rather than
38
- * releasing a stale impulse.
39
- */
40
- enabled: boolean;
41
- /**
42
- * Coulomb friction for this step. Defaults to `√(a.friction × b.friction)`
43
- * over the two colliders.
44
- */
45
- friction: number;
46
- /**
47
- * Restitution for this step. Defaults to `max(a.restitution, b.restitution)`
48
- * over the two colliders.
49
- */
50
- restitution: number;
51
- }
52
- /**
53
- * Called once per solid contact per fixed step, after contact generation and
54
- * before the solver runs, to adjust that contact for this step - the hook
55
- * one-way platforms, conditional friction and per-pair material overrides are
56
- * built on.
57
- *
58
- * A world has at most one modifier. It runs before islands are built, so
59
- * disabling a contact also keeps the two bodies from sleeping as one.
60
- */
61
- export type ContactModifier = (contact: ContactModifierContext) => void;
62
- //# sourceMappingURL=ContactModifier.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContactModifier.d.ts","sourceRoot":"","sources":["../../src/ContactModifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,gGAAgG;IAChG,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;;;;;;OAOG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAAC"}