Changeset 2502


Ignore:
Timestamp:
07/03/07 14:29:17 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/OnlineCullingCHC
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h

    r2360 r2502  
    253253        /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer 
    254254        bool mExecuteVertexProgramForAllPasses; 
    255  
    256255        /// if hierarchical culling is currently in use 
    257256        bool mIsHierarchicalCulling; 
     
    259258        /// do we use preprocessed visibility 
    260259        bool mViewCellsLoaded; 
    261  
    262260        /// the view cells manager handling the preprocesor stuff 
    263261        GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager; 
    264  
    265  
    266262        /// Used to assign Ogre meshes to view cell entries. 
    267263        GtpVisibilityPreprocessor::ObjectContainer mObjects; 
    268264 
    269         GtpVisibilityPreprocessor::ViewCell *mElementaryViewCell; 
     265        /// the currently visible view cell 
    270266        GtpVisibilityPreprocessor::ViewCell *mCurrentViewCell; 
    271267 
    272         /// If view cells are used. 
     268        /// If view cells + PVS is used for rendering. 
    273269        bool mUseViewCells; 
    274270 
     
    276272        bool mShowViewCells; 
    277273 
    278         /// if the view cells are filtered 
    279         bool mUseVisibilityFilter; 
    280  
     274        /// if render queue should be flushed occasionally 
    281275        bool mDeleteQueueAfterRendering; 
    282276 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp

    r2455 r2502  
    5252mViewCellsLoaded(false), 
    5353mUseViewCells(false), 
    54 mUseVisibilityFilter(false), 
    5554mCurrentViewCell(NULL), 
    56 mElementaryViewCell(NULL), 
    5755mDeleteQueueAfterRendering(true), 
    5856mNormalExecution(false), 
     
    113111{ 
    114112        CLEAR_CONTAINER(mObjects); 
    115  
    116113        OGRE_DELETE(mHierarchyInterface); 
    117         OGRE_DELETE(mCurrentViewCell); 
    118  
    119114        OGRE_DELETE(mObjReader); 
    120115} 
     
    169164        LoadScene(mFilename, mViewCellsFilename); 
    170165         
    171         // load view cells: load later ... 
    172         if (0) mViewCellsLoaded = LoadViewCells(mViewCellsFilename); 
    173  
    174166        if (mShowTerrain) 
    175167        {        
     
    292284                { 
    293285                        mShowTerrain = true; 
    294                         LogManager::getSingleton().logMessage("loading terrain"); 
     286                        LogManager::getSingleton().logMessage("scene: loading terrain"); 
    295287                } 
    296288                else 
    297289                { 
    298290                        mShowTerrain = false; 
    299                         LogManager::getSingleton().logMessage("loading geometry"); 
     291                        LogManager::getSingleton().logMessage("scene: loading geometry"); 
    300292                } 
    301293        } 
     
    564556{ 
    565557        GtpVisibilityPreprocessor::ObjectPvsIterator pit =  
    566                         mCurrentViewCell->GetPvs().GetIterator(); 
     558                mCurrentViewCell->GetPvs().GetIterator(); 
    567559 
    568560        while (pit.HasMoreEntries()) 
     
    587579//----------------------------------------------------------------------- 
    588580void OcclusionCullingSceneManager::ShowViewCellsGeometry() 
    589 {/* 
     581{ 
     582#if TODO 
    590583        // show only current view cell 
    591584        if (!mShowViewCells) 
     
    607600                                (*mit).second->_updateRenderQueue(getRenderQueue()); 
    608601                }        
    609         }*/ 
     602        } 
     603#endif 
    610604} 
    611605//----------------------------------------------------------------------- 
     
    697691        { 
    698692                // show current view cell geometry 
    699                 if (mCurrentViewCell)// && mCurrentViewCell->GetMesh()) 
     693                if (mCurrentViewCell) 
    700694                { 
    701695                        //const bool showSingleViewCell = true; 
     
    882876                mVisible.clear(); 
    883877                mBoxes.clear(); 
    884  
    885878                // clear render queue before depth pass 
    886879                getRenderQueue()->clear(); 
     
    11221115        } 
    11231116        if (key == "UseViewCells") 
    1124         {        
    1125                 if (!mViewCellsLoaded) 
    1126                 { 
     1117        { 
     1118                bool useViewCells = *static_cast<const bool *>(val); 
     1119 
     1120                if (useViewCells && !mViewCellsLoaded) 
     1121                {                
    11271122                        // try to load view cells 
    11281123                        mViewCellsLoaded = LoadViewCells(mViewCellsFilename);    
    1129                 } 
    1130  
    1131                 if (!mViewCellsLoaded) 
    1132                         return false; 
    11331124                 
     1125                        if (!mViewCellsLoaded) 
     1126                                // something went wrong => bail out 
     1127                                return false; 
     1128                } 
     1129 
    11341130                // only use this option if view cells are available 
    1135                 mUseViewCells = *static_cast<const bool *>(val); 
    1136  
    1137                 // reset view cell 
    1138                 OGRE_DELETE(mCurrentViewCell); 
    1139                          
    1140                 if (mUseViewCells) 
    1141                 { 
    1142                         mCurrentViewCell = mViewCellsManager->GenerateViewCell(); 
    1143                 } 
    1144                  
    1145                 // view cell corresponding to leaf in the view cell hierarchy 
    1146                 mElementaryViewCell = NULL; 
    1147  
    1148                 // all objects are set to invisible per default 
    1149                 SetObjectsVisible(!mUseViewCells); 
    1150  
     1131                mUseViewCells = useViewCells; 
     1132 
     1133                // reset current view cell 
     1134                mCurrentViewCell = NULL; 
     1135 
     1136                // if we don't use the view cells, all objects are set to invisible per default 
     1137                //SetObjectsVisible(!mUseViewCells); 
     1138 
     1139                // note: this sets the objects invisible which are not in the pvs ... 
    11511140                MovableObjectIterator movit = getMovableObjectIterator("Entity"); 
    11521141                while (movit.hasMoreElements()) 
     
    11811170                return true; 
    11821171        } 
    1183         if (key == "UseVisibilityFilter") 
    1184         { 
    1185                 mUseVisibilityFilter = *static_cast<const bool *>(val); 
    1186  
    1187                 // set null => recomputation of the pvs 
    1188         mElementaryViewCell = NULL; 
    1189  
    1190                 return true; 
    1191         } 
    11921172        if (key == "UseVisibilityQueries") 
    11931173        { 
    11941174                mUseVisibilityQueries = *static_cast<const bool *>(val); 
    1195  
    11961175                return true; 
    11971176        } 
     
    11991178        { 
    12001179                mUseFromPointQueries = *static_cast<const bool *>(val); 
    1201  
    12021180                return true; 
    12031181        } 
     
    12051183        { 
    12061184                mQueryMode = *static_cast<const int *>(val); 
    1207  
    12081185                return true; 
    12091186        } 
     
    16891666{ 
    16901667        GtpVisibilityPreprocessor::ObjectContainer::iterator it, it_end = mObjects.end(); 
    1691  
    16921668        for (it = mObjects.begin(); it != it_end; ++ it) 
    1693         { 
    1694                 GtpVisibilityPreprocessor::Intersectable *entry = *it; 
    1695  
    1696                 SetObjectVisible(entry, visible); 
    1697         } 
     1669                SetObjectVisible(*it, visible); 
    16981670} 
    16991671//----------------------------------------------------------------------- 
     
    17171689        mViewCellsManager =  
    17181690                GtpVisibilityPreprocessor::ViewCellsManager:: 
    1719                         LoadViewCells(filename, mObjects, false, &bconverter); 
     1691                        LoadViewCells(filename, mObjects, finalizeViewCells, &bconverter); 
    17201692         
    17211693        LogManager::getSingleton().logMessage("******** view cells loaded *********"); 
    17221694 
    17231695        // objects are set to invisible initially 
    1724         SetObjectsVisible(false); 
     1696        //SetObjectsVisible(false); 
    17251697 
    17261698        if (finalizeViewCells) 
    1727         { 
    17281699                CreateViewCellsGeometry(); 
    1729         } 
    17301700 
    17311701        return (mViewCellsManager != NULL); 
     
    17331703//------------------------------------------------------------------------- 
    17341704void OcclusionCullingSceneManager::ApplyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc,  
    1735                                                                                                         const bool load) 
     1705                                                                                                        const bool loadObjects) 
    17361706{        
    1737         // NOTE: should not encounter NULL view cell,  
    17381707        // rather apply view cell representing unbounded space then 
    17391708        if (!vc)  
    17401709        {        
    1741                 LogManager::getSingleton().logMessage("error: should not come here"); 
     1710                LogManager::getSingleton().logMessage("no view cell or outside of view space, setting everything to invisible"); 
    17421711                // question: if no view cell, set everything visible? 
    17431712                SetObjectsVisible(false); 
     
    17461715                 
    17471716        //////////// 
    1748         //-- set PVS of view cell to visible 
     1717        //-- set view cell PVS to visible 
    17491718 
    17501719        GtpVisibilityPreprocessor::ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 
     
    17531722        {                
    17541723                GtpVisibilityPreprocessor::Intersectable *obj = pit.Next(); 
    1755  
    17561724                // no associated geometry found 
    17571725                if (!obj) continue; 
    1758          
    1759                 SetObjectVisible(obj, load); 
     1726                SetObjectVisible(obj, loadObjects); 
    17601727        } 
    17611728} 
     
    17691736                OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition()); 
    17701737 
    1771         GtpVisibilityPreprocessor::ViewCell *newElementary =  
     1738        GtpVisibilityPreprocessor::ViewCell *viewCell =  
    17721739                mViewCellsManager->GetViewCell(viewPoint); 
    17731740 
    1774         // elementary view cell did not change => don't change pvs 
    1775         if (mElementaryViewCell == newElementary) 
     1741        // view cell did not change => don't change pvs 
     1742        if (mCurrentViewCell == viewCell) 
    17761743                return; 
    17771744 
    1778         mElementaryViewCell = newElementary; 
    1779          
    17801745 
    17811746        ////////////// 
    1782         //-- unload old pvs 
     1747        //-- unload old pvs and load new pvs 
    17831748 
    17841749        ApplyViewCellPvs(mCurrentViewCell, false); 
    17851750 
    1786         // the new view cell 
    1787         GtpVisibilityPreprocessor::ViewCell *viewCell; 
    1788                  
    1789         if (mUseVisibilityFilter) 
    1790         {        
    1791                 //////////// 
    1792                 //-- compute new filtered cell 
    1793  
    1794                 GtpVisibilityPreprocessor::PrVs prvs; 
    1795                 mViewCellsManager->GetPrVS(viewPoint, prvs, 5); 
    1796                 viewCell = prvs.mViewCell; 
    1797         } 
    1798         else 
    1799         { 
    1800                 viewCell = newElementary; 
    1801         } 
    1802  
    1803         /////////////// 
    1804         //-- load new pvs 
    1805  
    1806         ApplyViewCellPvs(viewCell, true); 
    1807  
    1808         if (viewCell) 
    1809         { 
    1810                 // store current view cell 
    1811                 mCurrentViewCell->SetPvs(viewCell->GetPvs()); 
    1812                 mCurrentViewCell->SetMesh(viewCell->GetMesh()); 
    1813                 mCurrentViewCell->SetId(viewCell->GetId()); 
    1814  
    1815                 // delete merge tree of filtered view cell 
    1816                 if (mUseVisibilityFilter) 
    1817                         mViewCellsManager->DeleteLocalMergeTree(viewCell); 
    1818         } 
     1751        mCurrentViewCell = viewCell; 
     1752        ApplyViewCellPvs(mCurrentViewCell, true); 
    18191753} 
    18201754//------------------------------------------------------------------------- 
     
    20892023                                                                                                bool includeOverlays) 
    20902024{ 
    2091         if (mNormalExecution) 
     2025        if (0 && mNormalExecution) 
    20922026        { 
    20932027                TerrainSceneManager::_renderScene(camera, vp, includeOverlays); 
     
    23182252                std::stringstream d;  
    23192253                d << "Query mode: " << queryModes  
    2320                   << " visible nodes: " << (int)visibleNodes.size()  
    2321                   << " visible geometry: " << (int)visibleGeometry.size(); 
     2254                  << ", visible nodes: " << (int)visibleNodes.size()  
     2255                  << ", visible geometry: " << (int)visibleGeometry.size(); 
    23222256 
    23232257                LogManager::getSingleton().logMessage(d.str()); 
     
    25452479                                                                                                           bool onlyShadowCasters)                                                                                
    25462480{ 
    2547         if (mNormalExecution || (!mUseVisibilityQueries == 0)) 
     2481        if (mNormalExecution || !mUseVisibilityQueries) 
    25482482        { 
    25492483                TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
     
    25672501        int queryModes = 0; 
    25682502 
    2569         if (mQueryMode != 0) 
     2503        if (mQueryMode != EXACT_QUERIES) 
    25702504        { 
    25712505                queryModes |= GtpVisibility::QueryManager::NODE_VISIBILITY; 
    25722506 
    2573                 if (mQueryMode == 2) 
     2507                // approximate visibility not for exact queries 
     2508                if (mQueryMode == APPROXIMATE_QUERIES) 
    25742509                        approximateVisibility = true; 
    25752510        } 
     
    26112546        } 
    26122547                 
    2613         if (0) 
     2548        if (1) 
    26142549        { 
    26152550                std::stringstream d;  
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp

    r2497 r2502  
    101101                        else 
    102102                        { 
    103                                 // fully visible subtree => render all in one bathc 
     103                                // fully visible subtree => render all in one batch 
    104104                                if (mHierarchyInterface->IsNodeFullyVisible(node)) 
    105105                                { 
     
    124124                                                mHierarchyInterface->SetNodeVisible(leaf, false); 
    125125 
    126                                                 // update node's visited flag 
     126                                                // update node's visited flag: this is important as we are not testing 
     127                                                // all nodes in the hierarchy in this mode 
    127128                                                mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId()); 
    128  
    129                                                 const bool testGeometry =mTestGeometryForVisibleLeaves; 
    130  
     129                                                // issue the query 
    131130                                                mHierarchyInterface->IssueNodeOcclusionQuery(node, mTestGeometryForVisibleLeaves); 
    132131                                        } 
Note: See TracChangeset for help on using the changeset viewer.