WIP
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
## Concept
|
||||
|
||||
**AABB** = **A**xis-**A**ligned **B**ounding **B**ox: a rectangle whose sides are
|
||||
parallel to the x and y axes (never rotated). They're cheap to test, which is why
|
||||
almost every 2D engine — including yours — uses them as the base collision shape.
|
||||
**AABB** = **A**xis-**A**ligned **B**ounding **B**ox: a rectangle whose sides
|
||||
are parallel to the x and y axes (never rotated). They're cheap to test, which
|
||||
is why almost every 2D engine — including yours — uses them as the base
|
||||
collision shape.
|
||||
|
||||
We represent one as a corner plus a size:
|
||||
|
||||
@@ -18,7 +19,7 @@ So the box spans `x .. x+w` horizontally and `y .. y+h` vertically.
|
||||
|
||||
This is the key insight you'll reuse for the rest of the workshop. Think of each
|
||||
box as a **shadow on the x-axis** and a **shadow on the y-axis**. Two boxes
|
||||
intersect only if *both* pairs of shadows intersect:
|
||||
intersect only if _both_ pairs of shadows intersect:
|
||||
|
||||
```
|
||||
overlapX: a.x < b.x + b.w AND b.x < a.x + a.w
|
||||
@@ -32,10 +33,10 @@ behind swept collision.
|
||||
|
||||
### The discrete trap (why this test alone isn't enough)
|
||||
|
||||
`aabbOverlap` only answers "are they overlapping *right now*?" If a fast object
|
||||
`aabbOverlap` only answers "are they overlapping _right now_?" If a fast object
|
||||
jumps from one side of a thin wall to the other in a single frame, it never
|
||||
overlaps the wall at any sampled instant — so this test says "no collision" and
|
||||
the object tunnels straight through. Steps 05+ fix that by testing the *path*,
|
||||
the object tunnels straight through. Steps 05+ fix that by testing the _path_,
|
||||
not the endpoints. Feel the gap here first; it's why everything after exists.
|
||||
|
||||
## Task
|
||||
|
||||
Reference in New Issue
Block a user