Simple AABB vs AABB collision detection
An AABB is an axis aligned bounding box. It’s mainly used in broadphase physics detection.
Assume this are the basic properties of an AABB.
struct AABB
{
Point c; // center point
float r[3]; // halfwidths
};
Then we can use this simple test to check if there is an overlap between the bounding boxes.
bool testAABBAABB(const AABB &a, const AABB &b)
{
float t;
if ( Abs(a.c[0] - b.c[0]) > (a.r[0] + b.r[0]) return false;
if ( Abs(a.c[1] - b.c[1]) > (a.r[1] + b.r[1]) return false;
if ( Abs(a.c[2] - b.c[2]) > (a.r[2] + b.r[2]) return false;
// We have an overlap
return true;
};
cool