void OctreeSceneManager::walkOctree( OctreeCamera *camera, RenderQueue *queue, Octree *octant, VisibleObjectsBoundsInfo* visibleBounds, bool foundvisible, bool onlyShadowCasters ) { //return immediately if nothing is in the node. if ( octant -> numNodes() == 0 ) return ; OctreeCamera::Visibility v = OctreeCamera::NONE; if ( foundvisible ) { v = OctreeCamera::FULL; } else if ( octant == mOctree ) { v = OctreeCamera::PARTIAL; } else { AxisAlignedBox box; octant -> _getCullBounds( &box ); v = camera -> getVisibility( box ); } // if the octant is visible, or if it's the root node... if ( v != OctreeCamera::NONE ) { //Add stuff to be rendered; Octree::NodeList::iterator it = octant -> mNodes.begin(); if ( mShowBoxes ) { mBoxes.push_back( octant->getWireBoundingBox() ); } bool vis = true; while ( it != octant -> mNodes.end() ) { OctreeNode * sn = *it; // if this octree is partially visible, manually cull all // scene nodes attached directly to this level. if ( v == OctreeCamera::PARTIAL ) vis = camera -> isVisible( sn -> _getWorldAABB() ); if ( vis ) { mNumObjects++; sn -> _addToRenderQueue(camera, queue, onlyShadowCasters, visibleBounds ); mVisible.push_back( sn ); if ( mDisplayNodes ) queue -> addRenderable( sn->getDebugRenderable() ); // check if the scene manager or this node wants the bounding box shown. if (sn->getShowBoundingBox() || mShowBoundingBoxes) sn->_addBoundingBoxToQueue(queue); } ++it; } Octree* child; bool childfoundvisible = (v == OctreeCamera::FULL); if ( (child = octant -> mChildren[ 0 ][ 0 ][ 0 ]) != 0 ) walkOctree( camera, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters ); if ( (child = octant -> mChildren[ 1 ][ 0 ][ 0 ]) != 0 ) walkOctree( camera, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters ); if ( (child = octant -> mChildren[ 0 ][ 1 ][ 0 ]) != 0 ) walkOctree( camera, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters ); if ( (child = octant -> mChildren[ 1 ][ 1 ][ 0 ]) != 0 ) walkOctree( camera, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters ); if ( (child = octant -> mChildren[ 0 ][ 0 ][ 1 ]) != 0 ) walkOctree( camera, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters ); if ( (child = octant -> mChildren[ 1 ][ 0 ][ 1 ]) != 0 ) walkOctree( camera, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters ); if ( (child = octant -> mChildren[ 0 ][ 1 ][ 1 ]) != 0 ) walkOctree( camera, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters ); if ( (child = octant -> mChildren[ 1 ][ 1 ][ 1 ]) != 0 ) walkOctree( camera, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters ); } }