Real-Time Physics Engines, Collision Detection, and Impulse Resolution
Real-time game physics engines simulate rigid-body motion, gravity, and collision responses. This guide covers the two-phase collision pipeline: Broadphase (Spatial Hashing, BVH) to eliminate non-colliding pairs, and Narrowphase (AABB, Separating Axis Theorem SAT, GJK), followed by sequential Impulse Resolution.
⚡ Quick Dive
Collision Detection Pipeline
N Entities ──► [ 1. Broadphase Filtering ] ──► Candidate Pairs ──► [ 2. Narrowphase Test ] ──► Contact Manifold ──► [ 3. Impulse Solver ]
(Spatial Hash / BVH: O(N log N)) (SAT / GJK: Exact intersection) (Calculates bounce & friction)
Separating Axis Theorem (SAT) Principle
[!NOTE] Separating Axis Theorem (SAT): Two convex 2D/3D polyhedra are colliding if and only if there is NO axis along which their 1D projections are disjoint. If even a single separating axis exists, the objects do not intersect.
📖 Extended Guide
1. 2D Axis-Aligned Bounding Box (AABB) Intersection
struct AABB {
float minX, minY, maxX, maxY;
};
bool checkCollision(const AABB& a, const AABB& b) {
return (a.minX <= b.maxX && a.maxX >= b.minX) &&
(a.minY <= b.maxY && a.maxY >= b.minY);
}