@flare-engine/physics 0.4.17 → 0.4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -68,10 +68,95 @@ by the `layer` bits colliders already carry (`mask` defaults to every layer). Th
68
68
  `raycast(ox, oy, dx, dy, maxDist, targets)` export remains for casting against an explicit list that
69
69
  is not in a world.
70
70
 
71
+ **The broadphase cell is a fixed 64 world units.** Neither `CollisionWorld` nor `SpatialIndex` takes
72
+ a cell-size option. It suits colliders of roughly 16-64 units. In a world of one unit per tile,
73
+ every collider shares a few cells, so `raycast` and `step` approach a scan of every collider. Scale
74
+ world units so a typical collider spans tens of units.
75
+
76
+ **A ray that starts inside a collider hits it at its exit distance**, not at 0. In this world of
77
+ unit tiles the ray starts in the box centred on (3.5, 3.5) and reports that box at 0.5:
78
+
79
+ ```ts
80
+ import { AABB, CollisionWorld } from '@flare-engine/physics';
81
+
82
+ const world = new CollisionWorld();
83
+ let id = 1;
84
+ for (let y = 0; y < 10; y++) for (let x = 0; x < 20; x++) world.add(id++, AABB(1, 1), x + 0.5, y + 0.5);
85
+ const hit = world.raycast(3.5, 3.5, 1, 0, 5); // entity 64, distance 0.5
86
+ ```
87
+
88
+ The `normal` of such a hit is the outward normal of the face the ray entered through behind its
89
+ origin for a box, and the outward normal at the exit point for a circle. To skip the collider the
90
+ ray starts in, put it on a layer the ray's `mask` leaves out, or start the ray just past its edge.
91
+ A ray that starts exactly on the edge still hits it, at distance 0.
92
+
71
93
  **The returned hit record is reused between calls** — read it, or copy what you need, before casting
72
94
  again. That is what keeps a per-frame ray allocation-free; the standalone helper by contrast returns
73
95
  a fresh hit (plus two nested `Vec2`s) from each call that hits, which the caller may keep.
74
96
 
