Changeset 1250


Ignore:
Timestamp:
08/21/06 17:05:45 (18 years ago)
Author:
szydlowski
Message:

implemented enhanced vis with early abort
also own frame & time counter in demo mode
fixed dependencies in solution file

Location:
GTP/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTreeAppListener.h

    r1220 r1250  
    114114                mBuildMethod(KdTree::KDBM_PRIORITYQUEUE), 
    115115                mDemoMode(false), 
    116                 mEnhancedVisibility(false) 
     116                mEnhancedVisibility(false), 
     117                mDemoInterval(1.0f) 
    117118                { 
    118119 
     
    134135                bool mDemoMode; 
    135136                bool mEnhancedVisibility; 
    136         }; 
     137                Real mDemoInterval; 
     138        }; 
     139 
     140        struct DemoStats 
     141        { 
     142                unsigned int mTotalNumFrames; 
     143                unsigned int mNumFrames; 
     144                Real mTotalEllapsedTime; 
     145                Real mEllapsedTime; 
     146        } mDemoStats; 
    137147 
    138148    // Constructor takes a RenderWindow because it uses that to determine input context 
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTree.cpp

    r1220 r1250  
    3737                                .addOpt("s","scenemgr", ARGUMENT_REQUIRED) 
    3838                                .addOpt("","comment", ARGUMENT_REQUIRED) 
    39                                 .addOpt("e","enhancevis", ARGUMENT_NONE); 
     39                                .addOpt("e","enhancevis", ARGUMENT_NONE) 
     40                                .addOpt("","logint",ARGUMENT_REQUIRED); 
    4041 
    4142 
     
    8788                                s << tmp; 
    8889                                s >> options.mKI; 
     90                                s.clear(); 
     91                        } 
     92 
     93                        if (cmdparser.getOpt("logint", tmp)) 
     94                        { 
     95                                s << tmp; 
     96                                s >> options.mDemoInterval; 
    8997                                s.clear(); 
    9098                        } 
     
    417425                KdTreeAppListener::SCENEMANAGERNAME[mOptions.mSceneManager], 
    418426                "MySceneManager"); 
    419         // set params depending on scene manager 
     427        // set params for kdtree scene manager 
    420428        if (mOptions.mSceneManager == KdTreeAppListener::SM_KDT) 
    421429        { 
     
    426434                mSceneMgr->setOption("RenderMethod", &mOptions.mRenderMethod); 
    427435                mSceneMgr->setOption("EnhancedVisibility", &mOptions.mEnhancedVisibility); 
     436                // fix 
     437                bool depthpass = false; 
     438                mSceneMgr->setOption("UseDepthPass", &depthpass); 
    428439        } 
    429440        // set algorithm when scene manager is OCM - numbering is different though 
    430         if (mOptions.mSceneManager == KdTreeAppListener::SM_OCM) 
     441        else if (mOptions.mSceneManager == KdTreeAppListener::SM_OCM) 
    431442        { 
    432443                int alg = CONV_KDT_TO_OCM_ALG(mOptions.mRenderMethod); 
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTreeAppListener.cpp

    r1220 r1250  
    131131mTimeUntilNextToggle(0.0f), 
    132132// stuff for walkthrough recording/playback 
    133 mTimeUntilNextLogWrite(0.0f), 
     133mTimeUntilNextLogWrite(options.mDemoInterval), 
    134134mTimeRemaining(0.0f), 
    135135mWaitBeforeDemoStart(0.0f), 
     
    10631063                mTimeRemaining -= evt.timeSinceLastFrame; 
    10641064 
     1065                // update stats 
     1066                ++ mDemoStats.mNumFrames; 
     1067                ++ mDemoStats.mTotalNumFrames; 
     1068                mDemoStats.mEllapsedTime += evt.timeSinceLastFrame; 
     1069                mDemoStats.mTotalEllapsedTime += evt.timeSinceLastFrame; 
     1070 
    10651071                // store fps when in demo mode 
    10661072                if (mOptions.mDemoMode) 
     
    10701076                        if (mTimeUntilNextLogWrite <= 0.0) 
    10711077                        { 
    1072                                 const RenderTarget::FrameStats& stats = mWindow->getStatistics(); 
    1073                                 mTimeUntilNextLogWrite += 1.0; 
    1074                                 mDemoFPS.push_back(stats.lastFPS); 
     1078                                mTimeUntilNextLogWrite += mOptions.mDemoInterval; 
     1079                                //const RenderTarget::FrameStats& stats = mWindow->getStatistics(); 
     1080                                //mDemoFPS.push_back(stats.lastFPS); 
     1081                                mDemoFPS.push_back(mDemoStats.mNumFrames / mDemoStats.mEllapsedTime); 
     1082                                mDemoStats.mNumFrames = 0; 
     1083                                mDemoStats.mEllapsedTime = 0.0f; 
    10751084                        } 
    10761085                } 
     
    12561265                mCurrFrame = mFrameList.begin(); 
    12571266                mTimeRemaining = mCurrFrame->mElapsedTime; 
     1267 
     1268                // reset stats 
     1269                mDemoStats.mNumFrames = 0; 
     1270                mDemoStats.mTotalNumFrames = 0; 
     1271                mDemoStats.mEllapsedTime = 0.0f; 
     1272                mDemoStats.mTotalEllapsedTime = 0.0f; 
    12581273        } 
    12591274        // stop playback 
     
    14521467        // stats 
    14531468        Real minFPS = Math::POS_INFINITY, maxFPS = 0.0, avgFPS = 0.0; 
    1454         String demofile; 
     1469        String line, storedname; 
     1470        String demopath, demoname; 
     1471        StringUtil::splitFilename(mOptions.mDemoInfileName, demoname, demopath); 
    14551472         
    14561473        // check if logfile exists 
     
    14581475        if (logread.is_open()) 
    14591476        { 
    1460                 // read first item, it's the name of the demo 
     1477                // read first line, shuold start with the name of the demo 
    14611478                // if matches, OK, otherwise do something 
    1462                 logread >> demofile; 
    1463                 if (!StringUtil::startsWith(demofile, mOptions.mDemoInfileName)) 
     1479                logread >> line; 
     1480                storedname = line.substr(0,line.find_first_of(',')); 
     1481                if (storedname != demoname) 
    14641482                { 
    14651483                        LogManager::getSingleton().logMessage( 
    14661484                                "##Error##: Saved demo stats do not match the current demo: " + 
    1467                                 demofile + " != " + mOptions.mDemoInfileName); 
     1485                                storedname + " != " + demoname); 
    14681486                        logread.close(); 
    14691487                        return; 
     
    14771495                { 
    14781496                        // demo title 
    1479                         logheader << mOptions.mDemoInfileName << fs; 
     1497                        logheader << demoname << fs; 
    14801498                        // seconds 
    14811499                        for (size_t i = 0; i < mDemoFPS.size(); i ++) 
     
    14841502                        } 
    14851503                        // minFPS, avgFPS, maxFPS, comment, record separator 
    1486                         logheader << "min FPS" << fs << "avg FPS" << fs << "max FPS" << fs << "Comment" << rs; 
     1504                        logheader << "\"min FPS\"" << fs << "\"avg FPS\"" << fs << "\"max FPS\"" << fs  
     1505                                << "\"# Frames \"" << fs << "\"Total Time\"" << fs << "\"Comment\"" << rs; 
    14871506                        logheader.close(); 
    14881507                } 
     
    15021521        { 
    15031522                // demo settings 
    1504                 logwrite << SCENEMANAGER[mOptions.mSceneManager]; 
     1523                logwrite << "\"" << SCENEMANAGER[mOptions.mSceneManager]; 
    15051524                if (mOptions.mSceneManager == SM_KDT) 
    15061525                { 
     
    15121531                        logwrite << ds << RENDERMETHOD[(mOptions.mRenderMethod+3)%3]; 
    15131532                } 
    1514                 logwrite << fs; 
     1533                logwrite << "\"" << fs; 
    15151534                // per second stats 
    15161535                for (std::list<Real>::iterator it = mDemoFPS.begin(); it != mDemoFPS.end(); it ++) 
     
    15221541                                maxFPS = *it; 
    15231542 
    1524                         avgFPS += *it; 
     1543                        //avgFPS += *it; 
    15251544 
    15261545                        logwrite << (int)(*it) << fs; 
    15271546 
    15281547                } 
    1529                 avgFPS /= mDemoFPS.size(); 
     1548                //avgFPS /= mDemoFPS.size(); 
     1549                avgFPS = mDemoStats.mTotalNumFrames / mDemoStats.mTotalEllapsedTime; 
    15301550                // minFPS, avgFPS, maxFPS, comment, record separator 
    1531                 logwrite << (int)minFPS << fs << (int)avgFPS << fs << (int)maxFPS << fs << mOptions.mComment << rs; 
     1551                logwrite << (int)minFPS << fs << (int)avgFPS << fs << (int)maxFPS << fs  
     1552                        << mDemoStats.mTotalNumFrames << fs << mDemoStats.mTotalEllapsedTime << fs  
     1553                        << "\"" << mOptions.mComment << "\"" << rs; 
    15321554                logwrite.close(); 
    15331555        } 
  • GTP/trunk/Lib/Vis/GtpVisibility.sln

    r1239 r1250  
    1010Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IVReader", "OnlineCullingCHC\IVReader\src\IVReader.vcproj", "{7319E499-473D-4CE5-9983-725D6E68A55D}" 
    1111        ProjectSection(ProjectDependencies) = postProject 
    12                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} = {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} 
    1312        EndProjectSection 
    1413EndProject 
     
    3029Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCullingTerrain", "..\..\App\Demos\Vis\HillyTerrain\OGRE\TestCullingTerrain.vcproj", "{248F19A6-2FE0-4F5D-8928-E0EA10609887}" 
    3130        ProjectSection(ProjectDependencies) = postProject 
     31                {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} = {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} 
     32                {7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D} 
    3233        EndProjectSection 
    3334EndProject 
     
    3536        ProjectSection(ProjectDependencies) = postProject 
    3637                {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} = {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} 
     38                {7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D} 
    3739        EndProjectSection 
    3840EndProject 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h

    r1220 r1250  
    213213                        virtual bool isEmpty() const = 0; 
    214214                        virtual bool hasGeometry() const = 0; 
     215                         
     216                        virtual void mergeLeaves(std::set<Leaf *>& leaves) = 0; 
    215217 
    216218                        // Gets this node's parent (NULL if this is the root). 
     
    223225                        // add contained objects to render queue 
    224226                        virtual void queueVisibleObjects(unsigned long currentFrame,  
    225                                 Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) = 0; 
     227                                Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes, bool fullVis = false) = 0; 
    226228 
    227229                        // add contained geometry (Entities) to list 
     
    326328                        virtual bool hasGeometry() const { return false; }; 
    327329 
     330                        virtual void mergeLeaves(std::set<Leaf *>& leaves) 
     331                        { 
     332                                for (std::set<Leaf *>::iterator it = mLeaves.begin(); it != mLeaves.end(); it++) 
     333                                        leaves.insert(*it); 
     334                        } 
     335 
    328336                        // a branch should have at least one child 
    329337                        virtual KdTree::Node * getLeftChild() const { return mLeft; }; 
     
    331339 
    332340                        virtual void queueVisibleObjects(unsigned long currentFrame,  
    333                                 Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) 
     341                                Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes, bool fullVis = false) 
    334342                        { 
    335343                                if (showBoxes) 
    336344                                        if (mLevel == mOwner->getHiLiteLevel() || mOwner->getShowAllBoxes()) 
    337345                                                queue->addRenderable(getWireBoundingBox()); 
     346 
     347                                if (fullVis) 
     348                                        for (std::set<Leaf *>::iterator it = mLeaves.begin(); it != mLeaves.end(); it ++) 
     349                                                (*it)->queueVisibleObjects(currentFrame, cam, queue, onlyShadowCasters, showBoxes, fullVis); 
    338350                        } 
    339351 
     
    347359                                mWorldAABB.setNull(); 
    348360 
     361                                // merge box & leaves 
    349362                                if (mLeft) 
     363                                { 
    350364                                        mWorldAABB.merge(mLeft->mWorldAABB); 
     365                                        mLeft->mergeLeaves(mLeaves); 
     366                                } 
    351367                                if (mRight) 
     368                                { 
    352369                                        mWorldAABB.merge(mRight->mWorldAABB); 
     370                                        mRight->mergeLeaves(mLeaves); 
     371                                } 
    353372 
    354373                                // update parent recursively 
     
    361380                        Plane  * mSplitPlane; 
    362381                        PlaneEvent::Side mPlaneSide; 
     382                protected: 
     383                        std::set<Leaf *> mLeaves; 
    363384                }; 
    364385 
     
    373394 
    374395                        // a leaf is a leaf, dammit 
    375                         virtual bool isLeaf() const { return true; }; 
     396                        virtual bool isLeaf() const { return true; } 
    376397 
    377398                        // a leaf is empty when it does not posses renderables 
    378                         virtual bool isEmpty() const { return mKdRenderables.empty(); }; 
     399                        virtual bool isEmpty() const { return mKdRenderables.empty(); } 
    379400 
    380401                        // a leaf has geometry when it has renderables 
    381                         virtual bool hasGeometry() const { return !mKdRenderables.empty(); }; 
     402                        virtual bool hasGeometry() const { return !mKdRenderables.empty(); } 
     403 
     404                        // a leaf adds itself to the leaf set 
     405                        virtual void mergeLeaves(std::set<Leaf *>& leaves)      { leaves.insert(this); } 
    382406 
    383407                        // a leaf never has children  
     
    386410 
    387411                        virtual void queueVisibleObjects(unsigned long currentFrame,  
    388                                 Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes); 
     412                                Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes, bool fullVis = false); 
    389413 
    390414                        virtual void getGeometryList(GtpVisibility::GeometryVector *geometryList); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeCamera.h

    r1212 r1250  
    5151        // enhanced visibility 
    5252        NodeVisibility getVisibilityEnhanced(const AxisAlignedBox& box) const; 
     53 
     54        // DEBUG 
     55        //mutable unsigned int mNumVisQueries; 
    5356protected: 
    5457 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp

    r1211 r1250  
    11881188                bool showBoxes, KdTree::NodeList& visibleNodes) 
    11891189        { 
     1190                // debug 
     1191                //cam->mNumVisQueries = 0; 
     1192 
    11901193                if (mKdRoot) 
    11911194                        recQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(), 
    11921195                                cam, queue, onlyShadowCasters, showBoxes, visibleNodes); 
     1196 
     1197                //mBuildLog->logMessage("Frame # " + StringConverter::toString(Root::getSingleton().getCurrentFrameNumber()) + 
     1198                //      " ," + StringConverter::toString(cam->mNumVisQueries) + " vis queries"); 
    11931199        } 
    11941200 
     
    12071213                        visibleNodes.push_back(node); 
    12081214 
    1209                         node->queueVisibleObjects(currentFrame, cam, queue, onlyShadowCasters, showBoxes); 
    1210  
    1211                         if (node->getLeftChild()) 
    1212                                 recQueueVisibleObjects(node->getLeftChild(), currentFrame,  
    1213                                 cam, queue, onlyShadowCasters, showBoxes, visibleNodes,  
    1214                                 (fullVis || vis == KdTreeCamera::KDNV_FULL) ? true : false); 
    1215                         if (node->getRightChild()) 
    1216                                 recQueueVisibleObjects(node->getRightChild(), currentFrame,  
    1217                                 cam, queue, onlyShadowCasters, showBoxes, visibleNodes,  
    1218                                 (fullVis || vis == KdTreeCamera::KDNV_FULL) ? true : false); 
     1215                        bool v = (fullVis || vis == KdTreeCamera::KDNV_FULL); 
     1216                        node->queueVisibleObjects(currentFrame, cam, queue, onlyShadowCasters, showBoxes, v); 
     1217 
     1218                        if (!v) 
     1219                        { 
     1220 
     1221                                if (node->getLeftChild()) 
     1222                                        recQueueVisibleObjects(node->getLeftChild(), currentFrame,  
     1223                                        cam, queue, onlyShadowCasters, showBoxes, visibleNodes, v); 
     1224                                if (node->getRightChild()) 
     1225                                        recQueueVisibleObjects(node->getRightChild(), currentFrame,  
     1226                                        cam, queue, onlyShadowCasters, showBoxes, visibleNodes, v); 
     1227                        } 
    12191228                } 
    12201229        } 
     
    13661375        //------------------------------------------------------------------------- 
    13671376        void KdTree::Leaf::queueVisibleObjects(unsigned long currentFrame,  
    1368                 Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) 
     1377                Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes, bool fullVis) 
    13691378        { 
    13701379                KdRenderableList::iterator it  = mKdRenderables.begin(); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeCamera.cpp

    r1212 r1250  
    2828{ 
    2929        mEnhancedVisMode = enhanced; 
    30         //if (mEnhancedVisMode) 
    31         //      getVisibility = getVisibilityEnhanced; 
    32         //else 
    33         //      getVisibility = getVisibilitySimple; 
    3430} 
    3531 
     
    4339KdTreeCamera::NodeVisibility KdTreeCamera::getVisibilityEnhanced(const AxisAlignedBox& box) const 
    4440{ 
     41        //++ mNumVisQueries; 
    4542        // Null boxes always invisible 
    4643        if ( box.isNull() ) 
     
    10198KdTreeCamera::NodeVisibility KdTreeCamera::getVisibilitySimple(const AxisAlignedBox& box) const 
    10299{ 
     100        //++ mNumVisQueries; 
     101 
    103102        // dummy 
    104103        FrustumPlane* culledBy = 0; 
Note: See TracChangeset for help on using the changeset viewer.