Axiom.SceneManagers.Bsp.BspIntersectionSceneQuery.Execute C# (CSharp) Method

Execute() public method

Go through each leaf node in BspLevel and check movables against each other and against BspBrush fragments. The bounding boxes of object are used when checking for the intersections.
public Execute ( IIntersectionSceneQueryListener listener ) : void
listener IIntersectionSceneQueryListener
return void
		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;
			}
		}
BspIntersectionSceneQuery