Changeset 2455


Ignore:
Timestamp:
06/14/07 17:24:08 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk
Files:
1 deleted
31 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp

    r2359 r2455  
    135135mUseDepthPass(false), 
    136136mTestGeometryForVisibleLeaves(false), 
     137mTestGeometryBounds(false), 
    137138mShowVisualization(false), 
    138139mCullCamera(false), 
     
    165166mUseViewCells(false), 
    166167mViewCellsLoaded(false), 
    167 mUseVisibilityFilter(false), 
    168168mFloorDist(2), 
    169169mFlushQueue(false), 
     
    171171m_iBoundingBoxLevel(0) 
    172172{ 
    173         //mInputDevice = PlatformManager::getSingleton().createInputReader(); 
    174         //mInputDevice->initialise(win, true, true); 
    175  
    176173        mEventProcessor = new EventProcessor(); 
    177174         
     
    242239        // the scale factor for the visualized bounding boxes 
    243240        mSceneMgr->setOption("NodeVizScale", &mVizScale); 
    244          
    245         ///////// 
    246         //-- set the current culling algorithm type 
    247         //setAlgorithm(mApplication->mAlgorithm); 
     241 
     242        int assumedIncr; 
     243        mSceneMgr->getOption("AssumedVisibility", &assumedIncr); 
     244        changeAssumedVisibility(assumedIncr); 
     245 
     246        ///// 
     247        // test geometry boundaries instead bounding box 
     248        mSceneMgr->getOption("TestGeometryBounds", &mTestGeometryBounds); 
     249        setTestGeometryBounds(mTestGeometryBounds); 
     250 
     251        ///////////////////////////////// 
     252        // culling algorithm 
    248253 
    249254        bool isNormalExecution; 
    250255                 
    251256        mSceneMgr->getOption("NormalExecution", &isNormalExecution); 
     257         
    252258        if (isNormalExecution) 
    253259        { 
    254260                // no algorithm 
    255                 mCurrentAlgorithm =  
    256                         GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS; 
     261                mCurrentAlgorithm = GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS; 
    257262        } 
    258263        else 
     
    261266        } 
    262267         
     268        // apply the chosen culling algorithm 
    263269        applyCurrentAlgorithm(); 
    264270         
     271 
    265272        /////////////////////////////// 
    266  
    267273        // set scene manager options 
     274         
     275        ////////// 
     276        mSceneMgr->getOption("TestGeometryForVisibleLeaves", &mTestGeometryForVisibleLeaves); 
    268277        setTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves); 
    269278 
    270         //mSceneMgr->setOption("UseDepthPass", &mUseDepthPass); 
     279        ///////////// 
    271280        mSceneMgr->getOption("UseDepthPass", &mUseDepthPass); 
    272281 
     
    278287        mSceneMgr->getOption("FlushQueue", &mFlushQueue); 
    279288         
     289        ////////// 
    280290        if (mFlushQueue) 
    281291                LogManager::getSingleton().logMessage("initial setting: flushing queue"); 
     
    283293                LogManager::getSingleton().logMessage("initial setting: not flushing queue"); 
    284294 
     295        ///////////// 
    285296        mSceneMgr->setOption("ShowOctree", &mShowOctree); 
    286297        mSceneMgr->setOption("ShowViewCells", &mShowViewCells); 
     
    290301        applyObjectType(); 
    291302 
    292         // initialise timer 
     303 
     304        /////////////// 
     305        // initialize timer 
     306 
    293307        mTimer = Root::getSingleton().getTimer(); 
    294308        mTimeFrameEnded = mTimeFrameStarted = mTimer->getMilliseconds(); 
    295309         
    296         // init view cell parameters 
    297         mSceneMgr->setOption("UseVisibilityFilter", &mUseVisibilityFilter); 
    298  
    299310        // reset statistics 
    300311        mWalkthroughStats.Reset(); 
     
    863874                mFrameInfo.push_back(info); 
    864875                 
    865                 // std::stringstream d; d << StringConverter::toString(info.position) << " " << StringConverter::toString(info.orientation); 
    866                 // LogManager::getSingleton().logMessage(d.str()); 
    867876                ++ i; 
    868877        } 
     
    892901                // we produced precomputed fps during the last replay => 
    893902                // save them to file 
    894                 if (mSavePrecomputedFps) //!mPrecomputedFpsFrameInfo.empty()) 
     903                if (mSavePrecomputedFps) 
    895904                { 
    896905                        std::string filename = msApprevAlgorithmCaptions[mCurrentAlgorithm] + "_frames.out"; 
     
    9971006 
    9981007        if (mAssumedVisibility < 0)  
    999         {        
    10001008                mAssumedVisibility = 0; 
    1001         } 
    10021009 
    10031010        char str[100]; sprintf(str,": %d", mAssumedVisibility); 
     
    12291236        mSceneMgr->setOption("TestGeometryForVisibleLeaves", &mTestGeometryForVisibleLeaves); 
    12301237         
    1231         /* disable optimization which tests geometry instead of aabb 
    1232          * for "delayed" rendering of transparents (i.e., render transparents after all the solids) 
    1233          * because otherwise visible transparents could be skipped 
    1234          */ 
    1235         bool delayedRendering = !mTestGeometryForVisibleLeaves; 
    1236  
    1237         mSceneMgr->setOption("DelayRenderTransparents", &delayedRendering); 
    1238  
     1238        // disable optimization for transparent objects, becaue otherwise visible  
     1239        // transparents could be skipped 
    12391240        if (mTestGeometryForVisibleLeaves) 
    1240         { 
    12411241                mTestGeometryForVisibleLeavesInfo->setCaption(": true"); 
    1242         } 
    12431242        else 
    1244         { 
    12451243                mTestGeometryForVisibleLeavesInfo->setCaption(": false"); 
    1246         } 
    1247 } 
     1244} 
     1245//----------------------------------------------------------------------- 
     1246void TerrainFrameListener::setTestGeometryBounds(bool testGeometryBounds) 
     1247{ 
     1248        mSceneMgr->setOption("TestGeometryBounds", &mTestGeometryBounds); 
     1249         
     1250        if (mTestGeometryBounds) 
     1251                LogManager::getSingleton().logMessage("Testing geometry boundaries"); 
     1252        else 
     1253                LogManager::getSingleton().logMessage("Testing bounding box of hierarchy node"); 
     1254} 
     1255 
    12481256//----------------------------------------------------------------------- 
    12491257void TerrainFrameListener::toggleShowOctree() 
     
    12931301} 
    12941302//----------------------------------------------------------------------- 
    1295 void TerrainFrameListener::toggleUseVisibilityFilter() 
    1296 { 
    1297         mUseVisibilityFilter = !mUseVisibilityFilter; 
    1298         mSceneMgr->setOption("UseVisibilityFilter", &mUseVisibilityFilter); 
    1299 } 
    1300 //----------------------------------------------------------------------- 
    13011303void TerrainFrameListener::toggleUseDepthPass() 
    13021304{ 
     
    14851487                break; 
    14861488        case KC_Q: 
    1487                 toggleUseVisibilityFilter(); 
     1489                mTestGeometryBounds = !mTestGeometryBounds; 
     1490                setTestGeometryBounds(mTestGeometryBounds); 
    14881491                break; 
    14891492        case KC_R: 
  • GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.h

    r2359 r2455  
    224224        void changeAssumedVisibility(int incr); 
    225225        void changeVizScale(const int incr); 
     226         
    226227        void setTestGeometryForVisibleLeaves(bool testGeometryForVisibleLeaves); 
     228         
     229        void setTestGeometryBounds(bool testGeometryBounds); 
     230 
    227231        /** Shows visualization of octree hierarchy nodes. 
    228232        */ 
    229233        void toggleShowOctree(); 
     234 
    230235        /** Shows visualization of the view cells. 
    231236        */ 
    232237        void toggleShowViewCells(); 
     238         
    233239        /** Toggles between view cells / no view cells. 
    234240        */ 
    235241        void toggleUseViewCells(); 
    236  
    237         void toggleUseVisibilityFilter(); 
    238242 
    239243        /** Toggles whether we use the initial depth pass. 
     
    372376        OverlayElement *mQueryGeometryVisibilityInfo; 
    373377        OverlayElement *mQueryPatchVisibilityInfo; 
    374         //OverlayElement *mHelpInfo; 
    375378 
    376379        RayQueryExecutor *mRayQueryExecutor; 
     
    378381 
    379382        bool mTestGeometryForVisibleLeaves; 
     383        bool mTestGeometryBounds; 
     384 
    380385        bool mShowOctree; 
    381386        bool mShowViewCells; 
     
    389394        bool mShowHelp; 
    390395        bool mStatsOn; 
     396         
     397 
     398        //////// 
     399        //-- true if the mouse buttons are down 
     400         
    391401        bool mLMouseDown; 
    392         // True if the mouse buttons are down 
    393402        bool mRMouseDown;     
    394403        bool mShutdownRequested; 
     
    397406        bool mUseAnimation; 
    398407         
     408 
    399409        int mItemBufferMode; 
    400410 
     
    410420         
    411421        Real mReplayTimeElapsed; 
    412         //EventProcessor* mEventProcessor; 
    413422    InputReader* mInputDevice; 
    414423    Camera* mCamera; 
     
    446455        bool mShowQueryStats; 
    447456         
    448         //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 
    449457        PlatformQueryManager *mQueryManager; 
    450458 
     
    467475        bool mUseViewCells; 
    468476        bool mViewCellsLoaded; 
    469         bool mUseVisibilityFilter; 
    470477 
    471478        float mFloorDist; 
  • GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp

    r2401 r2455  
    2525 
    2626 
    27 //using namespace GtpVisibility; 
    2827 
    2928/*************************************************************/ 
     
    478477                if (0) generateScene(1000, 2); // create trees 
    479478        } 
    480         int MaxDepth=30; 
    481         mSceneMgr->setOption("BiHierarchyMaxDepth", &MaxDepth); 
    482         int Mode=1; 
    483         mSceneMgr->setOption("EnhancedVisibility", &Mode); 
     479 
     480        int maxDepth = 30; 
     481         
     482        mSceneMgr->setOption("BiHierarchyMaxDepth", &maxDepth); 
     483         
     484        int mode = 1; 
     485         
     486        mSceneMgr->setOption("EnhancedVisibility", &mode); 
    484487        mSceneMgr->setOption("RebuildBiHierarchy", NULL); 
    485488        mSceneMgr->setOption("RebuildKdTree", NULL); 
     
    509512        //-- add animation state for new robots (located at the end of the list) 
    510513         
    511         for (int i = (int)entList->size() - num; i < (int)entList->size(); ++i) 
     514        for (size_t i = entList->size() - (unsigned int)num; i < entList->size(); ++ i) 
    512515        { 
    513516                mEntityStates.push_back(new EntityState((*entList)[i],  
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTreeAppListener.h

    r2382 r2455  
    7878                NODEVIZ_RENDER_NODES,  
    7979                NODEVIZ_RENDER_NODES_AND_CONTENT,  
     80                NODEVIZ_RENDER_PVS, 
    8081                NODEVIZ_MODES_NUM 
    8182        }; 
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTreeAppListener.cpp

    r2382 r2455  
    517517                mSceneMgr->setOption("RenderNodesForViz", &renderNodesForViz); 
    518518                mSceneMgr->setOption("RenderNodesContentForViz", &renderNodesContentForViz); 
    519                 mSceneMgr->setOption("RenderPvsForViz", &renderPvs); 
     519                mSceneMgr->setOption("RenderPvsForViz", &renderPvsForViz); 
    520520 
    521521        } 
     
    17791779                        for (size_t i = 0; i < mDemoFPS.size(); i ++) 
    17801780                        { 
    1781                                 logheader << (i+1) << fs; 
     1781                                logheader << (i + 1) << fs; 
    17821782                        } 
    17831783                        // minFPS, avgFPS, maxFPS, frames, time, render system, comment, record separator 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOctreeHierarchyInterface.h

    r2332 r2455  
    6464 
    6565        void PullUpLastVisited(GtpVisibility::HierarchyNode *node, const int frameId) const; 
    66         void DetermineVisibilityRatio(GtpVisibility::HierarchyNode *node) const; 
    67         float GetNodeVisibilityRatio(GtpVisibility::HierarchyNode *node) const; 
     66         
     67        GtpVisibility::HierarchyNode *GetParent(GtpVisibility::HierarchyNode *node); 
    6868 
    69         GtpVisibility::HierarchyNode *GetParent(GtpVisibility::HierarchyNode *node); 
     69 
     70         
     71        /** Returns #frames this node is assumed to be visible. 
     72        */ 
     73        int GetNodeAssumedVisible(GtpVisibility::HierarchyNode *node); 
     74 
     75        /** Sets #frames this node is assumed to be visible. 
     76        */ 
     77        void SetNodeAssumedVisible(GtpVisibility::HierarchyNode *node, int assumedVisible); 
     78         
     79        /** Decreases #frames this node is assumed to be visible. 
     80        */ 
     81        void DecNodeAssumedVisible(GtpVisibility::HierarchyNode *node); 
     82 
     83        void RenderGeometryBounds(GtpVisibility::HierarchyNode *node); 
    7084 
    7185 
     
    7791        */ 
    7892        AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node); 
     93 
    7994        /** Returns squared distance of center of box with respect to the camera . 
    8095                @param cam current camera 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgrePlatformHierarchyInterface.h

    r2332 r2455  
    2626{ 
    2727public: 
     28 
    2829        /** Construction taking the current scene manager and the  
    2930                current rendersystem as argument 
     
    3334        PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys); 
    3435        ~PlatformHierarchyInterface(); 
    35                  
    3636        /** Returns next available occlusion query or creates new one. 
    3737                @return the next occlusion query 
     
    7676        /** Issue a occlusion query for this node.  
    7777                @param node the current hierarchy node 
    78                 @param wasVisible if the node was visible in the last frame 
     78                @param gives a parameters that decideds on the type of occlusion query. 
     79                 
    7980                @returns occlusion query for this node 
    8081        */ 
    8182        GtpVisibility::OcclusionQuery *IssueNodeOcclusionQuery( 
    82                 GtpVisibility::HierarchyNode *node, const bool wasVisible); 
     83                GtpVisibility::HierarchyNode *node, const bool testGeometry = false); 
    8384 
    8485        /** Issue a occlusion query for this mesh. 
     
    8788        */ 
    8889        GtpVisibility::OcclusionQuery *IssueMeshOcclusionQuery(GtpVisibility::Mesh *mesh); 
    89  
    9090        /** If true, the interface finds and renders only objects which are marked as shadow casters. 
    9191                @remark This is important for the shadow texture pass 
     
    9595        */ 
    9696        bool GetOnlyShadowCasters(); 
    97         /** see set  
    98         */ 
    99         bool GetTestGeometryForVisibleLeaves(); 
    10097        /** see set 
    10198        */ 
    10299        SceneManager *GetSceneManager(); 
    103  
    104100        /** see set  
    105101        */ 
    106102        RenderSystem *GetRenderSystem(); 
    107          
    108103        /** true if bounding box query is currently active.  
    109104        */ 
    110105    bool IsBoundingBoxQuery(); 
    111  
     106        /** Issues occlusion queries for a patch. 
     107        */ 
    112108        GtpVisibility::OcclusionQuery *IssuePatchOcclusionQuery(GtpVisibility::Patch *patch); 
    113  
    114109        /** Deletes all occlusion queries. 
    115110        */ 
     
    126121 
    127122        void PullUpLastVisited(GtpVisibility::HierarchyNode *node, const int frameId) const {} 
    128         void DetermineVisibilityRatio(GtpVisibility::HierarchyNode *node) const {} 
    129123 
    130         float GetNodeVisibilityRatio(GtpVisibility::HierarchyNode *node) const { return 1.0f;} 
     124        GtpVisibility::HierarchyNode *GetParent(GtpVisibility::HierarchyNode *node) { return NULL; } 
    131125 
    132         GtpVisibility::HierarchyNode *GetParent(GtpVisibility::HierarchyNode *node) { return NULL;} 
     126        /** Returns #frames this node is assumed to be visible. 
     127        */ 
     128        virtual int GetNodeAssumedVisible(GtpVisibility::HierarchyNode *node) { return 0; }; 
     129        /** Sets #frames this node is assumed to be visible. 
     130        */ 
     131        virtual void SetNodeAssumedVisible(GtpVisibility::HierarchyNode *node, int assumedVisible) {}; 
     132        /** Decreases #frames this node is assumed to be visible. 
     133        */ 
     134        virtual void DecNodeAssumedVisible(GtpVisibility::HierarchyNode *node) {}; 
     135        /** Test tigher geometry bounds instead of hierarchy node. 
     136        */ 
     137        void SetTestGeometryBounds(bool testGeometryForLeaves); 
     138        /** See get 
     139        */ 
     140        int GetTestGeometryBounds(); 
    133141 
    134142 
     
    138146        */ 
    139147        void RenderGeometry(GtpVisibility::Mesh *geom); 
    140          
    141148        /** Renders the given patch  
    142149        */ 
    143150        void RenderPatch(GtpVisibility::Patch *patch); 
    144  
    145151        /** Materials for visualizing frustum and query culled nodes. 
    146152        */ 
    147153        void CreateNodeVizMaterials(); 
    148  
    149154        /** Returns pointer to current renderable bounding box geometry. 
    150155        */ 
    151156        SolidBoundingBox *GetSolidBoundingBox(); 
    152  
    153         /** A pass that prepares an occlusion query. 
    154                 @remark disables depth write, colour write, lighting, 
    155                 vertex and fragment program.*/ 
    156         //void SetOcclusionPass(); 
    157  
    158157        /** Renders given bounding box. 
    159158                @param box the bounding box of the scene node to be rendered  
    160159        */ 
    161160        void RenderBoundingBox(AxisAlignedBox *box); 
     161        /** Renders bounding boxes of the geometry. 
     162                @param node the node to be rendered 
     163        */ 
     164        virtual void RenderGeometryBounds(GtpVisibility::HierarchyNode *node) {}; 
     165         
     166 
     167        ///////////////////// 
    162168 
    163169        /** Renderable of an aabb. 
     
    179185        int mLeavePassesInQueue; 
    180186        bool mIsBoundingBoxQuery; 
     187 
     188        bool mTestGeometryBounds; 
    181189}; 
    182190 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBiHierarchyInterface.cpp

    r2348 r2455  
    8484        // reuse box if node is the same 
    8585        // only create renderable bounding box for new node 
    86         if (node != mSavedNode) 
     86        if (node != mOldNode) 
    8787        { 
    88                 mSavedNode = node; 
     88                mOldNode = node; 
    8989                mBox = BIHNODEPTR_CAST(node)->_getWorldAABB(); 
    9090        } 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBiHierarchySceneManager.cpp

    r2402 r2455  
    14291429        d << "Depth pass: " << StringConverter::toString(mUseDepthPass) << ", " 
    14301430                << "Delay transparents: " << StringConverter::toString(mDelayRenderTransparents) << ", " 
    1431                 << "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetTestGeometryForVisibleLeaves()) << ", " 
     1431                //<< "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetTestGeometryForVisibleLeaves()) << ", " 
    14321432                << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", " 
    14331433                << "Hierarchy nodes: " << (mBiHierarchy ? mBiHierarchy->getTreeStats().mNumNodes : 0) << ", "  
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeHierarchyInterface.cpp

    r2280 r2455  
    8484        // reuse box if node is the same 
    8585        // only create renderable bounding box for new node 
    86         if (node != mSavedNode) 
     86        if (node != mOldNode) 
    8787        { 
    88                 mSavedNode = node; 
     88                mOldNode = node; 
    8989                mBox = KDNODEPTR_CAST(node)->_getWorldAABB(); 
    9090        } 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp

    r2130 r2455  
    14191419        d << "Depth pass: " << StringConverter::toString(mUseDepthPass) << ", " 
    14201420                << "Delay transparents: " << StringConverter::toString(mDelayRenderTransparents) << ", " 
    1421                 << "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetTestGeometryForVisibleLeaves()) << ", " 
     1421                //<< "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetTestGeometryForVisibleLeaves()) << ", " 
    14221422                << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", " 
    14231423                << "Hierarchy nodes: " << (mKdTree ? mKdTree->getTreeStats().mNumNodes : 0) << ", "  
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp

    r2402 r2455  
    311311        } 
    312312 
     313        ///////////// 
    313314        val = config.getSetting("OnlineCullingAlgorithm"); 
    314315                 
     
    357358 
    358359        ///////////// 
    359         // terrain options 
     360        val = config.getSetting("TestGeometryForVisibleLeaves"); 
     361 
     362        if (!val.empty()) 
     363        { 
     364                if (val == "yes") 
     365                        mVisibilityManager->SetTestGeometryForVisibleLeaves(true); 
     366                else 
     367                        mVisibilityManager->SetTestGeometryForVisibleLeaves(false); 
     368        } 
     369 
     370        ///////////// 
     371        val = config.getSetting("TestGeometryBounds"); 
     372 
     373        if (!val.empty()) 
     374        { 
     375                if (val == "yes") 
     376                        mHierarchyInterface->SetTestGeometryBounds(true); 
     377                else 
     378                        mHierarchyInterface->SetTestGeometryBounds(false); 
     379        } 
     380 
     381        ///////////// 
     382        val = config.getSetting("AssumedVisibleFrames"); 
     383 
     384        if (!val.empty()) 
     385        { 
     386                mVisibilityManager->SetAssumedVisibilityForChc(atoi(val.c_str())); 
     387        } 
     388 
     389 
     390        ///////////// 
     391        val = config.getSetting("RandomUpdateCandidates"); 
     392 
     393        if (!val.empty()) 
     394        { 
     395                mVisibilityManager->SetRandomUpdateCandidatesForRuc(atoi(val.c_str())); 
     396        } 
     397 
     398 
     399        ///////////// 
     400        // output 
    360401 
    361402        if (mUseDepthPass) 
     
    395436        else 
    396437                LogManager::getSingleton().logMessage("not flushing queue after some frames"); 
     438 
     439        if (mVisibilityManager->GetTestGeometryForVisibleLeaves()) 
     440                LogManager::getSingleton().logMessage("test geometry for visible leaves"); 
     441        else 
     442                LogManager::getSingleton().logMessage("not testing geometry for visible leaves"); 
     443         
     444        if (mHierarchyInterface->GetTestGeometryBounds()) 
     445                LogManager::getSingleton().logMessage("test geometry bounds instead of bounding box"); 
     446        else 
     447                LogManager::getSingleton().logMessage("not testing geometry bounds instead of bounding box"); 
     448 
     449 
     450        ///////////// 
     451        // terrain options 
    397452 
    398453        if (!mShowTerrain) 
     
    12631318        d << "Depth pass: " << StringConverter::toString(mUseDepthPass) << ", " 
    12641319          << "Delay transparents: " << StringConverter::toString(mDelayRenderTransparents) << ", " 
    1265           << "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetTestGeometryForVisibleLeaves()) << ", " 
     1320//        << "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetTestGeometryForVisibleLeaves()) << ", " 
    12661321          << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", " 
    12671322          << "Hierarchy nodes: " << mNumOctants << ", "  
     
    16861741                LogManager::getSingleton().logMessage("error: should not come here"); 
    16871742                // question: if no view cell, set everything visible? 
    1688                 //SetObjectsVisible(true); 
    16891743                SetObjectsVisible(false); 
    16901744                return; 
     
    16931747        //////////// 
    16941748        //-- set PVS of view cell to visible 
    1695  
    1696         //std::stringstream d; d << "appying new view cell pvs: " << vc->GetPvs().GetSize(); 
    1697         //LogManager::getSingleton().logMessage(d.str()); 
    16981749 
    16991750        GtpVisibilityPreprocessor::ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 
     
    17171768        const GtpVisibilityPreprocessor::Vector3 viewPoint =  
    17181769                OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition()); 
    1719  
    1720         //std::stringstream d; d << "vp: " << viewPoint; 
    1721         //LogManager::getSingleton().logMessage(d.str()); 
    17221770 
    17231771        GtpVisibilityPreprocessor::ViewCell *newElementary =  
     
    21732221    } 
    21742222 
    2175         // Prepare render queue for receiving new objects 
    2176         //prepareRenderQueue(); 
    2177  
    21782223        mDestRenderSystem->_beginGeometryCount(); 
    21792224    // Begin the frame 
     
    22812326        /////////////////////// 
    22822327        //-- put items in render queue 
    2283         ////////// 
    22842328 
    22852329        getRenderQueue()->clear(); 
    22862330 
    2287         ////////////////////// 
    2288         //-- apply queries on geometry level 
    2289  
    22902331        if (!nodeVisibility) 
    22912332        { 
     2333                ////////////////// 
     2334                //-- apply queries on geometry level 
     2335 
    22922336                MeshInfoContainer::iterator geomIt, geomIt_end = visibleGeometry.end(); 
    22932337 
     
    23842428        if (camera->isWindowSet())   
    23852429        { 
    2386             const std::vector<Plane>& planeList =  
    2387                 camera->getWindowPlanes(); 
    2388             for (ushort i = 0; i < 4; ++i) 
     2430                        const std::vector<Plane>& planeList = camera->getWindowPlanes(); 
     2431 
     2432            for (ushort i = 0; i < 4; ++ i) 
    23892433            { 
    23902434                mDestRenderSystem->enableClipPlane(i, true); 
     
    24212465 
    24222466        RenderHierarchicalCulling(fillQueue); 
    2423         // _renderVisibleObjects(); 
    24242467    
    24252468    // End frame 
     
    25292572 
    25302573                if (mQueryMode == 2) 
    2531                 { 
    25322574                        approximateVisibility = true; 
    2533                 } 
    25342575        } 
    25352576        else 
     
    25422583                new OcclusionQueriesQueryManager(mHierarchyInterface, 
    25432584                                                                                 cam->getViewport(), 
    2544                                                                                  //mCurrentViewport, 
    25452585                                                                                 queryModes,  
    25462586                                                                                 itemBufferMode); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp

    r2360 r2455  
    33#include <OgreLogManager.h> 
    44#include <OgreStringConverter.h> 
     5#include <OgreOctreeNode.h> 
    56 
    67 
     
    187188} 
    188189//----------------------------------------------------------------------- 
    189 void OctreeHierarchyInterface::DetermineVisibilityRatio(GtpVisibility::HierarchyNode *node) const 
    190 {        
    191 #if 0    
    192         Octree *octant = static_cast<Octree *>(node); 
    193  
    194         // node not visited in this frame => no change 
    195         if (octant->lastVisited() != mFrameId) 
    196                 return; 
    197          
    198         // leaf node: terminate recursion 
    199         if (IsLeaf(node)) 
    200         { 
    201                 octant->setNumLeaves(1);         
    202                 octant->setNumVisibleLeaves(octant->isOctreeVisible() ? 1 : 0);  
    203                 return; 
    204         } 
    205  
    206         int numVisibleLeaves = 0; 
    207         int numLeaves = 0; 
    208  
    209         Octree *nextChild; 
    210          
    211         for (int i = 0; i < 8; ++ i) 
    212         { 
    213                 int x = (i & 4) / 4; 
    214                 int y = (i & 2) / 2; 
    215                 int z = i & 1; 
    216  
    217                 nextChild = octant->mChildren[x][y][z]; 
    218  
    219                 if (!nextChild) 
    220                         continue; 
    221                  
    222                 // recursive traversal 
    223                 DetermineVisibilityRatio(nextChild); 
    224                  
    225                 // this leaf is not fully visible 
    226                 numLeaves += nextChild->getNumLeaves(); 
    227                 numVisibleLeaves += nextChild->getNumVisibleLeaves(); 
    228         } 
    229  
    230         octant->setNumLeaves(numLeaves); 
    231         octant->setNumVisibleLeaves(numVisibleLeaves); 
    232 #endif 
    233 } 
    234 //----------------------------------------------------------------------- 
    235190void OctreeHierarchyInterface::RenderNode(GtpVisibility::HierarchyNode *node) 
    236191{ 
     
    290245} 
    291246//----------------------------------------------------------------------- 
    292 float OctreeHierarchyInterface::GetNodeVisibilityRatio(GtpVisibility::HierarchyNode *node) const 
    293 { 
    294 #if 0 
    295         return static_cast<Octree *>(node)->getVisibilityRatio(); 
    296 #else 
    297         return 1.0f; 
    298 #endif 
    299 } 
    300 //----------------------------------------------------------------------- 
    301247unsigned int OctreeHierarchyInterface::LastVisited(GtpVisibility::HierarchyNode *node) const 
    302248{ 
     
    312258        // reuse box if node is the same 
    313259        // only create renderable bounding box for new node 
    314         if (node != mSavedNode) 
    315         { 
    316                 mSavedNode = node; 
     260        if (node != mOldNode) 
     261        { 
     262                mOldNode = node; 
    317263            //static_cast<Octree *>(node)->_getCullBounds(&mBox); 
    318264                mBox = static_cast<Octree *>(node)->_getWorldAABB(); 
     
    374320                         
    375321                        for (int z = 0; z < 2; ++ z) 
    376                         {        
    377322                                for (int y = 0; y < 2; ++ y) 
    378                                 { 
    379323                                        for (int x = 0; x < 2; ++ x) 
    380                                         { 
    381324                                                if ((child = octree->mChildren[x][y][z]) != NULL) 
    382                                                 { 
    383325                                                        tStack.push(child); 
    384                                                 } 
    385                                         } 
    386                                 } 
    387                         } 
    388326                } 
    389327        } 
     
    394332{ 
    395333        Octree *octree = static_cast<Octree *>(node); 
    396  
    397334        return octree->getParent(); 
    398335} 
     336//----------------------------------------------------------------------- 
     337int OctreeHierarchyInterface::GetNodeAssumedVisible(GtpVisibility::HierarchyNode *node) 
     338{ 
     339        Octree *octree = static_cast<Octree *>(node); 
     340        return octree->getAssumedVisible(); 
     341} 
     342//----------------------------------------------------------------------- 
     343void OctreeHierarchyInterface::SetNodeAssumedVisible(GtpVisibility::HierarchyNode *node, int assumedVisible) 
     344{ 
     345        Octree *octree = static_cast<Octree *>(node); 
     346        octree->setAssumedVisible(assumedVisible); 
     347} 
     348//----------------------------------------------------------------------- 
     349void OctreeHierarchyInterface::DecNodeAssumedVisible(GtpVisibility::HierarchyNode *node) 
     350{ 
     351        Octree *octree = static_cast<Octree *>(node); 
     352        octree->decAssumedVisible(); 
     353} 
     354//----------------------------------------------------------------------- 
     355void OctreeHierarchyInterface::RenderGeometryBounds(GtpVisibility::HierarchyNode *node) 
     356{ 
     357        Octree *octree = static_cast<Octree *>(node); 
     358 
     359        NodeList::iterator it, it_end = octree->mNodes.end(); 
     360 
     361    for (it = octree->mNodes.begin(); it != it_end; ++ it) 
     362    { 
     363                RenderBoundingBox(&(*it)->_getWorldAABB()); 
     364    }    
     365} 
     366 
    399367 
    400368} // namespace Ogre 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformHierarchyInterface.cpp

    r2318 r2455  
    9999        mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 
    100100        mSceneManager->useRenderableViewProjModeWrapper(solidBox); 
    101         // HACK! (mySetPass should be setPass) 
     101         
    102102        // set no depth write, no color, no lighting material 
    103103        mSceneManager->setPassWrapper(solidBox->getTechnique()->getPass(0)); 
    104         //mSceneManager->_setPass(solidBox->getTechnique()->getPass(0));  
    105         //SetOcclusionPass(); 
    106  
    107104        solidBox->SetupBoundingBoxVertices(*box); 
    108105 
    109106        solidBox->getRenderOperation(ro); 
    110107        ro.srcRenderable = solidBox; 
     108         
    111109        //std::stringstream d; 
    112110        //d << "vt2: " << ro.vertexData; 
     
    132130        { 
    133131                mOcclusionQueries.push_back(new PlatformOcclusionQuery(mRenderSystem)); 
    134  
    135                 /*std::stringstream d; 
    136                 d << "resizing queries: " << (int)mOcclusionQueries.size() << std::endl; 
    137                 LogManager::getSingleton().logMessage(d.str());*/ 
    138132        } 
    139133         
     
    147141        GtpVisibility::HierarchyInterface::InitTraversal(); 
    148142         
    149         mSavedNode = NULL; 
     143        mOldNode = NULL; 
    150144        mLeavePassesInQueue = leavePassesInQueue; 
    151145 
     
    181175GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueNodeOcclusionQuery( 
    182176                                                                              GtpVisibility::HierarchyNode *node,  
    183                                                                                                                                                   const bool wasVisible)  
     177                                                                                                                                                  const bool testGeometry)  
    184178{ 
    185179        // get next available test id 
     
    189183        query->BeginQuery(); 
    190184         
    191         // if node is leaf and was visible => will be rendered anyway. 
    192         // In this case we can also test with the real geometry. 
    193         // If camera for culling is different from camera for rendering or only solids  
    194         // will be rendered => cannot optimize 
    195         if (mTestGeometryForVisibleLeaves && (mCamera == mCullCamera) && wasVisible && IsLeaf(node))  
    196         { 
     185        if (testGeometry && IsLeaf(node)) 
     186        { 
     187                // if node is a leaf and was visible => will be rendered anyway. 
     188                // In this case we can also test with the real geometry. 
    197189                RenderNode(node); 
    198190        } 
    199         else 
    200         { 
    201                 // this information is used e.g., by the scene graph, because the bounding box 
    202                 // must be treated differently to the scene geometry during rendering 
    203                 mIsBoundingBoxQuery = true; 
    204                 RenderBoundingBox(GetBoundingBox(node)); 
    205  
    206                 mIsBoundingBoxQuery = false; 
     191        else  
     192        { 
     193                if (mTestGeometryBounds && IsLeaf(node)) 
     194                { 
     195                        mIsBoundingBoxQuery = true; 
     196                        // we can also test the tighter bounds of the geometry instead of the hierarchy nodes. 
     197                        RenderGeometryBounds(node); 
     198                        mIsBoundingBoxQuery = false; 
     199                } 
     200                else 
     201                { 
     202                        // this information is used e.g., by the scene graph, because the bounding box 
     203                        // must be treated differently to the scene geometry during rendering 
     204                        mIsBoundingBoxQuery = true; 
     205                        RenderBoundingBox(GetBoundingBox(node)); 
     206                        mIsBoundingBoxQuery = false; 
     207                } 
    207208        } 
    208209 
     
    236237        //////// 
    237238        //-- the actual query test 
    238  
    239239        query->BeginQuery(); 
     240 
    240241        RenderGeometry(mesh); 
     242         
    241243        query->EndQuery(); 
    242244 
     
    244246} 
    245247//----------------------------------------------------------------------- 
    246 /*void PlatformHierarchyInterface::SetOcclusionPass() 
    247 { 
    248     // disable vertex and fragment program 
    249         mRenderSystem->unbindGpuProgram(GPT_VERTEX_PROGRAM); 
    250         mRenderSystem->unbindGpuProgram(GPT_FRAGMENT_PROGRAM); 
    251          
    252         // disable lighting 
    253         mRenderSystem->setLightingEnabled(false); 
    254  
    255     // Disable remaining texture units 
    256     mRenderSystem->_disableTextureUnitsFrom(0); 
    257  
    258     //--Set up non-texture related material settings 
    259     
    260         // Depth buffer settings 
    261         mRenderSystem->_setDepthBufferParams(true, false, CMPF_LESS_EQUAL); 
    262         // Set colour write mode off 
    263         mRenderSystem->_setColourBufferWriteEnabled(false, false, false, false); 
    264 }*/ 
    265 //----------------------------------------------------------------------- 
    266248SolidBoundingBox *PlatformHierarchyInterface::GetSolidBoundingBox() 
    267249{ 
    268250        if (!mSolidBoundingBox) 
    269         { 
    270251                mSolidBoundingBox = new SolidBoundingBox; 
    271                 //LogManager::getSingleton().logMessage("solid box created"); 
    272         } 
    273252 
    274253        return mSolidBoundingBox; 
     
    285264} 
    286265//----------------------------------------------------------------------- 
    287 bool PlatformHierarchyInterface::GetTestGeometryForVisibleLeaves() 
    288 { 
    289         return mTestGeometryForVisibleLeaves; 
    290 } 
    291 //----------------------------------------------------------------------- 
    292266bool PlatformHierarchyInterface::IsBoundingBoxQuery() 
    293267{ 
     
    314288        return mRenderSystem; 
    315289} 
     290//----------------------------------------------------------------------- 
     291void PlatformHierarchyInterface::SetTestGeometryBounds(bool testGeometryBounds) 
     292{ 
     293        mTestGeometryBounds = testGeometryBounds; 
     294} 
     295//----------------------------------------------------------------------- 
     296int PlatformHierarchyInterface::GetTestGeometryBounds() 
     297{ 
     298        return mTestGeometryBounds; 
     299} 
    316300 
    317301} // namespace Ogre 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformQueryManager.cpp

    r2280 r2455  
    1212namespace Ogre { 
    1313 
    14 //-----------------------------------------------------------------------  
    15 /* 
    16 PlatformQueryManager::PlatformQueryManager(PlatformHierarchyInterface *hierarchyInterface,  
    17                                                                                    Viewport *vp,  
    18                                                                                    int queryModes): 
    19 //QueryManager(hierarchyInterface, queryModes),  
    20 QueryManager(queryModes), 
    21 mViewport(vp),  
    22 mWasInitialised(false), 
    23 mHierarchyInterface(hierarchyInterface) 
    24 { 
    25 }*/ 
    26 //----------------------------------------------------------------------- 
    27 /*bool PlatformQueryManager::ShootRay(const Ray &ray,  
    28                                                                         std::vector<Mesh *> *visibleMeshes,  
    29                                                                         bool isGlobalLine) 
    30 { 
    31     // run OGRE ray shooting query 
    32     return false; 
    33 }*/ 
     14 
    3415//----------------------------------------------------------------------- 
    3516void PlatformQueryManager::ComputeFromPointVisibility( 
     
    4122                                                                                        const bool approximateVisibility) 
    4223{ 
    43         SceneManager *sm = 
    44                 static_cast<PlatformHierarchyInterface *> 
     24        SceneManager *sm = static_cast<PlatformHierarchyInterface *> 
    4525                                                                (mHierarchyInterface)->GetSceneManager(); 
    4626 
     
    9575                                            relativeVisibility, 
    9676                                                                approximateVisibility); 
    97                 //mViewport->getTarget()->update(); for(int j=0; j<10000000; j++)       printf("wait"); 
    9877 
    9978                // permute directions 
     
    176155        uchar *buf = mViewport->getTarget()->getBufferContents(dimx, dimy); 
    177156 
    178         //std::stringstream d; d << "dimx: " << dimx << ", dimy: " << dimy; LogManager::getSingleton().logMessage(d.str()); 
    179  
    180157        // loop through frame buffer and collect visible pixels 
    181158        for (int idx = 0; idx < dimy * dimx * 3; idx += 3) 
     
    185162                id += buf[idx + 1] << 8; 
    186163                id += buf[idx + 2]; 
    187  
    188                 //std::stringstream d; d << "myid: " << (int)buf[idx] << " " << (int)buf[idx + 1] << " " << (int)buf[idx + 2]; LogManager::getSingleton().logMessage(d.str()); 
    189164 
    190165                // if valid id <= add visibility (id values start at 1) 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreSceneContentGenerator.cpp

    r2280 r2455  
    1212namespace Ogre { 
    1313 
     14 
     15 
    1416/*************************************************************/ 
    1517/*           SceneContentGenerator implementation            */ 
     
    169171                        &mScale.x, &mScale.y, &mScale.z); 
    170172 
    171                 GenerateSceneObject(position, orientation, objName); 
    172                  
    173                 //std::stringstream d; d << StringConverter::toString(position) << " " << StringConverter::toString(orientation); 
    174                 //LogManager::getSingleton().logMessage(d.str()); 
    175         } 
     173                GenerateSceneObject(position, orientation, objName);     
     174        } 
     175 
    176176        ifstr.close(); 
    177177 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreSceneNodeHierarchyInterface.cpp

    r2280 r2455  
    121121{ 
    122122        // only create renderable bounding box for new node 
    123         if (node != mSavedNode) 
     123        if (node != mOldNode) 
    124124        { 
    125                 mSavedNode = node; 
     125                mOldNode = node; 
    126126                mBox = static_cast<SceneNode *>(node)->_getWorldAABB(); 
    127127        } 
     
    151151                { 
    152152                        Entity *ent = static_cast<Entity *>(movable); 
    153                         //std::stringstream d; d << "ent " << ent->getName();  
    154                         //LogManager::getSingleton().logMessage(d.str()); 
    155153                        geometryList->push_back(ent); 
    156154                } 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreSolidBoundingBox.cpp

    r2184 r2455  
    7171         /// Upload the index data to the card 
    7272         ibuf->writeData(0, ibuf->getSizeInBytes(), faces, true); 
    73          //mRenderOp.useSharedVertices = true; 
    7473         mRenderOp.indexData->indexBuffer = ibuf; 
    7574         // set material with no lighting, no color, no depth write 
    7675         SetOcclusionQueryMaterial(); 
    77          //setMaterial("BaseWhiteNoLighting"); 
    78  
    79         /* std::stringstream d; 
    80         d << "vtx: " << mRenderOp.vertexData; 
    81         LogManager::getSingleton().logMessage(d.str()); 
    82         */ 
    83  
    8476} 
    8577//----------------------------------------------------------------------- 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOptionsManager.cpp

    r2171 r2455  
    2424                return true; 
    2525        } 
     26 
    2627        if (key == "Threshold") 
    2728        { 
     
    3637        if (key == "TestGeometryForVisibleLeaves") 
    3738        { 
    38                 mHierarchyInterface->TestGeometryForVisibleLeaves(*static_cast<const bool *>(val)); 
     39                mVisibilityManager->SetTestGeometryForVisibleLeaves(*static_cast<const bool *>(val)); 
    3940                return true; 
    4041        } 
     
    7576                return true; 
    7677        } 
     78        if (key == "TestGeometryForVisibleLeaves") 
     79        { 
     80                * static_cast<bool *>(val) =  
     81                        mVisibilityManager->GetTestGeometryForVisibleLeaves(); 
     82                return true; 
     83        } 
     84        if (key == "AssumedVisibility") 
     85        { 
     86                * static_cast<unsigned int *>(val) =  
     87                        mVisibilityManager->GetAssumedVisibilityForChc(); 
     88                return true; 
     89        } 
     90        if (key == "TestGeometryForVisibleLeaves") 
     91        { 
     92                * static_cast<unsigned int *>(val) =  
     93                        mVisibilityManager->GetRandomUpdateCandidatesForRuc(); 
     94                return true; 
     95        } 
    7796         
    7897        return false; 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/include/CoherentHierarchicalCullingManager.h

    r2332 r2455  
    2121 
    2222        void RenderScene(); 
     23         
    2324        /** Sets assumed visibility (i.e., an estimation for  
    2425                how many frames the visibility is considered to be valid). 
     
    2728                if 0, the visibility is tested deterministically for each frame. 
    2829        */ 
    29         void SetAssumedVisibility(const unsigned int assumedVisibility); 
     30        void SetAssumedVisibility(const unsigned int assumedVisibility);         
     31        /** This is an optimization when issuing the occlusion test.  
     32                The test is done with actual geometry rather than the bounding  
     33                box of leave nodes previously marked as visible. 
     34 
     35                @param testGeometry if this optimization should be used 
     36                @remark this option is only useful for the coherent hierarchical culling algorithm 
     37        */ 
     38        void SetTestGeometryForVisibleLeaves(const bool testGeometry); 
     39        /** See TestGeometryForVisibleLeaves 
     40        */ 
     41        bool GetTestGeometryForVisibleLeaves(); 
     42 
    3043 
    3144protected: 
     
    4760        bool NodeInvalid(HierarchyNode *node) const; 
    4861 
     62        void AssignAssumedVisibility(GtpVisibility::HierarchyNode *node); 
     63 
     64 
     65        ////////////////////// 
     66 
    4967        /** number of steps the visibility is assumed to be valid. 
    5068        */ 
    5169        unsigned int mAssumedVisibility; 
    5270 
    53         /** Threshold for rand function to return positive result with respect to 
    54                 mAssumedVisibility. 
    55         */ 
    56         int mThreshold; 
     71        bool mTestGeometryForVisibleLeaves; 
    5772}; 
    5873 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/include/CoherentHierarchicalCullingManager2.h

    r2360 r2455  
    99{ 
    1010 
    11 /** Renders the scene with the coherent hierarchical culling algorithm.  
     11/** Renders the scene with the coherent hierarchical culling algorithm with 
     12        some additional features 
    1213*/ 
    13 class CoherentHierarchicalCullingManager2 : public CullingManager 
     14class CoherentHierarchicalCullingManager2: public CullingManager 
    1415{ 
    1516public: 
    1617        CoherentHierarchicalCullingManager2(); 
     18 
    1719        /** Constructor taking the assumed visibility into account, i.e., the estimation 
    1820                for how many frames the current visibility is considered to be valid 
     
    2022        CoherentHierarchicalCullingManager2(const unsigned int assumedVisibility); 
    2123 
     24        /** The main render routine. 
     25        */ 
    2226        void RenderScene(); 
     27 
    2328        /** Sets assumed visibility (i.e., an estimation for  
    2429                how many frames the visibility is considered to be valid). 
     
    3035 
    3136protected: 
     37 
    3238        /** Decides if node is considered to be visible depeding on the  
    3339                assumed visibility factor. 
     
    3541        */ 
    3642        bool DecideVisible(HierarchyNode *node) const; 
    37  
    3843 
    3944        /** Skip query for this node. 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h

    r2332 r2455  
    22#define _GtpVisibilityHierarchyInterface_H__ 
    33 
     4 
    45#include "DistanceQueue.h" 
    5 //#include "VisibilityMesh.h" 
    66#include <stack> 
     7 
    78 
    89namespace GtpVisibility { 
     
    5253        /** Issue a occlusion query for this node.  
    5354                @param node the current hierarchy node 
    54                 @param wasVisible if the node was visible in the last frame: based 
    55                 on this the method can decide on the way of querying 
     55                @param testGeometry (if geometry should be tested instead of the bb). 
    5656                @returns occlusion query for this node 
    5757        */ 
    5858        virtual OcclusionQuery *IssueNodeOcclusionQuery(HierarchyNode *node,  
    59                                                                                                         const bool wasVisible = false) = 0; 
     59                                                                                                        const bool testGeometry = false) = 0; 
    6060        /** Returns distance of the node to the view plane. 
    6161                @param node the hierarchy node 
     
    119119        */ 
    120120        HierarchyNode *GetHierarchyRoot() const; 
    121          
    122         /** This is an optimization when issuing the occlusion test.  
    123                 The test is done with actual geometry rather than the bounding  
    124                 box of leave nodes previously marked as visible. 
    125  
    126                 @param testGeometry if this optimization should be used 
    127                 @remark this option is only useful for the coherent hierarchical culling algorithm 
    128         */ 
    129         void TestGeometryForVisibleLeaves(bool testGeometry); 
    130  
    131121        /** Sets the scene root and initialises this hierarchy interface for a traversal.                
    132122                @remark also resets the statistics evaluated in the last traversal 
     
    142132        */ 
    143133        DistanceQueue *GetQueue(); 
    144  
    145134        /** Checks if the node is visible from the current view frustum. 
    146135                @param node the current node 
    147136        */ 
    148137        bool CheckFrustumVisible(HierarchyNode *node); 
    149  
    150138        /** Returns number of traversed nodes. 
    151139        */ 
     
    154142        */ 
    155143        unsigned int GetNumRenderedNodes(); 
    156  
    157144        /** Returns vector of visible hierarchy nodes from previous render. 
    158145        */ 
    159146        std::vector<HierarchyNode *> *GetVisibleNodes(); 
    160  
     147        /** Pulls up the last visited information of this node. 
     148        */ 
    161149        virtual void PullUpLastVisited(HierarchyNode *node, const int frameId) const = 0; 
    162         virtual void DetermineVisibilityRatio(HierarchyNode *node) const = 0; 
    163         virtual float GetNodeVisibilityRatio(HierarchyNode *node) const = 0; 
    164  
     150        /** Returns parent node. 
     151        */ 
    165152        virtual HierarchyNode *GetParent(HierarchyNode *node) = 0; 
     153        /** Returns #frames this node is assumed to be visible. 
     154        */ 
     155        virtual int GetNodeAssumedVisible(HierarchyNode *node) = 0; 
     156        /** Sets #frames this node is assumed to be visible. 
     157        */ 
     158        virtual void SetNodeAssumedVisible(HierarchyNode *node, int assumedVisible) = 0; 
     159        /** Decreases #frames this node is assumed to be visible. 
     160        */ 
     161        virtual void DecNodeAssumedVisible(HierarchyNode *node) = 0; 
    166162 
    167163protected: 
    168164 
    169  
    170         /// chc optimization for testing geometry of leaves instead of bounding box 
    171         bool mTestGeometryForVisibleLeaves; 
    172165        /// the current frame number 
    173166        unsigned int mFrameId; 
     167         
    174168        /// index of the lcurrent occlusion query in the array of queries 
    175169        /// NOTE: should rather be iterator 
     
    186180         
    187181        /// buffer for a node pointer 
    188         HierarchyNode *mSavedNode; 
     182        HierarchyNode *mOldNode; 
    189183 
    190184        /// list of rendered hierarchy nodes (e.g., useful for exact visibility queries) 
    191185        std::vector<HierarchyNode *> mVisibleNodes; 
    192186}; 
     187 
    193188} // namespace GtpVisibility 
    194189 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/include/RandomUpdateCullingManager.h

    r2259 r2455  
    1414{ 
    1515public: 
     16         
    1617        RandomUpdateCullingManager(); 
    17         /** Constructor taking the assumed visibility into account, i.e., the estimation 
    18                 for how many frames the current visibility is considered to be valid 
     18 
     19        /** Constructor taking the #random candidates tested per subtree into account. 
    1920        */ 
    20         RandomUpdateCullingManager(const unsigned int assumedVisibility); 
     21        RandomUpdateCullingManager(const unsigned int randomCandidates); 
    2122 
    2223        void RenderScene(); 
    23         /** Sets assumed visibility (i.e., an estimation for  
    24                 how many frames the visibility is considered to be valid). 
    25                 @param assumedVisibility indicates for how many frames the  
    26                 same visibility is be assumed. 
    27                 if 0, the visibility is tested deterministically for each frame. 
     24 
     25        /** Sets #random candidates tested per subtree. 
    2826        */ 
    29         void SetAssumedVisibility(const unsigned int assumedVisibility); 
     27        void SetRandomCandidates(const unsigned int randomCandidates); 
     28 
     29        /** This is an optimization when issuing the occlusion test.  
     30                The test is done with actual geometry rather than the bounding  
     31                box of leave nodes previously marked as visible. 
     32 
     33                @param testGeometry if this optimization should be used 
     34                @remark this option is only useful for the coherent hierarchical culling algorithm 
     35        */ 
     36        void SetTestGeometryForVisibleLeaves(const bool testGeometry); 
     37        /** See TestGeometryForVisibleLeaves 
     38        */ 
     39        bool GetTestGeometryForVisibleLeaves(); 
    3040 
    3141protected: 
    32  
    33         /** Decides if node is considered to be visible depeding on the  
    34                 assumed visibility factor. 
    35                 @returns if node is considered to be visible 
    36         */ 
    37         bool DecideVisible(HierarchyNode *node) const; 
    3842 
    3943        /** Skip query for this node. 
     
    4145        void SkipQuery(HierarchyNode *node) const; 
    4246 
    43         /** number of steps the visibility is assumed to be valid. 
    44         */ 
    45         unsigned int mAssumedVisibility; 
    4647 
    47         /** Threshold for rand function to return positive result  
    48                 with respect to mAssumedVisibility. 
    49         */ 
    50         int mThreshold; 
     48        //////////// 
    5149 
    52         int mRandomCandidates; 
     50        /// number of candidates that are tested per subtree 
     51        unsigned int mRandomCandidates; 
     52 
     53        bool mTestGeometryForVisibleLeaves; 
     54 
    5355}; 
    5456 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityManager.h

    r2280 r2455  
    5858        */ 
    5959        void SetAssumedVisibilityForChc(unsigned int assumedVisibility); 
    60          
     60        /** Random candidates per subtree for random update manager. 
     61                @note these options should rather be given by general parameter system using void * 
     62                and strings. 
     63        */ 
     64        void SetRandomUpdateCandidatesForRuc(unsigned int randomCandidatesForRuc); 
     65        /** See get 
     66        */ 
     67        unsigned int GetAssumedVisibilityForChc(); 
     68        /* See get 
     69        */ 
     70        unsigned int GetRandomUpdateCandidatesForRuc(); 
    6171        /** Sets pointer to a query manager.  
    6272        */ 
     
    6676        QueryManager *GetQueryManager(); 
    6777 
     78        void SetTestGeometryForVisibleLeaves(bool testGeometryForLeaves); 
     79        bool GetTestGeometryForVisibleLeaves(); 
     80 
     81        /** Returns the visibility environment. 
     82        */ 
    6883        VisibilityEnvironment *GetVisibilityEnvironment(); 
    6984 
     
    7388        CullingManager *mCullingManager; 
    7489        QueryManager *mQueryManager; 
     90 
    7591        PreprocessingManager *mPreprocessingManager; 
    7692        VisibilityEnvironment *mVisibilityEnvironment; 
     
    7995        unsigned int mVisibilityThreshold; 
    8096        unsigned int mAssumedVisibilityForChc; 
     97        unsigned int mRandomCandidatesForRuc; 
     98 
     99        bool mTestGeometryForVisibleLeaves; 
    81100}; 
     101 
    82102} // namespace GtpVisibility 
    83103 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/terrainCulling.cfg

    r2360 r2455  
    5252ResetMaterialForQueries=no 
    5353 
     54 
     55# Occlusion query is issued by rendering geometry itself instead of the bounding box 
     56# because have to render geometry for previously visible leaves anyway 
     57 
     58TestGeometryForVisibleLeaves=no 
     59 
     60 
     61# For CHC: frames a node is assumed to stay visible 
     62 
     63AssumedVisibleFrames=10 
     64 
     65 
     66# only for random update manager: the #random candidates that 
     67# are tested per visible subtree 
     68 
     69RandomUpdateCandidates=2 
     70 
     71# true if we want to tests the bounds of the geometry  
     72# instead of the boudning box of the hierarchy node 
     73 
     74TestGeometryBounds=no 
    5475 
    5576 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp

    r2452 r2455  
    33 
    44#include <time.h> 
     5#include <sstream> 
     6 
    57 
    68namespace GtpVisibility { 
    79 
    8 //----------------------------------------------------------------------- 
    9 CoherentHierarchicalCullingManager::CoherentHierarchicalCullingManager() 
    10 { 
    11         SetAssumedVisibility(0); 
    12         // initialise random generator in case we use assumed visibility 
    13         //srand(time(NULL)); 
     10 
     11static int batchSize = 5; 
     12 
     13//----------------------------------------------------------------------- 
     14CoherentHierarchicalCullingManager::CoherentHierarchicalCullingManager(): 
     15mAssumedVisibility(0) 
     16{ 
    1417} 
    1518//----------------------------------------------------------------------- 
    1619CoherentHierarchicalCullingManager::CoherentHierarchicalCullingManager( 
    17                                                                                                                 const unsigned int assumedVisibility) 
    18 { 
    19         SetAssumedVisibility(assumedVisibility); 
    20         // initialise random generator in case we use assumed visibility 
    21         //srand(time(NULL)); 
     20                                                                                                                const unsigned int assumedVisibility): 
     21mAssumedVisibility(assumedVisibility) 
     22{ 
     23} 
     24//----------------------------------------------------------------------- 
     25void CoherentHierarchicalCullingManager::AssignAssumedVisibility(GtpVisibility::HierarchyNode *node) 
     26{ 
     27        if (!mHierarchyInterface->IsNodeVisible(node)) 
     28                // previously invisible nodes: give random offset just for the first test after 
     29                // becoming visible to avoid that all nodes are tested in the same frame 
     30                mHierarchyInterface->SetNodeAssumedVisible(node, rand() * mAssumedVisibility / RAND_MAX); 
     31        else 
     32                mHierarchyInterface->SetNodeAssumedVisible(node, mAssumedVisibility); 
    2233} 
    2334//----------------------------------------------------------------------- 
     
    3546                ////////// 
    3647                //-- only wait for result if there are no nodes to process 
     48 
    3749                while (!queryQueue.empty() &&  
    3850                           (NodeInvalid(queryQueue.front().first) || 
     
    4355                        queryQueue.pop(); 
    4456 
     57                        // "invalid nodes" happen for hierarchies that have geometry 
     58                        // not neccessarily in the leaves: 
    4559                        // parent was tested invisible => remove children from queue 
    46                         if (NodeInvalid(node)) 
    47                         { 
    48                                 //CullingLogManager::GetSingleton()->LogMessage("skipping this node"); 
     60 
     61                        if (1 && NodeInvalid(node)) 
    4962                                continue; 
    50                         } 
     63 
    5164                        // tested visible 
    5265                        if (visiblePixels > mVisibilityThreshold) 
    5366                        { 
    54                                 // in case geometry is in interior node: ensure that we only traverse once 
     67                                // assing the #frames the node is assumed to stay visible 
     68                                AssignAssumedVisibility(node); 
     69 
     70                                // for previously visible interior node which contains geometry:  
     71                                // ensure that we did not already traverse this node  
     72                                // (which means that the visibility flag is set) 
    5573                                if (!mHierarchyInterface->IsNodeVisible(node)) 
    56                                 { 
    5774                                        mHierarchyInterface->TraverseNode(node); 
    58                                 } 
    5975 
    6076                                mHierarchyInterface->PullUpVisibility(node); 
     
    6581 
    6682                ++ mNumQueryCulledNodes; 
    67                                  
     83 
    6884                                if (mVisualizeCulledNodes) 
    69                                 { 
    7085                                        mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED); 
    71                                 } 
    7286                        } 
    7387                         
     
    7690                } 
    7791                 
     92                //////////////// 
    7893                //-- PART 2: hierarchical traversal 
     94 
    7995                if (!mHierarchyInterface->GetQueue()->empty()) 
    8096                { 
     
    8399                                 
    84100                        // parent was tested invisible => remove children from queue 
    85                         if (NodeInvalid(node)) 
    86                         { 
    87                                 //CullingLogManager::GetSingleton()->LogMessage("skipping this node"); 
     101                        if (1 && NodeInvalid(node)) 
    88102                                continue; 
    89                         } 
    90103 
    91104                        bool intersects = false; 
     
    96109 
    97110                                if (mVisualizeCulledNodes) 
    98                                 { 
    99111                                        mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED); 
    100                                 } 
    101112                        } 
    102113                        //-- if node intersects near plane, skip query because wrong results possible 
     
    112123                                 
    113124                                // if we assume node to be visible in this frame => skip query  
    114                                 const bool skipQuery = wasVisible &&  
    115                                                            (mAssumedVisibility > 0) &&  
     125                                const bool skipQuery = wasVisible && 
    116126                                                                           DecideVisible(node) &&  
    117127                                                                           mHierarchyInterface->HasGeometry(node); 
     
    127137                                bool issueQuery = !wasVisible || mHierarchyInterface->HasGeometry(node); 
    128138                                                         
    129                                 // reset node's visibility classification 
    130                                 // set visible if geometry in node so we only traverse once 
     139                                // set node's visibility classification 
     140                                // we identify previously visible / invisible nodes in the query queue 
    131141                                mHierarchyInterface->SetNodeVisible(node, wasVisible && issueQuery); 
    132142 
    133                                 // skip testing previously visible nodes without geometry 
    134143                                if (issueQuery) 
    135144                                { 
    136145                                        ++ mNumQueriesIssued; 
    137146                                         
     147                                        const bool testGeometry = wasVisible && mHierarchyInterface->IsLeaf(node) && mTestGeometryForVisibleLeaves; 
     148 
    138149                                        queryQueue.push(QueryPair(node, mHierarchyInterface-> 
    139                                                 IssueNodeOcclusionQuery(node, wasVisible))); 
     150                                                IssueNodeOcclusionQuery(node, testGeometry))); 
    140151                                } 
    141152                                else 
    142153                                { 
    143                                         // update node's visited flag 
     154                                        // skip testing previously visible nodes without geometry 
     155                    // just update node's visited flag 
    144156                                        mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 
    145157                                } 
     
    158170{ 
    159171        mAssumedVisibility = assumedVisibility; 
    160          
    161         if (!mAssumedVisibility) 
    162         { 
    163                 mThreshold = 0; 
    164         } 
    165         else 
    166         { 
    167                 mThreshold = RAND_MAX - RAND_MAX / mAssumedVisibility; 
    168                  // fix visibility 
    169                 if (mAssumedVisibility > 100) 
    170                         mThreshold = RAND_MAX; 
    171         } 
    172          
    173172} 
    174173//----------------------------------------------------------------------- 
    175174inline bool CoherentHierarchicalCullingManager::DecideVisible(HierarchyNode *node) const 
    176175{ 
    177         return rand() < mThreshold; 
     176        mHierarchyInterface->DecNodeAssumedVisible(node); 
     177        //std::stringstream d; d << "node visible: " << mHierarchyInterface->GetNodeAssumedVisible(node); 
     178        //CullingLogManager::GetSingleton()->LogMessage(d.str()); 
     179        return mHierarchyInterface->GetNodeAssumedVisible(node) > 0; 
    178180} 
    179181//----------------------------------------------------------------------- 
     
    196198                !mHierarchyInterface->IsNodeVisible(parent); 
    197199} 
    198 } // namespace GtpVisibility 
     200//----------------------------------------------------------------------- 
     201void CoherentHierarchicalCullingManager::SetTestGeometryForVisibleLeaves(const bool testGeometry) 
     202{ 
     203        mTestGeometryForVisibleLeaves = testGeometry; 
     204} 
     205//----------------------------------------------------------------------- 
     206bool CoherentHierarchicalCullingManager::GetTestGeometryForVisibleLeaves() 
     207{ 
     208        return mTestGeometryForVisibleLeaves; 
     209} 
     210 
     211} 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj

    r2360 r2455  
    259259                        </File> 
    260260                        <File 
    261                                 RelativePath=".\CoherentHierarchicalCullingManager2.cpp"> 
    262                         </File> 
    263                         <File 
    264261                                RelativePath=".\CullingLogManager.cpp"> 
    265262                        </File> 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/HierarchyInterface.cpp

    r2306 r2455  
    1010mNumTraversedNodes(0),  
    1111mHierarchyRoot(NULL),  
    12 mSavedNode(NULL),  
    13 mCurrentTestIdx(0),  
    14 mTestGeometryForVisibleLeaves(false) 
     12mOldNode(NULL),  
     13mCurrentTestIdx(0) 
    1514{        
    1615        mDistanceQueue = new DistanceQueue(GtDistance<HierarchyNode *>(this)); 
     
    7271} 
    7372//----------------------------------------------------------------------- 
    74 void HierarchyInterface::TestGeometryForVisibleLeaves(bool testGeometry) 
    75 { 
    76         mTestGeometryForVisibleLeaves = testGeometry; 
    77 } 
    78 //----------------------------------------------------------------------- 
    7973std::vector<HierarchyNode *> *HierarchyInterface::GetVisibleNodes() 
    8074{ 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp

    r2332 r2455  
    1313 
    1414const static int R_CANDIDATES = 1; 
    15 //----------------------------------------------------------------------- 
    16 RandomUpdateCullingManager::RandomUpdateCullingManager() 
    17 { 
    18         SetAssumedVisibility(0); 
    19         // initialise random generator in case we use assumed visibility 
    20         //srand(time(NULL)); 
    21  
    22         mRandomCandidates = R_CANDIDATES; 
    23 } 
    24 //----------------------------------------------------------------------- 
    25 RandomUpdateCullingManager::RandomUpdateCullingManager( 
    26                         const unsigned int assumedVisibility) 
    27 { 
    28         SetAssumedVisibility(assumedVisibility); 
    29         // initialise random generator in case we use assumed visibility 
    30         //srand(time(NULL)); 
    31  
    32         mRandomCandidates = R_CANDIDATES; 
     15 
     16//----------------------------------------------------------------------- 
     17RandomUpdateCullingManager::RandomUpdateCullingManager(): mRandomCandidates(R_CANDIDATES) 
     18{ 
     19} 
     20//----------------------------------------------------------------------- 
     21RandomUpdateCullingManager::RandomUpdateCullingManager(const unsigned int randomCandidates) 
     22{        
     23        mRandomCandidates = std::max(randomCandidates, (unsigned int)1); 
     24} 
     25//----------------------------------------------------------------------- 
     26void RandomUpdateCullingManager::SetRandomCandidates(const unsigned int randomCandidates) 
     27{ 
     28        mRandomCandidates = std::max(randomCandidates, (unsigned int)1); 
    3329} 
    3430//----------------------------------------------------------------------- 
     
    105101                        else 
    106102                        { 
    107                                  
     103                                // fully visible subtree => render all in one bathc 
    108104                                if (mHierarchyInterface->IsNodeFullyVisible(node)) 
    109105                                { 
    110 #if 1 
    111                                         // node fully visible => test only random leaves 
    112                                         for (int i = 0; i < mRandomCandidates; ++ i) 
    113                                         { 
    114                                                 HierarchyNode *randomLeaf = mHierarchyInterface->GetRandomLeaf(node); 
    115                                                  
    116                                                 if (!randomLeaf) 
    117                                                         continue; 
    118  
    119                                                 mHierarchyInterface->SetNodeVisible(randomLeaf, false); 
    120  
    121                                                 // update node's visited flag 
    122                                                 mHierarchyInterface->PullUpLastVisited(randomLeaf, mHierarchyInterface->GetFrameId()); 
    123  
    124                                                 queryQueue.push(QueryPair(randomLeaf,  
    125                                                         mHierarchyInterface->IssueNodeOcclusionQuery(node))); 
    126                                         } 
    127 #else 
    128                                         // test all leaves for visibility changes 
     106                                        // use different algorithm for finding random candidates 
    129107                                        HierarchyNodeContainer mynodes; 
    130108                                        mHierarchyInterface->CollectLeaves(node, mynodes); 
    131109 
     110                                        const int p = mRandomCandidates * RAND_MAX / (int)mynodes.size(); 
     111 
    132112                                        HierarchyNodeContainer::const_iterator nit, nit_end = mynodes.end(); 
    133113 
     114                                        int nodesTested = 0; 
    134115                                        for (nit = mynodes.begin(); nit != nit_end; ++ nit) 
    135116                                        { 
    136117                                                HierarchyNode *leaf = *nit; 
     118 
     119                                                if (rand() > p) 
     120                                                        continue; 
     121 
     122                                                ++ nodesTested; 
     123 
    137124                                                mHierarchyInterface->SetNodeVisible(leaf, false); 
    138125 
     
    140127                                                mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId()); 
    141128 
    142                                                 queryQueue.push(QueryPair(leaf,  
    143                                                         mHierarchyInterface->IssueNodeOcclusionQuery(node))); 
     129                                                const bool testGeometry =mTestGeometryForVisibleLeaves; 
     130 
     131                                                mHierarchyInterface->IssueNodeOcclusionQuery(node, mTestGeometryForVisibleLeaves); 
    144132                                        } 
    145 #endif 
     133                 
     134                                        //std::stringstream d; d << "rc: " << mRandomCandidates << " tested: " << nodesTested << " of " << (int)mynodes.size(); 
     135                                        //CullingLogManager::GetSingleton()->LogMessage(d.str()); 
     136 
    146137                                        mHierarchyInterface->RenderNodeRecursive(node); 
    147  
    148138                                        continue; 
    149139                                } 
     
    153143                                        (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId() - 1); 
    154144                                         
    155  
    156145                                // if we assume node to be visible in this frame => skip query  
    157                                 const bool skipQuery = wasVisible && (mAssumedVisibility > 0) &&  
    158                                         DecideVisible(node) && mHierarchyInterface->HasGeometry(node); 
     146                                const bool skipQuery = false;//wasVisible && mHierarchyInterface->HasGeometry(node); 
    159147 
    160148                                if (skipQuery) 
     
    181169                                        ++ mNumQueriesIssued; 
    182170                                         
     171                                        const bool testGeometry = wasVisible && mHierarchyInterface->IsLeaf(node) && mTestGeometryForVisibleLeaves; 
     172 
    183173                                        queryQueue.push(QueryPair(node, mHierarchyInterface-> 
    184                                                 IssueNodeOcclusionQuery(node, wasVisible))); 
     174                                                IssueNodeOcclusionQuery(node, testGeometry))); 
    185175                                } 
    186176                                 
     
    196186        // update the fully visible classifications 
    197187        mHierarchyInterface->DetermineFullVisibility(mHierarchyInterface->GetHierarchyRoot()); 
    198         //mHierarchyInterface->DetermineVisibilityRatio(mHierarchyInterface->GetHierarchyRoot()); 
    199 } 
    200 //----------------------------------------------------------------------- 
    201 void RandomUpdateCullingManager::SetAssumedVisibility(const unsigned int assumedVisibility) 
    202 { 
    203         mAssumedVisibility = assumedVisibility; 
    204          
    205         mThreshold = 0; 
    206  
    207         if (mAssumedVisibility > 0) 
    208         { 
    209                 mThreshold = RAND_MAX - RAND_MAX / mAssumedVisibility; 
    210                 if (mAssumedVisibility > 100) // no random decicion 
    211                         mThreshold = RAND_MAX; 
    212         } 
    213  
    214 } 
    215 //----------------------------------------------------------------------- 
    216 inline bool RandomUpdateCullingManager::DecideVisible(HierarchyNode *node) const 
    217 { 
    218         return rand() < mThreshold; 
    219188} 
    220189//----------------------------------------------------------------------- 
     
    227196        mHierarchyInterface->TraverseNode(node); 
    228197} 
     198//----------------------------------------------------------------------- 
     199void RandomUpdateCullingManager::SetTestGeometryForVisibleLeaves(const bool testGeometry) 
     200{ 
     201        mTestGeometryForVisibleLeaves = testGeometry; 
     202} 
     203//----------------------------------------------------------------------- 
     204bool RandomUpdateCullingManager::GetTestGeometryForVisibleLeaves() 
     205{ 
     206        return mTestGeometryForVisibleLeaves; 
     207} 
    229208 
    230209} // namespace GtpVisibility 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/StopAndWaitCullingManager.cpp

    r2292 r2455  
    4545                {        
    4646                        ++ mNumQueriesIssued; 
    47  
    4847                        unsigned int visiblePixels = 0; 
    49  
    50                         mHierarchyInterface->IssueNodeOcclusionQuery(node)->GetQueryResult(visiblePixels, true); 
     48                        const bool waitForResult = true; 
     49                        mHierarchyInterface->IssueNodeOcclusionQuery(node)->GetQueryResult(visiblePixels, waitForResult); 
    5150                 
    5251                        // node visible 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityManager.cpp

    r2289 r2455  
    4545                // delete old culling manager 
    4646                if (mCullingManager) 
    47                 { 
    4847                        delete mCullingManager; 
    49                 } 
    5048 
    5149                mCullingManagerType = ocmType; 
     
    5452                { 
    5553                case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING: 
    56                         mCullingManager = new CoherentHierarchicalCullingManager(mAssumedVisibilityForChc); 
     54                        { 
     55                                CoherentHierarchicalCullingManager *chcm = new CoherentHierarchicalCullingManager(mAssumedVisibilityForChc); 
     56                                chcm->SetTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves); 
     57                                mCullingManager = chcm; 
     58                        } 
    5759                        break; 
    58  
    5960                case VisibilityEnvironment::FRUSTUM_CULLING: 
    6061                        mCullingManager = new FrustumCullingManager(); 
    6162                        break; 
    62  
    6363                case VisibilityEnvironment::RANDOM_UPDATE_CULLING: 
    64                         mCullingManager = new RandomUpdateCullingManager();      
     64                        { 
     65                                RandomUpdateCullingManager *rum = new RandomUpdateCullingManager(mRandomCandidatesForRuc); 
     66                                rum->SetTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves); 
     67                                mCullingManager = rum; 
     68                        } 
    6569                        break; 
    66  
    6770                case VisibilityEnvironment::STOP_AND_WAIT_CULLING: 
    6871                        mCullingManager = new StopAndWaitCullingManager(); 
    69                         //mCullingManager = new RandomUpdateCullingManager(); 
    7072                        break; 
    71  
    7273                default: 
    7374                        mCullingManager = new CoherentHierarchicalCullingManager(mAssumedVisibilityForChc); 
    7475                        break; 
    75  
    7676                } 
    7777 
    7878                ///////// 
    7979                //-- set threshold 
     80 
    8081                mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);   
    8182        } 
     
    113114} 
    114115//----------------------------------------------------------------------- 
    115 void VisibilityManager::SetAssumedVisibilityForChc(unsigned int assumedVisibility)  
    116                                                                           
     116void VisibilityManager::SetAssumedVisibilityForChc(unsigned int assumedVisibility)                                                                        
    117117{ 
    118118        mAssumedVisibilityForChc = assumedVisibility; 
    119119 
    120         // in case we currently use chc 
    121         if (VisibilityManager::GetCullingManagerType() ==  
    122                 VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 
     120        if (mCullingManagerType == VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 
    123121        { 
    124122                static_cast<CoherentHierarchicalCullingManager *>(mCullingManager)-> 
    125                                 SetAssumedVisibility(assumedVisibility); 
     123                                SetAssumedVisibility(mAssumedVisibilityForChc); 
     124        } 
     125} 
     126//----------------------------------------------------------------------- 
     127void VisibilityManager::SetRandomUpdateCandidatesForRuc(unsigned int randomCandidates)                                                                    
     128{ 
     129        mRandomCandidatesForRuc = randomCandidates; 
     130 
     131        if (mCullingManagerType == VisibilityEnvironment::RANDOM_UPDATE_CULLING) 
     132        { 
     133                static_cast<RandomUpdateCullingManager *>(mCullingManager)-> 
     134                                SetRandomCandidates(mRandomCandidatesForRuc); 
    126135        } 
    127136} 
     
    131140        return mVisibilityEnvironment; 
    132141} 
     142//----------------------------------------------------------------------- 
     143unsigned int VisibilityManager::GetAssumedVisibilityForChc() 
     144{ 
     145        return mAssumedVisibilityForChc; 
     146} 
     147//----------------------------------------------------------------------- 
     148unsigned int VisibilityManager::GetRandomUpdateCandidatesForRuc() 
     149{ 
     150        return mRandomCandidatesForRuc; 
     151} 
     152//----------------------------------------------------------------------- 
     153void VisibilityManager::SetTestGeometryForVisibleLeaves(bool testGeometryForVisibleLeaves) 
     154{ 
     155        mTestGeometryForVisibleLeaves = testGeometryForVisibleLeaves; 
     156 
     157        if (mCullingManagerType == VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 
     158        { 
     159                static_cast<CoherentHierarchicalCullingManager *>(mCullingManager)-> 
     160                                SetTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves); 
     161        } 
     162        else if (mCullingManagerType == VisibilityEnvironment::RANDOM_UPDATE_CULLING) 
     163        { 
     164                static_cast<RandomUpdateCullingManager *>(mCullingManager)-> 
     165                                SetTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves); 
     166        } 
     167} 
     168//----------------------------------------------------------------------- 
     169bool VisibilityManager::GetTestGeometryForVisibleLeaves() 
     170{ 
     171        return mTestGeometryForVisibleLeaves; 
     172} 
    133173 
    134174} // namespace GtpVisibility 
Note: See TracChangeset for help on using the changeset viewer.