Ignore:
Timestamp:
08/04/06 17:38:52 (18 years ago)
Author:
szydlowski
Message:

occlusion queries in kdtree scene manager working, but performance issues
many features still not implemented (e.g., visualization)

Location:
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h

    r1182 r1183  
    211211                        //virtual void cbInsert(KdTree * caller, KdRenderable * rend) = 0; 
    212212 
    213                         WireBoundingBox * getWireBoundingBox() 
     213                        WireBoundingBox * getWireBoundingBox(bool node = true) 
    214214                        { 
    215215                                if (mWBB == 0) 
    216216                                        mWBB = new WireBoundingBox(); 
    217217 
    218                                 mWBB->setupBoundingBox(mAABB); 
     218                                if (node) 
     219                                        mWBB->setupBoundingBox(mAABB); 
     220                                else 
     221                                        mWBB->setupBoundingBox(mWorldAABB); 
    219222                                 
    220223#ifdef KDTREE_DEBUG 
     224                                SceneManager * sceneManager = Root::getSingleton()._getCurrentSceneManager(); 
    221225                                int level = -1; 
    222226                                bool boxes = false; 
    223                                 if (Root::getSingleton()._getCurrentSceneManager()->getOption("HighlightLevel",&level)) 
     227                                if (sceneManager->getOption("HighlightLevel",&level)) 
    224228                                { 
    225229                                        if (mLevel == level) 
     
    232236                                        { 
    233237                                                mWBB->setMaterial("BaseWhiteNoLighting"); 
    234                                                 if (Root::getSingleton()._getCurrentSceneManager()->getOption("ShowAllBoxes", &boxes)) 
     238                                                if (sceneManager->getOption("ShowAllBoxes", &boxes)) 
    235239                                                { 
    236240                                                        if (boxes) 
     
    279283                        /** Updates bound of the real aabb of kdtree 
    280284                        */ 
    281                         virtual void _updateBounds() = 0; 
    282  
     285                        virtual void _updateBounds(bool recurse = true) = 0; 
    283286 
    284287                        Branch * mParent; 
     
    325328 
    326329                        // branches do not posses geometry => just merge child aabbs 
    327                         virtual void _updateBounds() 
     330                        virtual void _updateBounds(bool recurse = true) 
    328331                        { 
    329332                                // reset box 
     
    336339 
    337340                                // update parent recursively 
    338                                 if (mParent) 
    339                                         mParent->_updateBounds(); 
     341                                if (recurse && mParent) 
     342                                        mParent->_updateBounds(recurse); 
    340343                        } 
    341344                         
     
    365368 
    366369                        // update the world aabb based on the contained geometry 
    367                         virtual void _updateBounds(); 
     370                        virtual void _updateBounds(bool recurse = true); 
    368371 
    369372                        virtual void remove(KdRenderable * rend) 
     
    464467                void dump(void); 
    465468                Real calcCost(void); 
     469 
     470                /** Switches between displaying the bounding box of the node and 
     471                the box of the contained scene nodes 
     472                */ 
     473                inline void setShowNodeAABB(bool show = true) { mShowNodeAABB = show; }; 
     474                inline bool getShowNodeAABB(void) { return mShowNodeAABB; }; 
    466475 
    467476                NodePtr getRoot(void) const { return mKdRoot; }; 
     
    523532                Stats mStats; 
    524533 
     534                // show node or object aabb 
     535                bool mShowNodeAABB; 
     536 
     537 
    525538                // DEBUG 
    526539                void KdTree::dump(KdTree::Node * node); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp

    r1182 r1183  
    329329        //---------------------------------------------------------------------------- 
    330330 
    331         KdTree::KdTree(int maxdepth): mMaxDepth(maxdepth), mKdRoot(0), mBuildMethod(KDBM_RECURSIVE), mBuildLog(0) 
     331        KdTree::KdTree(int maxdepth):  
     332        mMaxDepth(maxdepth),  
     333        mKdRoot(0),  
     334        mBuildMethod(KDBM_RECURSIVE),  
     335        mBuildLog(0),  
     336        mShowNodeAABB(true) 
    332337        { 
    333338#ifdef KDTREE_DEBUG 
     
    340345                        mp->setDiffuse(cv); 
    341346                } 
    342                 //try 
    343                 //{ 
    344                 //      ColourValue cv(0.0, 1.0, 0.0); 
    345                 //      MaterialPtr mp = MaterialManager::getSingleton().create("aabbHiLite","General"); 
    346                 //      mp->setSelfIllumination(cv); 
    347                 //      mp->setDiffuse(cv); 
    348                 //} 
    349                 //catch (Ogre::Exception&) 
    350                 //{ 
    351                 //      // SO FUCKING DON'T CARE !!! 
    352                 //} 
    353347#endif 
    354348                try 
     
    871865                        ++ mStats.mNumNodes; 
    872866                        ++ mStats.mNumLeaves; 
     867                        // update bounding box 
     868                        leaf->_updateBounds(false); 
    873869                        return leaf; 
    874870                } 
     
    957953                        // update stats 
    958954                        ++ mStats.mNumNodes; 
     955 
     956                        // update bounding box 
     957                        branch->_updateBounds(false); 
     958 
    959959 
    960960                        //assert(branch->mRight || branch->mLeft); 
     
    12611261                        } 
    12621262 
     1263                        // update bounding boxes when geometry (leaf) was added 
     1264                        if (newNode->isLeaf()) 
     1265                                newNode->_updateBounds(); 
     1266 
    12631267                        //cleanup 
    12641268                        OGRE_DELETE(sc.events); 
     
    13361340                        WireBoundingBox * wbb = 0; 
    13371341                        if (showBoxes) 
    1338                                 wbb = node->getWireBoundingBox(); 
     1342                                wbb = node->getWireBoundingBox(mShowNodeAABB); 
    13391343#endif 
    13401344 
     
    13571361#else 
    13581362                                if (showBoxes) 
    1359                                         queue->addRenderable(leaf->getWireBoundingBox()); 
     1363                                        queue->addRenderable(leaf->getWireBoundingBox(mShowNodeAABB)); 
    13601364#endif 
    13611365                        } 
     
    13681372#else 
    13691373                                if (showBoxes) 
    1370                                         queue->addRenderable(branch->getWireBoundingBox()); 
     1374                                        queue->addRenderable(branch->getWireBoundingBox(mShowNodeAABB)); 
    13711375#endif 
    13721376 
     
    14691473 
    14701474        // update the world aabb based on the contained geometry 
    1471         void KdTree::Leaf::_updateBounds() 
     1475        void KdTree::Leaf::_updateBounds(bool recurse) 
    14721476        { 
    14731477                // reset box 
     
    14791483                while (it != end) 
    14801484                { 
     1485                        //(*it)->_updateBounds(); 
    14811486                        mWorldAABB.merge((*it)->getBoundingBox()); 
    14821487                        it++; 
     
    14841489 
    14851490                // update parent recursively 
    1486                 if (mParent) 
    1487                         mParent->_updateBounds(); 
     1491                if (recurse && mParent) 
     1492                        mParent->_updateBounds(recurse); 
    14881493        } 
    14891494} // namespace Ogre 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp

    r1182 r1183  
    5959 
    6060mHierarchyInterface = new KdTreeHierarchyInterface(this, mDestRenderSystem); 
     61 
     62// test 
     63//String chc = "CHC"; 
     64//setOption("RenderMethod", &chc); 
    6165} 
    6266 
     
    240244                return true; 
    241245        } 
     246        else if (strKey == "ShowNodeAABB") 
     247        { 
     248                bool sn = *static_cast<const bool *>(pValue); 
     249                if (mKdTree) 
     250                        mKdTree->setShowNodeAABB(sn); 
     251                return true; 
     252        } 
     253        // options for CHC 
     254        if (strKey == "UseDepthPass") 
     255        { 
     256                mUseDepthPass = (*static_cast<const bool *>(pValue)); 
     257                return true; 
     258        } 
     259        if (strKey == "PrepareVisualization") 
     260        { 
     261                mShowVisualization = (*static_cast<const bool *>(pValue)); 
     262                return true; 
     263        } 
     264        if (strKey == "RenderNodesForViz") 
     265        { 
     266                mRenderNodesForViz = (*static_cast<const bool *>(pValue)); 
     267                return true; 
     268        } 
     269        if (strKey == "RenderNodesContentForViz") 
     270        { 
     271                mRenderNodesContentForViz = (*static_cast<const bool *>(pValue)); 
     272                return true; 
     273        } 
     274        if (strKey == "SkyBoxEnabled") 
     275        { 
     276                mSkyBoxEnabled = (*static_cast<const bool *>(pValue)); 
     277                return true; 
     278        } 
     279        if (strKey == "SkyPlaneEnabled") 
     280        { 
     281                mSkyPlaneEnabled = (*static_cast<const bool *>(pValue)); 
     282                return true; 
     283        } 
     284        if (strKey == "SkyDomeEnabled") 
     285        { 
     286                mSkyDomeEnabled = (*static_cast<const bool *>(pValue)); 
     287                return true; 
     288        } 
     289        if (strKey == "VisualizeCulledNodes") 
     290        { 
     291                mVisualizeCulledNodes = (*static_cast<const bool *>(pValue)); 
     292                return true; 
     293        } 
     294        if (strKey == "DelayRenderTransparents") 
     295        { 
     296                mDelayRenderTransparents = (*static_cast<const bool *>(pValue)); 
     297                return true; 
     298        } 
     299 
     300        if (strKey == "DepthWrite") 
     301        { 
     302                mEnableDepthWrite = (*static_cast<const bool *>(pValue)); 
     303                return true; 
     304        } 
     305        if (strKey == "UseItemBuffer") 
     306        { 
     307                mUseItemBuffer = (*static_cast<const bool *>(pValue)); 
     308                return true; 
     309        } 
     310        if (strKey == "ExecuteVertexProgramForAllPasses") 
     311        {  
     312                mExecuteVertexProgramForAllPasses  = (*static_cast<const bool *>(pValue)); 
     313                return true; 
     314        } 
     315        if (strKey == "RenderTransparentsForItemBuffer") 
     316        {  
     317                mRenderTransparentsForItemBuffer  = (*static_cast<const bool *>(pValue)); 
     318                return true; 
     319        } 
     320 
    242321 
    243322        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface) 
     
    270349        else if (strKey == "ShowAllBoxes") 
    271350        { 
    272                 *static_cast<bool *>(pDestValue) = mShowAllBoxes; 
     351                if (mRenderMethod == KdTree::KDRM_INTERNAL) 
     352                        *static_cast<bool *>(pDestValue) = mShowAllBoxes; 
     353                else 
     354                        *static_cast<bool *>(pDestValue) = mVisualizeCulledNodes; 
    273355                return true; 
    274356        } 
     
    308390                        return false; 
    309391                } 
     392                return true; 
     393        } 
     394        else if (strKey == "ShowKdTree") 
     395        { 
     396                *static_cast<bool *>(pDestValue) = mShowBoxes; 
     397                return true; 
     398        } 
     399        else if (strKey == "ShowNodeAABB") 
     400        { 
     401                if (mKdTree) 
     402                        *static_cast<bool *>(pDestValue) = mKdTree->getShowNodeAABB(); 
     403                else 
     404                        *static_cast<bool *>(pDestValue) = false; 
    310405                return true; 
    311406        } 
     
    331426        refKeys.push_back("RenderMethod"); 
    332427        refKeys.push_back("ShowKdTree"); 
     428        refKeys.push_back("ShowNodeAABB"); 
    333429        refKeys.push_back("TreeBox"); 
    334430#ifdef KDTREE_DEBUG 
     
    639735        while (it != end) 
    640736        { 
    641                 (*it)->queueObjects(cam, getRenderQueue(), onlyShadowCasters); 
     737                if (!(*it)->isQueued(mHierarchyInterface->GetFrameId(), cam)) 
     738                { 
     739                        (*it)->queueObjects(cam, getRenderQueue(), onlyShadowCasters); 
     740                } 
    642741                it++; 
    643742        } 
     
    841940        } 
    842941        // add bounding boxes of rendered objects 
    843         if (0) 
     942        //if (0) 
    844943                //for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 
    845944                //{ 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneNode.cpp

    r1182 r1183  
    1212 
    1313#include <OgreStringConverter.h> 
     14#include <OgreLogManager.h> 
    1415 
    1516namespace Ogre 
     
    140141        } 
    141142 
     143        // recalculate the world aabb 
    142144        AxisAlignedBox KdTreeSceneNode::getBoundingBox() const 
    143145        { 
     146#if 0 
     147                AxisAlignedBox box; 
     148 
     149                // Update bounds from own attached objects 
     150                ObjectMap::const_iterator it = mObjectsByName.begin(); 
     151                ObjectMap::const_iterator end = mObjectsByName.end(); 
     152                for ( ; it != end ; ++it) 
     153                { 
     154                        // Merge world bounds of each object 
     155                        box.merge(it->second->getWorldBoundingBox(true)); 
     156                } 
     157 
     158                if (box.getMinimum() != mWorldAABB.getMinimum() ||box.getMaximum() != mWorldAABB.getMaximum()) 
     159                { 
     160                        try 
     161                        { 
     162                                Log * log = LogManager::getSingleton().getLog("KdTreeBuild.log"); 
     163                                log->logMessage("mWorldAABB was not up to date"); 
     164                        } 
     165                        catch (Exception) 
     166                        { 
     167                                // F.U. 
     168                        } 
     169                } 
     170 
     171                return box; 
     172#else 
    144173                return mWorldAABB; 
     174#endif 
    145175        } 
    146176 
Note: See TracChangeset for help on using the changeset viewer.