Changeset 87 for trunk/VUT/Ogre/src


Ignore:
Timestamp:
05/09/05 01:24:02 (20 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/Ogre/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/Ogre/src/OgreBspHierarchyInterface.cpp

    r74 r87  
    2626} 
    2727//----------------------------------------------------------------------- 
    28 bool BspHierarchyInterface::HasGreaterDistance(GtpVisibility::HierarchyNode *node1,  
    29                                                                                            GtpVisibility::HierarchyNode *node2) const 
     28float BspHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 
    3029{ 
    31         return true; 
    32 } 
    33 //----------------------------------------------------------------------- 
    34 Real BspHierarchyInterface::GetSquaredViewDepth(const Camera* cam, const AxisAlignedBox* box) const 
    35 {                                                             
    3630        return 0.0f; 
    3731} 
  • trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp

    r86 r87  
    1616        mNumTraversedNodes ++; 
    1717 
     18        Octree *octree = static_cast<Octree *>(node); 
     19 
    1820        // if we come across some renderable geometry => render it 
    19         RenderNode(node); 
     21        if (octree->mNodes.size() > 0) 
     22        { 
     23                RenderNode(node); 
     24        } 
    2025         
    21         for(int i=0; i<8; ++i) 
     26        // if not all subtrees are empty 
     27        if (octree->numNodes() > (int)octree->mNodes.size()) 
    2228        { 
    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]; 
    2533 
    26         if (nextChild) 
    27                 { 
    28                         mDistanceQueue->push(nextChild); 
     34                        if (nextChild) 
     35                        { 
     36                                mDistanceQueue->push(nextChild); 
     37                        } 
    2938                } 
    3039        } 
     
    4655bool OctreeHierarchyInterface::HasGeometry(GtpVisibility::HierarchyNode *node) const 
    4756{ 
    48         return static_cast<Octree *>(node)->numNodes() > 0; 
     57        return static_cast<Octree *>(node)->mNodes.size() > 0; 
    4958} 
    5059//----------------------------------------------------------------------- 
     
    5463} 
    5564//----------------------------------------------------------------------- 
    56 bool OctreeHierarchyInterface::HasGreaterDistance(GtpVisibility::HierarchyNode *node1,  
    57                                                                                                   GtpVisibility::HierarchyNode *node2) const 
     65float OctreeHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 
    5866{ 
    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; 
    6668        Vector3 mid = ((box->getMinimum() - box->getMaximum()) * 0.5) + box->getMinimum(); 
    67         // use nearest point rather than midpoint 
    68         Vector3 camPos = cam->getDerivedPosition(); 
    6969 
    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(); 
    7571} 
    7672//----------------------------------------------------------------------- 
     
    113109                octant->setLastRendered(mFrameId); 
    114110 
    115                 if (!HasGeometry(octant)) return; 
    116  
    117111                static_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera, octant); 
    118112 
  • trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp

    r86 r87  
    2626void PlatformHierarchyInterface::DeleteQueries() 
    2727{ 
    28         for(unsigned int i=0; i < (unsigned int)mOcclusionQueries.size(); ++i) 
     28        for(int i=0; i < (int)mOcclusionQueries.size(); ++i) 
    2929                delete mOcclusionQueries[i]; 
    3030 
     
    105105        query->BeginQuery(); 
    106106                         
    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)) 
    110111        { 
    111         //      OutputDebugString("Using optimization!!\n"); 
    112112                RenderNode(node); 
    113113        } 
    114114        else 
    115         { 
    116         //      OutputDebugString("Not optimized!!\n"); 
     115        {*/ 
    117116                RenderBoundingBox(GetBoundingBox(node)); 
    118         } 
     117        //} 
    119118 
    120119        query->EndQuery(); 
  • trunk/VUT/Ogre/src/OgrePlatformOcclusionQuery.cpp

    r86 r87  
    1414} 
    1515//----------------------------------------------------------------------- 
    16 void PlatformOcclusionQuery::BeginQuery() const 
     16void PlatformOcclusionQuery::BeginQuery() 
    1717{ 
    1818        mHardwareOcclusionQuery->beginOcclusionQuery(); 
    1919} 
    2020//----------------------------------------------------------------------- 
    21 void PlatformOcclusionQuery::EndQuery() const 
     21void PlatformOcclusionQuery::EndQuery() 
    2222{ 
    2323        mHardwareOcclusionQuery->endOcclusionQuery(); 
  • trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp

    r85 r87  
    5656bool SceneNodeHierarchyInterface::HasGeometry(GtpVisibility::HierarchyNode *node) const 
    5757{ 
    58         SceneNode *sceneNode = static_cast<SceneNode *>(node); 
    59          
    60         return sceneNode->numAttachedObjects() > 0; 
     58        return static_cast<SceneNode *>(node)->numAttachedObjects() > 0; 
    6159} 
    6260//----------------------------------------------------------------------- 
     
    7472} 
    7573//----------------------------------------------------------------------- 
    76 bool SceneNodeHierarchyInterface::HasGreaterDistance(GtpVisibility::HierarchyNode *node1,  
    77                                                                                                          GtpVisibility::HierarchyNode *node2) const 
     74float SceneNodeHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 
    7875{ 
    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); 
    8377} 
    8478//----------------------------------------------------------------------- 
  • trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp

    r86 r87  
    1212//----------------------------------------------------------------------- 
    1313VisibilityOctreeSceneManager::VisibilityOctreeSceneManager( 
    14         GtpVisibility::VisibilityManager *visManager): mVisibilityManager(visManager) 
     14        GtpVisibility::VisibilityManager *visManager) 
     15: mVisibilityManager(visManager), mUseCulling(true) 
    1516{ 
    1617        mHierarchyInterface =  
    1718                new OctreeHierarchyInterface(this, mDestRenderSystem); 
    18  
     19//      visManager->SetCullingManager(GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING); 
    1920        //mDisplayNodes = true; 
    2021        //mShowBoundingBoxes = true; 
    2122        //mShowBoxes = true; 
     23 
    2224        mMaxDepth = 20; 
    2325} 
     
    3032void VisibilityOctreeSceneManager::_renderVisibleObjects() 
    3133{ 
     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 
    3247        //-- render background 
    3348        clearSpecialCaseRenderQueues(); 
     
    3651 
    3752        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 
    38         SceneManager::_renderVisibleObjects( ); 
     53        SceneManager::_renderVisibleObjects(); 
     54 
    3955#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    4056        _deleteRenderedQueueGroups(); 
     
    4662        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 
    4763 
    48         mHierarchyInterface->InitFrame(mOctree, mCameraInProgress); 
     64        //-- the hierarchical culling algorithm 
    4965        mVisibilityManager->ApplyVisibilityCulling(); 
    5066 
     
    5369#endif 
    5470 
    55         //-- render rest, e.g., overlay 
     71        //-- render remaining objects, e.g., overlay 
    5672        clearSpecialCaseRenderQueues(); 
    5773        SceneManager::_renderVisibleObjects(); 
    58         //_deleteRenderedQueueGroups(); 
    5974} 
    6075//----------------------------------------------------------------------- 
    6176void VisibilityOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 
    6277{ 
    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  
    6480        // in _renderVisibibleObjects  
     81        if(!mUseCulling) 
     82        { 
     83                OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
     84        } 
    6585} 
    6686//----------------------------------------------------------------------- 
     
    7898bool VisibilityOctreeSceneManager::setOption(const String & key, const void * val) 
    7999{ 
     100        if (key == "UseCulling") 
     101        { 
     102                mUseCulling = (*static_cast<const bool *>(val)); 
     103                return true; 
     104        } 
     105 
    80106        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 
    81107                setOption(key, val) || OctreeSceneManager::setOption(key, val); 
  • trunk/VUT/Ogre/src/OgreVisibilityOptionsManager.cpp

    r86 r87  
    5757                return true; 
    5858        } 
     59        if (key == "NumQueriesIssued") 
     60        { 
     61                * static_cast<unsigned int *>(val) =  
     62                        mVisibilityManager->GetCullingManager()->GetNumQueriesIssued(); 
     63                return true; 
     64        } 
    5965         
    6066        return false; 
  • trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp

    r74 r87  
    1313//----------------------------------------------------------------------- 
    1414VisibilitySceneManager::VisibilitySceneManager(GtpVisibility::VisibilityManager *visManager) 
    15 :mVisibilityManager(visManager) 
     15:mVisibilityManager(visManager), mUseCulling(true) 
    1616{ 
    1717        mHierarchyInterface = new SceneNodeHierarchyInterface(this, mDestRenderSystem); 
     
    2525void VisibilitySceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 
    2626{ 
    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        } 
    2834} 
    2935//----------------------------------------------------------------------- 
    3036void VisibilitySceneManager::_renderVisibleObjects() 
    3137{ 
    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 
    3352        clearSpecialCaseRenderQueues(); 
    3453        addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); 
     
    3655 
    3756        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 
    38         SceneManager::_renderVisibleObjects( ); 
     57        SceneManager::_renderVisibleObjects(); 
    3958#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    4059        _deleteRenderedQueueGroups(); 
    4160#endif 
     61 
    4262        //-- render visible objects (i.e., all but overlay) 
    4363        clearSpecialCaseRenderQueues(); 
     
    4565        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 
    4666 
    47         mHierarchyInterface->InitFrame(mSceneRoot, mCameraInProgress); 
     67        //-- the hierarchical culling algorithm 
    4868        mVisibilityManager->ApplyVisibilityCulling(); 
    4969 
     
    5474        //-- render overlay 
    5575        clearSpecialCaseRenderQueues(); 
    56         SceneManager::_renderVisibleObjects( ); 
    57  
    58         clearSpecialCaseRenderQueues(); 
     76        SceneManager::_renderVisibleObjects(); 
    5977} 
    6078//----------------------------------------------------------------------- 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r86 r87  
    77#include <OgreCamera.h> 
    88 
    9 //#include <windows.h> 
     9#include <windows.h> 
    1010 
    1111namespace Ogre { 
    12 //namespace GtpVisibility { 
     12 
    1313//----------------------------------------------------------------------- 
    1414VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 
    15         GtpVisibility::VisibilityManager *visManager): mVisibilityManager(visManager) 
     15        GtpVisibility::VisibilityManager *visManager) 
     16: mVisibilityManager(visManager), mUseCulling(true) 
    1617{ 
    1718        mHierarchyInterface =  
    1819                new OctreeHierarchyInterface(this, mDestRenderSystem); 
    1920 
    20         //mShowBoxes = true; 
    2121        //mDisplayNodes = true; 
    2222        //mShowBoundingBoxes = true; 
     
    3131void VisibilityTerrainSceneManager::_renderVisibleObjects() 
    3232{ 
     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 
    3346        //-- render background 
    3447        clearSpecialCaseRenderQueues(); 
     
    4760        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 
    4861 
    49         mHierarchyInterface->InitFrame(mOctree, mCameraInProgress); 
     62        //-- the hierarchical culling algorithm 
    5063        mVisibilityManager->ApplyVisibilityCulling(); 
    5164 
     
    5669        //-- render overlay 
    5770        clearSpecialCaseRenderQueues(); 
    58         SceneManager::_renderVisibleObjects( ); 
     71        SceneManager::_renderVisibleObjects(); 
    5972} 
    6073//----------------------------------------------------------------------- 
    6174void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 
    6275{ 
    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  
    6478        // in _renderVisibibleObjects  
     79        if(!mUseCulling) 
     80        { 
     81                OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
     82        } 
    6583} 
    6684//----------------------------------------------------------------------- 
     
    7997bool VisibilityTerrainSceneManager::setOption(const String & key, const void * val) 
    8098{ 
     99        if (key == "UseCulling") 
     100        { 
     101                mUseCulling = (*static_cast<const bool *>(val)); 
     102                return true; 
     103        } 
     104 
    81105        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 
    82106                setOption(key, val) || TerrainSceneManager::setOption(key, val); 
     
    115139        return mVisibilityManager; 
    116140} 
    117 //} // namespace GtpVisibility 
    118141} // namespace Ogre 
Note: See TracChangeset for help on using the changeset viewer.