Changeset 23
- Timestamp:
- 03/21/05 17:30:35 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCulling.vcproj
r22 r23 22 22 Optimization="0" 23 23 AdditionalIncludeDirectories=""$(OGRE_PATH)\Dependencies\include";"$(OGRE_PATH)\OgreMain\include";"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\Dependencies\include\CEGUI";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include"" 24 PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_DEBUG;WIN32;_STLP_DEBUG ;OGRE_COHERENT_OCCLUSION_CULLING"24 PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_DEBUG;WIN32;_STLP_DEBUG" 25 25 MinimalRebuild="TRUE" 26 26 BasicRuntimeChecks="3" -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h
r22 r23 73 73 PriorityQueue *mDistanceQueue; 74 74 75 unsigned int mFrameI D;75 unsigned int mFrameId; 76 76 unsigned int mVisibilityThreshold; 77 77 unsigned int mNumSceneNodes; -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp
r22 r23 5 5 #include "OgreCamera.h" 6 6 #include "OgreHardwareOcclusionQuery.h" 7 #include "OgreWireBoundingBox.h" 7 8 8 9 #include <windows.h> … … 12 13 //----------------------------------------------------------------------- 13 14 OcclusionCullingSceneManager::OcclusionCullingSceneManager(): 14 mFrameI D(1), mDistanceQueue(NULL), mVisibilityThreshold(0), mCurrentTestIdx(0),15 mFrameId(1), mDistanceQueue(NULL), mVisibilityThreshold(0), mCurrentTestIdx(0), 15 16 mQueryMode(MODE_RENDER), mNumSceneNodes(0) 16 17 { … … 25 26 { 26 27 deleteQueries(); 27 SceneManager::~SceneManager();28 //SceneManager::~SceneManager(); 28 29 } 29 30 //----------------------------------------------------------------------- … … 33 34 34 35 mDistanceQueue->push(mSceneRoot); 36 37 mCurrentTestIdx = 0; 35 38 //renderZPass(); 36 39 //renderCullFrustum(); 37 renderCoherentWithQueue(); 40 //renderCoherentWithQueue(); 41 renderStopAndWait(); 38 42 delete mDistanceQueue; 39 43 … … 46 50 */ 47 51 48 mFrameI D++;52 mFrameId ++; 49 53 } 50 54 //----------------------------------------------------------------------- … … 88 92 { 89 93 // identify previously visible nodes 90 bool wasVisible = node->isNodeVisible() && (node->lastVisited() == mFrameI D- 1);94 bool wasVisible = node->isNodeVisible() && (node->lastVisited() == mFrameId - 1); 91 95 92 96 // identify nodes that we cannot skip queries for … … 97 101 98 102 // update node's visited flag 99 node->setLastVisited(mFrameI D);103 node->setLastVisited(mFrameId); 100 104 101 105 // skip testing previously visible interior nodes … … 144 148 // interesting for the visualization 145 149 //node->SetVisible(false); 146 node->setLastVisited( 15);150 node->setLastVisited(mFrameId); 147 151 148 152 if(mCameraInProgress->isVisible(node->_getWorldAABB())) … … 152 156 unsigned int visiblePixels; 153 157 // wait if result not available 154 mOcclusionQueries[mCurrentTestIdx++]->pullOcclusionQuery(&visiblePixels);158 node->getOcclusionQuery()->pullOcclusionQuery(&visiblePixels); 155 159 160 //char str[100]; sprintf(str, "number: %d, id: %d", (int)visiblePixels, mCurrentTestIdx); 161 //MessageBox( NULL, str, "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL); 162 156 163 // node visible 157 164 if(visiblePixels > mVisibilityThreshold) … … 165 172 void OcclusionCullingSceneManager::issueOcclusionQuery(SceneNode *node, bool wasVisible) 166 173 { 174 // change state so the bounding box gets not actually rendered on the screen 175 setRenderingMode(MODE_RENDER); 176 167 177 // get next available test id 168 mOcclusionQueries[mCurrentTestIdx]->beginOcclusionQuery(); 169 170 // change state so the bounding box gets not actually rendered on the screen 171 setRenderingMode(MODE_QUERY); 178 HardwareOcclusionQuery *query = mOcclusionQueries[mCurrentTestIdx++]; 179 node->setOcclusionQuery(query); 180 181 query->beginOcclusionQuery(); 182 183 WireBoundingBox box; 184 box.setupBoundingBox(node->_getWorldAABB()); 185 172 186 //HACK: too slow 173 node->_addBoundingBoxToQueue(getRenderQueue()); 174 SceneManager::_renderVisibleObjects(); 175 getRenderQueue()->clear(); 176 /* static RenderOperation ro; 177 node->getRenderOperation(ro); 178 ro.srcRenderable = node; 179 mDestRenderSystem->_render(ro); */ 180 181 mOcclusionQueries[mCurrentTestIdx++]->endOcclusionQuery(); 187 188 /* 189 static RenderOperation ro; 190 191 192 static Matrix4 xform[256]; 193 unsigned short numMatrices; 194 195 //node->_addBoundingBoxToQueue(getRenderQueue()); 196 //SceneManager::_renderVisibleObjects(); 197 //getRenderQueue()->clear(); 198 199 // Set world transformation 200 /*box.getWorldTransforms(xform); 201 numMatrices = box.getNumWorldTransforms(); 202 if (numMatrices > 1) 203 { 204 mDestRenderSystem->_setWorldMatrices(xform, numMatrices); 205 } 206 else 207 { 208 mDestRenderSystem->_setWorldMatrix(*xform); 209 } 210 */ 211 // Issue view / projection changes if any 212 /*useRenderableViewProjMode(&box); 213 214 box.getRenderOperation(ro); 215 ro.srcRenderable = &box; 216 mDestRenderSystem->_render(ro);*/ 217 setPass(box.getTechnique()->getPass(0)); setRenderingMode(MODE_QUERY); 218 SceneManager::renderSingleObject(&box, box.getTechnique()->getPass(0), false); 219 220 query->endOcclusionQuery(); 182 221 } 183 222 … … 189 228 { 190 229 bool enabled = (mode == MODE_RENDER); 191 230 231 // char str[100]; sprintf(str, "number: %d", mode); 232 // MessageBox( NULL, str, "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL); 192 233 mDestRenderSystem->_setColourBufferWriteEnabled(enabled, 193 234 enabled, enabled, enabled); … … 231 272 { 232 273 int numnodes = countSceneNodes(mSceneRoot); 233 //char str[100]; sprintf(str, "number: %d", mNumSceneNodes);234 //MessageBox( NULL, str, "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL);235 274 236 275 //-- initialise occlusion queries. 237 276 if(numnodes != mNumSceneNodes) 238 277 { 278 deleteQueries(); 239 279 mNumSceneNodes = numnodes; 240 280 241 deleteQueries(); 242 243 for(int i=0; i < mNumSceneNodes; i++) 281 for(unsigned int i=0; i < mNumSceneNodes; i++) 244 282 { 245 283 HardwareOcclusionQuery *hw = mDestRenderSystem->createHardwareOcclusionQuery(); 246 284 mOcclusionQueries.push_back(hw); 247 285 } 286 //char str[100]; sprintf(str, "number: %d", mNumSceneNodes); 287 //MessageBox( NULL, str, "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL); 248 288 } 249 289 … … 286 326 void OcclusionCullingSceneManager::deleteQueries() 287 327 { 288 for( int i=0; i < mNumSceneNodes; i++)328 for(unsigned int i=0; i < mNumSceneNodes; i++) 289 329 delete mOcclusionQueries[i]; 290 330
Note: See TracChangeset
for help on using the changeset viewer.