Skip to content

bounceOffAabb

bounceOffAabb(mover, vel, obstacle): BounceResult | null

Defined in: src/modules/collision/narrowphase.ts:278

Resolve an AABB overlap with a pure velocity reflection on the minimum-separation axis.

Returns null when the two boxes are not overlapping (edge contact does not count). Callers must check aabbVsAabb first if they need to distinguish “no overlap” from “overlap resolved”.

The returned pushOut is the minimum translation vector — add it to the mover’s position to depenetrate. The returned velocity is the mover’s original velocity reflected on the separation axis; the caller should replace the mover’s velocity component with it.

Tie-break: when X and Y overlaps are equal, the Y axis wins (consistent with aabbVsAabbSwept).

Aabb

Vec2

Aabb

BounceResult | null