- Timestamp:
- 10/21/05 19:53:30 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/include/CoherentHierarchicalCullingManager.h
r155 r345 27 27 if 0, the visibility is tested deterministically for each frame. 28 28 */ 29 void SetAssumedVisibility( unsigned int assumedVisibility);29 void SetAssumedVisibility(const unsigned int assumedVisibility); 30 30 31 31 protected: … … 40 40 /** Skip query for this node. 41 41 */ 42 void SkipQuery(HierarchyNode *node) ;42 void SkipQuery(HierarchyNode *node) const; 43 43 44 44 -
trunk/VUT/GtpVisibility/include/HierarchyInterface.h
r175 r345 42 42 @param node the current node 43 43 */ 44 virtual void PullUpVisibility(HierarchyNode *node) = 0;44 virtual void PullUpVisibility(HierarchyNode *node) const = 0; 45 45 /** Issue a occlusion query for this node. 46 46 @param node the current hierarchy node … … 96 96 @param visible the visible flag 97 97 */ 98 virtual void SetNodeVisible(HierarchyNode *node, const bool visible) = 0;98 virtual void SetNodeVisible(HierarchyNode *node, const bool visible) const = 0; 99 99 /** Returns true if node has the visible flag set. See set 100 100 */ … … 105 105 */ 106 106 virtual void SetLastVisited(HierarchyNode *node, 107 const unsigned int frameId) = 0;107 const unsigned int frameId) const = 0; 108 108 /** Returns frame id when this node was last visited by the traverser. See set 109 109 */ … … 122 122 */ 123 123 virtual void VisualizeCulledNode(HierarchyNode *node, 124 CullingType type) = NULL;124 CullingType type) const = 0; 125 125 126 126 /** Returns vector of visible hierarchy nodes from previous render. -
trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
r343 r345 25 25 unsigned int visiblePixels = 0; 26 26 bool isAvailable = false; 27 //Ogre::LogManager::getSingleton().logMessage("Coherent Hierarchical Culling");27 Ogre::LogManager::getSingleton().logMessage("Coherent Hierarchical Culling\n"); 28 28 29 29 //-- PART 1: process finished occlusion queries … … 37 37 38 38 queryQueue.pop(); 39 40 std::stringstream d2; d2 << "fetch node from query queue " << node; 41 Ogre::LogManager::getSingleton().logMessage(d2.str()); 39 42 40 43 if (visiblePixels > mVisibilityThreshold) … … 60 63 mHierarchyInterface->GetQueue()->pop(); 61 64 65 std::stringstream d2; d2 << "fetch node from hierarchy queue " << node; 66 Ogre::LogManager::getSingleton().logMessage(d2.str()); 67 62 68 bool intersects = false; 63 69 … … 81 87 bool wasVisible = mHierarchyInterface->IsNodeVisible(node) && 82 88 (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId() - 1); 83 89 if (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId()) 90 { 91 std::stringstream d2; d2 << "!!!!lastVisited: " << mHierarchyInterface->LastVisited(node) << " " << node; 92 Ogre::LogManager::getSingleton().logMessage(d2.str()); 93 std::stringstream d; d << "!!!!!frameid: " << mHierarchyInterface->GetFrameId() << " " << node << "\n"; 94 Ogre::LogManager::getSingleton().logMessage(d.str()); 95 } 84 96 // if we assume node to be visible in this frame => skip query 85 97 // TODO: check this (not the expected speed up) … … 93 105 // identify nodes that we cannot skip queries for 94 106 // geometry not only in leaves => test for renderable geometry 95 bool issueQuery = !wasVisible || mHierarchyInterface->HasGeometry(node); 96 107 bool issueQuery = (mHierarchyInterface->LastVisited(node) != mHierarchyInterface->GetFrameId()) 108 && (!wasVisible || mHierarchyInterface->HasGeometry(node)); 109 97 110 // reset node's visibility classification 98 111 mHierarchyInterface->SetNodeVisible(node, false); … … 100 113 // update node's visited flag 101 114 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 102 115 116 std::stringstream d2; d2 << "lastVisited: " << mHierarchyInterface->LastVisited(node) << " " << node; 117 Ogre::LogManager::getSingleton().logMessage(d2.str()); 118 103 119 // skip testing previously visible nodes without geometry 104 120 if (issueQuery) … … 113 129 if (wasVisible) 114 130 { 131 std::stringstream d2; d2 << "traversing node " << node; 132 Ogre::LogManager::getSingleton().logMessage(d2.str()); 115 133 mHierarchyInterface->TraverseNode(node); 116 134 } … … 120 138 } 121 139 //----------------------------------------------------------------------- 122 void CoherentHierarchicalCullingManager::SetAssumedVisibility( unsigned int assumedVisibility)140 void CoherentHierarchicalCullingManager::SetAssumedVisibility(const unsigned int assumedVisibility) 123 141 { 124 142 mAssumedVisibility = assumedVisibility; … … 133 151 } 134 152 //----------------------------------------------------------------------- 135 bool CoherentHierarchicalCullingManager::DecideVisible(HierarchyNode *node) const153 inline bool CoherentHierarchicalCullingManager::DecideVisible(HierarchyNode *node) const 136 154 { 137 / *bool result = rand() < mThreshold; std::stringstream d; d << "Assumed vis: " << mAssumedVisibility << ", result: " << result;138 Ogre::LogManager::getSingleton().logMessage(d.str()); return result;*/155 //bool result = rand() < mThreshold; std::stringstream d; d << "Assumed vis: " << mAssumedVisibility << ", result: " << result; 156 //Ogre::LogManager::getSingleton().logMessage(d.str()); return result; 139 157 140 158 return rand() < mThreshold; 141 159 } 142 160 //----------------------------------------------------------------------- 143 void CoherentHierarchicalCullingManager::SkipQuery(HierarchyNode *node) 161 inline void CoherentHierarchicalCullingManager::SkipQuery(HierarchyNode *node) const 144 162 { 145 163 // -- set node to be visible in this frame, then traverse it 164 std::stringstream d2; d2 << "skipping node " << node; 165 Ogre::LogManager::getSingleton().logMessage(d2.str()); 146 166 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 147 167 168 mHierarchyInterface->SetNodeVisible(node, true); 148 169 mHierarchyInterface->PullUpVisibility(node); 149 170 mHierarchyInterface->TraverseNode(node); -
trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
r259 r345 18 18 19 19 bool intersects = false; 20 20 21 //if (mHierarchyInterface->HasGeometry(node) && (!mHierarchyInterface->IsLeaf(node))) ++ mNumFrustumCulledNodes; 22 // Ogre::LogManager::getSingleton().logMessage("no geometry"); 23 //else if (!mHierarchyInterface->IsLeaf(node)) ++ mNumQueriesIssued;// Ogre::LogManager::getSingleton().logMessage("has geometry"); 24 /*if (!mHierarchyInterface->HasGeometry(node)) 25 Ogre::LogManager::getSingleton().logMessage("no geometry"); 26 else Ogre::LogManager::getSingleton().logMessage("has geometry");*/ 21 27 if (!mHierarchyInterface->CheckFrustumVisible(node, intersects)) 22 28 { … … 36 42 else 37 43 { 38 39 44 ++ mNumQueriesIssued; 40 45 -
trunk/VUT/Ogre/include/OgreBspHierarchyInterface.h
r158 r345 19 19 //bool getOption( const String &, void * ); 20 20 //bool getOptionKeys( StringVector &refKeys ); 21 void PullUpVisibility(GtpVisibility::HierarchyNode *node) ;21 void PullUpVisibility(GtpVisibility::HierarchyNode *node) const; 22 22 /** Traverses given node. 23 23 @param node current node … … 30 30 float GetSquaredDistance(GtpVisibility::HierarchyNode *node) const; 31 31 32 void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) ;32 void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) const; 33 33 void SetLastVisited(GtpVisibility::HierarchyNode *node, 34 const unsigned int frameId) ;34 const unsigned int frameId) const; 35 35 36 36 bool IsNodeVisible(GtpVisibility::HierarchyNode *node) const; -
trunk/VUT/Ogre/include/OgreOctreeHierarchyInterface.h
r174 r345 25 25 See setOption 26 26 */ 27 void PullUpVisibility(GtpVisibility::HierarchyNode *node) ;27 void PullUpVisibility(GtpVisibility::HierarchyNode *node) const; 28 28 29 29 /** Traverses and renders the given node. … … 38 38 float GetSquaredDistance(GtpVisibility::HierarchyNode *node) const; 39 39 40 void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) ;41 void SetLastVisited(GtpVisibility::HierarchyNode *node, const unsigned int frameId) ;40 void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) const; 41 void SetLastVisited(GtpVisibility::HierarchyNode *node, const unsigned int frameId) const; 42 42 43 43 bool IsNodeVisible(GtpVisibility::HierarchyNode *node) const; … … 45 45 46 46 void VisualizeCulledNode(GtpVisibility::HierarchyNode *node, 47 GtpVisibility::CullingType type) ;47 GtpVisibility::CullingType type) const; 48 48 49 49 void GetNodeGeometryList(GtpVisibility::HierarchyNode *node, -
trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h
r158 r345 26 26 void TraverseNode(GtpVisibility::HierarchyNode *node); 27 27 void RenderNode(GtpVisibility::HierarchyNode *node); 28 void PullUpVisibility(GtpVisibility::HierarchyNode *node) ;28 void PullUpVisibility(GtpVisibility::HierarchyNode *node) const; 29 29 bool HasGeometry(GtpVisibility::HierarchyNode *node) const; 30 30 float GetSquaredDistance(GtpVisibility::HierarchyNode *node) const; 31 31 32 void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) ;32 void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) const; 33 33 void SetLastVisited(GtpVisibility::HierarchyNode *node, 34 const unsigned int frameId) ;34 const unsigned int frameId) const; 35 35 36 36 bool IsNodeVisible(GtpVisibility::HierarchyNode *node) const; … … 40 40 41 41 void VisualizeCulledNode(GtpVisibility::HierarchyNode *node, 42 GtpVisibility::CullingType type) ;42 GtpVisibility::CullingType type) const; 43 43 44 44 void GetNodeGeometryList(GtpVisibility::HierarchyNode *node, -
trunk/VUT/Ogre/src/OgreBspHierarchyInterface.cpp
r158 r345 32 32 //----------------------------------------------------------------------- 33 33 void BspHierarchyInterface::SetNodeVisible(GtpVisibility::HierarchyNode *node, 34 const bool visible) 34 const bool visible) const 35 35 { 36 36 } 37 37 //----------------------------------------------------------------------- 38 38 void BspHierarchyInterface::SetLastVisited(GtpVisibility::HierarchyNode *node, 39 const unsigned int frameId) 39 const unsigned int frameId) const 40 40 { 41 41 } 42 42 //----------------------------------------------------------------------- 43 void BspHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node) 43 void BspHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node) const 44 44 { 45 45 } -
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r343 r345 33 33 Octree *nextChild = 34 34 octree->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]; 35 35 36 36 if (nextChild) 37 37 { 38 std::stringstream d2; d2 << "pushing node " << nextChild; 39 Ogre::LogManager::getSingleton().logMessage(d2.str()); 38 40 mDistanceQueue->push(nextChild); 39 41 } … … 57 59 { 58 60 AxisAlignedBox *box = &static_cast<Octree *>(node)->mBox; 59 Vector3 mid= ((box->getMaximum() - box->getMinimum()) * 0.5) + box->getMinimum();60 61 return (mCullCamera->getDerivedPosition() - mid).squaredLength();61 Vector3 pos = ((box->getMaximum() - box->getMinimum()) * 0.5) + box->getMinimum(); 62 63 return (mCullCamera->getDerivedPosition() - pos).squaredLength(); 62 64 } 63 65 //----------------------------------------------------------------------- 64 66 void OctreeHierarchyInterface::SetNodeVisible(GtpVisibility::HierarchyNode *node, 65 const bool visible) 67 const bool visible) const 66 68 { 67 69 #ifdef GTP_VISIBILITY_MODIFIED_OGRE … … 71 73 //----------------------------------------------------------------------- 72 74 void OctreeHierarchyInterface::SetLastVisited(GtpVisibility::HierarchyNode *node, 73 const unsigned int frameId) 75 const unsigned int frameId) const 74 76 { 75 77 #ifdef GTP_VISIBILITY_MODIFIED_OGRE … … 78 80 } 79 81 //----------------------------------------------------------------------- 80 void OctreeHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node) 82 void OctreeHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node) const 81 83 { 82 84 #ifdef GTP_VISIBILITY_MODIFIED_OGRE … … 140 142 //----------------------------------------------------------------------- 141 143 void OctreeHierarchyInterface::VisualizeCulledNode(GtpVisibility::HierarchyNode *node, 142 GtpVisibility::CullingType type) 144 GtpVisibility::CullingType type) const 143 145 { 144 146 WireBoundingBox *box = static_cast<Octree *>(node)->getWireBoundingBox(); -
trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
r174 r345 62 62 } 63 63 //----------------------------------------------------------------------- 64 void SceneNodeHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node) 64 void SceneNodeHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node) const 65 65 { 66 66 #ifdef GTP_VISIBILITY_MODIFIED_OGRE … … 81 81 //----------------------------------------------------------------------- 82 82 void SceneNodeHierarchyInterface::SetNodeVisible(GtpVisibility::HierarchyNode *node, 83 const bool visible) 83 const bool visible) const 84 84 { 85 85 #ifdef GTP_VISIBILITY_MODIFIED_OGRE … … 90 90 //----------------------------------------------------------------------- 91 91 void SceneNodeHierarchyInterface::SetLastVisited(GtpVisibility::HierarchyNode *node, 92 const unsigned int frameId) 92 const unsigned int frameId) const 93 93 { 94 94 #ifdef GTP_VISIBILITY_MODIFIED_OGRE … … 131 131 //----------------------------------------------------------------------- 132 132 void SceneNodeHierarchyInterface::VisualizeCulledNode(GtpVisibility::HierarchyNode *node, 133 GtpVisibility::CullingType type) 133 GtpVisibility::CullingType type) const 134 134 { 135 135 // TODO -
trunk/VUT/chcdemo/HierarchyNode.cpp
r74 r345 459 459 } 460 460 461 462 float HierarchyNode::GetDistance()463 {464 return mDistance;465 }466 467 468 461 void HierarchyNode::SetDistance(float distance) 469 462 { -
trunk/VUT/chcdemo/HierarchyNode.h
r87 r345 53 53 bool Visible(); 54 54 //! last time this node was visited (in framenumber) 55 int LastVisited();55 unsigned int LastVisited(); 56 56 //! sets visible flag 57 57 void SetVisible(bool visible); 58 58 //! sets timestamp (current framenumber) 59 void SetLastVisited( int lastVisited);59 void SetLastVisited(unsigned int lastVisited); 60 60 //! is this node a leaf node (i.e., geometry) 61 61 bool IsLeaf(); -
trunk/VUT/chcdemo/RenderTraverser.cpp
r86 r345 199 199 // update node's visited flag 200 200 node->SetLastVisited(mFrameID); 201 201 //if (mFrameID == node->LastVisited()) mNumFrustumCulledNodes ++; 202 202 // skip testing previously visible interior nodes 203 203 if(leafOrWasInvisible) … … 215 215 { 216 216 // for stats 217 mNumFrustumCulledNodes ++;217 //mNumFrustumCulledNodes ++; 218 218 } 219 219 } … … 331 331 // get next available test id 332 332 unsigned int occlusionQuery = mOcclusionQueries[mCurrentTestIdx++]; 333 333 mNumFrustumCulledNodes ++; 334 334 node->SetOcclusionQuery(occlusionQuery); 335 335 // do the actual occlusion query for this node -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r343 r345 49 49 Real TerrainFrameListener::msObjectScales[] = 50 50 { 51 0. 1,51 0.07, 52 52 0.03, 53 53 //0.1, … … 191 191 192 192 // arb or nv queries 193 mSceneMgr->setOption("UseArbQueries", &mUseArbQueries);193 //mSceneMgr->setOption("UseArbQueries", &mUseArbQueries); 194 194 195 195 // reset statistics -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r254 r345 302 302 303 303 // if no objects in file, we generate new objects 304 if (!mTerrainContentGenerator->LoadObjects("objects.out"))305 {304 //if (!mTerrainContentGenerator->LoadObjects("objects.out")) 305 //{ 306 306 // the objects are generated randomly distributed over the terrain 307 307 generateScene(900, 0); // create soldiers, trees, ninjas 308 308 generateScene(500, 1); 309 309 generateScene(100, 2); 310 }310 //} 311 311 312 312 // no limitations on height => it is possible for the user to put single … … 317 317 void TestCullingTerrainApplication::generateScene(int num, int objectType) 318 318 { 319 Vector3 scale(TerrainFrameListener::msObjectScales[objectType], 320 TerrainFrameListener::msObjectScales[objectType], 321 TerrainFrameListener::msObjectScales[objectType]); 319 float val = TerrainFrameListener::msObjectScales[objectType]; 320 Vector3 scale(val, val, val); 322 321 323 322 // to provide much occlusion, … … 325 324 mTerrainContentGenerator->SetMinPos(Vector3(mTerrainMinPos)); 326 325 mTerrainContentGenerator->SetMaxPos(Vector3(mTerrainMaxPos.x, 75.0f, mTerrainMaxPos.z)); 327 326 std::stringstream d; d << "objscale: " << scale[0]; 327 Ogre::LogManager::getSingleton().logMessage(d.str()); 328 328 mTerrainContentGenerator->SetScale(scale); 329 329 mTerrainContentGenerator->SetOffset(TerrainFrameListener::msObjectTerrainOffsets[objectType]); -
trunk/VUT/work/iv/IVFrameListener.cpp
r343 r345 126 126 mSceneMgr->setOption("DelayRenderTransparents", &delayRenderTransparents); 127 127 mSceneMgr->setOption("UseDepthPass", &mUseDepthPass); 128 mSceneMgr->setOption("UseArbQueries", &mUseArbQueries);128 //mSceneMgr->setOption("UseArbQueries", &mUseArbQueries); 129 129 130 130 mSceneMgr->setOption("ShowOctree", &mShowOctree);
Note: See TracChangeset
for help on using the changeset viewer.