Changeset 74 for trunk/VUT/GtpVisibility
- Timestamp:
- 05/01/05 23:29:27 (20 years ago)
- Location:
- trunk/VUT/GtpVisibility
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/include/CoherentHierarchicalCullingManager.h
r59 r74 17 17 { 18 18 public: 19 CoherentHierarchicalCullingManager(HierarchyInterface *hierarchyInterface);20 19 void RenderScene(); 21 20 }; -
trunk/VUT/GtpVisibility/include/CullingManager.h
r59 r74 12 12 { 13 13 public: 14 /** Constructor taking a scene traverser for a specific type of hierarchy as argument. 14 /** Default constructor. 15 @remark an appropriate hierarchy interface must be provided for the algorithms to 16 work on specific hierarchy 15 17 */ 16 CullingManager( HierarchyInterface *hierarchyInterface);18 CullingManager(); 17 19 /** Renders the scene using a specific occlusion culling algorithm, e.g., coherent 18 20 hierarchical culling or stop and wait. … … 24 26 */ 25 27 void SetHierarchyInterface(HierarchyInterface *hierarchyInterface); 28 /** Sets the threshold for the visibiliy culling algorithm. 29 @param visibilityThreshold number of visible pixels where an object 30 is still considered invisible. 31 */ 32 void SetVisibilityThreshold(unsigned int visibilityThreshold); 33 34 /** Returns number of frustum culled nodes. 35 */ 36 unsigned int GetNumFrustumCulledNodes(); 37 /** Returns number of occlusion query culled nodes. 38 */ 39 unsigned int GetNumQueryCulledNodes(); 26 40 27 41 protected: … … 29 43 unsigned int mNumQueryCulledNodes; 30 44 unsigned int mNumFrustumCulledNodes; 45 unsigned int mVisibilityThreshold; 31 46 32 unsigned int mVisibilityThreshold;33 47 HierarchyInterface *mHierarchyInterface; 34 48 }; -
trunk/VUT/GtpVisibility/include/FrustumCullingManager.h
r59 r74 12 12 { 13 13 public: 14 FrustumCullingManager(HierarchyInterface *hierarchyInterface);15 14 void RenderScene(); 16 15 }; -
trunk/VUT/GtpVisibility/include/HierarchyInterface.h
r65 r74 19 19 @returns true if node is leaf 20 20 */ 21 virtual bool IsLeaf(HierarchyNode *node) = 0;21 virtual bool IsLeaf(HierarchyNode *node) const = 0; 22 22 /** Traverses the given node. 23 23 @param node the hierarchy node … … 41 41 */ 42 42 void SetSceneRoot(HierarchyNode *root); 43 /** Get the root of the scene hierarchy. 44 @return the hierarchy root 45 */ 46 HierarchyNode *GetSceneRoot() const { 47 return mSceneRoot; 48 } 43 /** Get the root of the scene hierarchy. 44 @return the hierarchy root 45 */ 46 HierarchyNode *GetSceneRoot() const; 49 47 /** Sets the scene root and initialises this scene traverser for a traversal. 50 48 @param root current scene root … … 52 50 */ 53 51 void InitFrame(HierarchyNode *root); 54 55 52 /** Returns current frame id. 56 53 @returns frame id 57 54 */ 58 int GetFrameId();55 unsigned int GetFrameId() const; 59 56 /** Returns the current distance queue. 60 57 @returns current distance queue … … 66 63 @param node2 the second node to be compared 67 64 */ 68 virtual bool HasGreaterDistance(HierarchyNode *node1, HierarchyNode *node2) = 0;65 virtual bool HasGreaterDistance(HierarchyNode *node1, HierarchyNode *node2) const = 0; 69 66 /** Checks if the node is visible from the current view frustum. 70 67 @param node the current node … … 72 69 */ 73 70 virtual bool CheckFrustumVisible(HierarchyNode *node, bool &intersects) = 0; 71 /** Checks if the node is visible from the current view frustum. 72 @param node the current node 73 */ 74 bool CheckFrustumVisible(HierarchyNode *node); 74 75 /** Returns next available occlusion query or creates new one. 75 76 @return the next occlusion query … … 80 81 @returns if the node has renderable geometry 81 82 */ 82 virtual bool HasGeometry(HierarchyNode *node) = 0;83 virtual bool HasGeometry(HierarchyNode *node) const = 0; 83 84 /** Sets the visible flag for this node. 84 85 @param node the current node … … 88 89 /** Returns true if node has the visible flag set. See set 89 90 */ 90 virtual bool IsNodeVisible(HierarchyNode *node) = 0;91 virtual bool IsNodeVisible(HierarchyNode *node) const = 0; 91 92 /** Sets the last visited frame id for this node. 92 93 @param node the current node 93 94 @param frameId the current frame id 94 95 */ 95 virtual void SetLastVisited(HierarchyNode *node, const int frameId) = 0; 96 virtual void SetLastVisited(HierarchyNode *node, 97 const unsigned int frameId) = 0; 96 98 /** Returns frame id when this node was last visited by the traverser. See set 97 99 */ 98 virtual int LastVisited(HierarchyNode *node) = 0; 100 virtual unsigned int LastVisited(HierarchyNode *node) const = 0; 101 /** Returns number of traversed nodes. 102 */ 103 unsigned int GetNumTraversedNodes(); 104 /** Returns number of rendered nodes. 105 */ 106 unsigned int GetNumRenderedNodes(); 99 107 100 108 protected: … … 105 113 106 114 //--- statistics 107 unsigned int mNumSceneNodes;108 115 unsigned int mNumTraversedNodes; 109 unsigned int mNumRenderedGeometry;110 116 unsigned int mNumRenderedNodes; 111 117 -
trunk/VUT/GtpVisibility/include/StopAndWaitCullingManager.h
r59 r74 11 11 { 12 12 public: 13 StopAndWaitCullingManager(HierarchyInterface *hierarchyInterface);14 13 void RenderScene(); 15 14 }; -
trunk/VUT/GtpVisibility/include/VisibilityEnvironment.h
r71 r74 13 13 /** Different types of occlusion culling algorithms 14 14 */ 15 enum CullingManagerType {FRUSTUM_CULLING, STOP_AND_WAIT, COHERENT_HIERARCHICAL_CULLING}; 15 enum CullingManagerType {FRUSTUM_CULLING, 16 STOP_AND_WAIT_CULLING, 17 COHERENT_HIERARCHICAL_CULLING, 18 NUM_CULLING_MANAGERS}; 16 19 17 20 /** Loads an environment from disk. … … 21 24 } // namespace GtpVisibility 22 25 23 /** @}*/ // end of group Visibility24 25 26 #endif // VisibilityEnvironment_H -
trunk/VUT/GtpVisibility/include/VisibilityManager.h
r71 r74 41 41 void ApplyVisibilityCulling(); 42 42 43 /** Sets the threshold for the visibiliy culling algorithm. 44 @param visibilityThreshold number of visible pixels where an object 45 is still considered invisible. 46 @remark automatically sets the threshold of the current and of 47 new culling managers to this value. 48 */ 49 void SetVisibilityCullingThreshold(unsigned int threshold); 50 43 51 protected: 44 52 … … 48 56 VisibilityEnvironment *mVisibilityEnvironment; 49 57 VisibilityEnvironment::CullingManagerType mCullingManagerType; 58 59 unsigned int mVisibilityThreshold; 60 50 61 }; 51 62 } // namespace GtpVisibility -
trunk/VUT/GtpVisibility/scripts/GtpVisibility.vcproj
r71 r74 20 20 Name="VCCLCompilerTool" 21 21 Optimization="0" 22 AdditionalIncludeDirectories=""$(OGRE_PATH) /OgreMain/include";..\include"22 AdditionalIncludeDirectories=""$(OGRE_PATH)\OgreMain\include";..\include" 23 23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB" 24 24 MinimalRebuild="TRUE" … … 55 55 <Configuration 56 56 Name="Release|Win32" 57 OutputDirectory="..\ bin\$(ConfigurationName)"57 OutputDirectory="..\lib\$(ConfigurationName)" 58 58 IntermediateDirectory="..\obj\$(ConfigurationName)" 59 59 ConfigurationType="4" … … 61 61 <Tool 62 62 Name="VCCLCompilerTool" 63 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\OgreMain\include"" 63 64 PreprocessorDefinitions="WIN32;NDEBUG;_LIB" 64 65 RuntimeLibrary="2" 65 UsePrecompiledHeader=" 3"66 UsePrecompiledHeader="0" 66 67 WarningLevel="3" 67 68 Detect64BitPortabilityProblems="TRUE" -
trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
r59 r74 3 3 namespace GtpVisibility { 4 4 5 //-----------------------------------------------------------------------6 CoherentHierarchicalCullingManager::CoherentHierarchicalCullingManager(HierarchyInterface *hierarchyInterface):7 CullingManager(hierarchyInterface)8 {9 }10 5 //----------------------------------------------------------------------- 11 6 void CoherentHierarchicalCullingManager::RenderScene() … … 46 41 bool intersects = false; 47 42 48 if (!mHierarchyInterface->CheckFrustumVisible(node, intersects))43 if (!mHierarchyInterface->CheckFrustumVisible(node, intersects)) 49 44 { 50 45 mNumFrustumCulledNodes ++; 51 continue;52 46 } 47 else 48 { 49 // if intersects near plane => skip occlusion query because wrong results possible 50 if (intersects) 51 { 52 // update octant's visited flag 53 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 53 54 54 // if intersects near plane => skip occlusion query because wrong results possible 55 if (intersects) 56 { 57 // update octant's visited flag 55 mHierarchyInterface->PullUpVisibility(node); 56 mHierarchyInterface->TraverseNode(node); 57 58 continue; 59 } 60 61 // identify previously visible nodes 62 bool wasVisible = mHierarchyInterface->IsNodeVisible(node) && 63 (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId() - 1); 64 65 // identify nodes that we cannot skip queries for 66 bool mustQuery = !wasVisible || mHierarchyInterface->HasGeometry(node) || mHierarchyInterface->IsLeaf(node); 67 68 // reset node's visibility classification 69 mHierarchyInterface->SetNodeVisible(node, false); 70 71 // update node's visited flag 58 72 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 59 60 mHierarchyInterface->PullUpVisibility(node);61 mHierarchyInterface->TraverseNode(node);62 63 continue;64 }65 66 // identify previously visible nodes67 bool wasVisible = mHierarchyInterface->IsNodeVisible(node) &&68 (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId() - 1);69 70 // identify nodes that we cannot skip queries for71 bool mustQuery = !wasVisible || mHierarchyInterface->HasGeometry(node) || mHierarchyInterface->IsLeaf(node);72 73 // reset node's visibility classification74 mHierarchyInterface->SetNodeVisible(node, false);75 76 // update node's visited flag77 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());78 73 79 // skip testing previously visible interior nodes80 if (mustQuery)81 {82 queryQueue.push(QueryPair(node, mHierarchyInterface->IssueOcclusionQuery(node)));83 }74 // skip testing previously visible interior nodes 75 if (mustQuery) 76 { 77 queryQueue.push(QueryPair(node, mHierarchyInterface->IssueOcclusionQuery(node))); 78 } 84 79 85 // always traverse a node if it was visible 86 if (wasVisible) 87 { 88 mHierarchyInterface->TraverseNode(node); 80 // always traverse a node if it was visible 81 if (wasVisible) 82 { 83 mHierarchyInterface->TraverseNode(node); 84 } 89 85 } 90 86 } -
trunk/VUT/GtpVisibility/src/CullingManager.cpp
r59 r74 4 4 5 5 //----------------------------------------------------------------------- 6 CullingManager::CullingManager( HierarchyInterface *hierarchyInterface):7 mHierarchyInterface( hierarchyInterface), mVisibilityThreshold(0), mNumQueryCulledNodes(0),6 CullingManager::CullingManager(): 7 mHierarchyInterface(NULL), mVisibilityThreshold(0), mNumQueryCulledNodes(0), 8 8 mNumFrustumCulledNodes(0) 9 9 { … … 14 14 mHierarchyInterface = hierarchyInterface; 15 15 } 16 //----------------------------------------------------------------------- 17 void CullingManager::SetVisibilityThreshold(unsigned int visibilityThreshold) 18 { 19 mVisibilityThreshold = visibilityThreshold; 20 } 21 //----------------------------------------------------------------------- 22 unsigned int CullingManager::GetNumFrustumCulledNodes() 23 { 24 return mNumFrustumCulledNodes; 25 } 26 //----------------------------------------------------------------------- 27 unsigned int CullingManager::GetNumQueryCulledNodes() 28 { 29 return mNumQueryCulledNodes; 30 } 16 31 } // namespace GtpVisibility -
trunk/VUT/GtpVisibility/src/DummyPreprocessingManager.cpp
r65 r74 3 3 namespace GtpVisibility { 4 4 5 DummyPreprocessingManager::DummyPreprocessingManager( HierarchyInterface *hierarchyInterface)5 DummyPreprocessingManager::DummyPreprocessingManager(HierarchyInterface *hierarchyInterface) 6 6 :PreprocessingManager(hierarchyInterface) 7 7 { … … 9 9 10 10 11 bool 12 DummyPreprocessingManager::ExportScene(const string filename) 11 bool DummyPreprocessingManager::ExportScene(const string filename) 13 12 { 14 13 ofstream s(filename.c_str()); … … 19 18 20 19 21 bool 22 DummyPreprocessingManager::LoadPreprocessedData(const string filename) 20 bool DummyPreprocessingManager::LoadPreprocessedData(const string filename) 23 21 { 24 22 // do nothing … … 31 29 Returns false if no viewcell was found. 32 30 */ 33 bool 34 DummyPreprocessingManager::LocateViewCellIds(const Vector3 ¢er, 35 const float radius, 36 vector<int> *viewCellIds 37 ) 31 bool DummyPreprocessingManager::LocateViewCellIds(const Vector3 ¢er, 32 const float radius, 33 vector<int> *viewCellIds) 38 34 { 39 35 return false; … … 43 39 Uses the specified viewcell to find its PVS 44 40 */ 45 int 46 DummyPreprocessingManager::AddViewCellPVS(const int cellID, 41 int DummyPreprocessingManager::AddViewCellPVS(const int cellID, 47 42 InfoContainer<NodeInfo> *visibleNodes, 48 43 InfoContainer<MeshInfo> *visibleMeshes ) -
trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp
r59 r74 1 1 #include "FrustumCullingManager.h" 2 3 #include <windows.h> 2 4 3 5 namespace GtpVisibility { 4 6 5 7 //----------------------------------------------------------------------- 6 FrustumCullingManager::FrustumCullingManager(HierarchyInterface *hierarchyInterface):7 CullingManager(hierarchyInterface)8 {9 }10 //-----------------------------------------------------------------------11 8 void FrustumCullingManager::RenderScene() 12 9 { 13 10 mNumFrustumCulledNodes = mNumQueryCulledNodes = 0; 14 15 while (!mHierarchyInterface->GetQueue()->empty())11 12 while (!mHierarchyInterface->GetQueue()->empty()) 16 13 { 17 14 HierarchyNode *node = mHierarchyInterface->GetQueue()->top(); … … 22 19 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 23 20 24 bool intersects = false; 25 26 if(mHierarchyInterface->CheckFrustumVisible(node, intersects)) 21 if (!mHierarchyInterface->CheckFrustumVisible(node)) 27 22 { 28 23 mNumFrustumCulledNodes ++; 29 continue;30 24 } 31 32 //if intersects near plane => skip occlusion query because wrong results possible 33 if(intersects) 34 { 35 mHierarchyInterface->SetNodeVisible(node, true); 25 else 26 { 27 mHierarchyInterface->SetNodeVisible(node, true); 36 28 mHierarchyInterface->TraverseNode(node); 37 continue;38 29 } 39 40 mHierarchyInterface->TraverseNode(node);41 30 } 42 31 } -
trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp
r59 r74 1 1 #include "HierarchyInterface.h" 2 2 3 //#include <windows.h>3 #include <windows.h> 4 4 5 5 namespace GtpVisibility { … … 7 7 //----------------------------------------------------------------------- 8 8 HierarchyInterface::HierarchyInterface(): 9 mFrameId( 1), mNumSceneNodes(0), mNumTraversedNodes(0),10 m NumRenderedNodes(0), mSceneRoot(0), mCurrentTestIdx(0)9 mFrameId(0), mNumTraversedNodes(0), mNumRenderedNodes(0), 10 mSceneRoot(0), mCurrentTestIdx(0) 11 11 { 12 12 mDistanceQueue = new DistanceQueue(GreaterDistance<HierarchyNode *>(this)); … … 25 25 void HierarchyInterface::InitFrame(HierarchyNode *root) 26 26 { 27 mFrameId = 0;27 mFrameId ++; 28 28 mNumTraversedNodes = 0; 29 29 mNumRenderedNodes = 0; … … 33 33 } 34 34 //----------------------------------------------------------------------- 35 int HierarchyInterface::GetFrameId() 35 unsigned int HierarchyInterface::GetFrameId() const 36 36 { 37 37 return mFrameId; … … 42 42 return mDistanceQueue; 43 43 } 44 //----------------------------------------------------------------------- 45 bool HierarchyInterface::CheckFrustumVisible(HierarchyNode *node) 46 { 47 bool intersects = false; 48 return CheckFrustumVisible(node, intersects); 49 } 50 //----------------------------------------------------------------------- 51 HierarchyNode *HierarchyInterface::GetSceneRoot() const 52 { 53 return mSceneRoot; 54 } 55 //----------------------------------------------------------------------- 56 unsigned int HierarchyInterface::GetNumTraversedNodes() 57 { 58 return mNumTraversedNodes; 59 } 60 //----------------------------------------------------------------------- 61 unsigned int HierarchyInterface::GetNumRenderedNodes() 62 { 63 return mNumRenderedNodes; 64 } 44 65 } // namespace GtpVisibility -
trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
r59 r74 3 3 namespace GtpVisibility { 4 4 5 //-----------------------------------------------------------------------6 StopAndWaitCullingManager::StopAndWaitCullingManager(HierarchyInterface *HierarchyInterface):7 CullingManager(HierarchyInterface)8 {9 }10 5 //----------------------------------------------------------------------- 11 6 void StopAndWaitCullingManager::RenderScene() … … 24 19 bool intersects = false; 25 20 26 if ( mHierarchyInterface->CheckFrustumVisible(node, intersects))21 if (!mHierarchyInterface->CheckFrustumVisible(node, intersects)) 27 22 { 28 23 mNumFrustumCulledNodes ++; 29 continue;30 }31 32 //if intersects near plane => skip occlusion query because wrong results possible33 if (intersects)34 {35 mHierarchyInterface->SetNodeVisible(node, true);36 mHierarchyInterface->TraverseNode(node);37 continue;38 }39 40 // node visible41 if (mHierarchyInterface->IssueOcclusionQuery(node)->GetQueryResult() >42 mVisibilityThreshold)43 {44 mHierarchyInterface->TraverseNode(node);45 24 } 46 25 else 47 26 { 48 mNumQueryCulledNodes ++; 27 //if intersects near plane => skip occlusion query because wrong results possible 28 if (intersects) 29 { 30 mHierarchyInterface->SetNodeVisible(node, true); 31 mHierarchyInterface->TraverseNode(node); 32 continue; 33 } 34 35 // node visible 36 if (mHierarchyInterface->IssueOcclusionQuery(node)->GetQueryResult() > 37 mVisibilityThreshold) 38 { 39 mHierarchyInterface->TraverseNode(node); 40 } 41 else 42 { 43 mNumQueryCulledNodes ++; 44 } 49 45 } 50 46 } -
trunk/VUT/GtpVisibility/src/VisibilityEnvironment.cpp
r59 r74 2 2 3 3 namespace GtpVisibility { 4 4 //----------------------------------------------------------------------- 5 5 VisibilityEnvironment::VisibilityEnvironment() 6 6 { 7 7 } 8 8 //----------------------------------------------------------------------- 9 9 void VisibilityEnvironment::LoadEnvironment() 10 10 { -
trunk/VUT/GtpVisibility/src/VisibilityManager.cpp
r65 r74 7 7 8 8 namespace GtpVisibility { 9 10 VisibilityManager::VisibilityManager(VisibilityEnvironment *visEnvironment) 9 //----------------------------------------------------------------------- 10 VisibilityManager::VisibilityManager(VisibilityEnvironment *visEnvironment): 11 mVisibilityThreshold(0) 11 12 { 12 13 mVisibilityEnvironment = visEnvironment; 13 //mVisibilityManagerType = VisibilityEnvironment::STOP_AND_WAIT; 14 //mVisibilityManager = new StopAndWaitCullingManager(NULL); 15 mCullingManagerType = VisibilityEnvironment::FRUSTUM_CULLING; 16 mCullingManager = new FrustumCullingManager(0); 14 15 mCullingManagerType = VisibilityEnvironment::STOP_AND_WAIT_CULLING; 16 mCullingManager = new StopAndWaitCullingManager(); 17 17 18 18 mQueryManager = new DummyQueryManager(0); 19 19 mPreprocessingManager = new DummyPreprocessingManager(0); 20 21 20 } 22 21 //----------------------------------------------------------------------- 23 22 VisibilityManager::~VisibilityManager() 24 23 { 25 24 delete mCullingManager; 26 25 } 27 28 void VisibilityManager::SetCullingManager(VisibilityEnvironment::CullingManagerType ocmType) 26 //----------------------------------------------------------------------- 27 void VisibilityManager::SetCullingManager( 28 VisibilityEnvironment::CullingManagerType ocmType) 29 29 { 30 30 if (mCullingManagerType != ocmType) … … 35 35 switch (ocmType) 36 36 { 37 case VisibilityEnvironment::STOP_AND_WAIT :38 mCullingManager = new StopAndWaitCullingManager( NULL);37 case VisibilityEnvironment::STOP_AND_WAIT_CULLING: 38 mCullingManager = new StopAndWaitCullingManager(); 39 39 break; 40 40 41 41 case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING: 42 mCullingManager = new CoherentHierarchicalCullingManager( NULL);42 mCullingManager = new CoherentHierarchicalCullingManager(); 43 43 break; 44 44 45 45 case VisibilityEnvironment::FRUSTUM_CULLING: 46 mCullingManager = new FrustumCullingManager( NULL);46 mCullingManager = new FrustumCullingManager(); 47 47 break; 48 48 default: 49 mCullingManager = new StopAndWaitCullingManager( NULL);49 mCullingManager = new StopAndWaitCullingManager(); 50 50 break; 51 51 } 52 52 } 53 53 } 54 54 //----------------------------------------------------------------------- 55 void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold) 56 { 57 mVisibilityThreshold = visibilityThreshold; 58 mCullingManager->SetVisibilityThreshold(mVisibilityThreshold); 59 } 60 //----------------------------------------------------------------------- 55 61 CullingManager *VisibilityManager::GetCullingManager() 56 62 { 57 63 return mCullingManager; 58 64 } 59 65 //----------------------------------------------------------------------- 60 66 void VisibilityManager::ApplyVisibilityCulling() 61 67 { 62 68 mCullingManager->RenderScene(); 63 69 } 64 70 //----------------------------------------------------------------------- 65 71 } // namespace GtpVisibility
Note: See TracChangeset
for help on using the changeset viewer.