intersectsBoundingSphere method

bool intersectsBoundingSphere(
  1. BoundingSphere sphere
)

Returns true if the given bounding sphere intersects this AABB.

Implementation

bool intersectsBoundingSphere(BoundingSphere sphere ) {
	// find the point on the AABB closest to the sphere center
	clampPoint( sphere.center, vector );

	// if that point is inside the sphere, the AABB and sphere intersect.
	return vector.squaredDistanceTo( sphere.center ) <= ( sphere.radius * sphere.radius );
}