time for a snapshot

This commit is contained in:
Schluffe
2026-07-11 17:48:28 +02:00
parent 135b7c3042
commit 7262752e16
47 changed files with 1712 additions and 61 deletions
+14 -10
View File
@@ -137,18 +137,22 @@ function sweptAABB(
positionB: Vector,
delta: number,
): null | number {
const ax = positionA.x + colliderA.offset.x;
const ay = positionA.y + colliderA.offset.y;
const bx = positionB.x + colliderB.offset.x;
const by = positionB.y + colliderB.offset.y;
// setup the "real" position for collider a
const ax = positionA.x + colliderA.offset.x; // calc the x position of the collider a
const ay = positionA.y + colliderA.offset.y; // calc the y position of the collider a
// setup the "real" position for collider b
const bx = positionB.x + colliderB.offset.x; // calc the x positoin of the collider b
const by = positionB.y + colliderB.offset.y; // calc the y position of the collider b
inflAABB.x = bx - colliderA.width;
inflAABB.y = by - colliderA.height;
inflAABB.width = colliderB.width + colliderA.width;
inflAABB.height = colliderB.height + colliderA.height;
// setup the inflated AABB
inflAABB.x = bx - colliderA.width; // calc the x position of the inflated AABB
inflAABB.y = by - colliderA.height; // calc the y position of the inflated AABB
inflAABB.width = colliderB.width + colliderA.width; // calc the width of the inflated AABB
inflAABB.height = colliderB.height + colliderA.height; // calc the height of the inflated AABB
const vx = velocityA.x * delta;
const vy = velocityA.y * delta;
// full-frame displacement for collider a
const vx = velocityA.x * delta; // scale x by delta for collider a
const vy = velocityA.y * delta; // scale y by delta for collider a
let txNear = (inflAABB.x - ax) / vx;
let txFar = (inflAABB.x + inflAABB.width - ax) / vx;