- Timestamp:
- 03/17/05 22:40:51 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h
r19 r21 48 48 void traverseNode(SceneNode *node); 49 49 void renderSceneNode(SceneNode *node); 50 void switchMode(bool switch2QueryMode); 51 52 void renderStopAndWait(); 50 53 /** renders the scene with view frustum culling only */ 51 54 void renderCullFrustum(); 55 56 void issueOcclusionQuery(SceneNode *node, bool wasVisible); 52 57 53 58 /** we use a priority queue rather than a renderstack */ … … 55 60 // RenderQueue* mDistanceQueue; 56 61 57 int mFrameID; 62 int mFrameID; 63 int mVisibilityThreshold; 64 int mCurrentTestIdx; 65 bool mIsQueryMode; 66 67 std::vector<HardwareOcclusionQuery *> mOcclusionQueries; 58 68 }; 59 69 -
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.