Changeset 87 for trunk/VUT/Ogre/src
- Timestamp:
- 05/09/05 01:24:02 (20 years ago)
- Location:
- trunk/VUT/Ogre/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/src/OgreBspHierarchyInterface.cpp
r74 r87 26 26 } 27 27 //----------------------------------------------------------------------- 28 bool BspHierarchyInterface::HasGreaterDistance(GtpVisibility::HierarchyNode *node1, 29 GtpVisibility::HierarchyNode *node2) const 28 float BspHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 30 29 { 31 return true;32 }33 //-----------------------------------------------------------------------34 Real BspHierarchyInterface::GetSquaredViewDepth(const Camera* cam, const AxisAlignedBox* box) const35 {36 30 return 0.0f; 37 31 } -
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r86 r87 16 16 mNumTraversedNodes ++; 17 17 18 Octree *octree = static_cast<Octree *>(node); 19 18 20 // if we come across some renderable geometry => render it 19 RenderNode(node); 21 if (octree->mNodes.size() > 0) 22 { 23 RenderNode(node); 24 } 20 25 21 for(int i=0; i<8; ++i) 26 // if not all subtrees are empty 27 if (octree->numNodes() > (int)octree->mNodes.size()) 22 28 { 23 Octree *nextChild = 24 static_cast<Octree *>(node)->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]; 29 for(int i=0; i<8; ++i) 30 { 31 Octree *nextChild = 32 octree->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]; 25 33 26 if (nextChild) 27 { 28 mDistanceQueue->push(nextChild); 34 if (nextChild) 35 { 36 mDistanceQueue->push(nextChild); 37 } 29 38 } 30 39 } … … 46 55 bool OctreeHierarchyInterface::HasGeometry(GtpVisibility::HierarchyNode *node) const 47 56 { 48 return static_cast<Octree *>(node)-> numNodes() > 0;57 return static_cast<Octree *>(node)->mNodes.size() > 0; 49 58 } 50 59 //----------------------------------------------------------------------- … … 54 63 } 55 64 //----------------------------------------------------------------------- 56 bool OctreeHierarchyInterface::HasGreaterDistance(GtpVisibility::HierarchyNode *node1, 57 GtpVisibility::HierarchyNode *node2) const 65 float OctreeHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 58 66 { 59 return GetSquaredViewDepth(mCamera, &static_cast<Octree *>(node1)->mBox) > 60 GetSquaredViewDepth(mCamera, &static_cast<Octree *>(node2)->mBox); 61 } 62 //----------------------------------------------------------------------- 63 Real OctreeHierarchyInterface::GetSquaredViewDepth(const Camera* cam, 64 const AxisAlignedBox* box) const 65 { 67 AxisAlignedBox *box = &static_cast<Octree *>(node)->mBox; 66 68 Vector3 mid = ((box->getMinimum() - box->getMaximum()) * 0.5) + box->getMinimum(); 67 // use nearest point rather than midpoint68 Vector3 camPos = cam->getDerivedPosition();69 69 70 Vector3 minPos(camPos.x < mid.x ? box->getMinimum().x : box->getMaximum().x, 71 camPos.y < mid.y ? box->getMinimum().y : box->getMaximum().y, 72 camPos.z < mid.z ? box->getMinimum().z : box->getMaximum().z); 73 74 return (camPos - minPos).squaredLength(); 70 return (mCamera->getDerivedPosition() - mid).squaredLength(); 75 71 } 76 72 //----------------------------------------------------------------------- … … 113 109 octant->setLastRendered(mFrameId); 114 110 115 if (!HasGeometry(octant)) return;116 117 111 static_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera, octant); 118 112 -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r86 r87 26 26 void PlatformHierarchyInterface::DeleteQueries() 27 27 { 28 for( unsigned int i=0; i < (unsignedint)mOcclusionQueries.size(); ++i)28 for(int i=0; i < (int)mOcclusionQueries.size(); ++i) 29 29 delete mOcclusionQueries[i]; 30 30 … … 105 105 query->BeginQuery(); 106 106 107 // if leaf and was visible => will be rendered anyway, thus we 108 // can also test with the real geometry 109 if(mUseOptimization && wasVisible && IsLeaf(node)) 107 // if node is leaf and was visible => 108 // will be rendered anyway. 109 // In this case we can also test with the real geometry. 110 /*if(mUseOptimization && wasVisible && IsLeaf(node)) 110 111 { 111 // OutputDebugString("Using optimization!!\n");112 112 RenderNode(node); 113 113 } 114 114 else 115 { 116 // OutputDebugString("Not optimized!!\n"); 115 {*/ 117 116 RenderBoundingBox(GetBoundingBox(node)); 118 }117 //} 119 118 120 119 query->EndQuery(); -
trunk/VUT/Ogre/src/OgrePlatformOcclusionQuery.cpp
r86 r87 14 14 } 15 15 //----------------------------------------------------------------------- 16 void PlatformOcclusionQuery::BeginQuery() const16 void PlatformOcclusionQuery::BeginQuery() 17 17 { 18 18 mHardwareOcclusionQuery->beginOcclusionQuery(); 19 19 } 20 20 //----------------------------------------------------------------------- 21 void PlatformOcclusionQuery::EndQuery() const21 void PlatformOcclusionQuery::EndQuery() 22 22 { 23 23 mHardwareOcclusionQuery->endOcclusionQuery(); -
trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
r85 r87 56 56 bool SceneNodeHierarchyInterface::HasGeometry(GtpVisibility::HierarchyNode *node) const 57 57 { 58 SceneNode *sceneNode = static_cast<SceneNode *>(node); 59 60 return sceneNode->numAttachedObjects() > 0; 58 return static_cast<SceneNode *>(node)->numAttachedObjects() > 0; 61 59 } 62 60 //----------------------------------------------------------------------- … … 74 72 } 75 73 //----------------------------------------------------------------------- 76 bool SceneNodeHierarchyInterface::HasGreaterDistance(GtpVisibility::HierarchyNode *node1, 77 GtpVisibility::HierarchyNode *node2) const 74 float SceneNodeHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 78 75 { 79 SceneNode *sceneNode1 = static_cast<SceneNode *>(node1); 80 SceneNode *sceneNode2 = static_cast<SceneNode *>(node2); 81 82 return sceneNode1->getSquaredViewDepth(mCamera) > sceneNode2->getSquaredViewDepth(mCamera); 76 return static_cast<SceneNode *>(node)->getSquaredViewDepth(mCamera); 83 77 } 84 78 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r86 r87 12 12 //----------------------------------------------------------------------- 13 13 VisibilityOctreeSceneManager::VisibilityOctreeSceneManager( 14 GtpVisibility::VisibilityManager *visManager): mVisibilityManager(visManager) 14 GtpVisibility::VisibilityManager *visManager) 15 : mVisibilityManager(visManager), mUseCulling(true) 15 16 { 16 17 mHierarchyInterface = 17 18 new OctreeHierarchyInterface(this, mDestRenderSystem); 18 19 // visManager->SetCullingManager(GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING); 19 20 //mDisplayNodes = true; 20 21 //mShowBoundingBoxes = true; 21 22 //mShowBoxes = true; 23 22 24 mMaxDepth = 20; 23 25 } … … 30 32 void VisibilityOctreeSceneManager::_renderVisibleObjects() 31 33 { 34 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress); 35 mVisibilityManager->GetCullingManager()->InitFrame(); 36 37 if(!mUseCulling) 38 { 39 OctreeSceneManager::_renderVisibleObjects(); 40 return; 41 } 42 43 //-- hierarchical culling 44 // the objects of different layers (e.g., background, scene, 45 // overlay) must be identified and rendered one after another 46 32 47 //-- render background 33 48 clearSpecialCaseRenderQueues(); … … 36 51 37 52 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 38 SceneManager::_renderVisibleObjects( ); 53 SceneManager::_renderVisibleObjects(); 54 39 55 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 40 56 _deleteRenderedQueueGroups(); … … 46 62 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 47 63 48 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress);64 //-- the hierarchical culling algorithm 49 65 mVisibilityManager->ApplyVisibilityCulling(); 50 66 … … 53 69 #endif 54 70 55 //-- render re st, e.g., overlay71 //-- render remaining objects, e.g., overlay 56 72 clearSpecialCaseRenderQueues(); 57 73 SceneManager::_renderVisibleObjects(); 58 //_deleteRenderedQueueGroups();59 74 } 60 75 //----------------------------------------------------------------------- 61 76 void VisibilityOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 62 77 { 63 // must be empty because objects are found and rendered in an interleaved fashion 78 // empty if hierarchical culling is used => 79 // we interleave identification and rendering of objects 64 80 // in _renderVisibibleObjects 81 if(!mUseCulling) 82 { 83 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 84 } 65 85 } 66 86 //----------------------------------------------------------------------- … … 78 98 bool VisibilityOctreeSceneManager::setOption(const String & key, const void * val) 79 99 { 100 if (key == "UseCulling") 101 { 102 mUseCulling = (*static_cast<const bool *>(val)); 103 return true; 104 } 105 80 106 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 81 107 setOption(key, val) || OctreeSceneManager::setOption(key, val); -
trunk/VUT/Ogre/src/OgreVisibilityOptionsManager.cpp
r86 r87 57 57 return true; 58 58 } 59 if (key == "NumQueriesIssued") 60 { 61 * static_cast<unsigned int *>(val) = 62 mVisibilityManager->GetCullingManager()->GetNumQueriesIssued(); 63 return true; 64 } 59 65 60 66 return false; -
trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp
r74 r87 13 13 //----------------------------------------------------------------------- 14 14 VisibilitySceneManager::VisibilitySceneManager(GtpVisibility::VisibilityManager *visManager) 15 :mVisibilityManager(visManager) 15 :mVisibilityManager(visManager), mUseCulling(true) 16 16 { 17 17 mHierarchyInterface = new SceneNodeHierarchyInterface(this, mDestRenderSystem); … … 25 25 void VisibilitySceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 26 26 { 27 // empty because we have to find objects in _renderVisibleObjects 27 // empty if hierarchical culling is used => 28 // we interleave identification and rendering of objects 29 // in _renderVisibibleObjects 30 if(!mUseCulling) 31 { 32 SceneManager::_findVisibleObjects(cam, onlyShadowCasters); 33 } 28 34 } 29 35 //----------------------------------------------------------------------- 30 36 void VisibilitySceneManager::_renderVisibleObjects() 31 37 { 32 //-- render background 38 mHierarchyInterface->InitFrame(mSceneRoot, mCameraInProgress); 39 mVisibilityManager->GetCullingManager()->InitFrame(); 40 41 if(!mUseCulling) 42 { 43 SceneManager::_renderVisibleObjects(); 44 return; 45 } 46 47 //-- hierarchical culling 48 // the objects of different layers (e.g., background, scene, 49 // overlay) must be identified and rendered one after another 50 51 //-- render background 33 52 clearSpecialCaseRenderQueues(); 34 53 addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); … … 36 55 37 56 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 38 SceneManager::_renderVisibleObjects( 57 SceneManager::_renderVisibleObjects(); 39 58 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 40 59 _deleteRenderedQueueGroups(); 41 60 #endif 61 42 62 //-- render visible objects (i.e., all but overlay) 43 63 clearSpecialCaseRenderQueues(); … … 45 65 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 46 66 47 mHierarchyInterface->InitFrame(mSceneRoot, mCameraInProgress);67 //-- the hierarchical culling algorithm 48 68 mVisibilityManager->ApplyVisibilityCulling(); 49 69 … … 54 74 //-- render overlay 55 75 clearSpecialCaseRenderQueues(); 56 SceneManager::_renderVisibleObjects( ); 57 58 clearSpecialCaseRenderQueues(); 76 SceneManager::_renderVisibleObjects(); 59 77 } 60 78 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r86 r87 7 7 #include <OgreCamera.h> 8 8 9 //#include <windows.h>9 #include <windows.h> 10 10 11 11 namespace Ogre { 12 //namespace GtpVisibility { 12 13 13 //----------------------------------------------------------------------- 14 14 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 15 GtpVisibility::VisibilityManager *visManager): mVisibilityManager(visManager) 15 GtpVisibility::VisibilityManager *visManager) 16 : mVisibilityManager(visManager), mUseCulling(true) 16 17 { 17 18 mHierarchyInterface = 18 19 new OctreeHierarchyInterface(this, mDestRenderSystem); 19 20 20 //mShowBoxes = true;21 21 //mDisplayNodes = true; 22 22 //mShowBoundingBoxes = true; … … 31 31 void VisibilityTerrainSceneManager::_renderVisibleObjects() 32 32 { 33 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress); 34 mVisibilityManager->GetCullingManager()->InitFrame(); 35 36 if(!mUseCulling) 37 { 38 OctreeSceneManager::_renderVisibleObjects(); 39 return; 40 } 41 42 //-- hierarchical culling 43 // the objects of different layers (e.g., background, scene, 44 // overlay) must be identified and rendered one after another 45 33 46 //-- render background 34 47 clearSpecialCaseRenderQueues(); … … 47 60 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 48 61 49 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress);62 //-- the hierarchical culling algorithm 50 63 mVisibilityManager->ApplyVisibilityCulling(); 51 64 … … 56 69 //-- render overlay 57 70 clearSpecialCaseRenderQueues(); 58 SceneManager::_renderVisibleObjects( 71 SceneManager::_renderVisibleObjects(); 59 72 } 60 73 //----------------------------------------------------------------------- 61 74 void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 62 75 { 63 // must be empty because objects are found and rendered in an interleaved fashion 76 // empty if hierarchical culling is used => 77 // we interleave identification and rendering of objects 64 78 // in _renderVisibibleObjects 79 if(!mUseCulling) 80 { 81 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 82 } 65 83 } 66 84 //----------------------------------------------------------------------- … … 79 97 bool VisibilityTerrainSceneManager::setOption(const String & key, const void * val) 80 98 { 99 if (key == "UseCulling") 100 { 101 mUseCulling = (*static_cast<const bool *>(val)); 102 return true; 103 } 104 81 105 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 82 106 setOption(key, val) || TerrainSceneManager::setOption(key, val); … … 115 139 return mVisibilityManager; 116 140 } 117 //} // namespace GtpVisibility118 141 } // namespace Ogre
Note: See TracChangeset
for help on using the changeset viewer.