Changeset 155 for trunk/VUT/GtpVisibility
- Timestamp:
- 07/05/05 18:35:47 (20 years ago)
- Location:
- trunk/VUT/GtpVisibility
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/include/CoherentHierarchicalCullingManager.h
r147 r155 15 15 public: 16 16 CoherentHierarchicalCullingManager(); 17 /** Constructor taking the assumed visibility into account, i.e., the estimation 18 for how many frames the current visibility is considered to be valid 19 */ 20 CoherentHierarchicalCullingManager(const unsigned int assumedVisibility); 21 17 22 void RenderScene(); 18 /** Sets assumed visibility which is a an estimation for e19 how many frames the visibility is considered to be vali ed23 /** Sets assumed visibility (i.e., an estimation for 24 how many frames the visibility is considered to be valid). 20 25 @param assumedVisibility indicates for how many frames the 21 26 same visibility is be assumed. … … 32 37 33 38 unsigned int mAssumedVisibility; 39 40 /** Skip query for this node. 41 */ 42 void SkipQuery(HierarchyNode *node); 43 44 34 45 /** Threshold for rand function to return positive result with respect to 35 46 mAssumedVisibility. -
trunk/VUT/GtpVisibility/include/HierarchyInterface.h
r154 r155 4 4 #include "DistanceQueue.h" 5 5 #include "VisibilityMesh.h" 6 #include <stack> 6 7 7 8 namespace GtpVisibility { … … 13 14 typedef std::pair<HierarchyNode *, OcclusionQuery *> QueryPair; 14 15 typedef std::queue<QueryPair> QueryQueue; 16 typedef std::stack<HierarchyNode *> TraversalStack; 15 17 16 18 /** Class which implements a hierarchy interface for a scene hierarchy. … … 28 30 */ 29 31 virtual bool IsLeaf(HierarchyNode *node) const = 0; 30 /** Traverses the given node.32 /** Traverses and renders the given node. 31 33 @param node the hierarchy node 32 34 */ 33 virtual void Traverse Node(HierarchyNode *node) = 0;35 virtual void TraverseAndRenderNode(HierarchyNode *node) = 0; 34 36 /** Renders current hierarchy node. 35 37 @param node current hierarchy node to be rendered … … 49 51 @param root the hierarchy root 50 52 */ 51 void Set SceneRoot(HierarchyNode *root);53 void SetHierarchyRoot(HierarchyNode *root); 52 54 /** Get the root of the scene hierarchy. 53 55 @return the hierarchy root 54 56 */ 55 HierarchyNode *GetSceneRoot() const; 56 /** Sets the scene root and initialises this scene traverser for a traversal. 57 @param root current scene root 58 @remark initialises some parameters, and also the statistics. 59 */ 60 void InitFrame(HierarchyNode *root); 57 HierarchyNode *GetHierarchyRoot() const; 58 /** Sets the scene root and initialises this hierarchy interface for a traversal. 59 @param frontToBack 60 if traversal is initialised for front-to-back rendering or 61 simple traversal of the nodes. 62 @remark also resets the statistics evaluated in the last traversal 63 */ 64 void InitTraversal(bool frontToBack = true); 61 65 /** Returns current frame id. 62 66 @returns frame id 63 67 */ 64 68 unsigned int GetFrameId() const; 65 /** Returns the current distance queue. 66 @returns current distance queue 69 /** Returns a pointer to the distance queue. 70 @returns current distance queue. 71 @remark the distance queue stores hierarchy nodes in a front-to-back order 67 72 */ 68 73 DistanceQueue *GetQueue(); … … 112 117 */ 113 118 unsigned int GetNumRenderedNodes(); 114 /** Optimization when issuing occlusion test: test is done with actual geometry 115 rather than the bounding box 116 @param useOptimization if the optimization should be used 117 */ 118 void SetUseOptimization(bool useOptimization); 119 119 120 //bool mIsShadowPass; 120 121 … … 137 138 virtual GtpVisibility::OcclusionQuery *IssueOcclusionQuery(GtpVisibility::Mesh *mesh) = 0; 138 139 139 /** Returns geometry of hierarchy node. 140 */ 141 virtual void GetGeometry(GtpVisibility::HierarchyNode *node, 140 /** Returns the geometry of a given hierarchy node. 141 @param node the hierarchy node containing the geometry 142 @param geometryList geometry is returned in this list 143 @param includeChildren if the geometry of the children should be taken into account 144 */ 145 virtual void GetNodeGeometryList(GtpVisibility::HierarchyNode *node, 142 146 GeometryList *geometryList, 143 147 bool includeChildren) = 0; … … 154 158 */ 155 159 virtual int GetNodeId(HierarchyNode *node) = 0; 160 161 /** This is an optimization when issuing the occlusion test. 162 The test is done with actual geometry rather than the bounding 163 box of leave nodes previously marked as visible 164 @param testGeometry if this optimization should be used 165 @remark this option is only useful for the coherent hierarchical culling algorithm 166 */ 167 void TestGeometryForVisibleLeaves(bool testGeometry); 168 169 /** 170 Traverses hierarchy and returns next node. 171 @returns next node in hierarchy. 172 */ 173 virtual HierarchyNode *GetNextNode() = 0; 174 156 175 protected: 157 158 bool mUseOptimization; 176 /// chc optimization for testing geometry of leaves instead of bounding box 177 bool mTestGeometryForVisibleLeaves; 178 159 179 unsigned int mFrameId; 160 180 161 181 int mCurrentTestIdx; 162 182 163 // --- statistics183 /// number of traversed nodes 164 184 unsigned int mNumTraversedNodes; 165 185 /// the distance queue used for rendering of nodes in front to back order. 166 186 DistanceQueue *mDistanceQueue; 167 HierarchyNode *mSceneRoot; 168 HierarchyNode *mPreviousNode; 187 /// internal structure for traversal 188 TraversalStack *mTraversalStack; 189 190 /// the root of the hierarchy 191 HierarchyNode *mHierarchyRoot; 192 193 // buffer for a node pointer 194 HierarchyNode *mSavedNode; 169 195 170 196 std::vector<HierarchyNode *> mRenderedNodes; 171 197 }; 172 198 } // namespace GtpVisibility 199 173 200 #endif // GtpVisisibilityHierarchyInterface_H -
trunk/VUT/GtpVisibility/include/VisibilityManager.h
r146 r155 52 52 void SetVisibilityCullingThreshold(unsigned int threshold); 53 53 54 /** Determines if optimization for coherent hierarchical culling is used.55 */56 void SetUseChcOptimization(bool useOptimization);57 54 /** Indicates for how long a frame is considered to be visible. 58 55 @param assumedVisibility estimation for how long visibility is assumed to be valid. 56 @remark this option is only valid for the coherent hierarchical culling algorithm 59 57 */ 60 void SetAssumedVisibility(unsigned int assumedVisibility); 58 void SetAssumedVisibilityForChc(unsigned int assumedVisibility); 59 61 60 /** Sets pointer to a query manager. 62 61 */ … … 75 74 76 75 unsigned int mVisibilityThreshold; 77 unsigned int mAssumedVisibility ;76 unsigned int mAssumedVisibilityForChc; 78 77 }; 79 78 } // namespace GtpVisibility -
trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
r148 r155 5 5 6 6 //----------------------------------------------------------------------- 7 CoherentHierarchicalCullingManager:: CoherentHierarchicalCullingManager(): 8 mAssumedVisibility(0), mThreshold(0) 7 CoherentHierarchicalCullingManager::CoherentHierarchicalCullingManager() 9 8 { 10 // initialise random generator because of assumed visibility 9 SetAssumedVisibility(0); 10 // initialise random generator in case we use assumed visibility 11 srand(time(NULL)); 12 } 13 //----------------------------------------------------------------------- 14 CoherentHierarchicalCullingManager::CoherentHierarchicalCullingManager(const unsigned int 15 assumedVisibility) 16 { 17 SetAssumedVisibility(assumedVisibility); 18 // initialise random generator in case we use assumed visibility 11 19 srand(time(NULL)); 12 20 } … … 32 40 { 33 41 mHierarchyInterface->PullUpVisibility(node); 34 mHierarchyInterface->Traverse Node(node);42 mHierarchyInterface->TraverseAndRenderNode(node); 35 43 } 36 44 else 37 45 { 38 mNumQueryCulledNodes ++;46 ++ mNumQueryCulledNodes; 39 47 40 48 if(mVisualizeCulledNodes) … … 62 70 } 63 71 } 72 // -- if node intersects near plane, skip query because wrong results possible 73 else if (intersects) 74 { 75 SkipQuery(node); 76 } 64 77 else 65 78 { … … 67 80 bool wasVisible = mHierarchyInterface->IsNodeVisible(node) && 68 81 (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId() - 1); 69 70 // if node is assumed to be visible in this frame => skip query 71 // if intersects near plane => also skip query because wrong results possible 72 bool assumeVisible = intersects || 73 (wasVisible && (mAssumedVisibility > 0) && 74 mHierarchyInterface->HasGeometry(node) && DecideVisible(node)); 75 76 if (assumeVisible) 82 83 // if we assume node to be visible in this frame => skip query 84 if (wasVisible && (mAssumedVisibility > 0) && DecideVisible(node))// && mHierarchyInterface->HasGeometry(node)) 77 85 { 78 // update node's visited flag 79 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 80 81 mHierarchyInterface->PullUpVisibility(node); 82 mHierarchyInterface->TraverseNode(node); 86 SkipQuery(node); 83 87 84 88 continue; … … 107 111 if (wasVisible) 108 112 { 109 mHierarchyInterface->Traverse Node(node);113 mHierarchyInterface->TraverseAndRenderNode(node); 110 114 } 111 115 } … … 129 133 bool CoherentHierarchicalCullingManager::DecideVisible(HierarchyNode *node) const 130 134 { 131 /*bool result = rand() < mThreshold; 132 std::stringstream d; d << "Assumed vis: " << mAssumedVisibility << ", result: " << result; 135 /*bool result = rand() < mThreshold; std::stringstream d; d << "Assumed vis: " << mAssumedVisibility << ", result: " << result; 133 136 Ogre::LogManager::getSingleton().logMessage(d.str()); return result;*/ 134 137 135 138 return rand() < mThreshold; 136 139 } 140 //----------------------------------------------------------------------- 141 void CoherentHierarchicalCullingManager::SkipQuery(HierarchyNode *node) 142 { 143 // -- set node to be visible in this frame, then traverse it 144 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 145 146 mHierarchyInterface->PullUpVisibility(node); 147 mHierarchyInterface->TraverseAndRenderNode(node); 148 } 149 137 150 } // namespace GtpVisibility -
trunk/VUT/GtpVisibility/src/DummyQueryManager.cpp
r144 r155 13 13 bool relativeVisibility) 14 14 { 15 visibleNodes->push_back(NodeInfo(mHierarchyInterface->Get SceneRoot(), 0, 0));15 visibleNodes->push_back(NodeInfo(mHierarchyInterface->GetHierarchyRoot(), 0, 0)); 16 16 17 17 // HierarchyInterface::MeshIterator *mi = … … 31 31 bool relativeVisibility) 32 32 { 33 visibleNodes->push_back(NodeInfo(mHierarchyInterface->Get SceneRoot(), 0, 0));33 visibleNodes->push_back(NodeInfo(mHierarchyInterface->GetHierarchyRoot(), 0, 0)); 34 34 35 35 // HierarchyInterface::MeshIterator *mi = -
trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp
r147 r155 28 28 { 29 29 mHierarchyInterface->SetNodeVisible(node, true); 30 mHierarchyInterface->Traverse Node(node);30 mHierarchyInterface->TraverseAndRenderNode(node); 31 31 } 32 32 } -
trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp
r130 r155 7 7 //----------------------------------------------------------------------- 8 8 HierarchyInterface::HierarchyInterface(): 9 mFrameId(0), mNumTraversedNodes(0), mSceneRoot(0), 10 mPreviousNode(0), mCurrentTestIdx(0), mUseOptimization(false) 11 //, mIsShadowPass(false) 9 mFrameId(0), mNumTraversedNodes(0), mHierarchyRoot(NULL), 10 mSavedNode(NULL), mCurrentTestIdx(0), mTestGeometryForVisibleLeaves(false) 12 11 { 13 12 mDistanceQueue = new DistanceQueue(GreaterDistance<HierarchyNode *>(this)); 13 mTraversalStack = new std::stack<HierarchyNode *>; 14 14 } 15 15 //----------------------------------------------------------------------- … … 17 17 { 18 18 delete mDistanceQueue; 19 delete mTraversalStack; 19 20 } 20 21 //----------------------------------------------------------------------- 21 void HierarchyInterface::Set SceneRoot(HierarchyNode *root)22 void HierarchyInterface::SetHierarchyRoot(HierarchyNode *root) 22 23 { 23 m SceneRoot = root;24 mHierarchyRoot = root; 24 25 } 25 26 //----------------------------------------------------------------------- 26 void HierarchyInterface::Init Frame(HierarchyNode *root)27 void HierarchyInterface::InitTraversal(bool frontToBack) 27 28 { 28 ++ mFrameId; 29 mCurrentTestIdx = 0; 30 mNumTraversedNodes = 0; 31 mRenderedNodes.clear(); 29 // initialise for front-to-back rendering 30 if (frontToBack) 31 { 32 ++ mFrameId; 33 mCurrentTestIdx = 0; 34 mNumTraversedNodes = 0; 35 mRenderedNodes.clear(); 32 36 33 SetSceneRoot(root); 34 mDistanceQueue->push(mSceneRoot); 37 mDistanceQueue->push(mHierarchyRoot); 38 } 39 else 40 { // initialise for simple node traversal 41 mTraversalStack->push(mHierarchyRoot); 42 } 35 43 } 36 44 //----------------------------------------------------------------------- … … 51 59 } 52 60 //----------------------------------------------------------------------- 53 HierarchyNode *HierarchyInterface::Get SceneRoot() const61 HierarchyNode *HierarchyInterface::GetHierarchyRoot() const 54 62 { 55 return m SceneRoot;63 return mHierarchyRoot; 56 64 } 57 65 //----------------------------------------------------------------------- … … 66 74 } 67 75 //----------------------------------------------------------------------- 68 void HierarchyInterface:: SetUseOptimization(bool useOptimization)76 void HierarchyInterface::TestGeometryForVisibleLeaves(bool testGeometry) 69 77 { 70 m UseOptimization = useOptimization;78 mTestGeometryForVisibleLeaves = testGeometry; 71 79 } 72 80 //----------------------------------------------------------------------- … … 75 83 return &mRenderedNodes; 76 84 } 77 78 85 } // namespace GtpVisibility -
trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
r139 r155 27 27 } 28 28 } 29 // if intersects near plane => skip occlusion query because wrong results possible 30 else if (intersects) 31 { 32 mHierarchyInterface->SetNodeVisible(node, true); 33 mHierarchyInterface->TraverseAndRenderNode(node); 34 } 29 35 else 30 36 { 31 // if intersects near plane => skip occlusion query because wrong results possible32 if (intersects)33 {34 mHierarchyInterface->SetNodeVisible(node, true);35 mHierarchyInterface->TraverseNode(node);36 continue;37 }38 37 39 38 ++ mNumQueriesIssued; … … 46 45 if (visiblePixels > mVisibilityThreshold) 47 46 { 48 mHierarchyInterface->Traverse Node(node);47 mHierarchyInterface->TraverseAndRenderNode(node); 49 48 } 50 49 else -
trunk/VUT/GtpVisibility/src/VisibilityManager.cpp
r153 r155 14 14 mPreprocessingManager(new DummyPreprocessingManager(NULL)), 15 15 mVisibilityEnvironment(visEnvironment), 16 mAssumedVisibility (0)16 mAssumedVisibilityForChc(0) 17 17 { 18 18 SetCullingManager(VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING); … … 27 27 } 28 28 //----------------------------------------------------------------------- 29 void VisibilityManager::SetCullingManager( 30 VisibilityEnvironment::CullingManagerType ocmType)29 void VisibilityManager::SetCullingManager(VisibilityEnvironment:: 30 CullingManagerType ocmType) 31 31 { 32 32 // change only if necessary … … 38 38 delete mCullingManager; 39 39 } 40 40 41 mCullingManagerType = ocmType; 41 42 … … 47 48 48 49 case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING: 49 mCullingManager = new CoherentHierarchicalCullingManager(); 50 dynamic_cast<CoherentHierarchicalCullingManager *>(mCullingManager)-> 51 SetAssumedVisibility(mAssumedVisibility); 50 mCullingManager = new CoherentHierarchicalCullingManager(mAssumedVisibilityForChc); 52 51 break; 53 52 … … 98 97 } 99 98 //----------------------------------------------------------------------- 100 void VisibilityManager::SetAssumedVisibility(unsigned int assumedVisibility) 99 void VisibilityManager::SetAssumedVisibilityForChc(unsigned int assumedVisibility) 100 101 101 { 102 mAssumedVisibility = assumedVisibility;102 mAssumedVisibilityForChc = assumedVisibility; 103 103 104 // in case we currently use chc 104 105 if (VisibilityManager::GetCullingManagerType() == 105 106 VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 106 107 { 107 108 dynamic_cast<CoherentHierarchicalCullingManager *>(mCullingManager)-> 108 SetAssumedVisibility( mAssumedVisibility);109 SetAssumedVisibility(assumedVisibility); 109 110 } 110 111 } 112 113 111 114 } // namespace GtpVisibility
Note: See TracChangeset
for help on using the changeset viewer.