This commit is contained in:
Schluffe
2026-07-30 22:06:28 +02:00
parent 7262752e16
commit ec9f2e2a2d
13 changed files with 873 additions and 68 deletions
+41
View File
@@ -0,0 +1,41 @@
import {
type AABB,
moveAndSlide,
penetrationVector,
type Vec,
} from "./given.ts";
export type Resolution = { x: number; y: number; settled: boolean };
/**
* Push `box` out of EVERY wall — even when one push shoves it into another.
*
* One pass over the walls is not enough: a push is a teleport, and a teleport
* can land you inside a wall the loop already cleared. So: run whole passes
* over the wall list, applying pushes (with the EPSILON slack — on the pushed
* axis only!), until a full pass finds nothing to fix. That pass proves you're
* settled.
*
* But some arrangements have NO free spot (a gap narrower than the box), and
* the passes would ping-pong forever. Cap them — 8 is plenty — and if the cap
* fires, report `settled: false`. You already believe in caps: your step-10
* loop has one for exactly the same reason.
*
* Returns where the box ended up and whether it truly got free.
*/
export function resolveOverlaps(box: AABB, walls: AABB[]): Resolution {
throw new Error("not implemented");
}
/**
* Step 12's safeMoveAndSlide, rebuilt on resolveOverlaps.
*
* Settled -> sweep from the safe spot, business as usual.
* Crushed (not settled) -> the sweep would be handed an overlapping box and
* you know exactly what it does with one of those. Don't feed it. Our crush
* policy: the walls win — the box stays where the resolver left it, finite,
* and waits for the gap to open.
*/
export function safeMoveAndSlide(box: AABB, v: Vec, walls: AABB[]): Vec {
throw new Error("not implemented");
}