- Timestamp:
- 07/05/05 18:35:47 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 30 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 -
trunk/VUT/Ogre/include/OgreBspHierarchyInterface.h
r154 r155 22 22 /** Traverses given node. 23 23 @param node current node 24 @remark pushes children on distance queue24 @remark pushes children on the distance queue 25 25 */ 26 void Traverse Node(GtpVisibility::HierarchyNode *node);26 void TraverseAndRenderNode(GtpVisibility::HierarchyNode *node); 27 27 void RenderNode(GtpVisibility::HierarchyNode *node); 28 28 bool IsLeaf(GtpVisibility::HierarchyNode *node) const; -
trunk/VUT/Ogre/include/OgreOctreeHierarchyInterface.h
r154 r155 29 29 /** Traverses given node. 30 30 @param node current node 31 @remark pushes children on distance queue31 @remark pushes children on a distance queue. 32 32 */ 33 void Traverse Node(GtpVisibility::HierarchyNode *node);33 void TraverseAndRenderNode(GtpVisibility::HierarchyNode *node); 34 34 void RenderNode(GtpVisibility::HierarchyNode *node); 35 35 bool IsLeaf(GtpVisibility::HierarchyNode *node) const; … … 46 46 GtpVisibility::CullingType type); 47 47 48 /*bool FindVisibleObjects(GtpVisibility::HierarchyNode *node, 49 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 50 bool includeChildren = false);*/ 51 52 void GetGeometry(GtpVisibility::HierarchyNode *node, 48 void GetNodeGeometryList(GtpVisibility::HierarchyNode *node, 53 49 GtpVisibility::GeometryList *geometryList, 54 50 bool includeChildren); … … 57 53 58 54 int GetNodeId(GtpVisibility::HierarchyNode *node); 55 56 GtpVisibility::HierarchyNode *GetNextNode(); 59 57 60 58 protected: … … 69 67 */ 70 68 Real GetSquaredViewDepth(const Camera* cam, const AxisAlignedBox* box) const; 69 70 int mCurrentOctreePosition; 71 71 }; 72 72 } // namespace Ogre -
trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
r139 r155 47 47 @remark This is a convenience method which resets the stats, 48 48 sets the current camera, and initialises the distance queue. 49 @param root root of the hierarchy50 49 @param cam the actual camera definding the view frustum 51 50 @param cullCam the camera used for culling. 52 @remark If null, the actual camera is used for both viewing and culling51 @remark If cullCam is null, the actual camera is used for both viewing and culling 53 52 */ 54 void InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam = NULL, 55 int leavePassesInQueue = 0); 53 void InitTraversal(Camera *cam, Camera *cullCam = NULL, int leavePassesInQueue = 0); 56 54 /** Checks if the node is visible from the current view frustum. 57 55 @param node the current node … … 95 93 /** see set 96 94 */ 97 bool Get UseOptimization();95 bool GetTestGeometryForVisibleLeaves(); 98 96 /** see set 99 97 */ -
trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h
r154 r155 24 24 bool IsLeaf(GtpVisibility::HierarchyNode *node) const; 25 25 26 void Traverse Node(GtpVisibility::HierarchyNode *node);26 void TraverseAndRenderNode(GtpVisibility::HierarchyNode *node); 27 27 void RenderNode(GtpVisibility::HierarchyNode *node); 28 28 void PullUpVisibility(GtpVisibility::HierarchyNode *node); … … 46 46 bool includeChildren = false);*/ 47 47 48 void Get Geometry(GtpVisibility::HierarchyNode *node,48 void GetNodeGeometryList(GtpVisibility::HierarchyNode *node, 49 49 GtpVisibility::GeometryList *geometryList, 50 50 bool includeChildren); … … 53 53 54 54 int GetNodeId(GtpVisibility::HierarchyNode *node); 55 56 GtpVisibility::HierarchyNode *GetNextNode(); 55 57 }; 56 58 -
trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
r153 r155 122 122 int mLeavePassesInQueue; 123 123 ShadowTechnique mSavedShadowTechnique; 124 125 bool mRenderOnlyBoundingBoxes; 124 126 }; 125 127 -
trunk/VUT/Ogre/resources/VisibilityDemo.overlay
r147 r155 22 22 left 5 23 23 top 5 24 width 4 0024 width 430 25 25 height 90 26 26 material Core/StatsBlockCenter … … 46 46 element TextArea(Example/Visibility/AlgorithmInfo): Example/Visibility/Templates/BasicText 47 47 { 48 left 17048 left 210 49 49 top 5 50 width 9050 width 120 51 51 height 30 52 52 caption : … … 57 57 left 5 58 58 top 20 59 width 9059 width 120 60 60 height 30 61 61 caption [-][+] Threshold … … 63 63 element TextArea(Example/Visibility/ThresholdInfo): Example/Visibility/Templates/BasicText 64 64 { 65 left 17065 left 210 66 66 top 20 67 width 9068 height 30 69 caption : 70 } 71 element TextArea(Example/Visibility/ UseOptimization): Example/Visibility/Templates/BasicText67 width 120 68 height 30 69 caption : 70 } 71 element TextArea(Example/Visibility/TestGeometryForVisibleLeaves): Example/Visibility/Templates/BasicText 72 72 { 73 73 left 5 74 74 top 35 75 width 9076 height 30 77 caption [ O] Optimization78 } 79 element TextArea(Example/Visibility/ UseOptimizationInfo): Example/Visibility/Templates/BasicText80 { 81 left 17075 width 120 76 height 30 77 caption [G] Test Geometry For Leaves 78 } 79 element TextArea(Example/Visibility/TestGeometryForVisibleLeavesInfo): Example/Visibility/Templates/BasicText 80 { 81 left 210 82 82 top 35 83 width 9083 width 120 84 84 height 30 85 85 caption : … … 89 89 left 5 90 90 top 50 91 width 9091 width 120 92 92 height 30 93 93 caption [X] Depth pass … … 95 95 element TextArea(Example/Visibility/UseDepthPassInfo): Example/Visibility/Templates/BasicText 96 96 { 97 left 17097 left 210 98 98 top 50 99 width 9099 width 120 100 100 height 30 101 101 caption : … … 105 105 left 5 106 106 top 65 107 width 90107 width 120 108 108 height 30 109 109 caption [8][9] Assumed Visibility … … 112 112 element TextArea(Example/Visibility/AssumedVisibilityInfo): Example/Visibility/Templates/BasicText 113 113 { 114 left 170114 left 210 115 115 top 65 116 width 90116 width 120 117 117 height 30 118 118 caption : … … 128 128 top 5 129 129 width 320 130 height 1 20130 height 150 131 131 material Core/StatsBlockCenter 132 132 border_size 1 1 1 1 … … 249 249 left 180 250 250 top 95 251 width 90 252 font_name TrebuchetMSBold 253 caption : 254 } 255 element TextArea(Example/Visibility/DelayedQueriesIssued): Example/Visibility/Templates/BasicText 256 { 257 left 5 258 top 110 259 width 180 260 height 30 261 caption Avg. queries issued 262 } 263 element TextArea(Example/Visibility/DelayedQueriesIssuedInfo): Example/Visibility/Templates/BasicText 264 { 265 left 180 266 top 110 267 width 90 268 font_name TrebuchetMSBold 269 caption : 270 } 271 element TextArea(Example/Visibility/DelayedTraversedNodes): Example/Visibility/Templates/BasicText 272 { 273 left 5 274 top 125 275 width 180 276 height 30 277 caption Avg. traversed Nodes 278 } 279 element TextArea(Example/Visibility/DelayedTraversedNodesInfo): Example/Visibility/Templates/BasicText 280 { 281 left 180 282 top 125 251 283 width 90 252 284 font_name TrebuchetMSBold -
trunk/VUT/Ogre/src/OgreBspHierarchyInterface.cpp
r87 r155 12 12 } 13 13 //----------------------------------------------------------------------- 14 void BspHierarchyInterface::Traverse Node(GtpVisibility::HierarchyNode *node)14 void BspHierarchyInterface::TraverseAndRenderNode(GtpVisibility::HierarchyNode *node) 15 15 { 16 16 } -
trunk/VUT/Ogre/src/OgreItemBufferQueryManager.cpp
r154 r155 32 32 SceneManager *sm = pfHierarchyInterface->GetSceneManager(); 33 33 34 // -- Render scene as item buffer (e.g., color coded objects)34 // ---- Render scene as item buffer (i.e., objects with their id as color codes) 35 35 36 36 // const_cast allowed because camera is not changed in renderScene … … 49 49 mViewport->setBackgroundColour(ColourValue(0, 0, 0, 0)); 50 50 51 //pfHierarchyInterface->GetRenderSystem()->clearFrameBuffer(FBT_COLOUR); 52 // render item buffer51 52 // --- render item buffer 53 53 pfHierarchyInterface->GetSceneManager()->_renderScene(pCam, mViewport, false); 54 54 55 56 55 57 // reset old overlay status 56 58 mViewport->setOverlaysEnabled(overlayEnabled); … … 84 86 ((*visibleGeometry)[id]).AddVisibility(1, 1); 85 87 } 86 /*else { std::stringstream d;87 d << "adding pixel to geometry with id: " << id << ", buf 1: " << (int)buf[idx] << ", buf 2: " << (int)buf[idx + 1] << ", buf 3: " << (int)buf[idx + 2];88 LogManager::getSingleton().logMessage(d.str()); }*/89 88 } 90 89 … … 101 100 return; 102 101 102 103 103 mWasInitialised = true; 104 104 105 SceneManager::EntityIterator it = 106 dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)-> 107 GetSceneManager()->getEntityIterator(); 105 SceneManager *sm = 106 dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->GetSceneManager(); 107 108 SceneManager::EntityIterator it = sm->getEntityIterator(); 108 109 109 110 // TODO: make this more efficient … … 115 116 visibleGeometry->push_back(GtpVisibility::MeshInfo(it.getNext(), 0, 0)); 116 117 } 118 119 // -- initialise hierarchy interface for simple node traversal 120 mHierarchyInterface->InitTraversal(false); 121 122 GtpVisibility::HierarchyNode *node = NULL; 123 124 while (node = mHierarchyInterface->GetNextNode()) 125 { 126 visibleNodes->push_back(GtpVisibility::NodeInfo(node, 0, 0)); 127 } 117 128 } 129 118 130 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreOcclusionQueriesQueryManager.cpp
r154 r155 83 83 if (i == 0) 84 84 { 85 mHierarchyInterface->Get Geometry(*nodeIt, &geometryList, false);85 mHierarchyInterface->GetNodeGeometryList(*nodeIt, &geometryList, false); 86 86 } 87 87 } … … 105 105 mViewport->setOverlaysEnabled(overlayEnabled); 106 106 107 // ---- collect results107 // ---- collect results 108 108 GtpVisibility::QueryList::iterator visQueryIt, projQueryIt; 109 109 … … 135 135 } 136 136 137 // ---- queries for geometry137 // ---- queries for geometry 138 138 geometryIt_end = geometryList.end(); 139 139 … … 154 154 ++visQueryIt; 155 155 156 // approximate depth ordering during rendering =>156 // WARNING: approximate depth ordering during rendering => 157 157 // geometry maybe occluded 158 158 if (visiblePixels > 0) -
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r154 r155 10 10 //----------------------------------------------------------------------- 11 11 OctreeHierarchyInterface::OctreeHierarchyInterface(OctreeSceneManager *sm, RenderSystem *rsys): 12 SceneNodeHierarchyInterface(sm, rsys) 13 { 14 } 15 //----------------------------------------------------------------------- 16 void OctreeHierarchyInterface::Traverse Node(GtpVisibility::HierarchyNode *node)12 SceneNodeHierarchyInterface(sm, rsys), mCurrentOctreePosition(0) 13 { 14 } 15 //----------------------------------------------------------------------- 16 void OctreeHierarchyInterface::TraverseAndRenderNode(GtpVisibility::HierarchyNode *node) 17 17 { 18 18 ++ mNumTraversedNodes; … … 84 84 Octree *octant = static_cast<Octree *>(node); 85 85 86 while (octant && !octant->isOctreeVisible())86 while (octant && !octant->isOctreeVisible()) 87 87 { 88 88 octant->setOctreeVisible(true); … … 129 129 AxisAlignedBox *OctreeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 130 130 { 131 if (node != m PreviousNode)132 { 133 m PreviousNode = node;131 if (node != mSavedNode) 132 { 133 mSavedNode = node; 134 134 //static_cast<Octree *>(node)->_getCullBounds(&mBox); 135 135 mBox = static_cast<Octree *>(node)->_getWorldAABB(); 136 //std::stringstream d; d << mBox;LogManager::getSingleton().logMessage(d.str());137 136 } 138 137 … … 157 156 } 158 157 //----------------------------------------------------------------------- 159 void OctreeHierarchyInterface::Get Geometry(GtpVisibility::HierarchyNode *node,158 void OctreeHierarchyInterface::GetNodeGeometryList(GtpVisibility::HierarchyNode *node, 160 159 GtpVisibility::GeometryList *geometryList, 161 160 bool includeChildren) … … 166 165 for (nodeIt = static_cast<Octree *>(node)->mNodes.begin(); nodeIt != nodeIt_end; ++nodeIt) 167 166 { 168 SceneNodeHierarchyInterface::Get Geometry(*nodeIt, geometryList, includeChildren);167 SceneNodeHierarchyInterface::GetNodeGeometryList(*nodeIt, geometryList, includeChildren); 169 168 } 170 169 } … … 180 179 } 181 180 //----------------------------------------------------------------------- 182 /*bool OctreeHierarchyInterface::FindVisibleObjects(GtpVisibility::HierarchyNode *node, 183 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 184 bool includeChildren) 185 { 186 bool foundVisible = false; 187 188 PlatformOcclusionQuery query(mRenderSystem); 189 190 NodeList *nodes = &static_cast<Octree *>(node)->mNodes; 181 GtpVisibility::HierarchyNode *OctreeHierarchyInterface::GetNextNode() 182 { 183 if (mTraversalStack->empty()) 184 return NULL; 191 185 192 NodeList::const_iterator nodeIt = nodes->begin(), nodeIt_end; 193 194 nodeIt_end = nodes->end(); 195 196 while (nodeIt != nodeIt_end) 197 { 198 OctreeNode *octreeNode = (*nodeIt); 199 if (SceneNodeHierarchyInterface::FindVisibleObjects(octreeNode, visibleGeometry, includeChildren)) 186 Octree *octree = static_cast<Octree *>(mTraversalStack->top()); 187 mTraversalStack->pop(); 188 189 for(int i=0; i<8; ++i) 190 { 191 Octree *nextChild = 192 octree->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]; 193 194 if (nextChild) 200 195 { 201 foundVisible = true;196 mTraversalStack->push(nextChild); 202 197 } 203 ++nodeIt; 204 } 205 206 return foundVisible; 207 }*/ 208 198 } 199 200 return octree; 201 } 202 209 203 } // namespace Ogre -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r139 r155 130 130 } 131 131 //----------------------------------------------------------------------- 132 void PlatformHierarchyInterface::InitFrame(GtpVisibility::HierarchyNode *root, 133 Camera *cam, Camera *cullCam, int leavePassesInQueue) 134 { 135 GtpVisibility::HierarchyInterface::InitFrame(root); 136 137 mPreviousNode = NULL; 132 void PlatformHierarchyInterface::InitTraversal(Camera *cam, Camera *cullCam, int leavePassesInQueue) 133 { 134 GtpVisibility::HierarchyInterface::InitTraversal(); 135 136 mSavedNode = NULL; 138 137 mLeavePassesInQueue = leavePassesInQueue; 139 138 … … 178 177 // If camera for culling is different from camera for rendering or only solids 179 178 // will be rendereded => cannot optimize 180 if (m UseOptimization&& (mCamera == mCullCamera) && wasVisible && IsLeaf(node))179 if (mTestGeometryForVisibleLeaves && (mCamera == mCullCamera) && wasVisible && IsLeaf(node)) 181 180 { 182 181 //LogManager::getSingleton().logMessage("render node\n"); … … 253 252 } 254 253 //----------------------------------------------------------------------- 255 bool PlatformHierarchyInterface::Get UseOptimization()256 { 257 return m UseOptimization;254 bool PlatformHierarchyInterface::GetTestGeometryForVisibleLeaves() 255 { 256 return mTestGeometryForVisibleLeaves; 258 257 } 259 258 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
r154 r155 17 17 } 18 18 //----------------------------------------------------------------------- 19 void SceneNodeHierarchyInterface::Traverse Node(GtpVisibility::HierarchyNode *node)19 void SceneNodeHierarchyInterface::TraverseAndRenderNode(GtpVisibility::HierarchyNode *node) 20 20 { 21 21 ++ mNumTraversedNodes; … … 121 121 { 122 122 // only create renderable bounding box for new node 123 if (node != m PreviousNode)123 if (node != mSavedNode) 124 124 { 125 m PreviousNode = node;125 mSavedNode = node; 126 126 mBox = static_cast<SceneNode *>(node)->_getWorldAABB(); 127 127 } … … 136 136 } 137 137 //----------------------------------------------------------------------- 138 void SceneNodeHierarchyInterface::Get Geometry(GtpVisibility::HierarchyNode *node,138 void SceneNodeHierarchyInterface::GetNodeGeometryList(GtpVisibility::HierarchyNode *node, 139 139 GtpVisibility::GeometryList *geometryList, 140 140 bool includeChildren) … … 151 151 { 152 152 Entity *ent = static_cast<Entity *>(movable); 153 //std::stringstream d; d << "ent " << ent->getName(); LogManager::getSingleton().logMessage(d.str()); 153 //std::stringstream d; d << "ent " << ent->getName(); 154 //LogManager::getSingleton().logMessage(d.str()); 154 155 geometryList->push_back(ent); 155 156 } … … 166 167 return static_cast<SceneNode *>(node)->getId(); 167 168 } 169 //----------------------------------------------------------------------- 170 GtpVisibility::HierarchyNode *SceneNodeHierarchyInterface::GetNextNode() 171 { 172 if (mTraversalStack->empty()) 173 return NULL; 174 175 SceneNode *node = static_cast<SceneNode *>(mTraversalStack->top()); 176 mTraversalStack->pop(); 177 178 // internal node: add children to priority queue for further processing 179 Node::ChildNodeIterator it = node->getChildIterator(); 180 181 while (it.hasMoreElements()) 182 { 183 mTraversalStack->push(it.getNext()); 184 } 185 186 return node; 187 } 168 188 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r154 r155 184 184 bool leaveTransparentsInQueue = mDelayRenderTransparents && !mUseDepthPass; 185 185 186 // -- initialise interface for rendering traversal of the hierarchy 187 mHierarchyInterface->SetHierarchyRoot(mOctree); 188 186 189 // possible two cameras (one for culling, one for rendering) 187 mHierarchyInterface->Init Frame(mOctree,mCameraInProgress,190 mHierarchyInterface->InitTraversal(mCameraInProgress, 188 191 mCullCamera ? getCamera("CullCamera") : NULL, 189 192 leaveTransparentsInQueue); 193 190 194 191 195 // reset culling manager stats … … 352 356 d << "Depth pass: " << StringConverter::toString(mUseDepthPass) << ", " 353 357 << "Delay transparents: " << StringConverter::toString(mDelayRenderTransparents) << ", " 354 << "Use optimization: " << StringConverter::toString(mHierarchyInterface->Get UseOptimization()) << ", "358 << "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetTestGeometryForVisibleLeaves()) << ", " 355 359 << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << "\n" 356 360 << "Hierarchy nodes: " << mNumOctreeNodes << ", " -
trunk/VUT/Ogre/src/OgreVisibilityOptionsManager.cpp
r146 r155 26 26 if (key == "AssumedVisibility") 27 27 { 28 mVisibilityManager->SetAssumedVisibility (*static_cast<const int *>(val));28 mVisibilityManager->SetAssumedVisibilityForChc(*static_cast<const int *>(val)); 29 29 return true; 30 30 } 31 if (key == " UseOptimization")31 if (key == "TestGeometryForVisibleLeaves") 32 32 { 33 mHierarchyInterface-> SetUseOptimization(*static_cast<const bool *>(val));33 mHierarchyInterface->TestGeometryForVisibleLeaves(*static_cast<const bool *>(val)); 34 34 return true; 35 35 } -
trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp
r139 r155 40 40 if (!mShowVisualization) 41 41 { 42 // two cameras (one for culling, one for rendering)43 mHierarchyInterface->Init Frame(mSceneRoot,mCameraInProgress);42 mHierarchyInterface->SetHierarchyRoot(mSceneRoot); 43 mHierarchyInterface->InitTraversal(mCameraInProgress); 44 44 45 45 // reset culling manager stats -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r154 r155 30 30 mEnableDepthWrite(true), 31 31 mSkipTransparents(false), 32 mSavedShadowTechnique(SHADOWTYPE_NONE) 32 mSavedShadowTechnique(SHADOWTYPE_NONE), 33 mRenderOnlyBoundingBoxes(false) 33 34 { 34 35 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); … … 126 127 if (mRenderNodesForViz) 127 128 { 128 OctreeNode *node = *it; 129 if ((node->numAttachedObjects() > 0) && (node->numChildren() == 0) 130 && node->getAttachedObject(0)->getMovableType() == "Entity") 131 getRenderQueue()->addRenderable(node); 129 if (((*it)->numAttachedObjects() > 0) && ((*it)->numChildren() == 0) 130 && (*it)->getAttachedObject(0)->getMovableType() == "Entity") 131 getRenderQueue()->addRenderable((*it)); 132 132 133 133 // addbounding boxes instead of node itself … … 213 213 PrepareVisualization(cam); 214 214 } 215 else 215 else if (mRenderOnlyBoundingBoxes) 216 { 217 } 218 else 216 219 { 217 220 // for hierarchical culling, we interleave identification 218 221 // and rendering of objects in _renderVisibibleObjects 219 222 220 // only for the shadow pass we use standard rendering 223 // for the shadow pass we use only standard rendering 224 // because of low occlusion 221 225 if (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 222 226 mIlluminationStage == IRS_RENDER_TO_TEXTURE) … … 225 229 } 226 230 // only shadow casters will be rendered in shadow texture pass 227 // mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);231 // mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 228 232 } 229 233 //TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); … … 236 240 void VisibilityTerrainSceneManager::_renderVisibleObjects() 237 241 { 242 // save ambient light to reset later 238 243 ColourValue savedAmbient = mAmbientLight; 239 244 240 // visualization or shadow pass: apply standard rendering 241 if (mShowVisualization || (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 242 mIlluminationStage == IRS_RENDER_TO_TEXTURE)) 245 // --- apply standard rendering for some cases 246 // e.g., visualization, shadow pass 247 248 if (mShowVisualization || mRenderOnlyBoundingBoxes || 249 (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && mIlluminationStage == IRS_RENDER_TO_TEXTURE)) 243 250 { 244 251 IlluminationRenderStage savedStage = mIlluminationStage; 245 252 246 253 if (mShowVisualization) 247 // disable illumination stage so we haveno shadows in visualization254 // disable illumination stage because we want no shadows in visualization 248 255 mIlluminationStage = IRS_NONE; 249 256 … … 455 462 d << "Depth pass: " << StringConverter::toString(mUseDepthPass) << ", " 456 463 << "Delay transparents: " << StringConverter::toString(mDelayRenderTransparents) << ", " 457 << "Use optimization: " << StringConverter::toString(mHierarchyInterface->Get UseOptimization()) << ", "464 << "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetTestGeometryForVisibleLeaves()) << ", " 458 465 << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", " 459 466 << "Hierarchy nodes: " << mNumOctreeNodes << ", " … … 699 706 (mLeavePassesInQueue & RenderPriorityGroup::TRANSPARENT_PASSES); 700 707 708 // -- initialise interface for rendering traversal of the hierarchy 709 mHierarchyInterface->SetHierarchyRoot(mOctree); 710 701 711 // possible two cameras (one for culling, one for rendering) 702 mHierarchyInterface->Init Frame(mOctree, cam,703 mCullCamera ? getCamera("CullCamera") : NULL,704 mLeavePassesInQueue);712 mHierarchyInterface->InitTraversal(mCameraInProgress, 713 mCullCamera ? getCamera("CullCamera") : NULL, 714 mLeavePassesInQueue); 705 715 706 716 //std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;LogManager::getSingleton().logMessage(d.str()); -
trunk/VUT/work/TestCulling/TestCullingApplication.cpp
r139 r155 112 112 mShowOctree(false), 113 113 mUseDepthPass(false), 114 m UseOptimization(true),114 mTestGeometryForVisibleLeaves(true), 115 115 mShowVisualization(false), 116 116 mVisualizeCulledNodes(false) … … 137 137 mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/RenderedNodesInfo"); 138 138 mObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ObjectsInfo"); 139 m UseOptimizationInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseOptimizationInfo");139 mTestGeometryForVisibleLeavesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/TestGeometryForVisibleLeavesInfo"); 140 140 mQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueriesIssuedInfo"); 141 141 142 142 143 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); … … 148 149 mRenderedNodesInfo->setCaption(": 0"); 149 150 mObjectsInfo->setCaption(": 0"); 150 m UseOptimizationInfo->setCaption(": true");151 mTestGeometryForVisibleLeavesInfo->setCaption(": true"); 151 152 mQueriesIssuedInfo->setCaption(": 0"); 153 152 154 153 155 setAlgorithm(mCurrentAlgorithm); 154 156 155 mSceneMgr->setOption(" UseOptimization", &mUseOptimization);157 mSceneMgr->setOption("TestGeometryForVisibleLeaves", &mTestGeometryForVisibleLeaves); 156 158 mSceneMgr->setOption("UseDepthPass", &mUseDepthPass); 157 159 mSceneMgr->setOption("ShowVizualisation", &mShowVisualization); … … 236 238 KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); 237 239 KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 238 KEY_PRESSED(KC_O, 0.3, toggle UseOptimization());240 KEY_PRESSED(KC_O, 0.3, toggleTestGeometryForVisibleLeaves()); 239 241 KEY_PRESSED(KC_C, 0.3, toggleUseDepthPass()); 240 242 KEY_PRESSED(KC_V, 0.3, toggleShowViz()); … … 264 266 } 265 267 //----------------------------------------------------------------------- 266 void TerrainFrameListener::toggle UseOptimization()267 { 268 m UseOptimization = !mUseOptimization;269 270 mSceneMgr->setOption(" UseOptimization", &mUseOptimization);271 272 if(m UseOptimization)273 m UseOptimizationInfo->setCaption(": true");268 void TerrainFrameListener::toggleTestGeometryForVisibleLeaves() 269 { 270 mTestGeometryForVisibleLeaves = !mTestGeometryForVisibleLeaves; 271 272 mSceneMgr->setOption("TestGeometryForVisibleLeaves", &mTestGeometryForVisibleLeaves); 273 274 if(mTestGeometryForVisibleLeaves) 275 mTestGeometryForVisibleLeavesInfo->setCaption(": true"); 274 276 else 275 m UseOptimizationInfo->setCaption(": false");277 mTestGeometryForVisibleLeavesInfo->setCaption(": false"); 276 278 } 277 279 //----------------------------------------------------------------------- -
trunk/VUT/work/TestCulling/TestCullingApplication.h
r133 r155 64 64 void changeThreshold(int incr); 65 65 void updateStats(); 66 void toggle UseOptimization();66 void toggleTestGeometryForVisibleLeaves(); 67 67 void toggleShowOctree(); 68 68 void toggleUseDepthPass(); … … 87 87 OverlayElement *mRenderedNodesInfo; 88 88 OverlayElement *mObjectsInfo; 89 OverlayElement *m UseOptimizationInfo;89 OverlayElement *mTestGeometryForVisibleLeavesInfo; 90 90 OverlayElement *mQueriesIssuedInfo; 91 91 92 92 SceneContentGenerator *mSceneContentGenerator; 93 93 94 bool m UseOptimization;94 bool mTestGeometryForVisibleLeaves; 95 95 bool mShowOctree; 96 96 bool mUseDepthPass; -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r154 r155 89 89 mShowOctree(false), 90 90 mUseDepthPass(false), 91 m UseOptimization(true),91 mTestGeometryForVisibleLeaves(true), 92 92 mShowVisualization(false), 93 93 mCullCamera(false), … … 101 101 mShowQueryStats(false), 102 102 mQueryManager(NULL), 103 mVisibilityManager(NULL) 103 mVisibilityManager(NULL), 104 mDelayedQueriesIssued(0.0), 105 mDelayedTraversedNodes(0.0) 104 106 { 105 107 //mInputDevice = PlatformManager::getSingleton().createInputReader(); … … 129 131 mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/AlgorithmInfo"); 130 132 mThresholdInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ThresholdInfo"); 131 m UseOptimizationInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseOptimizationInfo");133 mTestGeometryForVisibleLeavesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/TestGeometryForVisibleLeavesInfo"); 132 134 mUseDepthPassInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseDepthPassInfo"); 133 135 mAssumedVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/AssumedVisibilityInfo"); … … 140 142 mObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ObjectsInfo"); 141 143 mQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueriesIssuedInfo"); 142 144 mDelayedQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/DelayedQueriesIssuedInfo"); 145 mDelayedTraversedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/DelayedTraversedNodesInfo"); 146 143 147 mAlgorithmInfo->setCaption(": " + currentAlgorithmCaptions[mCurrentAlgorithm]); 144 148 mThresholdInfo->setCaption(": 0"); … … 149 153 mRenderedNodesInfo->setCaption(": 0"); 150 154 mObjectsInfo->setCaption(": 0"); 151 m UseOptimizationInfo->setCaption(": true");155 mTestGeometryForVisibleLeavesInfo->setCaption(": true"); 152 156 mUseDepthPassInfo->setCaption(": false"); 153 157 mQueriesIssuedInfo->setCaption(": 0"); 154 158 mAssumedVisibilityInfo->setCaption(": 0"); 155 159 mDelayedQueriesIssuedInfo->setCaption(": 0"); 160 mDelayedTraversedNodesInfo->setCaption(": 0"); 156 161 157 162 //-- visibility query stats overlay … … 170 175 171 176 // set scene manager options 172 mSceneMgr->setOption(" UseOptimization", &mUseOptimization);177 mSceneMgr->setOption("TestGeometryForVisibleLeaves", &mTestGeometryForVisibleLeaves); 173 178 174 179 // apply delayed rendering (i.e., transparents after hierarchical culling pass) 175 180 // only if optimization is not used 176 bool delayRenderTransparents = !m UseOptimization;181 bool delayRenderTransparents = !mTestGeometryForVisibleLeaves; 177 182 178 183 mSceneMgr->setOption("DelayRenderTransparents", &delayRenderTransparents); … … 736 741 mSceneMgr->getOption("NumFrustumCulledNodes", &opt); sprintf(str,": %d", opt); 737 742 mFrustumCulledNodesInfo->setCaption(str); 738 739 mSceneMgr->getOption("NumQueriesIssued", &opt); sprintf(str,": %d", opt); 743 744 // delay so there is no jump 745 mSceneMgr->getOption("NumQueriesIssued", &opt); 746 sprintf(str,": %d", (int)opt); 740 747 mQueriesIssuedInfo->setCaption(str); 741 748 … … 754 761 sprintf(str,": %d", mTerrainContentGenerator->GetObjectCount()); 755 762 mObjectsInfo->setCaption(str); 763 764 // delay so there is no jump 765 mSceneMgr->getOption("NumQueriesIssued", &opt); 766 mDelayedQueriesIssued = mDelayedQueriesIssued * 0.8 + (float)opt * 0.2; 767 sprintf(str,": %d", (int)mDelayedQueriesIssued); 768 mDelayedQueriesIssuedInfo->setCaption(str); 769 770 mSceneMgr->getOption("NumTraversedNodes", &opt); 771 mDelayedTraversedNodes = mDelayedTraversedNodes * 0.8 + (float)opt * 0.2; 772 sprintf(str,": %d", (int)mDelayedTraversedNodes); 773 mDelayedTraversedNodesInfo->setCaption(str); 774 756 775 } 757 776 catch (...) … … 761 780 } 762 781 //----------------------------------------------------------------------- 763 void TerrainFrameListener::toggle UseOptimization()764 { 765 m UseOptimization = !mUseOptimization;766 mSceneMgr->setOption(" UseOptimization", &mUseOptimization);782 void TerrainFrameListener::toggleTestGeometryForVisibleLeaves() 783 { 784 mTestGeometryForVisibleLeaves = !mTestGeometryForVisibleLeaves; 785 mSceneMgr->setOption("TestGeometryForVisibleLeaves", &mTestGeometryForVisibleLeaves); 767 786 768 787 // disable optimization which tests geometry instead of aabb 769 788 // for delayed rendering (i.e., render transparents after all the solids) 770 789 // because otherwise visible transparents could be skipped 771 bool delayedRendering = !mUseOptimization; 790 bool delayedRendering = !mTestGeometryForVisibleLeaves; 791 772 792 mSceneMgr->setOption("DelayRenderTransparents", &delayedRendering); 773 793 774 if (m UseOptimization)775 { 776 m UseOptimizationInfo->setCaption(": true");794 if (mTestGeometryForVisibleLeaves) 795 { 796 mTestGeometryForVisibleLeavesInfo->setCaption(": true"); 777 797 } 778 798 else 779 799 { 780 m UseOptimizationInfo->setCaption(": false");800 mTestGeometryForVisibleLeavesInfo->setCaption(": false"); 781 801 } 782 802 } … … 898 918 toggleDisplayCameraDetails(); 899 919 break; 900 case KC_ O:901 toggle UseOptimization();920 case KC_G: 921 toggleTestGeometryForVisibleLeaves(); 902 922 break; 903 923 case KC_T: -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r154 r155 109 109 void changeThreshold(int incr); 110 110 void changeAssumedVisibility(int incr); 111 void toggle UseOptimization();111 void toggleTestGeometryForVisibleLeaves(); 112 112 void toggleShowOctree(); 113 113 void toggleUseDepthPass(); … … 159 159 OverlayElement *mTraversedNodesInfo; 160 160 OverlayElement *mHierarchyNodesInfo; 161 OverlayElement *m UseOptimizationInfo;161 OverlayElement *mTestGeometryForVisibleLeavesInfo; 162 162 OverlayElement *mUseDepthPassInfo; 163 163 OverlayElement *mRenderedNodesInfo; 164 164 OverlayElement *mObjectsInfo; 165 165 OverlayElement *mQueriesIssuedInfo; 166 OverlayElement *mDelayedQueriesIssuedInfo; 167 OverlayElement *mDelayedTraversedNodesInfo; 166 168 167 169 OverlayElement *mQueryTypeInfo; … … 175 177 TerrainContentGenerator *mTerrainContentGenerator; 176 178 177 bool m UseOptimization;179 bool mTestGeometryForVisibleLeaves; 178 180 bool mShowOctree; 179 181 bool mUseDepthPass; … … 236 238 //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 237 239 PlatformQueryManager *mQueryManager; 240 241 float mDelayedQueriesIssued; 242 float mDelayedTraversedNodes; 238 243 }; 239 244 -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r150 r155 162 162 163 163 // the objects are generated on the whole terrain 164 //mTerrainContentGenerator->GenerateScene(1500, "robot");165 mTerrainContentGenerator->GenerateScene(1500, "athene");164 mTerrainContentGenerator->GenerateScene(1500, "robot"); 165 //mTerrainContentGenerator->GenerateScene(1500, "athene"); 166 166 //mTerrainContentGenerator->GenerateScene(500, "ninja"); 167 167 }
Note: See TracChangeset
for help on using the changeset viewer.