Changeset 2555 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/05/07 15:36:52 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOctreeHierarchyInterface.h
r2455 r2555 33 33 */ 34 34 void TraverseNode(GtpVisibility::HierarchyNode *node); 35 void TraverseNode2(GtpVisibility::HierarchyNode *node); 35 36 /** @copydoc HierarchyInterface::RenderNode */ 36 37 void RenderNode(GtpVisibility::HierarchyNode *node); … … 83 84 void RenderGeometryBounds(GtpVisibility::HierarchyNode *node); 84 85 86 void AddToQueue(GtpVisibility::HierarchyNode *node); 87 88 void RenderQueue(); 85 89 86 90 protected: -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgrePlatformHierarchyInterface.h
r2455 r2555 140 140 int GetTestGeometryBounds(); 141 141 142 142 virtual void AddToQueue(GtpVisibility::HierarchyNode *node) {}; 143 144 virtual void RenderQueue() {}; 145 146 virtual void TraverseNode2(GtpVisibility::HierarchyNode *node) {}; 147 143 148 protected: 144 149 … … 187 192 188 193 bool mTestGeometryBounds; 194 195 bool mTestMode; 189 196 }; 190 197 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBiHierarchySceneManager.cpp
r2542 r2555 218 218 { 219 219 mRenderMethod = rm; 220 int cmt = GtpVisibility::VisibilityEnvironment:: RANDOM_UPDATE_CULLING;220 int cmt = GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING_PLUSPLUS; 221 221 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface) 222 222 .setOption("Algorithm", &cmt); … … 242 242 else if (val == GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 243 243 mRenderMethod = BiHierarchy::BIHRM_GTP_CHC; 244 else if (val == GtpVisibility::VisibilityEnvironment:: RANDOM_UPDATE_CULLING)244 else if (val == GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING_PLUSPLUS) 245 245 mRenderMethod = BiHierarchy::BIHRM_GTP_RU; 246 246 // default, should never happen -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r2547 r2555 323 323 LogManager::getSingleton().logMessage("Using stop and wait algorithm"); 324 324 } 325 else if (val == " RUC")325 else if (val == "CHC++") 326 326 { 327 327 algorithm = 328 GtpVisibility::VisibilityEnvironment:: RANDOM_UPDATE_CULLING;329 330 LogManager::getSingleton().logMessage("Using random update culling");328 GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING_PLUSPLUS; 329 330 LogManager::getSingleton().logMessage("Using chc ++"); 331 331 } 332 332 else if (val == "VFC") -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp
r2455 r2555 32 32 Octree *nextChild; 33 33 34 for (int z = 0; z < 2; ++ z) 35 { 36 for (int y = 0; y < 2; ++ y) 37 { 38 for (int x = 0; x < 2; ++ x) 39 { 40 nextChild = octree->mChildren[x][y][z]; 41 42 if (nextChild) 43 GetQueue()->push(nextChild); 44 } 45 } 46 } 34 nextChild = octree->mChildren[0][0][0]; if (nextChild) GetQueue()->push(nextChild); 35 nextChild = octree->mChildren[1][0][0]; if (nextChild) GetQueue()->push(nextChild); 36 nextChild = octree->mChildren[0][1][0]; if (nextChild) GetQueue()->push(nextChild); 37 nextChild = octree->mChildren[1][1][0]; if (nextChild) GetQueue()->push(nextChild); 38 nextChild = octree->mChildren[0][0][1]; if (nextChild) GetQueue()->push(nextChild); 39 nextChild = octree->mChildren[1][0][1]; if (nextChild) GetQueue()->push(nextChild); 40 nextChild = octree->mChildren[0][1][1]; if (nextChild) GetQueue()->push(nextChild); 41 nextChild = octree->mChildren[1][1][1]; if (nextChild) GetQueue()->push(nextChild); 42 } 43 } 44 //----------------------------------------------------------------------- 45 void OctreeHierarchyInterface::TraverseNode2(GtpVisibility::HierarchyNode *node) 46 { 47 ++ mNumTraversedNodes; 48 49 Octree *octree = static_cast<Octree *>(node); 50 51 // if we come across some renderable geometry => render it 52 if (!octree->mNodes.empty()) 53 { 54 AddToQueue(node); 55 } 56 57 // if not all subtrees are empty 58 if (!IsLeaf(node)) 59 { 60 Octree *nextChild; 61 62 nextChild = octree->mChildren[0][0][0]; if (nextChild) GetQueue()->push(nextChild); 63 nextChild = octree->mChildren[1][0][0]; if (nextChild) GetQueue()->push(nextChild); 64 nextChild = octree->mChildren[0][1][0]; if (nextChild) GetQueue()->push(nextChild); 65 nextChild = octree->mChildren[1][1][0]; if (nextChild) GetQueue()->push(nextChild); 66 nextChild = octree->mChildren[0][0][1]; if (nextChild) GetQueue()->push(nextChild); 67 nextChild = octree->mChildren[1][0][1]; if (nextChild) GetQueue()->push(nextChild); 68 nextChild = octree->mChildren[0][1][1]; if (nextChild) GetQueue()->push(nextChild); 69 nextChild = octree->mChildren[1][1][1]; if (nextChild) GetQueue()->push(nextChild); 47 70 } 48 71 } … … 195 218 if (octant->lastRendered() != mFrameId) 196 219 { 220 mTestMode = false; 221 197 222 octant->setLastRendered(mFrameId); 198 223 OctreeSceneManager *ocm = 199 224 static_cast<OctreeSceneManager *>(mSceneManager); 200 225 201 ocm->_ renderOctant(mCamera,226 ocm->_addOctantToQueue(mCamera, 202 227 octant, 203 228 mOnlyShadowCasters, 204 229 mLeavePassesInQueue); 205 230 231 ocm->_renderOctant(mLeavePassesInQueue); 232 206 233 mVisibleNodes.push_back(node); 207 234 } 235 #endif 236 } 237 //----------------------------------------------------------------------- 238 void OctreeHierarchyInterface::AddToQueue(GtpVisibility::HierarchyNode *node) 239 { 240 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 241 Octree *octant = static_cast<Octree *>(node); 242 243 if (octant->lastRendered() != mFrameId) 244 { 245 OctreeSceneManager *ocm = 246 static_cast<OctreeSceneManager *>(mSceneManager); 247 248 octant->setLastRendered(mFrameId); 249 250 ocm->_addOctantToQueue(mCamera, 251 octant, 252 mOnlyShadowCasters, 253 mLeavePassesInQueue); 254 255 mVisibleNodes.push_back(node); 256 } 257 #endif 258 } 259 //----------------------------------------------------------------------- 260 void OctreeHierarchyInterface::RenderQueue() 261 { 262 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 263 mTestMode = false; 264 265 OctreeSceneManager *ocm = 266 static_cast<OctreeSceneManager *>(mSceneManager); 267 ocm->_renderOctant(mLeavePassesInQueue); 208 268 #endif 209 269 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformHierarchyInterface.cpp
r2497 r2555 98 98 99 99 mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 100 mSceneManager->useRenderableViewProjModeWrapper(solidBox);100 //mSceneManager->useRenderableViewProjModeWrapper(solidBox); 101 101 102 102 // set no depth write, no color, no lighting material 103 mSceneManager->setPassWrapper(solidBox->getTechnique()->getPass(0)); 103 if (!mTestMode) 104 { 105 mTestMode = true; 106 mSceneManager->setPassWrapper(solidBox->getTechnique()->getPass(0)); 107 } 108 104 109 solidBox->SetupBoundingBoxVertices(*box); 105 110 … … 147 152 // create materials for node visualization 148 153 CreateNodeVizMaterials(); 154 155 mTestMode = false; 149 156 } 150 157 //----------------------------------------------------------------------- -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformOcclusionQuery.cpp
r944 r2555 29 29 const bool waitForResult) const 30 30 { 31 // return mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels, waitForResult); 32 33 bool isAvailable = true; 34 35 if (!waitForResult) 31 if (waitForResult || !mHardwareOcclusionQuery->isStillOutstanding()) 36 32 { 37 isAvailable = !mHardwareOcclusionQuery->isStillOutstanding(); 33 //return mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels); 34 mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels); 35 return true; 38 36 } 39 37 40 //std::stringstream d; d << mHardwareOcclusionQuery << ", available: " << isAvailable << ", waitforresult: " << waitForResult;41 // Ogre::LogManager::getSingleton().logMessage(d.str());42 43 if (isAvailable)44 return mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels);45 46 38 return false; 47 39 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/include/CoherentHierarchicalCullingManager.h
r2455 r2555 70 70 71 71 bool mTestGeometryForVisibleLeaves; 72 73 QueryQueue mQueryQueue; 72 74 }; 73 75 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/include/CoherentHierarchicalCullingPlusPlusManager.h
r2553 r2555 1 #ifndef _ BatchedQueriesCullingManager_H__2 #define _ BatchedQueriesCullingManager_H__1 #ifndef _CoherentHierarchicalCullingPlusPlusManager_H__ 2 #define _CoherentHierarchicalCullingPlusPlusManager_H__ 3 3 4 #include "C oherentHierarchicalCullingManager.h"4 #include "CullingManager.h" 5 5 #include "HierarchyInterface.h" 6 6 … … 11 11 /** Renders the scene with the coherent hierarchical culling algorithm. 12 12 */ 13 class BatchedQueriesCullingManager : public CoherentHierarchicalCullingManager13 class CoherentHierarchicalCullingPlusPlusManager: public CullingManager 14 14 { 15 15 public: 16 BatchedQueriesCullingManager();16 CoherentHierarchicalCullingPlusPlusManager(); 17 17 /** Constructor taking the assumed visibility into account, i.e., the estimation 18 18 for how many frames the current visibility is considered to be valid 19 19 */ 20 BatchedQueriesCullingManager(const unsigned int assumedVisibility);20 CoherentHierarchicalCullingPlusPlusManager(const unsigned int assumedVisibility); 21 21 22 22 void RenderScene(); 23 23 24 void SetMaxPending(int maxPending); 24 /** Sets assumed visibility (i.e., an estimation for 25 how many frames the visibility is considered to be valid). 26 @param assumedVisibility indicates for how many frames the 27 same visibility is be assumed. 28 if 0, the visibility is tested deterministically for each frame. 29 */ 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 25 43 26 44 protected: 27 45 28 void IssueMultipleQueries(PendingQueue &pendingQueue, QueryQueue &queryQueue); 46 /** Decides if node is considered to be visible depeding on the 47 assumed visibility factor. 48 @returns if node is considered to be visible 49 */ 50 bool DecideVisible(HierarchyNode *node) const; 29 51 30 /** maximal pending nodes.52 /** Skip query for this node. 31 53 */ 32 int mMaxPending; 54 void SkipQuery(HierarchyNode *node) const; 55 56 /** If this node is still valid for traversal in this frame. 57 It is possible that the parent was tested invisible before 58 so this node can be skipped. 59 */ 60 bool NodeInvalid(HierarchyNode *node) const; 61 62 void AssignAssumedVisibility(GtpVisibility::HierarchyNode *node); 63 64 void IssueBatchedQuery(HierarchyNodeContainer &nodes); 65 66 inline void IssueQuery(HierarchyNode *node, const bool testGeometry); 67 68 69 ////////////////////// 70 71 /** number of steps the visibility is assumed to be valid. 72 */ 73 unsigned int mAssumedVisibility; 74 75 bool mTestGeometryForVisibleLeaves; 76 77 QueryQueue mQueryQueue; 78 79 std::queue<HierarchyNode *> mVisibleNodes; 80 HierarchyNodeContainer mInvisibleNodes; 81 82 int mMaxInvisibleNodesSize; 33 83 }; 34 84 35 85 } // namespace GtpVisibility 36 86 37 #endif // BatchedQueriesCullingManager_H87 #endif // CoherentHierarchicalCullingPlusPlusManager_H -
GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h
r2543 r2555 164 164 */ 165 165 virtual void DecNodeAssumedVisible(HierarchyNode *node) = 0; 166 167 virtual void AddToQueue(GtpVisibility::HierarchyNode *node) = 0; 168 169 virtual void RenderQueue() = 0; 170 171 virtual void TraverseNode2(GtpVisibility::HierarchyNode *node) = 0; 166 172 167 173 protected: -
GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityEnvironment.h
r2289 r2555 22 22 */ 23 23 enum CullingManagerType {COHERENT_HIERARCHICAL_CULLING, 24 COHERENT_HIERARCHICAL_CULLING_PLUSPLUS, 25 STOP_AND_WAIT_CULLING, 24 26 FRUSTUM_CULLING, 25 RANDOM_UPDATE_CULLING, 26 STOP_AND_WAIT_CULLING, 27 NUM_CULLING_MANAGERS}; 27 NUM_CULLING_MANAGERS}; 28 28 29 29 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/terrainCulling.cfg
r2497 r2555 3 3 # 4 4 5 OnlineCullingAlgorithm= RUC5 OnlineCullingAlgorithm=CHC++ 6 6 #OnlineCullingAlgorithm=CHC 7 7 #OnlineCullingAlgorithm=SWC … … 87 87 88 88 #Scene=../../../../../resources/media/house_test1.iv 89 #Scene=../../../../../resources/media/city1500_flat_1.iv;../../../../../resources/media/roofs_1500.iv;../../../../../resources/media/CityRoads60.iv;../../../../../resources/media/CityPlane60.iv89 Scene=../../../../../resources/media/city1500_flat_1.iv;../../../../../resources/media/roofs_1500.iv;../../../../../resources/media/CityRoads60.iv;../../../../../resources/media/CityPlane60.iv 90 90 #Scene=../../../../../resources/media/city1.iv;../../../../../resources/media/roofs_1500.iv;../../../../../resources/media/CityRoads60.iv;../../../../../resources/media/CityPlane60.iv 91 91 … … 96 96 # 97 97 98 Scene=terrain98 #Scene=terrain 99 99 100 100 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp
r2455 r2555 9 9 10 10 11 static int batchSize = 5;12 11 13 12 //----------------------------------------------------------------------- … … 36 35 { 37 36 if (0) CullingLogManager::GetSingleton()->LogMessage("chc"); 38 QueryQueue queryQueue;39 37 unsigned int visiblePixels = 0; 40 38 … … 42 40 //-- PART 1: process finished occlusion queries 43 41 44 while (!mHierarchyInterface->GetQueue()->empty() || ! queryQueue.empty())42 while (!mHierarchyInterface->GetQueue()->empty() || !mQueryQueue.empty()) 45 43 { 46 44 ////////// 47 45 //-- only wait for result if there are no nodes to process 48 46 49 while (! queryQueue.empty() &&50 (NodeInvalid( queryQueue.front().first) ||51 queryQueue.front().second->GetQueryResult(47 while (!mQueryQueue.empty() && 48 (NodeInvalid(mQueryQueue.front().first) || 49 mQueryQueue.front().second->GetQueryResult( 52 50 visiblePixels, mHierarchyInterface->GetQueue()->empty()))) 53 51 { 54 HierarchyNode *node = queryQueue.front().first;55 queryQueue.pop();52 HierarchyNode *node = mQueryQueue.front().first; 53 mQueryQueue.pop(); 56 54 57 55 // "invalid nodes" happen for hierarchies that have geometry … … 145 143 ++ mNumQueriesIssued; 146 144 147 const bool testGeometry = wasVisible && mHierarchyInterface->IsLeaf(node) && mTestGeometryForVisibleLeaves; 148 149 queryQueue.push(QueryPair(node, mHierarchyInterface-> 145 const bool testGeometry = 146 wasVisible && mHierarchyInterface->IsLeaf(node) && mTestGeometryForVisibleLeaves; 147 148 mQueryQueue.push(QueryPair(node, mHierarchyInterface-> 150 149 IssueNodeOcclusionQuery(node, testGeometry))); 151 150 } … … 192 191 { 193 192 // parent was tested invisible in this frame 194 HierarchyNode *parent = mHierarchyInterface->GetParent(node); 195 return196 parent&&197 (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId()) &&198 !mHierarchyInterface->IsNodeVisible(parent);193 return ( 194 mHierarchyInterface->GetParent(node) && 195 (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId()) && 196 !mHierarchyInterface->IsNodeVisible(mHierarchyInterface->GetParent(node)) 197 ); 199 198 } 200 199 //----------------------------------------------------------------------- -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingPlusPlusManager.cpp
r2553 r2555 1 #include "BatchedQueriesCullingManager.h" 1 #include "CoherentHierarchicalCullingPlusPlusManager.h" 2 #include "CullingLogManager.h" 3 4 #include <time.h> 5 #include <sstream> 6 2 7 3 8 4 9 namespace GtpVisibility { 5 10 6 //----------------------------------------------------------------------- 7 BatchedQueriesCullingManager::BatchedQueriesCullingManager(): 8 mMaxPending(5) 9 { 10 } 11 //----------------------------------------------------------------------- 12 BatchedQueriesCullingManager::BatchedQueriesCullingManager(const unsigned int 13 assumedVisibility): 14 CoherentHierarchicalCullingManager(assumedVisibility), mMaxPending(5) 15 { 16 } 17 18 //----------------------------------------------------------------------- 19 void BatchedQueriesCullingManager::RenderScene() 20 { 21 QueryQueue queryQueue; 11 12 static const bool CULL_INVALID_NODES = false; 13 14 //----------------------------------------------------------------------- 15 CoherentHierarchicalCullingPlusPlusManager::CoherentHierarchicalCullingPlusPlusManager(): 16 mAssumedVisibility(0), mMaxInvisibleNodesSize(50) 17 { 18 } 19 //----------------------------------------------------------------------- 20 CoherentHierarchicalCullingPlusPlusManager::CoherentHierarchicalCullingPlusPlusManager( 21 const unsigned int assumedVisibility): 22 mAssumedVisibility(assumedVisibility), mMaxInvisibleNodesSize(50) 23 { 24 } 25 //----------------------------------------------------------------------- 26 void CoherentHierarchicalCullingPlusPlusManager::AssignAssumedVisibility(GtpVisibility::HierarchyNode *node) 27 { 28 if (!mHierarchyInterface->IsNodeVisible(node)) 29 // previously invisible nodes: give random offset just for the first test after 30 // becoming visible to avoid that all nodes are tested in the same frame 31 mHierarchyInterface->SetNodeAssumedVisible(node, rand() * mAssumedVisibility / RAND_MAX); 32 else 33 mHierarchyInterface->SetNodeAssumedVisible(node, mAssumedVisibility); 34 } 35 //----------------------------------------------------------------------- 36 void CoherentHierarchicalCullingPlusPlusManager::RenderScene() 37 { 38 if (0) CullingLogManager::GetSingleton()->LogMessage("chc++"); 39 22 40 unsigned int visiblePixels = 0; 23 41 24 PendingQueue pendingQueue; 25 42 ///////////// 26 43 //-- PART 1: process finished occlusion queries 27 while (!mHierarchyInterface->GetQueue()->empty() || !queryQueue.empty() ||!pendingQueue.empty()) 44 45 while (!mHierarchyInterface->GetQueue()->empty() || !mQueryQueue.empty() || 46 !mInvisibleNodes.empty() || !mVisibleNodes.empty()) 28 47 { 29 while (!queryQueue.empty() && 30 queryQueue.front().second->GetQueryResult(visiblePixels, 31 mHierarchyInterface->GetQueue()->empty())) 48 ////////// 49 //-- only wait for result if there are no nodes to process 50 51 bool resultAvailable = false; 52 while ( 53 !mQueryQueue.empty() && 54 (NodeInvalid(mQueryQueue.front().first) || 55 mHierarchyInterface->GetQueue()->empty() || 56 (resultAvailable = mQueryQueue.front().second->GetQueryResult(visiblePixels, false))) 57 ) 32 58 { 33 HierarchyNode *node = queryQueue.front().first; 34 35 queryQueue.pop(); 36 59 HierarchyNode *node = mQueryQueue.front().first; 60 61 // "invalid nodes" happen for hierarchies that store geometry in the interiors 62 // parent was tested invisible => remove children from queue 63 if (NodeInvalid(node)) {mQueryQueue.pop(); continue;} 64 65 // during the wait time issue nodes from visible queue 66 while (!mVisibleNodes.empty() && !resultAvailable) 67 { 68 HierarchyNode *vn = mVisibleNodes.front(); 69 mVisibleNodes.pop(); 70 IssueQuery(vn, false); 71 72 // check if result is already availalbe 73 resultAvailable = mQueryQueue.front().second->GetQueryResult(visiblePixels, false); 74 } 75 76 if (!resultAvailable) 77 mQueryQueue.front().second->GetQueryResult(visiblePixels, true); 78 79 resultAvailable = false; 80 mQueryQueue.pop(); 81 82 // tested visible 37 83 if (visiblePixels > mVisibilityThreshold) 38 84 { 39 // ensure that we only traverse once if geometry in node 85 // assing the #frames the node is assumed to stay visible 86 AssignAssumedVisibility(node); 87 88 // for previously visible interior node which contains geometry: 89 // ensure that we did not already traverse this node 90 // (which means that the visibility flag is set) 40 91 if (!mHierarchyInterface->IsNodeVisible(node)) 41 mHierarchyInterface->TraverseNode (node);92 mHierarchyInterface->TraverseNode2(node); 42 93 43 94 mHierarchyInterface->PullUpVisibility(node); … … 50 101 51 102 if (mVisualizeCulledNodes) 52 {53 103 mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED); 54 104 } 55 } 105 106 // update node's visited flag 107 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 56 108 } 57 109 110 //////////////// 58 111 //-- PART 2: hierarchical traversal 112 59 113 if (!mHierarchyInterface->GetQueue()->empty()) 60 114 { … … 62 116 mHierarchyInterface->GetQueue()->pop(); 63 117 118 // parent was tested invisible => remove children from queue 119 if (NodeInvalid(node)) continue; 120 64 121 bool intersects = false; 65 122 … … 69 126 70 127 if (mVisualizeCulledNodes) 71 {72 128 mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED); 73 } 74 } 75 // -- if node intersects near plane, skip query because wrong results possible 129 } 76 130 else if (intersects) 77 131 { 132 //-- if node intersects near plane, skip query because wrong results possible 78 133 SkipQuery(node); 79 134 } … … 85 140 86 141 // if we assume node to be visible in this frame => skip query 87 bool skipQuery = wasVisible && (mAssumedVisibility > 0) && 88 DecideVisible(node) && mHierarchyInterface->HasGeometry(node); 142 const bool skipQuery = wasVisible && 143 DecideVisible(node) && 144 mHierarchyInterface->HasGeometry(node); 89 145 90 146 if (skipQuery) … … 96 152 // identify nodes that we cannot skip queries for 97 153 // geometry not only in leaves => test for renderable geometry 98 bool issueQuery = !wasVisible || mHierarchyInterface->HasGeometry(node);154 const bool issueQuery = !wasVisible || mHierarchyInterface->HasGeometry(node); 99 155 100 // reset node's visibility classification101 // set visible if geometry in node so we only traverse once156 // set node's visibility classification 157 // we identify previously visible / invisible nodes in the query queue 102 158 mHierarchyInterface->SetNodeVisible(node, wasVisible && issueQuery); 103 159 104 // update node's visited flag105 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());106 107 // skip testing previously visible nodes without geometry108 160 if (issueQuery) 109 161 { 110 162 ++ mNumQueriesIssued; 111 // add to the pending queue instead of immediate query 112 if ((int)pendingQueue.size() < mMaxPending) 113 pendingQueue.push(PendingQuery(node, wasVisible)); 163 164 if (!wasVisible) 165 { 166 mInvisibleNodes.push_back(node); 167 168 if ((int)mInvisibleNodes.size() >= mMaxInvisibleNodesSize) 169 { 170 mHierarchyInterface->RenderQueue(); 171 // issue the batched queries 172 IssueBatchedQuery(mInvisibleNodes); 173 } 174 } 114 175 else 115 176 { 116 IssueMultipleQueries(pendingQueue, queryQueue); 177 mVisibleNodes.push(node); 178 //IssueQuery(node, false); 117 179 } 180 } 181 else 182 { 183 // skip testing previously visible nodes without geometry 184 // just update node's visited flag 185 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 118 186 } 119 187 … … 121 189 if (wasVisible) 122 190 { 123 mHierarchyInterface->TraverseNode (node);191 mHierarchyInterface->TraverseNode2(node); 124 192 } 125 193 } 126 194 } 127 195 128 // issue rest of queries 129 IssueMultipleQueries(pendingQueue, queryQueue); 196 197 if (mHierarchyInterface->GetQueue()->empty() && !mInvisibleNodes.empty()) 198 { 199 if (0) 200 { 201 std::stringstream d; 202 d << "inv nodes: " << (int)mInvisibleNodes.size(); 203 CullingLogManager::GetSingleton()->LogMessage(d.str()); 204 } 205 206 mHierarchyInterface->RenderQueue(); 207 IssueBatchedQuery(mInvisibleNodes); 208 } 209 210 // issue rest of nodes from nodes from visible queue 211 if (mHierarchyInterface->GetQueue()->empty() && mQueryQueue.empty() && !mVisibleNodes.empty()) 212 { 213 if (0) 214 { 215 std::stringstream d; 216 d << "vis nodes: " << (int)mVisibleNodes.size(); 217 CullingLogManager::GetSingleton()->LogMessage(d.str()); 218 } 219 220 while (!mVisibleNodes.empty()) 221 { 222 IssueQuery(mVisibleNodes.front(), false); 223 mVisibleNodes.pop(); 224 } 225 } 130 226 } 131 } 132 133 void BatchedQueriesCullingManager::IssueMultipleQueries(PendingQueue &pendingQueue, 134 QueryQueue &queryQueue) 135 { 136 while (!pendingQueue.empty()) 227 228 229 if (0) 137 230 { 138 HierarchyNode *node = pendingQueue.front().first; 139 const bool wasVisible = pendingQueue.front().second; 140 141 pendingQueue.pop(); 142 143 queryQueue.push(QueryPair(node, mHierarchyInterface-> 144 IssueNodeOcclusionQuery(node, wasVisible))); 231 std::stringstream d; 232 d << "queries: " << (int)mQueryQueue.size() << " vis: " << (int)mVisibleNodes.size() << " inv: " << (int)mInvisibleNodes.size(); 233 CullingLogManager::GetSingleton()->LogMessage(d.str()); 145 234 } 146 } 147 148 void BatchedQueriesCullingManager::SetMaxPending(int maxPending) 149 { 150 mMaxPending = maxPending; 151 } 152 153 } // namespace GtpVisibility 235 236 // render rest 237 mHierarchyInterface->RenderQueue(); 238 } 239 //----------------------------------------------------------------------- 240 void CoherentHierarchicalCullingPlusPlusManager::SetAssumedVisibility(const unsigned int assumedVisibility) 241 { 242 mAssumedVisibility = assumedVisibility; 243 } 244 //----------------------------------------------------------------------- 245 inline bool CoherentHierarchicalCullingPlusPlusManager::DecideVisible(HierarchyNode *node) const 246 { 247 mHierarchyInterface->DecNodeAssumedVisible(node); 248 //std::stringstream d; d << "node visible: " << mHierarchyInterface->GetNodeAssumedVisible(node); 249 //CullingLogManager::GetSingleton()->LogMessage(d.str()); 250 return mHierarchyInterface->GetNodeAssumedVisible(node) > 0; 251 } 252 //----------------------------------------------------------------------- 253 inline void CoherentHierarchicalCullingPlusPlusManager::SkipQuery(HierarchyNode *node) const 254 { 255 //-- set node to be visible in this frame, then traverse it 256 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 257 258 mHierarchyInterface->PullUpVisibility(node); 259 mHierarchyInterface->TraverseNode2(node); 260 } 261 //----------------------------------------------------------------------- 262 inline bool CoherentHierarchicalCullingPlusPlusManager::NodeInvalid(HierarchyNode *node) const 263 { 264 if (!CULL_INVALID_NODES) return false; 265 266 // parent was tested invisible in this frame 267 return ( 268 mHierarchyInterface->GetParent(node) && 269 (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId()) && 270 !mHierarchyInterface->IsNodeVisible(mHierarchyInterface->GetParent(node)) 271 ); 272 } 273 //----------------------------------------------------------------------- 274 void CoherentHierarchicalCullingPlusPlusManager::SetTestGeometryForVisibleLeaves(const bool testGeometry) 275 { 276 mTestGeometryForVisibleLeaves = testGeometry; 277 } 278 //----------------------------------------------------------------------- 279 bool CoherentHierarchicalCullingPlusPlusManager::GetTestGeometryForVisibleLeaves() 280 { 281 return mTestGeometryForVisibleLeaves; 282 } 283 //----------------------------------------------------------------------- 284 inline void CoherentHierarchicalCullingPlusPlusManager::IssueQuery(HierarchyNode *node, 285 const bool queryGeometry) 286 { 287 mQueryQueue.push(QueryPair(node, mHierarchyInterface-> 288 IssueNodeOcclusionQuery(node, queryGeometry))); 289 } 290 //----------------------------------------------------------------------- 291 void CoherentHierarchicalCullingPlusPlusManager::IssueBatchedQuery(HierarchyNodeContainer &nodes) 292 { 293 HierarchyNodeContainer::const_iterator nit, nit_end = nodes.end(); 294 295 for (nit = nodes.begin(); nit != nit_end; ++ nit) 296 IssueQuery(*nit, false); 297 298 nodes.clear(); 299 } 300 301 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/FrustumCullingManager.cpp
r2292 r2555 31 31 { 32 32 mHierarchyInterface->SetNodeVisible(node, true); 33 mHierarchyInterface->TraverseNode (node);33 mHierarchyInterface->TraverseNode2(node); 34 34 } 35 35 } 36 mHierarchyInterface->RenderQueue(); 36 37 } 37 38 } // namespace GtpVisibility -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj
r2542 r2555 253 253 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 254 254 <File 255 RelativePath="..\src\BatchedQueriesCullingManager.cpp">256 </File>257 <File258 255 RelativePath="..\src\CoherentHierarchicalCullingManager.cpp"> 256 </File> 257 <File 258 RelativePath=".\CoherentHierarchicalCullingPlusPlusManager.cpp"> 259 259 </File> 260 260 <File … … 297 297 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 298 298 <File 299 RelativePath="..\include\BatchedQueriesCullingManager.h">300 </File>301 <File302 299 RelativePath="..\include\CoherentHierarchicalCullingManager.h"> 303 300 </File> 304 301 <File 305 RelativePath="..\include\CoherentHierarchicalCulling Manager2.h">302 RelativePath="..\include\CoherentHierarchicalCullingPlusPlusManager.h"> 306 303 </File> 307 304 <File -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityManager.cpp
r2455 r2555 5 5 #include "DummyPreprocessingManager.h" 6 6 #include "RandomUpdateCullingManager.h" 7 #include "CoherentHierarchicalCullingPlusPlusManager.h" 7 8 #include "CullingLogManager.h" 8 9 … … 19 20 mAssumedVisibilityForChc(0) 20 21 { 21 #if 122 22 SetCullingManager(VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING); 23 #endif24 #if 025 SetCullingManager(VisibilityEnvironment::STOP_AND_WAIT_CULLING);26 #endif27 #if 028 SetCullingManager(VisibilityEnvironment::FRUSTUM_CULLING);29 #endif30 23 } 31 24 //----------------------------------------------------------------------- … … 61 54 mCullingManager = new FrustumCullingManager(); 62 55 break; 63 case VisibilityEnvironment:: RANDOM_UPDATE_CULLING:56 case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING_PLUSPLUS: 64 57 { 65 RandomUpdateCullingManager *rum = new RandomUpdateCullingManager(mRandomCandidatesForRuc);66 rum->SetTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves);67 mCullingManager = rum;58 CoherentHierarchicalCullingPlusPlusManager *chcm = 59 new CoherentHierarchicalCullingPlusPlusManager(mAssumedVisibilityForChc); 60 mCullingManager = chcm; 68 61 } 69 62 break; … … 118 111 mAssumedVisibilityForChc = assumedVisibility; 119 112 120 if (mCullingManagerType == VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING)113 switch (mCullingManagerType) 121 114 { 115 case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING: 122 116 static_cast<CoherentHierarchicalCullingManager *>(mCullingManager)-> 123 117 SetAssumedVisibility(mAssumedVisibilityForChc); 118 break; 119 case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING_PLUSPLUS: 120 static_cast<CoherentHierarchicalCullingPlusPlusManager *>(mCullingManager)-> 121 SetAssumedVisibility(mAssumedVisibilityForChc); 122 break; 124 123 } 125 124 } … … 129 128 mRandomCandidatesForRuc = randomCandidates; 130 129 131 if (mCullingManagerType == VisibilityEnvironment:: RANDOM_UPDATE_CULLING)130 if (mCullingManagerType == VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING_PLUSPLUS) 132 131 { 133 132 static_cast<RandomUpdateCullingManager *>(mCullingManager)-> … … 160 159 SetTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves); 161 160 } 162 else if (mCullingManagerType == VisibilityEnvironment::RANDOM_UPDATE_CULLING)161 /*else if (mCullingManagerType == VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING_PLUSPLUS) 163 162 { 164 163 static_cast<RandomUpdateCullingManager *>(mCullingManager)-> 165 164 SetTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves); 166 } 165 }*/ 167 166 } 168 167 //-----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.