Axiom.SceneManagers.Bsp.BspSceneManager.WalkTree C# (CSharp) Method

WalkTree() protected method

Walks the BSP tree looking for the node which the camera is in, and tags any geometry which is in a visible leaf for later processing.
protected WalkTree ( Camera camera, bool onlyShadowCasters ) : Axiom.SceneManagers.Bsp.BspNode
camera Axiom.Core.Camera
onlyShadowCasters bool
return Axiom.SceneManagers.Bsp.BspNode
		protected BspNode WalkTree( Camera camera, bool onlyShadowCasters )
		{
			if ( level == null )
			{
				return null;
			}

			// Locate the leaf node where the camera is located
			BspNode cameraNode = level.FindLeaf( camera.DerivedPosition );

			matFaceGroupMap.Clear();
			faceGroupChecked.Clear();

			// Scan through all the other leaf nodes looking for visibles
			int i = level.NumNodes - level.LeafStart;
			int p = level.LeafStart;
			BspNode node;

			while ( i-- > 0 )
			{
				node = level.Nodes[ p ];

				if ( level.IsLeafVisible( cameraNode, node ) )
				{
					// Visible according to PVS, check bounding box against frustum
					//if ( camera.IsObjectVisible( node.BoundingBox ) )
					{
						ProcessVisibleLeaf( node, camera, onlyShadowCasters );

						if ( showNodeAABs )
							AddBoundingBox( node.BoundingBox, true );
					}
				}

				p++;
			}

			return cameraNode;
		}