public PCZone FindZoneForPoint( Vector3 point )
{
PCZone bestZone = defaultZone;
Real bestVolume = Real.PositiveInfinity;
foreach ( PCZone zone in zones )
{
AxisAlignedBox aabb = new AxisAlignedBox();
zone.GetAABB( ref aabb );
SceneNode enclosureNode = zone.EnclosureNode;
if ( null != enclosureNode )
{
// since this is the "local" AABB, add in world translation of the enclosure node
aabb.Minimum = aabb.Minimum + enclosureNode.DerivedPosition;
aabb.Maximum = aabb.Maximum + enclosureNode.DerivedPosition;
}
if ( aabb.Contains( point ) )
{
if ( aabb.Volume < bestVolume )
{
// this zone is "smaller" than the current best zone, so make it
// the new best zone
bestZone = zone;
bestVolume = aabb.Volume;
}
}
}
return bestZone;
}