Exemplo n.º 1
0
bool AABBInHalfSpace(const AABB & box, const float * plane)
{
	/*
		Main Idea: 
            -> Separating-axis test with only normal of the plane.
	*/

	float radius = box.GetExtent(0) * abs(plane[0])
				+ box.GetExtent(1) * abs(plane[1])
				+ box.GetExtent(2) * abs(plane[2]);
	float signed_distance = box.GetCenter()[0] * plane[0]
							+ box.GetCenter()[1] * plane[1]
							+ box.GetCenter()[2] * plane[2] 
							+ plane[3];
	return signed_distance + radius >= 0; //Only test if box is in positive side of plane.
}
Exemplo n.º 2
0
bool AABB::Intersects(AABB& other)
{
	for (int i = 0; i < 3; ++i)
	{
		if (extents[i].Intersects(other.GetExtent(i)))
			return true;
	}
	return false;
}