Ignore:
Timestamp:
10/05/07 15:36:52 (17 years ago)
Author:
mattausch
Message:

added partial implementation of chc++. problem: bounding box rendering in Ogre is VERY slow

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp

    r2455 r2555  
    3232                Octree *nextChild; 
    3333 
    34                 for (int z = 0; z < 2; ++ z) 
    35                 {        
    36                         for (int y = 0; y < 2; ++ y) 
    37                         { 
    38                                 for (int x = 0; x < 2; ++ x) 
    39                                 { 
    40                                         nextChild = octree->mChildren[x][y][z]; 
    41          
    42                                         if (nextChild) 
    43                         GetQueue()->push(nextChild); 
    44                                 } 
    45             } 
    46         } 
     34                nextChild = octree->mChildren[0][0][0]; if (nextChild) GetQueue()->push(nextChild); 
     35                nextChild = octree->mChildren[1][0][0]; if (nextChild) GetQueue()->push(nextChild); 
     36                nextChild = octree->mChildren[0][1][0]; if (nextChild) GetQueue()->push(nextChild); 
     37                nextChild = octree->mChildren[1][1][0]; if (nextChild) GetQueue()->push(nextChild); 
     38                nextChild = octree->mChildren[0][0][1]; if (nextChild) GetQueue()->push(nextChild); 
     39                nextChild = octree->mChildren[1][0][1]; if (nextChild) GetQueue()->push(nextChild); 
     40                nextChild = octree->mChildren[0][1][1]; if (nextChild) GetQueue()->push(nextChild); 
     41                nextChild = octree->mChildren[1][1][1]; if (nextChild) GetQueue()->push(nextChild); 
     42        } 
     43} 
     44//----------------------------------------------------------------------- 
     45void OctreeHierarchyInterface::TraverseNode2(GtpVisibility::HierarchyNode *node) 
     46{ 
     47        ++ mNumTraversedNodes; 
     48 
     49        Octree *octree = static_cast<Octree *>(node); 
     50 
     51        // if we come across some renderable geometry => render it 
     52        if (!octree->mNodes.empty()) 
     53        { 
     54                AddToQueue(node); 
     55        } 
     56         
     57        // if not all subtrees are empty 
     58        if (!IsLeaf(node)) 
     59        { 
     60                Octree *nextChild; 
     61 
     62                nextChild = octree->mChildren[0][0][0]; if (nextChild) GetQueue()->push(nextChild); 
     63                nextChild = octree->mChildren[1][0][0]; if (nextChild) GetQueue()->push(nextChild); 
     64                nextChild = octree->mChildren[0][1][0]; if (nextChild) GetQueue()->push(nextChild); 
     65                nextChild = octree->mChildren[1][1][0]; if (nextChild) GetQueue()->push(nextChild); 
     66                nextChild = octree->mChildren[0][0][1]; if (nextChild) GetQueue()->push(nextChild); 
     67                nextChild = octree->mChildren[1][0][1]; if (nextChild) GetQueue()->push(nextChild); 
     68                nextChild = octree->mChildren[0][1][1]; if (nextChild) GetQueue()->push(nextChild); 
     69                nextChild = octree->mChildren[1][1][1]; if (nextChild) GetQueue()->push(nextChild); 
    4770        } 
    4871} 
     
    195218        if (octant->lastRendered() != mFrameId) 
    196219        { 
     220                mTestMode = false; 
     221 
    197222                octant->setLastRendered(mFrameId); 
    198223                OctreeSceneManager *ocm =  
    199224                        static_cast<OctreeSceneManager *>(mSceneManager); 
    200225 
    201                 ocm->_renderOctant(mCamera,  
     226                ocm->_addOctantToQueue(mCamera,  
    202227                                                   octant,  
    203228                                                   mOnlyShadowCasters,  
    204229                                                   mLeavePassesInQueue); 
    205230 
     231                ocm->_renderOctant(mLeavePassesInQueue); 
     232 
    206233                mVisibleNodes.push_back(node); 
    207234        } 
     235#endif   
     236} 
     237//----------------------------------------------------------------------- 
     238void OctreeHierarchyInterface::AddToQueue(GtpVisibility::HierarchyNode *node) 
     239{ 
     240#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
     241        Octree *octant = static_cast<Octree *>(node); 
     242 
     243        if (octant->lastRendered() != mFrameId) 
     244        { 
     245                OctreeSceneManager *ocm =  
     246                        static_cast<OctreeSceneManager *>(mSceneManager); 
     247 
     248                octant->setLastRendered(mFrameId); 
     249 
     250                ocm->_addOctantToQueue(mCamera,  
     251                                                   octant,  
     252                                                   mOnlyShadowCasters,  
     253                                                   mLeavePassesInQueue); 
     254 
     255                mVisibleNodes.push_back(node); 
     256        } 
     257#endif   
     258} 
     259//----------------------------------------------------------------------- 
     260void OctreeHierarchyInterface::RenderQueue() 
     261{ 
     262#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
     263        mTestMode = false; 
     264 
     265        OctreeSceneManager *ocm =  
     266                        static_cast<OctreeSceneManager *>(mSceneManager); 
     267        ocm->_renderOctant(mLeavePassesInQueue); 
    208268#endif   
    209269} 
Note: See TracChangeset for help on using the changeset viewer.