public Visibility GetVisibility( AxisAlignedBox bound )
{
// Null boxes always invisible
if ( bound.IsNull )
return Visibility.None;
// Get centre of the box
Vector3 centre = bound.Center;
// Get the half-size of the box
Vector3 halfSize = bound.HalfSize;
bool all_inside = true;
// Check originplane if told to
if ( mUseOriginPlane )
{
PlaneSide side = mOriginPlane.GetSide( centre, halfSize );
if ( side == PlaneSide.Negative )
{
return Visibility.None;
}
// We can't return now as the box could be later on the negative side of another plane.
if ( side == PlaneSide.Both )
{
all_inside = false;
}
}
// For each active culling plane, see if the entire aabb is on the negative side
// If so, object is not visible
foreach ( PCPlane plane in mActiveCullingPlanes )
{
PlaneSide xside = plane.GetSide( centre, halfSize );
if ( xside == PlaneSide.Negative )
{
return Visibility.None;
}
// We can't return now as the box could be later on the negative side of a plane.
if ( xside == PlaneSide.Both )
{
all_inside = false;
}
}
if ( all_inside )
return Visibility.Full;
else
return Visibility.Partial;
}