97
+ ## Pixel masks
98
+
99
+ A `MaskShape` is a sprite's solid pixels as a bitmask, for contact that follows the art instead of
100
+ its box. It sits beside `Shape`, not in it: `CollisionWorld` does not take one. Keep a box collider
101
+ for the broadphase and refine the pairs it reports.
102
+
103
+ ```ts
104
+ import {
105
+ createMaskPose,
106
+ createMaskShape,
107
+ maskOverlapsBox,
108
+ maskOverlapsCircle,
109
+ maskOverlapsMask,
110
+ rayVsMask,
111
+ } from '@flare-engine/physics';
112
+
113
+ declare const shipX: number, shipY: number, turn: number;
114
+ declare const rock: ReturnType<typeof createMaskShape>;
115
+ declare const rockPose: ReturnType<typeof createMaskPose>;
116
+
117
+ // Built once, at load. `#` is solid.
118
+ const ship = createMaskShape(['.#.', '###', '#.#']);
119
+
120
+ // One pose per entity, reused every frame.
121
+ const pose = createMaskPose();
122
+ pose.px = 1.5; // the pivot, in mask px: the point that sits on the position
123
+ pose.py = 1.5;
124
+ pose.unit = 4; // world units per mask px
125
+
126
+ pose.x = shipX;
127
+ pose.y = shipY;
128
+ pose.cos = Math.cos(turn);
129
+ pose.sin = Math.sin(turn);
130
+
131
+ maskOverlapsBox(ship, pose, 10, 10, 2, 2); // world box: centre, half extents
132
+ maskOverlapsCircle(ship, pose, 10, 10, 3);
133
+ maskOverlapsMask(ship, pose, rock, rockPose);
134
+ rayVsMask(ship, pose, 0, 0, 1, 0, 500); // distance, 0 if it starts inside, -1 on a miss
135
+ ```
136
+
137
+ A mask is `{ x, y, w, h, words }`: bounds in the sprite frame's px (`x` / `y` offset the solid region
138
+ from the frame's corner, so a collider need not be centred on its entity) and `Math.ceil(w / 32)`
139
+ 32-bit words per row, bit `c & 31` of word `c >>> 5` for column `c`. `words` may be a `number[]` or
140
+ a `Uint32Array`, so a generated table of that layout is a `MaskShape` as it stands.
141
+
142
+ What each test promises:
143
+
144
+ - **Touching is not overlapping**, as everywhere else in this package.
145
+ - `maskOverlapsCircle`, `maskOverlapsMask` and `rayVsMask` work in the mask's own frame and are exact
146
+ at any turn, up to floating-point rounding.
147
+ - `maskOverlapsBox` takes a box that is axis-aligned in the world. Against a turned mask it tests the
148
+ box's bounding box in the mask's frame: exact at a multiple of a quarter turn, generous by the
149
+ box's corners otherwise. Its `erode` flag tests the mask shrunk by 1 px.
150
+ - `maskOverlapsSweptBox` samples `maskOverlapsBox` along a segment, at most half a px apart, so a
151
+ fast box cannot skip a 1 px feature. It takes at most 257 samples; a longer segment is sampled
152
+ more coarsely and can miss.
153
+ - `maskStripStop` gives where an axis-aligned beam first meets the mask; a turned pixel counts by its
154
+ bounding box.
155
+ - `maskBoundsInto` writes the world box around the posed bounds, for a broadphase query.
156
+
157
+ None of these allocates. `maskOverlapsMask` walks the pixels of both masks inside the overlap of
158
+ their bounds, so use it on pairs a box test already passed.
159
+
75
160
  See [API spec](https://github.com/grzott/flare-engine/blob/main/docs/design/api-specs.md#flare-enginephysics).
76
161
 
77
162
  ## License
package/dist/index.d.mts CHANGED
@@ -89,6 +89,13 @@ interface RaycastTarget {
89
89
  *
90
90
  * The returned hit is a fresh object — the caller may keep it; later calls do
91
91
  * not overwrite it. Among targets at equal distance the first in `targets` wins.
92
+ *
93
+ * A ray that starts inside a collider hits that collider at its exit
94
+ * distance, not at 0. The hit's `normal` is then the outward normal of the
95
+ * face the ray entered through behind its origin for a box, and the outward
96
+ * normal at the exit point for a circle. To skip the collider a ray starts in,
97
+ * leave it out of `targets`, or start the ray just past its edge: a ray that
98
+ * starts exactly on the edge still hits it, at distance 0.
92
99
  * @param ox Ray origin X
93
100
  * @param oy Ray origin Y
94
101
  * @param dx Ray direction X (should be normalized)
@@ -114,6 +121,11 @@ interface CollisionPair {
114
121
  /**
115
122
  * AABB collision world. Manages entities with shapes, detects overlaps each step,
116
123
  * and emits collision/trigger signals.
124
+ *
125
+ * The broadphase is a uniform grid of fixed 64-world-unit cells, with no option to
126
+ * change it. It suits colliders of roughly 16-64 units. In a world of one unit per
127
+ * tile, colliders crowd a few cells and `step` and `raycast` approach a scan of
128
+ * every collider, so scale world units up to match.
117
129
  */
118
130
  export declare class CollisionWorld {
119
131
  readonly onCollisionStart: Signal<CollisionPair>;
@@ -129,9 +141,7 @@ export declare class CollisionWorld {
129
141
  private pairBufA;
130
142
  private pairBufB;
131
143
  private activePairs;
132
- /** Reusable query result buffer. */
133
- private queryBuf;
134
- /** Reusable bounds rect — avoids per-entity Rect allocation in step(). */
144
+ /** Reusable bounds rect — avoids a Rect allocation per add / setPosition. */
135
145
  private boundsBuf;
136
146
  /**
137
147
  * Add an entity with a shape. Positional twin of `addCollider`, and re-adding
@@ -160,11 +170,13 @@ export declare class CollisionWorld {
160
170
  get broadphaseSize(): number;
161
171
  /** Run one collision detection step. */
162
172
  step(): void;
173
+ /** A pair is a trigger pair when either of its entities is a trigger. */
174
+ private isTriggerPair;
163
175
  /**
164
- * The one place that decides trigger vs collision for a pair and emits its
165
- * enter or exit signal. `a` and `b` are the pair's two entries in either
166
- * order. They are passed in rather than looked up because in `remove` the
167
- * removed entity is already gone from `entries`.
176
+ * The one place that emits a pair's enter or exit signal, in the trigger or
177
+ * the collision family. `trigger` is passed in rather than looked up because
178
+ * `remove` and a re-add classify by data `entries` no longer holds: the
179
+ * removed entry, and the `isTrigger` the entity had before the re-add.
168
180
  */
169
181
  private emitPair;
170
182
  /** Zero-alloc collider bounds — writes the AABB of entity's shape into `out`. Returns null when entity is absent. */
@@ -174,7 +186,6 @@ export declare class CollisionWorld {
174
186
  /** Remove all entities. */
175
187
  clear(): void;
176
188
  /** Reused across raycasts — see `raycast`. */
177
- private raycastBounds;
178
189
  private raycastCandidates;
179
190
  private raycastHit;
180
191
  /**
@@ -189,6 +200,13 @@ export declare class CollisionWorld {
189
200
  * bits colliders already carry; it defaults to every layer. Triggers are
190
201
  * included — a ray asking "what is over there" wants them.
191
202
  *
203
+ * A ray that starts inside a collider hits that collider at its exit
204
+ * distance, not at 0. The hit's `normal` is then the outward normal of the
205
+ * face the ray entered through behind its origin for a box, and the outward
206
+ * normal at the exit point for a circle. To skip the collider a ray starts in,
207
+ * put it on a layer `mask` leaves out, or start the ray just past its edge: a
208
+ * ray that starts exactly on the edge still hits it, at distance 0.
209
+ *
192
210
  * The returned record is **reused between calls**: read it, or copy what you
193
211
  * need, before casting again. That is what keeps a per-frame ray allocation-
194
212
  * free; the standalone helper by contrast returns a fresh hit from each call
@@ -205,6 +223,121 @@ export declare class CollisionWorld {
205
223
  /** Scratch record handed to `rayVsShapeInto` per candidate. */
206
224
  private scratchHit;
207
225
  }
226
+ /**
227
+ * A pixel mask: the bounds of its solid region inside a sprite frame, in frame
228
+ * px from the frame's top-left corner, and its rows as 32-bit words —
229
+ * `Math.ceil(w / 32)` per row, top row first. Bit `c & 31` of word `c >>> 5`
230
+ * holds column `c` of the bounds; a set bit is solid. `x` / `y` are the offset
231
+ * that lets a mask sit anywhere relative to its pose's pivot.
232
+ *
233
+ * It is not a member of the `Shape` union and `CollisionWorld` does not take
234
+ * one: keep a box collider for the broadphase and refine its pairs with the
235
+ * `mask…` functions.
236
+ */
237
+ interface MaskShape {
238
+ readonly x: number;
239
+ readonly y: number;
240
+ readonly w: number;
241
+ readonly h: number;
242
+ readonly words: ArrayLike<number>;
243
+ }
244
+ /**
245
+ * Where a mask is in the world: the entity's position (`x`, `y`), the cosine
246
+ * and sine of its turn (radians, clockwise with y down, as a sprite is turned
247
+ * about its anchor), the pivot (`px`, `py`) in frame px — the point of the
248
+ * frame that sits on the position — and `unit`, world units per px (above 0).
249
+ */
250
+ interface MaskPose {
251
+ x: number;
252
+ y: number;
253
+ cos: number;
254
+ sin: number;
255
+ px: number;
256
+ py: number;
257
+ unit: number;
258
+ }
259
+ /** An unturned pose at the origin: pivot at the frame's corner, 1 unit per px. */
260
+ export declare function createMaskPose(): MaskPose;
261
+ /**
262
+ * Build a mask from rows of text, top row first: `#` is solid, any other
263
+ * character clear. The bounds are the whole drawing — as wide as the longest
264
+ * row — placed at (`x`, `y`) in the frame. Allocates; call at load.
265
+ */
266
+ export declare function createMaskShape(rows: readonly string[], x?: number, y?: number): MaskShape;
267
+ /**
268
+ * Whether the pixel at frame column `col`, row `row` (integers) is solid;
269
+ * outside the bounds nothing is. With `erode`, solid only when its four
270
+ * neighbours are solid too: the mask eroded by 1 px. Zero-alloc.
271
+ */
272
+ export declare function isMaskSolidAt(m: MaskShape, col: number, row: number, erode?: boolean): boolean;
273
+ /**
274
+ * The world bounding box of a posed mask's bounds rectangle: for a turned mask,
275
+ * the axis-aligned box around the turned rectangle. It bounds every solid pixel
276
+ * but is not shrunk to them. Zero-alloc — writes `out` and returns it.
277
+ */
278
+ export declare function maskBoundsInto(m: MaskShape, p: MaskPose, out: Rect): Rect;
279
+ /** Allocating twin of `maskBoundsInto`. */
280
+ export declare function maskBounds(m: MaskShape, p: MaskPose): Rect;
281
+ /**
282
+ * Whether a world box, centre (`cx`, `cy`) and half extents (`hw`, `hh`),
283
+ * overlaps a solid pixel. Touching an edge is not overlapping. `erode` tests
284
+ * the mask eroded by 1 px.
285
+ *
286
+ * The box is axis-aligned in the world, so against a turned mask it is tested
287
+ * by its bounding box in the mask's frame: exact for a turn that is a multiple
288
+ * of a quarter, generous by the box's corners for any other. Zero-alloc.
289
+ */
290
+ export declare function maskOverlapsBox(m: MaskShape, p: MaskPose, cx: number, cy: number, hw: number, hh: number, erode?: boolean): boolean;
291
+ /**
292
+ * Whether a box swept from (`x0`, `y0`) to (`x1`, `y1`) overlaps a solid pixel
293
+ * anywhere along the segment, so a fast body cannot skip a 1 px feature. It is
294
+ * `maskOverlapsBox` sampled along the segment, both ends included: samples are
295
+ * at most half a px apart, and at most the box's smaller non-zero half extent.
296
+ * A sweep is capped at 257 samples; a segment too long for that spacing is
297
+ * sampled more coarsely and can miss. Zero-alloc.
298
+ */
299
+ export declare function maskOverlapsSweptBox(m: MaskShape, p: MaskPose, x0: number, y0: number, x1: number, y1: number, hw: number, hh: number): boolean;
300
+ /**
301
+ * Whether a world circle overlaps a solid pixel. The circle is taken into the
302
+ * mask's frame, where it is still a circle, and tested against each pixel's
303
+ * square, so the result is exact at any turn. Strict, like `shapeOverlap`:
304
+ * touching is not overlapping, and a zero radius hits only strictly inside a
305
+ * pixel. Zero-alloc.
306
+ */
307
+ export declare function maskOverlapsCircle(m: MaskShape, p: MaskPose, cx: number, cy: number, radius: number): boolean;
308
+ /**
309
+ * Whether a solid pixel of `a` overlaps a solid pixel of `b`. Each pose may be
310
+ * turned and scaled independently. Every solid pixel of one mask inside the
311
+ * other's world bounds is taken into the other's frame as a turned square and
312
+ * tested against the solid pixels there by separating axes, so pixels are
313
+ * compared as the squares they are, not by bounding boxes: exact up to
314
+ * floating-point rounding. Touching is not overlapping; for masks at different
315
+ * turns a contact within rounding of touching can read either way.
316
+ *
317
+ * Cost grows with the pixels of both masks inside the overlap of their bounds
318
+ * — this is the narrow phase for a pair a box broadphase already passed.
319
+ * Zero-alloc.
320
+ */
321
+ export declare function maskOverlapsMask(a: MaskShape, pa: MaskPose, b: MaskShape, pb: MaskPose): boolean;
322
+ /**
323
+ * The distance along a world ray from (`ox`, `oy`), unit direction (`dx`,
324
+ * `dy`), to the first solid pixel it enters, at most `len`; `0` when it starts
325
+ * inside one; `-1` when it meets none. A grid walk over the mask's pixels in
326
+ * its own frame, so the distance is exact at any turn. Zero-alloc.
327
+ *
328
+ * Unlike `rayVsShapeInto` it reports a distance only — no point, no normal —
329
+ * and a ray starting inside a solid pixel reads `0` rather than its exit.
330
+ */
331
+ export declare function rayVsMask(m: MaskShape, p: MaskPose, ox: number, oy: number, dx: number, dy: number, len: number): number;
332
+ /**
333
+ * Where a beam filling the world rect [`x0`, `x1`] × [`y0`, `y1`] and
334
+ * travelling along one axis — (`dirX`, `dirY`) is one of (0, -1), (0, 1),
335
+ * (1, 0) and (-1, 0) — first meets the mask: the near edge of the nearest
336
+ * solid pixel that overlaps the rect, as a world coordinate on the beam's
337
+ * axis. `NaN` when no solid pixel overlaps it. A turned pixel counts by its
338
+ * bounding box. Visits every pixel of the mask. Zero-alloc.
339
+ */
340
+ export declare function maskStripStop(m: MaskShape, p: MaskPose, x0: number, y0: number, x1: number, y1: number, dirX: number, dirY: number): number;
208
341
  /**
209
342
  * Minimal structural type for a solid tile position in grid coordinates.
210
343
  * `TileCollider[]` from `@flare-engine/tilemap` is structurally assignable here
@@ -304,5 +437,5 @@ export declare class SpatialIndex<T> {
304
437
  private _link;
305
438
  private _unlink;
306
439
  }
307
- export type { AABBShape, CircleShape as CircleShapeType, Collider, CollisionPair, Overlap, RaycastHit, RaycastTarget, Shape, SolidGrid, SolidGridOptions, SolidGridOutside, SolidTile };
440
+ export type { AABBShape, CircleShape as CircleShapeType, Collider, CollisionPair, MaskPose, MaskShape, Overlap, RaycastHit, RaycastTarget, Shape, SolidGrid, SolidGridOptions, SolidGridOutside, SolidTile };
308
441
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/shape.ts","../src/collider.ts","../src/raycast.ts","../src/collision-world.ts","../src/solid-grid.ts","../src/spatial-index.ts"],"mappings":";;;UAGiB;WACN;;WAEA;;WAEA;;;iBAIM;WACN;WACA;;;KAIC,QAAQ,YAAY;;wBAGhB,KAAK,eAAe,iBAAiB;;wBAKrC,YAAY,iBAAiB;;wBAK7B,YAAY,OAAO,OAAO,WAAW,YAAY;;wBAajD,gBAAgB,OAAO,OAAO,WAAW,WAAW,KAAK,OAAO;;wBAgBhE,aACd,QAAQ,OACR,YACA,YACA,QAAQ,OACR,YACA;;;;;;;;;;;;;;;;;UA2Fe;;EAEf;EACA;;EAEA;;;wBAIc,iBAAiB;wBAIjB,YACd,QAAQ,OACR,YACA,YACA,QAAQ,OACR,YACA,YACA,KAAK,UACJ;;wBA0Ba,QACd,QAAQ,OACR,YACA,YACA,QAAQ,OACR,YACA,aACC;;UChNc;;EAEf,OAAO;;EAEP;;EAEA;;EAEA;;;wBAIc,eAAe,OAAO,OAAO,OAAO,QAAQ,KAAK,sBAAsB;;UCXtE;;EAEf;;EAEA;;EAEA,OAAO;;EAEP,QAAQ;;;UAIO;EACf;EACA,OAAO;EACP;EACA;;;;;;;;;;;;;;wBAuBc,QACd,YACA,YACA,YACA,YACA,iBACA,kBAAkB,kBACjB;;;;;;;;;wBAqCa,eACd,YACA,YACA,YACA,YACA,iBACA,gBACA,OAAO,OACP,WACA,WACA,KAAK,aACJ;;UCxFc;WACN;WACA;;;;;;qBAuCE;WACF,kBAAgB,OAAA;WAChB,gBAAc,OAAA;WACd,gBAAc,OAAA;WACd,eAAa,OAAA;UAEd;UACA;;;;;UAKA;UACA;UACA;;UAEA;;UAEA;;;;;EAMR,IACE,gBACA,OAAO,OACP,WACA,WACA,qBACA,gBACA;;;;;;;;;;;;EAsCF,YAAY,gBAAgB,UAAU,UAAU,WAAW;;EAK3D,OAAO;;EAmBP,YAAY,gBAAgB,WAAW;;MAUnC;;MAKA;;EAKJ;;;;;;;UAwDQ;;EAmBR,sBAAsB,gBAAgB,KAAK,OAAO;;EAQlD,kBAAkB,iBAAiB;;EAOnC;;UASQ;UACA;UACA;;;;;;;;;;;;;;;;;;;;;;;;;EA+BR,QACE,YACA,YACA,YACA,YACA,iBACA,gBACC;;UAyDK;;;;;;;UCjWO;WACN;WACA;;;;;;;;KASC;UAEK;;WAEN,UAAU;;;;;;;UAQJ;WACN;WACA;WACA;WACA,OAAO;WACP,SAAS;;;;;;;wBAQJ,eACd,eACA,gBACA,kBACA,gBAAgB,aAChB,UAAU,mBACT;;;;;;;;wBAqBa,cACd,MAAM,WACN,WACA,WACA,eACA;;;;;;;wBA+Bc,UAAU,MAAM,WAAW,aAAa;;;;;;wBAUxC,WAAW,MAAM,WAAW,aAAa,aAAa;;;;;;;wBAuBtD,iBACd,MAAM,WACN,WACA,WACA,YACA,YACA,eACA,eACA,KAAK,OACJ;;;;;;;;qBCrFU,aAAa;UAChB;UACA;UACA;UACA;;MAGJ;;;;;EAQJ,OAAO,MAAM,GAAG,QAAQ;;EAmBxB,OAAO,MAAM;;EAgBb,OAAO,MAAM,GAAG,QAAQ;;;;;EAgBxB,MAAM,QAAQ,MAAM,SAAS,MAAM;;EAgCnC;UAOQ;UAmBA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/shape.ts","../src/collider.ts","../src/raycast.ts","../src/collision-world.ts","../src/mask.ts","../src/solid-grid.ts","../src/spatial-index.ts"],"mappings":";;;UAGiB;WACN;;WAEA;;WAEA;;;iBAIM;WACN;WACA;;;KAIC,QAAQ,YAAY;;wBAGhB,KAAK,eAAe,iBAAiB;;wBAKrC,YAAY,iBAAiB;;wBAK7B,YAAY,OAAO,OAAO,WAAW,YAAY;;wBAajD,gBAAgB,OAAO,OAAO,WAAW,WAAW,KAAK,OAAO;;wBAgBhE,aACd,QAAQ,OACR,YACA,YACA,QAAQ,OACR,YACA;;;;;;;;;;;;;;;;;UA2Fe;;EAEf;EACA;;EAEA;;;wBAIc,iBAAiB;wBAIjB,YACd,QAAQ,OACR,YACA,YACA,QAAQ,OACR,YACA,YACA,KAAK,UACJ;;wBA0Ba,QACd,QAAQ,OACR,YACA,YACA,QAAQ,OACR,YACA,aACC;;UChNc;;EAEf,OAAO;;EAEP;;EAEA;;EAEA;;;wBAIc,eAAe,OAAO,OAAO,OAAO,QAAQ,KAAK,sBAAsB;;UCXtE;;EAEf;;EAEA;;EAEA,OAAO;;EAEP,QAAQ;;;UAIO;EACf;EACA,OAAO;EACP;EACA;;;;;;;;;;;;;;;;;;;;;wBA8Bc,QACd,YACA,YACA,YACA,YACA,iBACA,kBAAkB,kBACjB;;;;;;;;;wBAqCa,eACd,YACA,YACA,YACA,YACA,iBACA,gBACA,OAAO,OACP,WACA,WACA,KAAK,aACJ;;UCrFc;WACN;WACA;;;;;;;;;;;qBAiCE;WACF,kBAAgB,OAAA;WAChB,gBAAc,OAAA;WACd,gBAAc,OAAA;WACd,eAAa,OAAA;UAEd;UACA;;;;;UAKA;UACA;UACA;;UAEA;;;;;EAMR,IACE,gBACA,OAAO,OACP,WACA,WACA,qBACA,gBACA;;;;;;;;;;;;EAuEF,YAAY,gBAAgB,UAAU,UAAU,WAAW;;EAK3D,OAAO;;EAoBP,YAAY,gBAAgB,WAAW;;MAUnC;;MAKA;;EAKJ;;UAmEQ;;;;;;;UAUA;;EAaR,sBA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ACJ;;;;;;;;qBCpHU,aAAa;UAChB;UACA;UACA;UACA;;MAGJ;;;;;EAQJ,OAAO,MAAM,GAAG,QAAQ;;EA0BxB,OAAO,MAAM;;EAgBb,OAAO,MAAM,GAAG,QAAQ;;;;;EAqCxB,MAAM,QAAQ,MAAM,SAAS,MAAM;;EAgCnC;UAQQ;UAoBA"}
package/dist/index.d.ts CHANGED
@@ -89,6 +89,13 @@ interface RaycastTarget {
89
89
  *
90
90
  * The returned hit is a fresh object — the caller may keep it; later calls do
91
91
  * not overwrite it. Among targets at equal distance the first in `targets` wins.
92
+ *
93
+ * A ray that starts inside a collider hits that collider at its exit
94
+ * distance, not at 0. The hit's `normal` is then the outward normal of the
95
+ * face the ray entered through behind its origin for a box, and the outward
96
+ * normal at the exit point for a circle. To skip the collider a ray starts in,
97
+ * leave it out of `targets`, or start the ray just past its edge: a ray that
98
+ * starts exactly on the edge still hits it, at distance 0.
92
99
  * @param ox Ray origin X
93
100
  * @param oy Ray origin Y
94
101
  * @param dx Ray direction X (should be normalized)
@@ -114,6 +121,11 @@ interface CollisionPair {
114
121
  /**
115
122
  * AABB collision world. Manages entities with shapes, detects overlaps each step,
116
123
  * and emits collision/trigger signals.
124
+ *
125
+ * The broadphase is a uniform grid of fixed 64-world-unit cells, with no option to
126
+ * change it. It suits colliders of roughly 16-64 units. In a world of one unit per
127
+ * tile, colliders crowd a few cells and `step` and `raycast` approach a scan of
128
+ * every collider, so scale world units up to match.
117
129
  */
