Changeset 21 for trunk/VUT/OcclusionCullingSceneManager/src
- Timestamp:
- 03/17/05 22:40:51 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp
r19 r21 4 4 #include "OgreRenderSystem.h" 5 5 #include "OgreCamera.h" 6 #include "OgreHardwareOcclusionQuery.h" 7 6 8 #include <windows.h> 7 9 … … 10 12 //----------------------------------------------------------------------- 11 13 OcclusionCullingSceneManager::OcclusionCullingSceneManager(): 12 mFrameID(1), mDistanceQueue(NULL) 14 mFrameID(1), mDistanceQueue(NULL), mVisibilityThreshold(0), mCurrentTestIdx(0), 15 mIsQueryMode(false) 13 16 { 14 17 } … … 68 71 } 69 72 } 73 74 75 //----------------------------------------------------------------------- 76 void OcclusionCullingSceneManager::renderStopAndWait() 77 { 78 while(!mDistanceQueue->empty()) 79 { 80 SceneNode *node = mDistanceQueue->top(); 81 mDistanceQueue->pop(); 82 83 // interesting for the visualization, so rest and set 84 //node->SetVisible(false); 85 86 if(mCameraInProgress->isVisible(node->_getWorldAABB())) 87 { 88 issueOcclusionQuery(node, false); 89 90 unsigned int visiblePixels; 91 // wait if result not available 92 mOcclusionQueries[mCurrentTestIdx++]->pullOcclusionQuery(&visiblePixels); 93 94 // node visible 95 if(visiblePixels > mVisibilityThreshold) 96 { 97 traverseNode(node); 98 } 99 } 100 } 101 } 102 103 void OcclusionCullingSceneManager::issueOcclusionQuery(SceneNode *node, bool wasVisible) 104 { 105 // get next available test id 106 mOcclusionQueries[mCurrentTestIdx]->beginOcclusionQuery(); 107 108 // change state so the bounding box gets not actually rendered on the screen 109 switchMode(false); 110 node->_addBoundingBoxToQueue(getRenderQueue()); 111 SceneManager::_renderVisibleObjects(); 112 getRenderQueue()->clear(); 113 switchMode(true); 114 115 mOcclusionQueries[mCurrentTestIdx++]->endOcclusionQuery(); 116 } 117 118 119 //----------------------------------------------------------------------- 120 void OcclusionCullingSceneManager::switchMode(bool switch2QueryMode) 121 { 122 // boolean used to avoid unnecessary state changes 123 if(switch2QueryMode != mIsQueryMode) 124 { 125 mDestRenderSystem->_setColourBufferWriteEnabled(switch2QueryMode, 126 switch2QueryMode, switch2QueryMode, switch2QueryMode); 127 mDestRenderSystem->_setDepthBufferWriteEnabled(switch2QueryMode); 128 mDestRenderSystem->setLightingEnabled(switch2QueryMode); 129 mIsQueryMode = switch2QueryMode; 130 } 131 } 132 70 133 71 134 //-----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.