Changeset 87
- Timestamp:
- 05/09/05 01:24:02 (20 years ago)
- Location:
- trunk/VUT
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/include/CullingManager.h
r74 r87 38 38 */ 39 39 unsigned int GetNumQueryCulledNodes(); 40 /** Returns number of issued occlusion queries. 41 */ 42 unsigned int GetNumQueriesIssued(); 43 /** basic initializations on beginning of each frame, e.g., 44 resets statistics. 45 */ 46 void InitFrame(); 40 47 41 48 protected: 42 49 43 50 unsigned int mNumQueryCulledNodes; 44 51 unsigned int mNumFrustumCulledNodes; 45 52 unsigned int mVisibilityThreshold; 53 unsigned int mNumQueriesIssued; 46 54 47 55 HierarchyInterface *mHierarchyInterface; -
trunk/VUT/GtpVisibility/include/DistanceQueue.h
r59 r87 25 25 bool operator() (T v1, T v2) const 26 26 { 27 return mHierarchyInterface-> HasGreaterDistance(v1,v2);27 return mHierarchyInterface->GetSquaredDistance(v1) > mHierarchyInterface->GetSquaredDistance(v2); 28 28 } 29 29 -
trunk/VUT/GtpVisibility/include/HierarchyInterface.h
r86 r87 59 59 */ 60 60 DistanceQueue *GetQueue(); 61 /** Returns true if node 1 has greater distance to the view 62 plane than node 2. 63 @param node1 the first node to be compared 64 @param node2 the second node to be compared 61 /** Returns distance of the node to the view plane. 62 @param node1 the hierarchy node 65 63 */ 66 virtual bool HasGreaterDistance(HierarchyNode *node1, HierarchyNode *node2) const = 0;64 virtual float GetSquaredDistance(HierarchyNode *node) const = 0; 67 65 /** Checks if the node is visible from the current view frustum. 68 66 @param node the current node -
trunk/VUT/GtpVisibility/include/OcclusionQuery.h
r86 r87 20 20 @remark the query counts the number of visible pixels between it's begin and end 21 21 */ 22 virtual void BeginQuery() const= 0;22 virtual void BeginQuery() = 0; 23 23 /** Ends occlusion query. 24 24 */ 25 virtual void EndQuery() const= 0;25 virtual void EndQuery() = 0; 26 26 }; 27 27 -
trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
r86 r87 7 7 void CoherentHierarchicalCullingManager::RenderScene() 8 8 { 9 mNumFrustumCulledNodes = mNumQueryCulledNodes = 0; 10 // OutputDebugString("Coherent Culling\n"); 9 InitFrame(); 11 10 12 11 QueryQueue queryQueue; 13 12 unsigned int visiblePixels = 0; 14 13 bool isAvailable = false; 15 14 16 15 //-- PART 1: process finished occlusion queries 17 16 while (!mHierarchyInterface->GetQueue()->empty() || !queryQueue.empty()) … … 21 20 mHierarchyInterface->GetQueue()->empty())) 22 21 { 22 //if (mHierarchyInterface->GetQueue()->empty())OutputDebugString("empty\n"); 23 23 24 HierarchyNode *node = queryQueue.front().first; 24 25 … … 35 36 } 36 37 } 37 38 38 39 //-- PART 2: hierarchical traversal 39 40 if (!mHierarchyInterface->GetQueue()->empty()) … … 67 68 68 69 // identify nodes that we cannot skip queries for 69 bool mustQuery = !wasVisible || mHierarchyInterface->HasGeometry(node) || 70 mHierarchyInterface->IsLeaf(node); 70 // geometry not only in leaves => test for renderable geometry 71 bool issueQuery = !wasVisible || mHierarchyInterface->HasGeometry(node); 72 //mHierarchyInterface->IsLeaf(node); 71 73 72 74 // reset node's visibility classification … … 76 78 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 77 79 78 // skip testing previously visible interior nodes79 if ( mustQuery)80 // skip testing previously visible nodes without geometry 81 if (issueQuery) 80 82 { 81 queryQueue.push(QueryPair(node, 82 mHierarchyInterface->IssueOcclusionQuery(node, wasVisible))); 83 mNumQueriesIssued ++; 84 85 queryQueue.push(QueryPair(node, mHierarchyInterface-> 86 IssueOcclusionQuery(node, wasVisible))); 83 87 } 84 88 -
trunk/VUT/GtpVisibility/src/CullingManager.cpp
r74 r87 6 6 CullingManager::CullingManager(): 7 7 mHierarchyInterface(NULL), mVisibilityThreshold(0), mNumQueryCulledNodes(0), 8 mNumFrustumCulledNodes(0) 8 mNumFrustumCulledNodes(0), mNumQueriesIssued(0) 9 9 { 10 10 } … … 29 29 return mNumQueryCulledNodes; 30 30 } 31 //----------------------------------------------------------------------- 32 unsigned int CullingManager::GetNumQueriesIssued() 33 { 34 return mNumQueriesIssued; 35 } 36 //----------------------------------------------------------------------- 37 void CullingManager::InitFrame() 38 { 39 mNumFrustumCulledNodes = mNumQueryCulledNodes = mNumQueriesIssued = 0; 40 } 31 41 } // namespace GtpVisibility -
trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp
r86 r87 7 7 void FrustumCullingManager::RenderScene() 8 8 { 9 mNumFrustumCulledNodes = mNumQueryCulledNodes = 0; 10 //OutputDebugString("Frustum Culling\n"); 9 InitFrame(); 11 10 12 11 while (!mHierarchyInterface->GetQueue()->empty()) -
trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
r86 r87 7 7 void StopAndWaitCullingManager::RenderScene() 8 8 { 9 mNumFrustumCulledNodes = mNumQueryCulledNodes = 0; 10 //OutputDebugString("Stop and Wait Culling\n"); 11 9 InitFrame(); 10 12 11 while (!mHierarchyInterface->GetQueue()->empty()) 13 12 { 14 13 HierarchyNode *node = mHierarchyInterface->GetQueue()->top(); 15 14 mHierarchyInterface->GetQueue()->pop(); 16 15 17 16 // interesting for visualization purpose 18 17 mHierarchyInterface->SetNodeVisible(node, false); … … 35 34 } 36 35 36 mNumQueriesIssued ++; 37 37 38 unsigned int visiblePixels = 0; 38 39 -
trunk/VUT/Ogre/include/OgreBspHierarchyInterface.h
r74 r87 28 28 bool IsLeaf(GtpVisibility::HierarchyNode *node) const; 29 29 bool HasGeometry(GtpVisibility::HierarchyNode *node) const; 30 bool HasGreaterDistance(GtpVisibility::HierarchyNode *node1, 31 GtpVisibility::HierarchyNode *node2) const; 30 float GetSquaredDistance(GtpVisibility::HierarchyNode *node) const; 32 31 33 32 void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible); … … 44 43 */ 45 44 AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node); 46 /** Returns squared distance of center of box with respect to the camera . 47 @param cam current camera 48 @param box axis aligned box 49 */ 50 Real GetSquaredViewDepth(const Camera* cam, const AxisAlignedBox* box) const; 45 51 46 unsigned int mNumOctreeNodes; 52 47 }; -
trunk/VUT/Ogre/include/OgreOctreeHierarchyInterface.h
r74 r87 35 35 bool IsLeaf(GtpVisibility::HierarchyNode *node) const; 36 36 bool HasGeometry(GtpVisibility::HierarchyNode *node) const; 37 bool HasGreaterDistance(GtpVisibility::HierarchyNode *node1, 38 GtpVisibility::HierarchyNode *node2) const; 37 float GetSquaredDistance(GtpVisibility::HierarchyNode *node) const; 39 38 40 39 void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible); -
trunk/VUT/Ogre/include/OgrePlatformOcclusionQuery.h
r86 r87 22 22 virtual bool GetQueryResult(unsigned int &queryResult, 23 23 const bool waitForResult) const; 24 virtual void BeginQuery() const;25 virtual void EndQuery() const;24 virtual void BeginQuery(); 25 virtual void EndQuery(); 26 26 27 27 protected: -
trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h
r85 r87 25 25 void PullUpVisibility(GtpVisibility::HierarchyNode *node); 26 26 bool HasGeometry(GtpVisibility::HierarchyNode *node) const; 27 bool HasGreaterDistance(GtpVisibility::HierarchyNode *node1, 28 GtpVisibility::HierarchyNode *node2) const; 27 float GetSquaredDistance(GtpVisibility::HierarchyNode *node) const; 29 28 30 29 void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible); -
trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h
r78 r87 54 54 OctreeHierarchyInterface *mHierarchyInterface; 55 55 GtpVisibility::VisibilityManager *mVisibilityManager; 56 bool mUseCulling; 56 57 }; 57 58 -
trunk/VUT/Ogre/include/OgreVisibilitySceneManager.h
r59 r87 56 56 SceneNodeHierarchyInterface *mHierarchyInterface; 57 57 GtpVisibility::VisibilityManager *mVisibilityManager; 58 bool mUseCulling; 58 59 }; 59 60 } // namespace Ogre -
trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
r59 r87 57 57 OctreeHierarchyInterface *mHierarchyInterface; 58 58 GtpVisibility::VisibilityManager *mVisibilityManager; 59 bool mUseCulling; 59 60 }; 60 61 -
trunk/VUT/Ogre/resources/VisibilityDemo.overlay
r86 r87 9 9 left 5 10 10 top 5 11 width 4 5011 width 400 12 12 height 60 13 13 material Core/StatsBlockCenter … … 33 33 font_name TrebuchetMSBold 34 34 char_height 16 35 caption [ A] Algorithm35 caption [SPACE] Algorithm 36 36 colour_top 0.5 0.7 0.5 37 37 colour_bottom 0.3 0.5 0.3 … … 110 110 vert_align top 111 111 horz_align right 112 left - 355112 left -250 113 113 top 5 114 width 450115 height 1 05114 width 320 115 height 120 116 116 material Core/StatsBlockCenter 117 117 border_size 1 1 1 1 … … 256 256 colour_bottom 0.3 0.5 0.3 257 257 } 258 element TextArea(Example/Visibility/ NumObjects)258 element TextArea(Example/Visibility/Objects) 259 259 { 260 260 metrics_mode pixels … … 269 269 colour_bottom 0.3 0.5 0.3 270 270 } 271 element TextArea(Example/Visibility/ NumObjectsInfo)271 element TextArea(Example/Visibility/ObjectsInfo) 272 272 { 273 273 metrics_mode pixels … … 282 282 colour_bottom 0.3 0.5 0.3 283 283 } 284 285 284 element TextArea(Example/Visibility/QueriesIssued) 285 { 286 metrics_mode pixels 287 left 5 288 top 95 289 width 180 290 height 30 291 font_name TrebuchetMSBold 292 char_height 16 293 caption Queries issued 294 colour_top 0.5 0.7 0.5 295 colour_bottom 0.3 0.5 0.3 296 } 297 element TextArea(Example/Visibility/QueriesIssuedInfo) 298 { 299 metrics_mode pixels 300 left 180 301 top 95 302 width 90 303 height 30 304 font_name TrebuchetMSBold 305 char_height 16 306 caption : 307 colour_top 0.5 0.7 0.5 308 colour_bottom 0.3 0.5 0.3 309 } 286 310 } 287 311 } -
trunk/VUT/Ogre/src/OgreBspHierarchyInterface.cpp
r74 r87 26 26 } 27 27 //----------------------------------------------------------------------- 28 bool BspHierarchyInterface::HasGreaterDistance(GtpVisibility::HierarchyNode *node1, 29 GtpVisibility::HierarchyNode *node2) const 28 float BspHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 30 29 { 31 return true;32 }33 //-----------------------------------------------------------------------34 Real BspHierarchyInterface::GetSquaredViewDepth(const Camera* cam, const AxisAlignedBox* box) const35 {36 30 return 0.0f; 37 31 } -
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r86 r87 16 16 mNumTraversedNodes ++; 17 17 18 Octree *octree = static_cast<Octree *>(node); 19 18 20 // if we come across some renderable geometry => render it 19 RenderNode(node); 21 if (octree->mNodes.size() > 0) 22 { 23 RenderNode(node); 24 } 20 25 21 for(int i=0; i<8; ++i) 26 // if not all subtrees are empty 27 if (octree->numNodes() > (int)octree->mNodes.size()) 22 28 { 23 Octree *nextChild = 24 static_cast<Octree *>(node)->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]; 29 for(int i=0; i<8; ++i) 30 { 31 Octree *nextChild = 32 octree->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]; 25 33 26 if (nextChild) 27 { 28 mDistanceQueue->push(nextChild); 34 if (nextChild) 35 { 36 mDistanceQueue->push(nextChild); 37 } 29 38 } 30 39 } … … 46 55 bool OctreeHierarchyInterface::HasGeometry(GtpVisibility::HierarchyNode *node) const 47 56 { 48 return static_cast<Octree *>(node)-> numNodes() > 0;57 return static_cast<Octree *>(node)->mNodes.size() > 0; 49 58 } 50 59 //----------------------------------------------------------------------- … … 54 63 } 55 64 //----------------------------------------------------------------------- 56 bool OctreeHierarchyInterface::HasGreaterDistance(GtpVisibility::HierarchyNode *node1, 57 GtpVisibility::HierarchyNode *node2) const 65 float OctreeHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 58 66 { 59 return GetSquaredViewDepth(mCamera, &static_cast<Octree *>(node1)->mBox) > 60 GetSquaredViewDepth(mCamera, &static_cast<Octree *>(node2)->mBox); 61 } 62 //----------------------------------------------------------------------- 63 Real OctreeHierarchyInterface::GetSquaredViewDepth(const Camera* cam, 64 const AxisAlignedBox* box) const 65 { 67 AxisAlignedBox *box = &static_cast<Octree *>(node)->mBox; 66 68 Vector3 mid = ((box->getMinimum() - box->getMaximum()) * 0.5) + box->getMinimum(); 67 // use nearest point rather than midpoint68 Vector3 camPos = cam->getDerivedPosition();69 69 70 Vector3 minPos(camPos.x < mid.x ? box->getMinimum().x : box->getMaximum().x, 71 camPos.y < mid.y ? box->getMinimum().y : box->getMaximum().y, 72 camPos.z < mid.z ? box->getMinimum().z : box->getMaximum().z); 73 74 return (camPos - minPos).squaredLength(); 70 return (mCamera->getDerivedPosition() - mid).squaredLength(); 75 71 } 76 72 //----------------------------------------------------------------------- … … 113 109 octant->setLastRendered(mFrameId); 114 110 115 if (!HasGeometry(octant)) return;116 117 111 static_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera, octant); 118 112 -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r86 r87 26 26 void PlatformHierarchyInterface::DeleteQueries() 27 27 { 28 for( unsigned int i=0; i < (unsignedint)mOcclusionQueries.size(); ++i)28 for(int i=0; i < (int)mOcclusionQueries.size(); ++i) 29 29 delete mOcclusionQueries[i]; 30 30 … … 105 105 query->BeginQuery(); 106 106 107 // if leaf and was visible => will be rendered anyway, thus we 108 // can also test with the real geometry 109 if(mUseOptimization && wasVisible && IsLeaf(node)) 107 // if node is leaf and was visible => 108 // will be rendered anyway. 109 // In this case we can also test with the real geometry. 110 /*if(mUseOptimization && wasVisible && IsLeaf(node)) 110 111 { 111 // OutputDebugString("Using optimization!!\n");112 112 RenderNode(node); 113 113 } 114 114 else 115 { 116 // OutputDebugString("Not optimized!!\n"); 115 {*/ 117 116 RenderBoundingBox(GetBoundingBox(node)); 118 }117 //} 119 118 120 119 query->EndQuery(); -
trunk/VUT/Ogre/src/OgrePlatformOcclusionQuery.cpp
r86 r87 14 14 } 15 15 //----------------------------------------------------------------------- 16 void PlatformOcclusionQuery::BeginQuery() const16 void PlatformOcclusionQuery::BeginQuery() 17 17 { 18 18 mHardwareOcclusionQuery->beginOcclusionQuery(); 19 19 } 20 20 //----------------------------------------------------------------------- 21 void PlatformOcclusionQuery::EndQuery() const21 void PlatformOcclusionQuery::EndQuery() 22 22 { 23 23 mHardwareOcclusionQuery->endOcclusionQuery(); -
trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
r85 r87 56 56 bool SceneNodeHierarchyInterface::HasGeometry(GtpVisibility::HierarchyNode *node) const 57 57 { 58 SceneNode *sceneNode = static_cast<SceneNode *>(node); 59 60 return sceneNode->numAttachedObjects() > 0; 58 return static_cast<SceneNode *>(node)->numAttachedObjects() > 0; 61 59 } 62 60 //----------------------------------------------------------------------- … … 74 72 } 75 73 //----------------------------------------------------------------------- 76 bool SceneNodeHierarchyInterface::HasGreaterDistance(GtpVisibility::HierarchyNode *node1, 77 GtpVisibility::HierarchyNode *node2) const 74 float SceneNodeHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 78 75 { 79 SceneNode *sceneNode1 = static_cast<SceneNode *>(node1); 80 SceneNode *sceneNode2 = static_cast<SceneNode *>(node2); 81 82 return sceneNode1->getSquaredViewDepth(mCamera) > sceneNode2->getSquaredViewDepth(mCamera); 76 return static_cast<SceneNode *>(node)->getSquaredViewDepth(mCamera); 83 77 } 84 78 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r86 r87 12 12 //----------------------------------------------------------------------- 13 13 VisibilityOctreeSceneManager::VisibilityOctreeSceneManager( 14 GtpVisibility::VisibilityManager *visManager): mVisibilityManager(visManager) 14 GtpVisibility::VisibilityManager *visManager) 15 : mVisibilityManager(visManager), mUseCulling(true) 15 16 { 16 17 mHierarchyInterface = 17 18 new OctreeHierarchyInterface(this, mDestRenderSystem); 18 19 // visManager->SetCullingManager(GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING); 19 20 //mDisplayNodes = true; 20 21 //mShowBoundingBoxes = true; 21 22 //mShowBoxes = true; 23 22 24 mMaxDepth = 20; 23 25 } … … 30 32 void VisibilityOctreeSceneManager::_renderVisibleObjects() 31 33 { 34 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress); 35 mVisibilityManager->GetCullingManager()->InitFrame(); 36 37 if(!mUseCulling) 38 { 39 OctreeSceneManager::_renderVisibleObjects(); 40 return; 41 } 42 43 //-- hierarchical culling 44 // the objects of different layers (e.g., background, scene, 45 // overlay) must be identified and rendered one after another 46 32 47 //-- render background 33 48 clearSpecialCaseRenderQueues(); … … 36 51 37 52 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 38 SceneManager::_renderVisibleObjects( ); 53 SceneManager::_renderVisibleObjects(); 54 39 55 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 40 56 _deleteRenderedQueueGroups(); … … 46 62 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 47 63 48 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress);64 //-- the hierarchical culling algorithm 49 65 mVisibilityManager->ApplyVisibilityCulling(); 50 66 … … 53 69 #endif 54 70 55 //-- render re st, e.g., overlay71 //-- render remaining objects, e.g., overlay 56 72 clearSpecialCaseRenderQueues(); 57 73 SceneManager::_renderVisibleObjects(); 58 //_deleteRenderedQueueGroups();59 74 } 60 75 //----------------------------------------------------------------------- 61 76 void VisibilityOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 62 77 { 63 // must be empty because objects are found and rendered in an interleaved fashion 78 // empty if hierarchical culling is used => 79 // we interleave identification and rendering of objects 64 80 // in _renderVisibibleObjects 81 if(!mUseCulling) 82 { 83 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 84 } 65 85 } 66 86 //----------------------------------------------------------------------- … … 78 98 bool VisibilityOctreeSceneManager::setOption(const String & key, const void * val) 79 99 { 100 if (key == "UseCulling") 101 { 102 mUseCulling = (*static_cast<const bool *>(val)); 103 return true; 104 } 105 80 106 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 81 107 setOption(key, val) || OctreeSceneManager::setOption(key, val); -
trunk/VUT/Ogre/src/OgreVisibilityOptionsManager.cpp
r86 r87 57 57 return true; 58 58 } 59 if (key == "NumQueriesIssued") 60 { 61 * static_cast<unsigned int *>(val) = 62 mVisibilityManager->GetCullingManager()->GetNumQueriesIssued(); 63 return true; 64 } 59 65 60 66 return false; -
trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp
r74 r87 13 13 //----------------------------------------------------------------------- 14 14 VisibilitySceneManager::VisibilitySceneManager(GtpVisibility::VisibilityManager *visManager) 15 :mVisibilityManager(visManager) 15 :mVisibilityManager(visManager), mUseCulling(true) 16 16 { 17 17 mHierarchyInterface = new SceneNodeHierarchyInterface(this, mDestRenderSystem); … … 25 25 void VisibilitySceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 26 26 { 27 // empty because we have to find objects in _renderVisibleObjects 27 // empty if hierarchical culling is used => 28 // we interleave identification and rendering of objects 29 // in _renderVisibibleObjects 30 if(!mUseCulling) 31 { 32 SceneManager::_findVisibleObjects(cam, onlyShadowCasters); 33 } 28 34 } 29 35 //----------------------------------------------------------------------- 30 36 void VisibilitySceneManager::_renderVisibleObjects() 31 37 { 32 //-- render background 38 mHierarchyInterface->InitFrame(mSceneRoot, mCameraInProgress); 39 mVisibilityManager->GetCullingManager()->InitFrame(); 40 41 if(!mUseCulling) 42 { 43 SceneManager::_renderVisibleObjects(); 44 return; 45 } 46 47 //-- hierarchical culling 48 // the objects of different layers (e.g., background, scene, 49 // overlay) must be identified and rendered one after another 50 51 //-- render background 33 52 clearSpecialCaseRenderQueues(); 34 53 addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); … … 36 55 37 56 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 38 SceneManager::_renderVisibleObjects( 57 SceneManager::_renderVisibleObjects(); 39 58 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 40 59 _deleteRenderedQueueGroups(); 41 60 #endif 61 42 62 //-- render visible objects (i.e., all but overlay) 43 63 clearSpecialCaseRenderQueues(); … … 45 65 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 46 66 47 mHierarchyInterface->InitFrame(mSceneRoot, mCameraInProgress);67 //-- the hierarchical culling algorithm 48 68 mVisibilityManager->ApplyVisibilityCulling(); 49 69 … … 54 74 //-- render overlay 55 75 clearSpecialCaseRenderQueues(); 56 SceneManager::_renderVisibleObjects( ); 57 58 clearSpecialCaseRenderQueues(); 76 SceneManager::_renderVisibleObjects(); 59 77 } 60 78 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r86 r87 7 7 #include <OgreCamera.h> 8 8 9 //#include <windows.h>9 #include <windows.h> 10 10 11 11 namespace Ogre { 12 //namespace GtpVisibility { 12 13 13 //----------------------------------------------------------------------- 14 14 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 15 GtpVisibility::VisibilityManager *visManager): mVisibilityManager(visManager) 15 GtpVisibility::VisibilityManager *visManager) 16 : mVisibilityManager(visManager), mUseCulling(true) 16 17 { 17 18 mHierarchyInterface = 18 19 new OctreeHierarchyInterface(this, mDestRenderSystem); 19 20 20 //mShowBoxes = true;21 21 //mDisplayNodes = true; 22 22 //mShowBoundingBoxes = true; … … 31 31 void VisibilityTerrainSceneManager::_renderVisibleObjects() 32 32 { 33 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress); 34 mVisibilityManager->GetCullingManager()->InitFrame(); 35 36 if(!mUseCulling) 37 { 38 OctreeSceneManager::_renderVisibleObjects(); 39 return; 40 } 41 42 //-- hierarchical culling 43 // the objects of different layers (e.g., background, scene, 44 // overlay) must be identified and rendered one after another 45 33 46 //-- render background 34 47 clearSpecialCaseRenderQueues(); … … 47 60 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 48 61 49 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress);62 //-- the hierarchical culling algorithm 50 63 mVisibilityManager->ApplyVisibilityCulling(); 51 64 … … 56 69 //-- render overlay 57 70 clearSpecialCaseRenderQueues(); 58 SceneManager::_renderVisibleObjects( 71 SceneManager::_renderVisibleObjects(); 59 72 } 60 73 //----------------------------------------------------------------------- 61 74 void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 62 75 { 63 // must be empty because objects are found and rendered in an interleaved fashion 76 // empty if hierarchical culling is used => 77 // we interleave identification and rendering of objects 64 78 // in _renderVisibibleObjects 79 if(!mUseCulling) 80 { 81 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 82 } 65 83 } 66 84 //----------------------------------------------------------------------- … … 79 97 bool VisibilityTerrainSceneManager::setOption(const String & key, const void * val) 80 98 { 99 if (key == "UseCulling") 100 { 101 mUseCulling = (*static_cast<const bool *>(val)); 102 return true; 103 } 104 81 105 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 82 106 setOption(key, val) || TerrainSceneManager::setOption(key, val); … … 115 139 return mVisibilityManager; 116 140 } 117 //} // namespace GtpVisibility118 141 } // namespace Ogre -
trunk/VUT/chcdemo/HierarchyNode.h
r86 r87 109 109 static void InitKdTree(HierarchyNode *root); 110 110 111 float Get Distance();111 float GetSquaredDistance(); 112 112 void SetDistance(float distance); 113 113 -
trunk/VUT/work/TestCulling/SceneContentGenerator.cpp
r86 r87 21 21 mMinAngle(Vector3(0.0f, 0.0f, 0.0f)), 22 22 mMaxAngle(Vector3(360, 360, 360)), 23 mScale(0. 05, 0.05, 0.05)23 mScale(0.1, 0.1, 0.1) 24 24 { 25 25 } -
trunk/VUT/work/TestCulling/TestCullingApplication.cpp
r86 r87 110 110 mSceneContentGenerator(sceneContentGenerator), 111 111 mVisibilityThreshold(0), 112 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 112 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 113 mShowOctree(true), 114 mUseCulling(false) 113 115 { 114 116 // Reduce move speed … … 132 134 mHierarchyNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/HierarchyNodesInfo"); 133 135 mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/RenderedNodesInfo"); 134 m NumObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/NumObjectsInfo");136 mObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ObjectsInfo"); 135 137 mUseOptimizationInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseOptimizationInfo"); 138 mQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueriesIssuedInfo"); 136 139 137 140 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); … … 142 145 mHierarchyNodesInfo->setCaption(": 0"); 143 146 mRenderedNodesInfo->setCaption(": 0"); 144 m NumObjectsInfo->setCaption(": 0");147 mObjectsInfo->setCaption(": 0"); 145 148 mUseOptimizationInfo->setCaption(": true"); 149 mQueriesIssuedInfo->setCaption(": 0"); 146 150 147 151 setAlgorithm(mCurrentAlgorithm); … … 226 230 KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 227 231 KEY_PRESSED(KC_O, 0.3, toggleUseOptimization()); 228 //KEY_PRESSED(KC_T, 1, change);229 230 changeStats();232 KEY_PRESSED(KC_C, 0.3, toggleUseCulling()); 233 234 updateStats(); 231 235 232 236 return ExampleFrameListener::frameStarted(evt) && ExampleFrameListener::frameEnded(evt); … … 271 275 } 272 276 //----------------------------------------------------------------------- 277 void MouseQueryListener::toggleUseCulling() 278 { 279 mUseCulling = !mUseCulling; 280 281 mSceneMgr->setOption("UseCulling", &mUseCulling); 282 } 283 //----------------------------------------------------------------------- 273 284 void MouseQueryListener::setAlgorithm(int algorithm) 274 285 { … … 277 288 } 278 289 //----------------------------------------------------------------------- 279 void MouseQueryListener:: changeStats()290 void MouseQueryListener::updateStats() 280 291 { 281 292 unsigned int opt = 0; … … 285 296 mFrustumCulledNodesInfo->setCaption(str); 286 297 298 mSceneMgr->getOption("NumQueriesIssued", &opt); sprintf(str,": %d", opt); 299 mQueriesIssuedInfo->setCaption(str); 300 287 301 mSceneMgr->getOption("NumQueryCulledNodes", &opt); sprintf(str,": %d", opt); 288 302 mQueryCulledNodesInfo->setCaption(str); … … 298 312 299 313 sprintf(str,": %d", mSceneContentGenerator->GetObjectCount()); 300 m NumObjectsInfo->setCaption(str);314 mObjectsInfo->setCaption(str); 301 315 } 302 316 //----------------------------------------------------------------------- -
trunk/VUT/work/TestCulling/TestCullingApplication.h
r86 r87 63 63 void setAlgorithm(int algorithm); 64 64 void changeThreshold(int incr); 65 void changeStats();65 void updateStats(); 66 66 void toggleUseOptimization(); 67 67 void toggleShowOctree(); 68 void toggleUseCulling(); 68 69 69 70 protected: … … 84 85 OverlayElement *mHierarchyNodesInfo; 85 86 OverlayElement *mRenderedNodesInfo; 86 OverlayElement *m NumObjectsInfo;87 OverlayElement *mObjectsInfo; 87 88 OverlayElement *mUseOptimizationInfo; 89 OverlayElement *mQueriesIssuedInfo; 88 90 89 91 SceneContentGenerator *mSceneContentGenerator; … … 91 93 bool mUseOptimization; 92 94 bool mShowOctree; 95 bool mUseCulling; 93 96 }; 94 97 -
trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.cpp
r85 r87 50 50 //----------------------------------------------------------------------- 51 51 TerrainContentGenerator::TerrainContentGenerator(SceneManager *sm): 52 SceneContentGenerator(sm), mMaxHeight( 100)52 SceneContentGenerator(sm), mMaxHeight(50) 53 53 { 54 54 mMinPos = Vector3(0.0f, 5000.0f, 0.0f); -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r86 r87 96 96 97 97 mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr); 98 99 mTerrainContentGenerator->GenerateScene(500, "ninja.mesh"); 100 mTerrainContentGenerator->GenerateScene(500, "robot.mesh"); 98 // mTerrainContentGenerator->GenerateScene(500, "ninja.mesh"); 99 mTerrainContentGenerator->GenerateScene(1000, "robot.mesh"); 101 100 102 101 // no limitations needed anymore: the user can set … … 150 149 mTerrainContentGenerator(sceneGenerator), 151 150 mVisibilityThreshold(0), 152 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 151 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 152 mShowOctree(true), 153 mUseCulling(false) 153 154 { 154 155 // Reduce move speed … … 174 175 mHierarchyNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/HierarchyNodesInfo"); 175 176 mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/RenderedNodesInfo"); 176 m NumObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/NumObjectsInfo");177 mObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ObjectsInfo"); 177 178 mUseOptimizationInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseOptimizationInfo"); 178 179 mQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueriesIssuedInfo"); 180 179 181 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 180 182 mThresholdInfo->setCaption(": 0"); … … 184 186 mHierarchyNodesInfo->setCaption(": 0"); 185 187 mRenderedNodesInfo->setCaption(": 0"); 186 m NumObjectsInfo->setCaption(": 0");188 mObjectsInfo->setCaption(": 0"); 187 189 mUseOptimizationInfo->setCaption(": true"); 190 mQueriesIssuedInfo->setCaption(": 0"); 188 191 189 192 setAlgorithm(mCurrentAlgorithm); 190 193 toggleUseOptimization(); 191 194 toggleShowOctree(); 195 toggleUseCulling(); 192 196 193 197 pOver->show(); … … 301 305 KEY_PRESSED(KC_O, 0.3, toggleUseOptimization()); 302 306 KEY_PRESSED(KC_S, 0.3, toggleShowOctree()); 303 //KEY_PRESSED(KC_T, 1, change);304 305 changeStats();307 KEY_PRESSED(KC_C, 0.3, toggleUseCulling()); 308 309 updateStats(); 306 310 307 311 return ExampleFrameListener::frameStarted(evt) && ExampleFrameListener::frameEnded(evt); … … 329 333 void MouseQueryListener::setAlgorithm(int algorithm) 330 334 { 331 //OutputDebugString("changing algorithm\n");332 335 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 333 336 mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm); 334 337 } 335 338 //----------------------------------------------------------------------- 336 void MouseQueryListener:: changeStats()339 void MouseQueryListener::updateStats() 337 340 { 338 341 unsigned int opt = 0; … … 342 345 mFrustumCulledNodesInfo->setCaption(str); 343 346 347 mSceneMgr->getOption("NumQueriesIssued", &opt); sprintf(str,": %d", opt); 348 mQueriesIssuedInfo->setCaption(str); 349 344 350 mSceneMgr->getOption("NumQueryCulledNodes", &opt); sprintf(str,": %d", opt); 345 351 mQueryCulledNodesInfo->setCaption(str); … … 355 361 356 362 sprintf(str,": %d", mTerrainContentGenerator->GetObjectCount()); 357 m NumObjectsInfo->setCaption(str);363 mObjectsInfo->setCaption(str); 358 364 } 359 365 //----------------------------------------------------------------------- … … 375 381 376 382 mSceneMgr->setOption("ShowOctree", &mShowOctree); 383 } 384 //----------------------------------------------------------------------- 385 void MouseQueryListener::toggleUseCulling() 386 { 387 mUseCulling = !mUseCulling; 388 389 mSceneMgr->setOption("UseCulling", &mUseCulling); 377 390 } 378 391 //----------------------------------------------------------------------- -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r86 r87 62 62 void setAlgorithm(int algorithm); 63 63 void changeThreshold(int incr); 64 void changeStats();64 void updateStats(); 65 65 void toggleUseOptimization(); 66 66 void toggleShowOctree(); 67 void toggleUseCulling(); 67 68 68 69 protected: … … 84 85 OverlayElement *mUseOptimizationInfo; 85 86 OverlayElement *mRenderedNodesInfo; 86 OverlayElement *mNumObjectsInfo; 87 OverlayElement *mObjectsInfo; 88 OverlayElement *mQueriesIssuedInfo; 87 89 88 90 SceneNode *mCurrentObject; // The newly created object … … 94 96 bool mUseOptimization; 95 97 bool mShowOctree; 98 bool mUseCulling; 96 99 }; 97 100
Note: See TracChangeset
for help on using the changeset viewer.