118
130
  export declare class CollisionWorld {
119
131
  readonly onCollisionStart: Signal<CollisionPair>;
@@ -129,9 +141,7 @@ export declare class CollisionWorld {
129
141
  private pairBufA;
130
142
  private pairBufB;
131
143
  private activePairs;
132
- /** Reusable query result buffer. */
133
- private queryBuf;
134
- /** Reusable bounds rect — avoids per-entity Rect allocation in step(). */
144
+ /** Reusable bounds rect — avoids a Rect allocation per add / setPosition. */
135
145
  private boundsBuf;
136
146
  /**
137
147
  * Add an entity with a shape. Positional twin of `addCollider`, and re-adding
@@ -160,11 +170,13 @@ export declare class CollisionWorld {
160
170
  get broadphaseSize(): number;
161
171
  /** Run one collision detection step. */
162
172
  step(): void;
173
+ /** A pair is a trigger pair when either of its entities is a trigger. */
174
+ private isTriggerPair;
163
175
  /**
164
- * The one place that decides trigger vs collision for a pair and emits its
165
- * enter or exit signal. `a` and `b` are the pair's two entries in either
166
- * order. They are passed in rather than looked up because in `remove` the
167
- * removed entity is already gone from `entries`.
176
+ * The one place that emits a pair's enter or exit signal, in the trigger or
177
+ * the collision family. `trigger` is passed in rather than looked up because
178
+ * `remove` and a re-add classify by data `entries` no longer holds: the
179
+ * removed entry, and the `isTrigger` the entity had before the re-add.
168
180
  */
169
181
  private emitPair;
170
182
  /** Zero-alloc collider bounds — writes the AABB of entity's shape into `out`. Returns null when entity is absent. */
@@ -174,7 +186,6 @@ export declare class CollisionWorld {
174
186
  /** Remove all entities. */
175
187
  clear(): void;
176
188
  /** Reused across raycasts — see `raycast`. */
177
- private raycastBounds;
178
189
  private raycastCandidates;
179
190
  private raycastHit;
180
191
  /**
@@ -189,6 +200,13 @@ export declare class CollisionWorld {
189
200
  * bits colliders already carry; it defaults to every layer. Triggers are
190
201
  * included — a ray asking "what is over there" wants them.
191
202
  *
203
+ * A ray that starts inside a collider hits that collider at its exit
204
+ * distance, not at 0. The hit's `normal` is then the outward normal of the
205
+ * face the ray entered through behind its origin for a box, and the outward
206
+ * normal at the exit point for a circle. To skip the collider a ray starts in,
207
+ * put it on a layer `mask` leaves out, or start the ray just past its edge: a
208
+ * ray that starts exactly on the edge still hits it, at distance 0.
209
+ *
192
210
  * The returned record is **reused between calls**: read it, or copy what you
193
211
  * need, before casting again. That is what keeps a per-frame ray allocation-
194
212
  * free; the standalone helper by contrast returns a fresh hit from each call
@@ -205,6 +223,121 @@ export declare class CollisionWorld {
205
223
  /** Scratch record handed to `rayVsShapeInto` per candidate. */
206
224
  private scratchHit;
207
225
  }
226
+ /**
227
+ * A pixel mask: the bounds of its solid region inside a sprite frame, in frame
228
+ * px from the frame's top-left corner, and its rows as 32-bit words —
229
+ * `Math.ceil(w / 32)` per row, top row first. Bit `c & 31` of word `c >>> 5`
230
+ * holds column `c` of the bounds; a set bit is solid. `x` / `y` are the offset
231
+ * that lets a mask sit anywhere relative to its pose's pivot.
232
+ *
233
+ * It is not a member of the `Shape` union and `CollisionWorld` does not take
234
+ * one: keep a box collider for the broadphase and refine its pairs with the
235
+ * `mask…` functions.
236
+ */
237
+ interface MaskShape {
238
+ readonly x: number;
239
+ readonly y: number;
240
+ readonly w: number;
241
+ readonly h: number;
242
+ readonly words: ArrayLike<number>;
243
+ }
244
+ /**
245
+ * Where a mask is in the world: the entity's position (`x`, `y`), the cosine
246
+ * and sine of its turn (radians, clockwise with y down, as a sprite is turned
247
+ * about its anchor), the pivot (`px`, `py`) in frame px — the point of the
248
+ * frame that sits on the position — and `unit`, world units per px (above 0).
249
+ */
250
+ interface MaskPose {
251
+ x: number;
252
+ y: number;
253
+ cos: number;
254
+ sin: number;
255
+ px: number;
256
+ py: number;
257
+ unit: number;
258
+ }
259
+ /** An unturned pose at the origin: pivot at the frame's corner, 1 unit per px. */
260
+ export declare function createMaskPose(): MaskPose;
261
+ /**
262
+ * Build a mask from rows of text, top row first: `#` is solid, any other
263
+ * character clear. The bounds are the whole drawing — as wide as the longest
264
+ * row — placed at (`x`, `y`) in the frame. Allocates; call at load.
265
+ */
266
+ export declare function createMaskShape(rows: readonly string[], x?: number, y?: number): MaskShape;
267
+ /**
268
+ * Whether the pixel at frame column `col`, row `row` (integers) is solid;
269
+ * outside the bounds nothing is. With `erode`, solid only when its four
270
+ * neighbours are solid too: the mask eroded by 1 px. Zero-alloc.
271
+ */
272
+ export declare function isMaskSolidAt(m: MaskShape, col: number, row: number, erode?: boolean): boolean;
273
+ /**
274
+ * The world bounding box of a posed mask's bounds rectangle: for a turned mask,
275
+ * the axis-aligned box around the turned rectangle. It bounds every solid pixel
276
+ * but is not shrunk to them. Zero-alloc — writes `out` and returns it.
277
+ */
278
+ export declare function maskBoundsInto(m: MaskShape, p: MaskPose, out: Rect): Rect;
279
+ /** Allocating twin of `maskBoundsInto`. */
280
+ export declare function maskBounds(m: MaskShape, p: MaskPose): Rect;
281
+ /**
282
+ * Whether a world box, centre (`cx`, `cy`) and half extents (`hw`, `hh`),
283
+ * overlaps a solid pixel. Touching an edge is not overlapping. `erode` tests
284
+ * the mask eroded by 1 px.
285
+ *
286
+ * The box is axis-aligned in the world, so against a turned mask it is tested
287
+ * by its bounding box in the mask's frame: exact for a turn that is a multiple
288
+ * of a quarter, generous by the box's corners for any other. Zero-alloc.
289
+ */
290
+ export declare function maskOverlapsBox(m: MaskShape, p: MaskPose, cx: number, cy: number, hw: number, hh: number, erode?: boolean): boolean;
291
+ /**
292
+ * Whether a box swept from (`x0`, `y0`) to (`x1`, `y1`) overlaps a solid pixel
293
+ * anywhere along the segment, so a fast body cannot skip a 1 px feature. It is
294
+ * `maskOverlapsBox` sampled along the segment, both ends included: samples are
295
+ * at most half a px apart, and at most the box's smaller non-zero half extent.
296
+ * A sweep is capped at 257 samples; a segment too long for that spacing is
297
+ * sampled more coarsely and can miss. Zero-alloc.
298
+ */
299
+ export declare function maskOverlapsSweptBox(m: MaskShape, p: MaskPose, x0: number, y0: number, x1: number, y1: number, hw: number, hh: number): boolean;
300
+ /**
301
+ * Whether a world circle overlaps a solid pixel. The circle is taken into the
302
+ * mask's frame, where it is still a circle, and tested against each pixel's
303
+ * square, so the result is exact at any turn. Strict, like `shapeOverlap`:
304
+ * touching is not overlapping, and a zero radius hits only strictly inside a
305
+ * pixel. Zero-alloc.
306
+ */
307
+ export declare function maskOverlapsCircle(m: MaskShape, p: MaskPose, cx: number, cy: number, radius: number): boolean;
308
+ /**
309
+ * Whether a solid pixel of `a` overlaps a solid pixel of `b`. Each pose may be
310
+ * turned and scaled independently. Every solid pixel of one mask inside the
311
+ * other's world bounds is taken into the other's frame as a turned square and
312
+ * tested against the solid pixels there by separating axes, so pixels are
313
+ * compared as the squares they are, not by bounding boxes: exact up to
314
+ * floating-point rounding. Touching is not overlapping; for masks at different
315
+ * turns a contact within rounding of touching can read either way.
316
+ *
317
+ * Cost grows with the pixels of both masks inside the overlap of their bounds
318
+ * — this is the narrow phase for a pair a box broadphase already passed.
319
+ * Zero-alloc.
320
+ */
321
+ export declare function maskOverlapsMask(a: MaskShape, pa: MaskPose, b: MaskShape, pb: MaskPose): boolean;
322
+ /**
323
+ * The distance along a world ray from (`ox`, `oy`), unit direction (`dx`,
324
+ * `dy`), to the first solid pixel it enters, at most `len`; `0` when it starts
325
+ * inside one; `-1` when it meets none. A grid walk over the mask's pixels in
326
+ * its own frame, so the distance is exact at any turn. Zero-alloc.
327
+ *
328
+ * Unlike `rayVsShapeInto` it reports a distance only — no point, no normal —
329
+ * and a ray starting inside a solid pixel reads `0` rather than its exit.
330
+ */
331
+ export declare function rayVsMask(m: MaskShape, p: MaskPose, ox: number, oy: number, dx: number, dy: number, len: number): number;
332
+ /**
333
+ * Where a beam filling the world rect [`x0`, `x1`] × [`y0`, `y1`] and
334
+ * travelling along one axis — (`dirX`, `dirY`) is one of (0, -1), (0, 1),
335
+ * (1, 0) and (-1, 0) — first meets the mask: the near edge of the nearest
336
+ * solid pixel that overlaps the rect, as a world coordinate on the beam's
337
+ * axis. `NaN` when no solid pixel overlaps it. A turned pixel counts by its
338
+ * bounding box. Visits every pixel of the mask. Zero-alloc.
339
+ */
340
+ export declare function maskStripStop(m: MaskShape, p: MaskPose, x0: number, y0: number, x1: number, y1: number, dirX: number, dirY: number): number;
208
341
  /**
209
342
  * Minimal structural type for a solid tile position in grid coordinates.
210
343
  * `TileCollider[]` from `@flare-engine/tilemap` is structurally assignable here
@@ -304,5 +437,5 @@ export declare class SpatialIndex<T> {
304
437
  private _link;
305
438
  private _unlink;
306
439
  }
307
- export type { AABBShape, CircleShape as CircleShapeType, Collider, CollisionPair, Overlap, RaycastHit, RaycastTarget, Shape, SolidGrid, SolidGridOptions, SolidGridOutside, SolidTile };
440
+ export type { AABBShape, CircleShape as CircleShapeType, Collider, CollisionPair, MaskPose, MaskShape, Overlap, RaycastHit, RaycastTarget, Shape, SolidGrid, SolidGridOptions, SolidGridOutside, SolidTile };
308
441
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/shape.ts","../src/collider.ts","../src/raycast.ts","../src/collision-world.ts","../src/solid-grid.ts","../src/spatial-index.ts"],"mappings":";;;UAGiB;WACN;;WAEA;;WAEA;;;iBAIM;WACN;WACA;;;KAIC,QAAQ,YAAY;;wBAGhB,KAAK,eAAe,iBAAiB;;wBAKrC,YAAY,iBAAiB;;wBAK7B,YAAY,OAAO,OAAO,WAAW,YAAY;;wBAajD,gBAAgB,OAAO,OAAO,WAAW,WAAW,KAAK,OAAO;;wBAgBhE,aACd,QAAQ,OACR,YACA,YACA,QAAQ,OACR,YACA;;;;;;;;;;;;;;;;;UA2Fe;;EAEf;EACA;;EAEA;;;wBAIc,iBAAiB;wBAIjB,YACd,QAAQ,OACR,YACA,YACA,QAAQ,OACR,YACA,YACA,KAAK,UACJ;;wBA0Ba,QACd,QAAQ,OACR,YACA,YACA,QAAQ,OACR,YACA,aACC;;UChNc;;EAEf,OAAO;;EAEP;;EAEA;;EAEA;;;wBAIc,eAAe,OAAO,OAAO,OAAO,QAAQ,KAAK,sBAAsB;;UCXtE;;EAEf;;EAEA;;EAEA,OAAO;;EAEP,QAAQ;;;UAIO;EACf;EACA,OAAO;EACP;EACA;;;;;;;;;;;;;;wBAuBc,QACd,YACA,YACA,YACA,YACA,iBACA,kBAAkB,kBACjB;;;;;;;;;wBAqCa,eACd,YACA,YACA,YACA,YACA,iBACA,gBACA,OAAO,OACP,WACA,WACA,KAAK,aACJ;;UCxFc;WACN;WACA;;;;;;qBAuCE;WACF,kBAAgB,OAAA;WAChB,gBAAc,OAAA;WACd,gBAAc,OAAA;WACd,eAAa,OAAA;UAEd;UACA;;;;;UAKA;UACA;UACA;;UAEA;;UAEA;;;;;EAMR,IACE,gBACA,OAAO,OACP,WACA,WACA,qBACA,gBACA;;;;;;;;;;;;EAsCF,YAAY,gBAAgB,UAAU,UAAU,WAAW;;EAK3D,OAAO;;EAmBP,YAAY,gBAAgB,WAAW;;MAUnC;;MAKA;;EAKJ;;;;;;;UAwDQ;;EAmBR,sBAAsB,gBAAgB,KAAK,OAAO;;EAQlD,kBAAkB,iBAAiB;;EAOnC;;UASQ;UACA;UACA;;;;;;;;;;;;;;;;;;;;;;;;;EA+BR,QACE,YACA,YACA,YACA,YACA,iBACA,gBACC;;UAyDK;;;;;;;UCjWO;WACN;WACA;;;;;;;;KASC;UAEK;;WAEN,UAAU;;;;;;;UAQJ;WACN;WACA;WACA;WACA,OAAO;WACP,SAAS;;;;;;;wBAQJ,eACd,eACA,gBACA,kBACA,gBAAgB,aAChB,UAAU,mBACT;;;;;;;;wBAqBa,cACd,MAAM,WACN,WACA,WACA,eACA;;;;;;;wBA+Bc,UAAU,MAAM,WAAW,aAAa;;;;;;wBAUxC,WAAW,MAAM,WAAW,aAAa,aAAa;;;;;;;wBAuBtD,iBACd,MAAM,WACN,WACA,WACA,YACA,YACA,eACA,eACA,KAAK,OACJ;;;;;;;;qBCrFU,aAAa;UAChB;UACA;UACA;UACA;;MAGJ;;;;;EAQJ,OAAO,MAAM,GAAG,QAAQ;;EAmBxB,OAAO,MAAM;;EAgBb,OAAO,MAAM,GAAG,QAAQ;;;;;EAgBxB,MAAM,QAAQ,MAAM,SAAS,MAAM;;EAgCnC;UAOQ;UAmBA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/shape.ts","../src/collider.ts","../src/raycast.ts","../src/collision-world.ts","../src/mask.ts","../src/solid-grid.ts","../src/spatial-index.ts"],"mappings":";;;UAGiB;WACN;;WAEA;;WAEA;;;iBAIM;WACN;WACA;;;KAIC,QAAQ,YAAY;;wBAGhB,KAAK,eAAe,iBAAiB;;wBAKrC,YAAY,iBAAiB;;wBAK7B,YA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