- Timestamp:
- 06/18/08 17:33:16 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.cpp
r2770 r2771 5 5 #include "SceneEntity.h" 6 6 #include "RenderState.h" 7 8 9 using namespace std; 7 10 8 11 … … 35 38 mVisibilityThreshold(0), 36 39 mBvh(NULL), 37 mIsQueryMode(false),38 40 mUseOptimization(false), 39 41 mFrameId(-1), 40 42 mUseRenderQueue(false), 41 mAssumedVisibleFrames(10) 43 mAssumedVisibleFrames(10), 44 mMaxBatchSize(50) 42 45 { 43 46 } … … 78 81 void RenderTraverser::RenderNode(BvhNode *node) 79 82 { 80 if (mUseRenderQueue) 81 { 82 int geometrySize; 83 SceneEntity **geom = mBvh->GetGeometry(node, geometrySize); 84 mRenderQueue.Enqueue(geom, geometrySize); 85 mStats.mNumRenderedGeometry += geometrySize; 86 } 87 else 88 { 89 if (mRenderState->SetState(RenderState::RENDER)) 90 ++ mStats.mNumStateChanges; 91 92 mStats.mNumRenderedGeometry += mBvh->Render(node, mRenderState); 93 } 83 if (node->GetLastRenderedFrame() != mFrameId) 84 { 85 //cout << "big error!!" << endl; 86 node->SetLastRenderedFrame(mFrameId); 87 88 if (mUseRenderQueue) 89 { 90 int geometrySize; 91 SceneEntity **geom = mBvh->GetGeometry(node, geometrySize); 92 mRenderQueue.Enqueue(geom, geometrySize); 93 mStats.mNumRenderedGeometry += geometrySize; 94 } 95 else 96 { 97 if (mRenderState->SetState(RenderState::RENDER)) 98 ++ mStats.mNumStateChanges; 99 100 mStats.mNumRenderedGeometry += mBvh->Render(node, mRenderState); 101 } 102 } 94 103 } 95 104 … … 130 139 } 131 140 132 // if this node is a previous visible leaf => will be rendered anyway, thus we133 // can also test with the real geometry141 // if this node is a previous visible leaf: 142 // leaves will be rendered anyway => we can also test with the real geometry 134 143 if (wasVisible && mUseOptimization) 135 144 { 136 mStats.mNumRenderedGeometry += mBvh->Render(node, mRenderState);145 RenderNode(node); 137 146 } 138 147 else … … 151 160 152 161 153 void RenderTraverser::SetVisibilityThreshold(int threshold)154 {155 mVisibilityThreshold = threshold;156 }157 158 159 int RenderTraverser::GetVisibilityThreshold() const160 {161 return mVisibilityThreshold;162 }163 164 165 void RenderTraverser::SetUseOptimization(bool useOptimization)166 {167 mUseOptimization = useOptimization;168 }169 170 171 172 162 void RenderTraverser::RenderScene() 173 163 { … … 182 172 ++ mFrameId; 183 173 184 mBvh->InitFrame( mCamera, mFrameId);174 mBvh->InitFrame(); 185 175 186 176 mStats.Reset(); … … 195 185 Traverse(); 196 186 197 // render the rest of the objects198 if (mUseRenderQueue)199 {200 if (mRenderState->SetState(RenderState::RENDER))201 ++ mStats.mNumStateChanges;202 203 mRenderQueue.Render();204 mRenderQueue.Clear();205 }206 207 187 mRenderState->Reset(); 208 188 … … 221 201 } 222 202 223 } 203 204 205 206 void RenderTraverser::SetVisibilityThreshold(int threshold) 207 { 208 mVisibilityThreshold = threshold; 209 } 210 211 212 void RenderTraverser::SetUseOptimization(bool useOptimization) 213 { 214 mUseOptimization = useOptimization; 215 } 216 217 218 }
Note: See TracChangeset
for help on using the changeset viewer.