/// <summary>
/// Intersection test with an <see cref="AxisAlignedBox"/>.
/// </summary>
/// <remarks>
/// May return false positives but will never miss an intersection.
/// </remarks>
/// <param name="box">Box to test.</param>
/// <returns>True if interesecting, false otherwise.</returns>
public bool Intersects(AxisAlignedBox box)
{
if (box.IsNull)
{
return(false);
}
if (box.IsInfinite)
{
return(true);
}
// Get centre of the box
Vector3 center = box.Center;
// Get the half-size of the box
Vector3 halfSize = box.HalfSize;
// If all Points are on outside of any plane, we fail
Vector3[] points = box.Corners;
for (int i = 0; i < planes.Count; i++)
{
Plane plane = (Plane)planes[i];
PlaneSide side = plane.GetSide(center, halfSize);
if (side == outside)
{
// Found a splitting plane therefore return not intersecting
return(false);
}
}
// couldn't find a splitting plane, assume intersecting
return(true);
}