public bool intersects( PlaneBoundedVolume pbv )
{
// Only check if portal is open
if ( mOpen )
{
switch ( mType )
{
case PORTAL_TYPE.PORTAL_TYPE_QUAD:
{
// first check sphere of the portal
if ( !pbv.Intersects( mDerivedSphere ) )
{
return false;
}
// if the portal corners are all outside one of the planes of the pbv,
// then the portal does not intersect the pbv. (this can result in
// some false positives, but it's the best I can do for now)
foreach ( Plane plane in pbv.planes )
{
bool allOutside = true;
for ( int i = 0; i < 4; i++ )
{
if ( plane.GetSide( mDerivedCorners[ i ] ) != pbv.outside )
{
allOutside = false;
}
}
if ( allOutside )
{
return false;
}
}
}
break;
case PORTAL_TYPE.PORTAL_TYPE_AABB:
{
AxisAlignedBox aabb = new AxisAlignedBox( mDerivedCorners[ 0 ], mDerivedCorners[ 1 ] );
if ( !pbv.Intersects( aabb ) )
{
return false;
}
}
break;
case PORTAL_TYPE.PORTAL_TYPE_SPHERE:
if ( !pbv.Intersects( mDerivedSphere ) )
{
return false;
}
break;
}
}
return false;
}