public override void Execute( IIntersectionSceneQueryListener listener )
{
//Issue: some movable-movable intersections could be reported twice if 2 movables
//overlap 2 leaves?
BspLevel lvl = ( (BspSceneManager)this.creator ).Level;
int leafPoint = lvl.LeafStart;
int numLeaves = lvl.NumLeaves;
objIntersections.Clear();
brushIntersections.Clear();
while ( --numLeaves >= 0 )
{
BspNode leaf = lvl.Nodes[ leafPoint ];
objectsDone.Clear();
foreach ( MovableObject aObj in leaf.Objects.Values )
{
// skip this object if collision not enabled
if ( ( aObj.QueryFlags & queryMask ) == 0 )
continue;
// get it's bounds
AxisAlignedBox aBox = aObj.GetWorldBoundingBox();
// check object against the others in this node
foreach ( MovableObject bObj in objectsDone )
{
if ( aBox.Intersects( bObj.GetWorldBoundingBox() ) )
{
// check if this pair is already reported
IList interObjList = objIntersections.FindBucket( aObj );
if ( interObjList == null || interObjList.Contains( bObj ) == false )
{
objIntersections.Add( aObj, bObj );
listener.OnQueryResult( aObj, bObj );
}
}
}
if ( ( QueryTypeMask & (uint)SceneQueryTypeMask.WorldGeometry ) != 0 )
{
// check object against brushes
if ( ( QueryTypeMask & (ulong)SceneQueryTypeMask.WorldGeometry ) != 0 )
{
foreach ( BspBrush brush in leaf.SolidBrushes )
{
if ( brush == null )
continue;
// test brush against object
boundedVolume.planes = brush.Planes;
if ( boundedVolume.Intersects( aBox ) )
{
// check if this pair is already reported
IList interBrushList = brushIntersections.FindBucket( aObj );
if ( interBrushList == null || interBrushList.Contains( brush ) == false )
{
brushIntersections.Add( aObj, brush );
// report this brush as it's WorldFragment
listener.OnQueryResult( aObj, brush.Fragment );
}
}
}
}
}
objectsDone.Add( aObj );
}
++leafPoint;
}
}