- Timestamp:
- 06/11/08 00:18:07 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.cpp
r2746 r2754 4 4 5 5 6 #if TOIMPLEMENT 6 namespace CHCDemo 7 { 7 8 8 9 RenderTraverser::RenderTraverser(): 9 10 mFrameID(1), 10 11 mVisibilityThreshold(0), 11 mHierarchyRoot(NULL), 12 mOcclusionQueries(NULL), 13 mCurrentQueryIdx(0), 12 mBvh(NULL), 14 13 mIsQueryMode(false), 15 mNumTraversedNodes(0),16 mNumQueryCulledNodes(0),17 mNumFrustumCulledNodes(0),18 mRenderTime(0),19 mNumRenderedGeometry(0),20 14 mUseOptimization(true), 21 m UseArbQueries(false)15 mCurrentQueryIdx(0) 22 16 { 23 17 } … … 26 20 RenderTraverser::~RenderTraverser() 27 21 { 28 DelQueries();29 } 30 31 32 void RenderTraverser::Render(int mode)22 //DelQueries(); 23 } 24 25 26 /*void RenderTraverser::Render(int mode) 33 27 { 34 28 mDistanceQueue.push(mHierarchyRoot); … … 61 55 62 56 finishTiming(); 63 } 64 65 /** 66 This is the standard render traversal algorithm doing only frustum culling 67 */ 68 void RenderTraverser::RenderCullFrustum() 69 { 70 while(!mDistanceQueue.empty()) 71 { 72 HierarchyNode *node = mDistanceQueue.top(); 73 mDistanceQueue.pop(); 74 75 // interesting for the visualization, so rest and set 76 node->SetVisible(false); 77 mNumTraversedNodes ++; 78 79 bool intersects; 80 81 if(InsideViewFrustum(node, intersects)) 82 { 83 // update node's visited flag => needed for rendering 84 // so set it also here 85 node->SetLastVisited(mFrameID); 86 node->SetVisible(true); 87 TraverseNode(node); 88 } 89 else 90 { 91 mNumFrustumCulledNodes ++; 92 } 93 } 94 } 95 96 void RenderTraverser::RenderStopAndWait() 97 { 98 while(! mDistanceQueue.empty()) 99 { 100 HierarchyNode *node = mDistanceQueue.top(); 101 mDistanceQueue.pop(); 102 mNumTraversedNodes ++; 103 // interesting for the visualization, so rest and set 104 node->SetVisible(false); 105 106 bool intersects; 107 108 if(InsideViewFrustum(node, intersects)) 109 { 110 // update node's visited flag 111 node->SetLastVisited(mFrameID); 112 113 // for near plane intersecting abbs possible 114 // wrong results => skip occlusion query 115 if(intersects) 116 { 117 node->SetVisible(true); 118 TraverseNode(node); 119 } 120 else 121 { 122 IssueOcclusionQuery(node, false); 123 124 // wait if result not available 125 int visiblePixels = GetOcclusionQueryResult(node); 126 127 // node visible 128 if(visiblePixels > mVisibilityThreshold) 129 { 130 node->SetVisible(true); 131 TraverseNode(node); 132 } 133 else 134 { 135 mNumQueryCulledNodes ++; 136 } 137 } 138 } 139 else 140 { 141 mNumFrustumCulledNodes ++; 142 } 143 } 144 } 145 146 void RenderTraverser::RenderCoherentWithQueue() 147 { 148 QueryQueue queryQueue; 149 150 //-- PART 1: process finished occlusion queries 151 while (!mDistanceQueue.empty() || !queryQueue.empty()) 152 { 153 while (!queryQueue.empty() && 154 (ResultAvailable(queryQueue.front()) || mDistanceQueue.empty())) 155 { 156 HierarchyNode *node = queryQueue.front(); 157 queryQueue.pop(); 158 159 // wait until result available 160 int visiblePixels = GetOcclusionQueryResult(node); 161 162 if(visiblePixels > mVisibilityThreshold) 163 { 164 PullUpVisibility(node); 165 TraverseNode(node); 166 } 167 else 168 { 169 mNumQueryCulledNodes ++; 170 } 171 } 172 173 //-- PART 2: hierarchical traversal 174 if (!mDistanceQueue.empty()) 175 { 176 HierarchyNode *node = mDistanceQueue.top(); 177 178 mDistanceQueue.pop(); 179 180 mNumTraversedNodes ++; 181 182 bool intersects; 183 184 if (InsideViewFrustum(node, intersects)) 185 { 186 // for near plane intersecting bounding box possible 187 // wrong results => skip occlusion query 188 if(intersects) 189 { 190 // update node's visited flag 191 node->SetLastVisited(mFrameID); 192 node->SetVisible(true); 193 PullUpVisibility(node); 194 TraverseNode(node); 195 } 196 else 197 { 198 // identify previously visible nodes 199 bool wasVisible = node->Visible() && (node->LastVisited() == mFrameID - 1); 200 201 // identify nodes that we cannot skip queries for 202 bool leafOrWasInvisible = (node->LastVisited() != mFrameID) && (!wasVisible || node->IsLeaf()); 203 204 // reset node's visibility classification 205 node->SetVisible(false); 206 207 // update node's visited flag 208 node->SetLastVisited(mFrameID); 209 210 // skip testing previously visible interior nodes 211 if(leafOrWasInvisible) 212 { 213 IssueOcclusionQuery(node, wasVisible); 214 queryQueue.push(node); 215 } 216 217 // always traverse a node if it was visible 218 if(wasVisible) 219 TraverseNode(node); 220 } 221 } 222 else 223 { 224 // for stats 225 mNumFrustumCulledNodes ++; 226 } 227 } 228 } 229 } 230 57 }*/ 58 59 #if 0 231 60 void RenderTraverser::TraverseNode(HierarchyNode *node) 232 61 { … … 533 362 534 363 535 int RenderTraverser::GetVisibilityThreshold() 536 { 537 return mVisibilityThreshold; 538 } 364 #endif 365 539 366 540 367 void RenderTraverser::SetUseOptimization(bool useOptimization) … … 544 371 } 545 372 546 547 #endif 373 }
Note: See TracChangeset
for help on using the changeset viewer.