Changeset 726


Ignore:
Timestamp:
04/04/06 23:55:38 (18 years ago)
Author:
mattausch
Message:

improved performance of TerrainSceneManager?
revisit octreescenemanager

Location:
GTP/trunk/Lib/Vis
Files:
24 edited

Legend:

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

    r187 r726  
    153153        std::vector<PlatformOcclusionQuery *> mOcclusionQueries; 
    154154 
     155        Vector3 mCameraPosition; 
    155156        bool mOnlyShadowCasters; 
    156157        int mLeavePassesInQueue; 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityTerrainSceneManager.h

    r347 r726  
    1111#include "OgrePlatformQueryManager.h" 
    1212#include "VisibilityManager.h" 
    13  
    1413 
    1514namespace Ogre { 
     
    5655        virtual void renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs,  
    5756            bool doLightIteration, const LightList* manualLightList = 0); 
    58  
    5957        /** Writes out stats into the Ogre log file. 
    6058        */ 
    6159        void WriteLog(); 
    6260 
    63         /** Override pass so we can do the z-fail pass.  
     61        /** We override this because we want to include the z-fail pass.  
    6462        */ 
    6563        Pass* setPass(Pass* pass); 
    66  
    6764        /** Override from SceneManager so we can skip all but first pass for depth pass.  
    6865        */ 
    6966        bool validatePassForRendering(Pass* pass); 
    70  
     67        /** This function renders renderables using false color ids. 
     68        */ 
    7169        void RenderItemBuffer(RenderPriorityGroup* pGroup); 
     70        /** Renders a single object using false color id. 
     71        */ 
    7272        void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass); 
     73        /** Overritten from scene manager to include the false color id rendering of the 
     74                scene objects. 
     75        */ 
    7376        void renderQueueGroupObjects(RenderQueueGroup* pGroup); 
    7477 
     
    8992        void endFrame(); 
    9093 
     94        /** Override this because we must handle shadows differently. 
     95        */ 
    9196        void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup); 
     97        /** Override this because we must handle shadows differently. 
     98        */ 
    9299        void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup); 
    93  
    94         /** Override standard function so octree boxes are always of equal side length. 
    95                 This has advantages for CHC, because terrain tiles are in different octree nodes 
    96                 and can be culled. 
    97         */ 
    98         void setWorldGeometry( const String& filename ); 
    99100 
    100101protected: 
     
    161162 
    162163        bool mIsHierarchicalCulling; 
     164 
     165        std::ofstream mDummyLog; 
    163166}; 
    164167 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj

    r722 r726  
    9494                                BufferSecurityCheck="FALSE" 
    9595                                EnableFunctionLevelLinking="TRUE" 
    96                                 RuntimeTypeInfo="TRUE" 
     96                                RuntimeTypeInfo="FALSE" 
    9797                                UsePrecompiledHeader="0" 
    9898                                WarningLevel="3" 
     
    227227                                        RelativePath="..\include\OgreVisibilitySceneManager.h"> 
    228228                                </File> 
     229                                <File 
     230                                        RelativePath="..\include\VspBspTree.h"> 
     231                                </File> 
    229232                        </Filter> 
    230233                        <Filter 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp

    r720 r726  
    380380 
    381381        getRenderQueue()->clear(); // finally clear render queue 
    382         OGRE_DELETE(mRenderQueue); // HACK: should be cleared before... 
     382        OGRE_DELETE(mRenderQueue); // HACK: should be cleared before ... 
    383383        WriteLog(); // write out stats 
    384384 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp

    r645 r726  
    2727        // we need access to the scene manager and the rendersystem 
    2828        PlatformHierarchyInterface *pfHierarchyInterface =  
    29                 dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface); 
     29                //dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface); 
     30                static_cast<PlatformHierarchyInterface *>(mHierarchyInterface); 
    3031 
    3132        // disable overlays, reset them later 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp

    r722 r726  
    2121 
    2222        // if we come across some renderable geometry => render it 
    23         if (octree->mNodes.size() > 0) 
     23        if (!octree->mNodes.empty()) 
    2424        { 
    2525                RenderNode(node); 
    2626        } 
    2727         
    28         //if (octree->numNodes() > (int)octree->mNodes.size()) // if not all subtrees are empty 
     28        // if not all subtrees are empty 
    2929        if (!IsLeaf(node)) 
    3030        { 
    31                 for(int i=0; i<8; ++i) 
    32                 { 
    33                         Octree *nextChild =  
    34                                 octree->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]; 
    35                          
    36                         if (nextChild) 
    37                         { 
    38                                 mDistanceQueue->push(nextChild); 
    39                         } 
    40                 } 
     31                Octree *nextChild; 
     32 
     33                if ((nextChild = octree->mChildren[0][0][0]) != NULL) 
     34                        mDistanceQueue->push(nextChild); 
     35                if ((nextChild = octree->mChildren[0][0][1]) != NULL) 
     36                        mDistanceQueue->push(nextChild); 
     37                if ((nextChild = octree->mChildren[0][1][0]) != NULL) 
     38                        mDistanceQueue->push(nextChild); 
     39                if ((nextChild = octree->mChildren[0][1][1]) != NULL) 
     40                mDistanceQueue->push(nextChild); 
     41                if ((nextChild = octree->mChildren[1][0][0]) != NULL) 
     42                        mDistanceQueue->push(nextChild); 
     43                if ((nextChild = octree->mChildren[1][0][1]) != NULL) 
     44                        mDistanceQueue->push(nextChild); 
     45                if ((nextChild = octree->mChildren[1][1][0]) != NULL) 
     46                        mDistanceQueue->push(nextChild); 
     47                if ((nextChild = octree->mChildren[1][1][1]) != NULL) 
     48                        mDistanceQueue->push(nextChild); 
    4149        } 
    4250} 
     
    5664float OctreeHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 
    5765{ 
    58         LogManager::getSingleton().logMessage("here4"); 
     66        const Vector3 bmin = static_cast<Octree *>(node)->mBox.getMinimum(); 
     67        const Vector3 bmax = static_cast<Octree *>(node)->mBox.getMaximum(); 
    5968 
    60         const AxisAlignedBox &box = static_cast<Octree *>(node)->mBox; 
    61         const Vector3 pos = ((box.getMaximum() - box.getMinimum()) * 0.5) + box.getMinimum(); 
     69        const Vector3 pos = (bmax - bmin) * 0.5 + bmin; 
    6270         
    63         return (mCullCamera->getDerivedPosition() - pos).squaredLength(); 
     71        return (mCameraPosition - pos).squaredLength(); 
    6472} 
    6573//----------------------------------------------------------------------- 
     
    101109        { 
    102110                octant->setLastRendered(mFrameId); 
    103  
    104                 dynamic_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera,  
    105                         octant, mOnlyShadowCasters, mLeavePassesInQueue); 
     111                OctreeSceneManager *ocm =  
     112                        //dynamic_cast<OctreeSceneManager *>(mSceneManager); 
     113                        static_cast<OctreeSceneManager *>(mSceneManager); 
     114                ocm->_renderOctant(mCamera, octant, mOnlyShadowCasters, mLeavePassesInQueue); 
    106115 
    107116                mVisibleNodes.push_back(node); 
     
    155164        } 
    156165 
    157         dynamic_cast<OctreeSceneManager *>(mSceneManager)->getBoxes()->push_back(box); 
     166        //dynamic_cast<OctreeSceneManager *>(mSceneManager)->getBoxes()->push_back(box); 
     167        static_cast<OctreeSceneManager *>(mSceneManager)->getBoxes()->push_back(box); 
    158168} 
    159169//----------------------------------------------------------------------- 
    160 void OctreeHierarchyInterface::GetNodeGeometryList(GtpVisibility::HierarchyNode *node,   
    161                                                                                    GtpVisibility::GeometryVector *geometryList,  
    162                                                                                    bool includeChildren) 
     170void OctreeHierarchyInterface::GetNodeGeometryList(GtpVisibility::HierarchyNode *node, 
     171                                                                                                   GtpVisibility::GeometryVector *geometryList,  
     172                                                                                                   bool includeChildren) 
    163173{ 
    164174        NodeList::const_iterator nodeIt, nodeIt_end; 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformHierarchyInterface.cpp

    r316 r726  
    1111 
    1212//----------------------------------------------------------------------- 
    13 PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys): 
    14 mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL), mCamera(NULL),  
    15 mCullCamera(NULL), mOnlyShadowCasters(false), mLeavePassesInQueue(0), 
    16 mIsBoundingBoxQuery(false) 
     13PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm,  
     14                                                                                                           RenderSystem *rsys): 
     15mSceneManager(sm),  
     16mRenderSystem(rsys),  
     17mSolidBoundingBox(NULL),  
     18mCamera(NULL),  
     19mCullCamera(NULL),  
     20mOnlyShadowCasters(false),  
     21mLeavePassesInQueue(0), 
     22mIsBoundingBoxQuery(false), 
     23mCameraPosition(Vector3(0, 0, 0)) 
    1724{ 
    1825} 
     
    131138        mCullCamera = cullCam ? cullCam : cam; 
    132139 
     140        mCameraPosition = mCullCamera->getDerivedPosition(); 
    133141        // create materials for node visualization 
    134142        CreateNodeVizMaterials(); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformQueryManager.cpp

    r316 r726  
    3131                               bool relativeVisibility) 
    3232{ 
    33         SceneManager *sm = dynamic_cast<PlatformHierarchyInterface *> 
     33        SceneManager *sm = //dynamic_cast<PlatformHierarchyInterface *> 
     34                static_cast<PlatformHierarchyInterface *> 
    3435                (mHierarchyInterface)->GetSceneManager(); 
    3536 
     
    9394        // we need access to the scene manager and the rendersystem 
    9495        PlatformHierarchyInterface *pfHierarchyInterface =  
    95                 dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface); 
     96                //dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface); 
     97                static_cast<PlatformHierarchyInterface *>(mHierarchyInterface); 
    9698 
    9799        SceneManager *sm = pfHierarchyInterface->GetSceneManager(); 
     
    189191 
    190192        SceneManager *sm =  
    191                 dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->GetSceneManager(); 
     193                //dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->GetSceneManager(); 
     194                static_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->GetSceneManager(); 
    192195 
    193196        SceneManager::EntityIterator it = sm->getEntityIterator(); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp

    r720 r726  
    2424mLeavePassesInQueue(0), 
    2525mDelayRenderTransparents(true), 
    26 //mDelayRenderTransparents(false), 
    27 //mUseDepthPass(true), 
    2826mUseDepthPass(false), 
    2927mIsDepthPassPhase(false), 
    3028mUseItemBuffer(false), 
    31 //mUseItemBuffer(true), 
    3229mIsItemBufferPhase(false), 
    3330mCurrentEntityId(1), 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityTerrainSceneManager.cpp

    r720 r726  
    1010#include <OgreSubEntity.h> 
    1111 
    12 // HACK 
    13 const static DEBUG_CHC = false; 
     12 
     13// normal terrain rendering 
     14const static NORMAL_RENDER_HACK = false; 
    1415 
    1516namespace Ogre { 
     
    1718//----------------------------------------------------------------------- 
    1819VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 
    19                                                         GtpVisibility::VisibilityManager *visManager):  
     20        GtpVisibility::VisibilityManager *visManager): 
     21TerrainSceneManager(), 
    2022mVisibilityManager(visManager),  
    2123mShowVisualization(false), 
     
    2830mIsDepthPassPhase(false), 
    2931mUseItemBuffer(false), 
    30 //mUseItemBuffer(true), 
    3132mIsItemBufferPhase(false), 
    3233mCurrentEntityId(1), 
     
    101102        //mItemBufferPass->setAmbient(1, 1, 0); 
    102103} 
    103 //------------------------------------------------------------------------- 
    104 void VisibilityTerrainSceneManager::setWorldGeometry( const String& filename ) 
    105 { 
    106     // Clear out any existing world resources (if not default) 
    107     if (ResourceGroupManager::getSingleton().getWorldResourceGroupName() !=  
    108         ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) 
    109     { 
    110         ResourceGroupManager::getSingleton().clearResourceGroup( 
    111             ResourceGroupManager::getSingleton().getWorldResourceGroupName()); 
    112     } 
    113  
    114     mTerrainPages.clear(); 
    115          
    116         // Load the configuration 
    117     loadConfig(filename); 
    118  
    119     // Resize the octree, allow for 1 page for now 
    120     float max_x = mOptions.scale.x * mOptions.pageSize; 
    121     float max_y = mOptions.scale.y; 
    122     float max_z = mOptions.scale.z * mOptions.pageSize; 
    123  
    124         float maxAxis = std::max(max_x, max_y); 
    125         maxAxis = std::max(maxAxis, max_z); 
    126         resize(AxisAlignedBox(0, 0, 0, maxAxis, maxAxis, maxAxis)); 
    127      
    128     setupTerrainMaterial(); 
    129     setupTerrainPages(); 
    130 } 
    131  
    132104//----------------------------------------------------------------------- 
    133105void VisibilityTerrainSceneManager::PrepareVisualization(Camera *cam) 
     
    146118        // ignore 
    147119    } 
     120        // add bounding boxes of rendered objects 
    148121        for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 
    149122        { 
    150123                getRenderQueue()->addRenderable(*it); 
    151124        } 
     125         
    152126        if (mRenderNodesForViz || mRenderNodesContentForViz) 
    153127        { 
     
    182156Pass *VisibilityTerrainSceneManager::setPass(Pass* pass) 
    183157{ 
     158        if (NORMAL_RENDER_HACK) 
     159        { 
     160                return SceneManager::setPass(pass); 
     161        } 
     162 
    184163        // TODO: setting vertex program is not efficient 
    185164        //Pass *usedPass = ((mIsDepthPassPhase && !pass->hasVertexProgram()) ? mDepthPass : pass);  
    186165         
    187166        // set depth fill pass if we currently do not make an aabb occlusion query 
    188         const bool useDepthPass = 1 && 
     167        const bool useDepthPass =  
    189168                (mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery()); 
    190169 
     
    196175        // set illumination stage to NONE so no shadow material is used  
    197176        // for depth pass or for occlusion query 
    198         if (1 &&  
    199                 (mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery())) 
     177        if (mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery()) 
    200178        { 
    201179                mIlluminationStage = IRS_NONE; 
     
    203181         
    204182        // --- set vertex program of current pass in order to set correct depth 
    205         if (mExecuteVertexProgramForAllPasses  
    206                 && mIsDepthPassPhase  
    207                 && pass->hasVertexProgram()) 
     183        if (mExecuteVertexProgramForAllPasses &&  
     184                mIsDepthPassPhase &&  
     185                pass->hasVertexProgram()) 
    208186        { 
    209187                // add vertex program of current pass to depth pass 
     
    254232                                                                                                                bool onlyShadowCasters) 
    255233{ 
     234        if (NORMAL_RENDER_HACK) 
     235        { 
     236                TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
     237                return; 
     238        } 
     239 
    256240        //-- show visible scene nodes and octree bounding boxes from last frame 
    257241        if (mShowVisualization) 
     
    273257 
    274258                // only shadow casters will be rendered in shadow texture pass 
    275                 if (0) 
    276                         mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
     259                if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
    277260        } 
    278261         
     
    285268void VisibilityTerrainSceneManager::_renderVisibleObjects() 
    286269{ 
     270        if (NORMAL_RENDER_HACK) 
     271        { 
     272                TerrainSceneManager::_renderVisibleObjects(); 
     273 
     274                return; 
     275        } 
     276 
    287277        InitDepthPass();          // create material for depth pass 
    288278        InitItemBufferPass(); // create material for item buffer pass 
     
    309299        } 
    310300        else //-- the hierarchical culling algorithm 
    311         { 
     301        {  
     302                // from TerrainSceneManager 
     303                mDestRenderSystem -> setLightingEnabled(false); 
     304 
    312305                // don't render backgrounds for item buffer 
    313306                if (mUseItemBuffer) 
     
    327320                setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 
    328321 
    329                 TerrainSceneManager::_renderVisibleObjects(); 
     322                OctreeSceneManager::_renderVisibleObjects(); 
    330323                ///////////////////////////////////////////////// 
    331324 
     
    356349                mVisibilityManager->ApplyVisibilityCulling(); 
    357350 
    358                 // delete remaining renderables from queue (all not in mLeavePassesInQueue) 
     351                // delete remaining renderables from queue: 
     352                // all which are not in mLeavePassesInQueue) 
    359353#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    360354                _deleteRenderedQueueGroups(mLeavePassesInQueue); 
     
    367361                mLeavePassesInQueue = 0; 
    368362                 
    369  
     363#if 1    
    370364                // add visible nodes found by the visibility culling algorithm 
    371 #if 1 
    372365                if (mUseDepthPass) 
    373366                { 
    374                         for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++ it) 
     367                        NodeList::const_iterator it, it_end = mVisible.end(); 
     368 
     369                        //getRenderQueue()->clear(); 
     370                        for (it = mVisible.begin(); it != it_end; ++ it) 
    375371                        { 
    376372                                (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 
     
    382378                clearSpecialCaseRenderQueues(); 
    383379         
    384                 if (!DEBUG_CHC) 
    385                         TerrainSceneManager::_renderVisibleObjects(); 
     380                OctreeSceneManager::_renderVisibleObjects(); 
    386381        } 
    387382                 
     
    394389 
    395390        getRenderQueue()->clear(); // finally clear render queue 
    396         OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared... 
    397  
    398         //WriteLog(); // write out stats 
     391        if (0) OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ... 
     392 
     393        if (0) WriteLog(); // write out stats 
    399394} 
    400395 
     
    402397void VisibilityTerrainSceneManager::_updateSceneGraph(Camera* cam) 
    403398{ 
     399        if (NORMAL_RENDER_HACK) 
     400        { 
     401                TerrainSceneManager::_updateSceneGraph(cam); 
     402                return; 
     403        } 
     404 
    404405        mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface); 
    405406        mHierarchyInterface->SetRenderSystem(mDestRenderSystem); 
     
    531532} 
    532533//----------------------------------------------------------------------- 
    533 GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::getVisibilityManager( void ) 
     534GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::getVisibilityManager() 
    534535{ 
    535536        return mVisibilityManager; 
     
    549550          << "Query culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumQueryCulledNodes() << ", " 
    550551          << "Frustum culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumFrustumCulledNodes() << ", " 
    551       << "Queries issued: " << mVisibilityManager->GetCullingManager()->GetNumQueriesIssued() << "\n"; 
     552      << "Queries issued: " << mVisibilityManager->GetCullingManager()->GetNumQueriesIssued() << ", " 
     553          << "Found objects: " << (int)mVisible.size() << "\n"; 
    552554 
    553555        LogManager::getSingleton().logMessage(d.str()); 
     
    560562{ 
    561563        // for correct rendering, transparents must be rendered after hierarchical culling 
    562         if (1 && !mSkipTransparents) 
    563         { 
    564                 OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList); 
     564        // => do nothing 
     565        if (NORMAL_RENDER_HACK || !mSkipTransparents) 
     566        { 
     567                SceneManager::renderObjects(objs, doLightIteration, manualLightList); 
    565568        } 
    566569} 
    567570//----------------------------------------------------------------------- 
    568571bool VisibilityTerrainSceneManager::validatePassForRendering(Pass* pass) 
    569 { 
     572{        
     573        if (NORMAL_RENDER_HACK) 
     574        { 
     575                return SceneManager::validatePassForRendering(pass); 
     576        } 
     577 
    570578        // skip all but first pass if we are doing the depth pass 
    571579        if ((mIsDepthPassPhase || mIsItemBufferPhase) && (pass->getIndex() > 0)) 
     
    584592void VisibilityTerrainSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 
    585593{ 
    586         if (!mIsItemBufferPhase) 
    587         { 
    588                 TerrainSceneManager::renderQueueGroupObjects(pGroup); 
     594        if (NORMAL_RENDER_HACK || !mIsItemBufferPhase) 
     595        { 
     596                SceneManager::renderQueueGroupObjects(pGroup); 
    589597                return; 
    590598        } 
     
    616624                        continue; 
    617625 
    618                 // Render only first pass 
     626                // Render only first pass of renderable as false color 
    619627                if (ipass->first->getIndex() > 0) 
    620628                        continue; 
     
    627635                for (irend = rendList->begin(); irend != irendend; ++irend) 
    628636                { 
    629                         std::stringstream d; d << "itembuffer, pass name: " <<  
     637                        if (0) 
     638                        { 
     639                                std::stringstream d; d << "itembuffer, pass name: " <<  
    630640                                ipass->first->getParent()->getParent()->getName(); 
    631                                  
    632                         //LogManager::getSingleton().logMessage(d.str()); 
     641                                LogManager::getSingleton().logMessage(d.str()); 
     642                        } 
    633643                         
    634644                        RenderSingleObjectForItemBuffer(*irend, ipass->first); 
     
    636646        } 
    637647 
    638         // -- TRANSPARENT LOOP: must be handled differently  
     648        //-- TRANSPARENT LOOP: must be handled differently from solids 
    639649 
    640650        // transparents are treated either as solids or completely discarded 
     
    729739        mLeavePassesInQueue = 0; 
    730740 
    731         if (!DEBUG_CHC && !mUseDepthPass && !mUseItemBuffer) 
     741        if (!mUseDepthPass && !mUseItemBuffer) 
    732742        { 
    733743                if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) 
     
    760770        // skip rendering transparents during the hierarchical culling 
    761771        // (because they will be rendered afterwards) 
    762         mSkipTransparents = !DEBUG_CHC &&  
     772        mSkipTransparents =  
    763773                (mIsDepthPassPhase || (mLeavePassesInQueue & RenderPriorityGroup::TRANSPARENT_PASSES)); 
    764774 
     
    800810} 
    801811//----------------------------------------------------------------------- 
    802 void VisibilityTerrainSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 
     812void VisibilityTerrainSceneManager::renderAdditiveStencilShadowedQueueGroupObjects( 
     813        RenderQueueGroup* pGroup) 
    803814{ 
    804815        // only render solid passes during hierarchical culling 
     
    832843} 
    833844//----------------------------------------------------------------------- 
    834 void VisibilityTerrainSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 
     845void VisibilityTerrainSceneManager::renderModulativeStencilShadowedQueueGroupObjects( 
     846        RenderQueueGroup* pGroup) 
    835847{ 
    836848   if (mIsHierarchicalCulling) 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/include/DistanceQueue.h

    r722 r726  
    2323        {} 
    2424         
    25         bool operator() (T v1, T v2) const 
     25        bool operator() (const T v1, const T v2) const 
    2626        { 
    27                 return false;//mHierarchyInterface->GetSquaredDistance(v1) > mHierarchyInterface->GetSquaredDistance(v2); 
     27                //return false; 
     28                return mHierarchyInterface->GetSquaredDistance(v1) > mHierarchyInterface->GetSquaredDistance(v2); 
    2829        } 
    2930                 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h

    r606 r726  
    7272        */ 
    7373        DistanceQueue *GetQueue(); 
     74         
    7475        /** Returns distance of the node to the view plane. 
    75                 @param node1 the hierarchy node 
     76                @param node the hierarchy node 
    7677        */                       
    7778        virtual float GetSquaredDistance(HierarchyNode *node) const = 0; 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp

    r350 r726  
    3030        while (!mHierarchyInterface->GetQueue()->empty() || !queryQueue.empty()) 
    3131        { 
     32                // only wait for result if queue is empty 
    3233                while (!queryQueue.empty() &&  
    3334                           queryQueue.front().second->GetQueryResult(visiblePixels,  
     
    4041                        if (visiblePixels > mVisibilityThreshold) 
    4142                        { 
    42                                 // ensure that we only traverse once if geometry in node 
     43                                // in case geometry is in omterior node: ensure that we only traverse once 
    4344                                if (!mHierarchyInterface->IsNodeVisible(node)) 
     45                                { 
    4446                                        mHierarchyInterface->TraverseNode(node); 
     47                                } 
     48 
    4549                                mHierarchyInterface->PullUpVisibility(node); 
    4650                        } 
     
    96100                                { 
    97101                                        SkipQuery(node); 
    98  
    99102                                        continue; 
    100103                                } 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/FrustumCullingManager.cpp

    r720 r726  
    88{ 
    99        if (0) Ogre::LogManager::getSingleton().logMessage("Frustum Culling"); 
     10 
    1011        while (!mHierarchyInterface->GetQueue()->empty()) 
    1112        { 
    1213                HierarchyNode *node = mHierarchyInterface->GetQueue()->top(); 
    1314                mHierarchyInterface->GetQueue()->pop(); 
    14                  
     15 
    1516                // interesting for visualization purpose 
    1617                mHierarchyInterface->SetNodeVisible(node, false); 
     
    3334        } 
    3435} 
    35  
    3636} // namespace GtpVisibility 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/HierarchyInterface.cpp

    r316 r726  
    77//----------------------------------------------------------------------- 
    88HierarchyInterface::HierarchyInterface():  
    9 mFrameId(0), mNumTraversedNodes(0), mHierarchyRoot(NULL),  
    10 mSavedNode(NULL), mCurrentTestIdx(0), mTestGeometryForVisibleLeaves(false) 
     9mFrameId(0),  
     10mNumTraversedNodes(0),  
     11mHierarchyRoot(NULL),  
     12mSavedNode(NULL),  
     13mCurrentTestIdx(0),  
     14mTestGeometryForVisibleLeaves(false) 
    1115{        
    1216        mDistanceQueue = new DistanceQueue(GtDistance<HierarchyNode *>(this)); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityManager.cpp

    r722 r726  
    1818mAssumedVisibilityForChc(0) 
    1919{ 
    20  
    2120#if 1 
    2221        SetCullingManager(VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING); 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj

    r722 r726  
    6565                        <Tool 
    6666                                Name="VCCLCompilerTool" 
     67                                InlineFunctionExpansion="2" 
     68                                FavorSizeOrSpeed="1" 
     69                                OptimizeForWindowsApplication="TRUE" 
    6770                                AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;..\include;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;..\src;&quot;$(CG_INC_PATH)&quot;;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces" 
    6871                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB;" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp

    r704 r726  
    156156       
    157157      currentMesh->AddFace(face); 
    158       if (meshGrouping != 0 && 
    159                                         currentMesh->mFaces.size() >=  meshGrouping) { 
     158      if (meshGrouping != 0 && currentMesh->mFaces.size() >=  meshGrouping) { 
    160159                if (ROTATE_SCENE) 
    161160                        RotateMesh(currentMesh); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r719 r726  
    24412441                { 
    24422442                        geom.Add(candidatePolys[i], candidatePlanes[i]); 
    2443                         //      geom.mPolys.push_back(candidates[i]); 
    24442443                } 
    24452444        } 
     
    24562455 
    24572456 
    2458 int BspTree::FindNeighbors(BspNode *n, vector<BspLeaf *>  
    2459                                                    &neighbors, 
     2457int BspTree::FindNeighbors(BspNode *n,  
     2458                                                   vector<BspLeaf *> &neighbors, 
    24602459                                                   const bool onlyUnmailed) const 
    24612460{ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r722 r726  
    21042104        { 
    21052105                exporter->ExportMesh(vc->GetMesh()); 
     2106         
    21062107                return; 
    21072108        } 
    21082109 
     2110         
     2111        if (clipPlane) 
     2112        { 
     2113                ViewCellContainer leaves; 
     2114                mViewCellsTree->CollectLeaves(vc, leaves); 
     2115                ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     2116 
     2117                for (it = leaves.begin(); it != it_end; ++ it) 
     2118                { 
     2119                        BspNodeGeometry geom; 
     2120 
     2121                        BspNodeGeometry front; 
     2122                        BspNodeGeometry back; 
     2123 
     2124                        BspLeaf *leaf = dynamic_cast<BspViewCell *>(*it)->mLeaf; 
     2125                        mBspTree->ConstructGeometry(leaf, geom); 
     2126 
     2127                        const float eps = 0.00000001f; 
     2128                        const int cf = geom.Side(*clipPlane, eps); 
     2129 
     2130                        if (cf == -1) 
     2131                        { 
     2132                                exporter->ExportPolygons(geom.GetPolys()); 
     2133                        } 
     2134                        else if (cf == 0) 
     2135                        { 
     2136                                geom.SplitGeometry(front, 
     2137                                                                   back, 
     2138                                                                   *clipPlane, 
     2139                                                                   mViewSpaceBox,  
     2140                                                                   eps); 
     2141         
     2142                                //Debug << "geo size: " << geom.Size() << endl; 
     2143                                //Debug << "size b: " << back.Size() << " f: " << front.Size() << endl; 
     2144                                if (back.Valid()) 
     2145                                { 
     2146                                        exporter->ExportPolygons(back.GetPolys()); 
     2147                                }                        
     2148                        } 
     2149                } 
     2150        } 
     2151        else 
     2152        { 
     2153                BspNodeGeometry geom; 
     2154                mBspTree->ConstructGeometry(vc, geom); 
     2155                         
     2156                exporter->ExportPolygons(geom.GetPolys()); 
     2157        } 
     2158} 
     2159 
     2160 
     2161void BspViewCellsManager::CreateMesh(ViewCell *vc) 
     2162{ 
     2163        // delete previous mesh 
     2164        ///DEL_PTR(vc->GetMesh()); 
    21092165        BspNodeGeometry geom; 
    21102166        mBspTree->ConstructGeometry(vc, geom); 
    21112167 
    2112         if (clipPlane) 
    2113         { 
    2114                 const int cf = Polygon3::ClassifyPlane(geom.GetPolys(), *clipPlane, 0.0001f); 
    2115  
    2116                 if (cf == Polygon3::BACK_SIDE) 
    2117                 { 
    2118                         exporter->ExportPolygons(geom.GetPolys()); 
    2119                 } 
    2120                 else if (cf == Polygon3::SPLIT) 
    2121                 { 
    2122                         BspNodeGeometry front; 
    2123                         BspNodeGeometry back; 
    2124  
    2125                         geom.SplitGeometry(front, 
    2126                                                            back, 
    2127                                                            *clipPlane, 
    2128                                                            mViewSpaceBox,  
    2129                                                            0.0001f); 
    2130  
    2131                         if (back.Valid()) 
    2132                                 exporter->ExportPolygons(back.GetPolys()); 
    2133                 } 
    2134         } 
    2135         else 
    2136         { 
    2137                 exporter->ExportPolygons(geom.GetPolys()); 
    2138         } 
    2139 } 
    2140  
    2141  
    2142 void BspViewCellsManager::CreateMesh(ViewCell *vc) 
    2143 { 
    2144         if (vc->GetMesh()) 
    2145                 delete vc->GetMesh(); 
    2146  
    2147         BspNodeGeometry geom; 
    2148          
    2149         mBspTree->ConstructGeometry(vc, geom); 
    2150  
    21512168        Mesh *mesh = new Mesh(); 
     2169 
    21522170        geom.AddToMesh(*mesh); 
    21532171        vc->SetMesh(mesh); 
     2172        // put mesh into mesh container so we can savely delete it 
    21542173        mMeshContainer.push_back(mesh); 
    21552174} 
     
    27852804} 
    27862805 
     2806 
    27872807void VspKdViewCellsManager::Visualize(const ObjectContainer &objects, 
    27882808                                                                          const VssRayContainer &sampleRays) 
     
    28822902        Exporter *exporter = Exporter::GetExporter("vspkdtree_merged.x3d"); 
    28832903 
    2884         //if (exportGeometry) exporter->SetWireframe(); 
    2885         //else exporter->SetFilled(); 
    28862904 
    28872905        ExportViewCellsForViz(exporter); 
     
    40004018void VspBspViewCellsManager::CreateMesh(ViewCell *vc) 
    40014019{ 
    4002         if (vc->GetMesh()) 
    4003                 delete vc->GetMesh(); 
    4004  
    4005          
     4020        //if (vc->GetMesh()) delete vc->GetMesh(); 
    40064021        BspNodeGeometry geom; 
    40074022 
     
    40114026        geom.AddToMesh(*mesh); 
    40124027        vc->SetMesh(mesh); 
     4028        // put mesh into mesh container so we can savely delete it 
    40134029        mMeshContainer.push_back(mesh); 
    40144030} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r719 r726  
    458458 
    459459        EvalPriority(tData); 
    460          
    461  
    462         if (mSimulateOctree) 
    463         tData.mAxis = 0; 
     460 
    464461 
    465462        // first node is kd node, i.e. an axis aligned box 
     
    569566                                                          geom); 
    570567 
    571          
    572568 
    573569        // compute first split candidate 
     
    695691                VspBspTraversalData tBackData; 
    696692 
    697                 if (mSimulateOctree) 
    698                 {       // choose axes in circular motion 
    699                         tFrontData.mAxis = (tData.mAxis + 1) % 3; 
    700                         tBackData.mAxis = (tData.mAxis + 1) % 3; 
    701                 } 
    702  
    703693                // create new interior node and two leaf nodes 
    704694                // or return leaf as it is (if maxCostRatio missed) 
     
    709699                Plane3 splitPlane; 
    710700                BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 
    711  
     701                 
     702                // choose next split plane 
    712703                if (!SelectPlane(splitPlane, leaf, tData, tFrontData, tBackData, splitAxis)) 
    713704                { 
     
    722713                } 
    723714         
     715                // if this a valid split => subdivide this node further 
    724716                if (splitFurther) //-- continue subdivision 
    725717                { 
     
    732724 
    733725                        tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && (splitAxis < 3)); 
     726                        tFrontData.mAxis = tBackData.mAxis = splitAxis; 
    734727 
    735728                        // how often was max cost ratio missed in this branch? 
     
    740733                        EvalPriority(tBackData); 
    741734 
     735                        // evaluate subdivision stats 
    742736                        if (1) 
    743737                        { 
    744  
    745738                                float cFront = (float)tFrontData.mPvs * tFrontData.mProbability; 
    746739                                float cBack = (float)tBackData.mPvs * tBackData.mProbability; 
     
    823816} 
    824817 
    825  
     818// subdivide using a split plane queue 
    826819BspNode *VspBspTree::Subdivide(VspBspSplitQueue &tQueue, 
    827820                                                           VspBspSplitCandidate &splitCandidate) 
     
    839832 
    840833                //-- continue subdivision 
     834                 
    841835                // create new interior node and two leaf node 
    842836                const Plane3 splitPlane = splitCandidate.mSplitPlane; 
     
    853847 
    854848                tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && (splitAxis < 3)); 
    855                  
     849                tFrontData.mAxis = tBackData.mAxis = splitAxis; 
     850 
    856851                // how often was max cost ratio missed in this branch? 
    857852                tFrontData.mMaxCostMisses = maxCostMisses; 
     
    960955 
    961956        // compute locally best split plane 
    962         bool success = SelectPlane(splitData.mSplitPlane, leaf, tData,  
     957    bool success = SelectPlane(splitData.mSplitPlane, leaf, tData,  
    963958                                                           frontData, backData, splitData.mSplitAxis); 
    964959 
     
    14031398                sAxis = Random(3); 
    14041399        else if (mSimulateOctree) 
    1405                 sAxis = tData.mAxis; 
     1400                sAxis = (tData.mAxis + 1) % 3; 
    14061401                 
    14071402        //Debug << "use special axis: " << useSpecialAxis << endl; 
     
    20122007 
    20132008        const int pvsSize = data.mPvs; 
    2014 //cout << "here433" << endl; 
     2009 
    20152010        RayInfoContainer::const_iterator rit, rit_end = data.mRays->end(); 
    20162011 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp

    r712 r726  
    11451145                for (oit = objects.begin(); oit != oit_end; ++ oit) 
    11461146                { 
    1147                         if (1) 
    1148                         { 
     1147                        if (0) 
    11491148                                SetForcedMaterial(RandomMaterial()); 
    1150                         } 
    1151  
     1149                         
    11521150                        ExportIntersectable(*oit); 
    11531151                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r712 r726  
    5757 
    5858 
     59static void RotateMesh(Mesh *mesh) 
     60{ 
     61        VertexContainer::iterator it, it_end = mesh->mVertices.end(); 
     62 
     63        const float angle = 30.0f * PI / 180.0f; 
     64        const Matrix4x4 rot = RotationYMatrix(angle); 
     65 
     66        for (it = mesh->mVertices.begin(); it != it_end; ++ it) 
     67        { 
     68                (*it) = rot * (*it);         
     69        } 
     70} 
    5971 
    6072// --------------------------------------------------------------------------- 
     
    96108 
    97109 
    98 static void RotateMesh(Mesh *mesh) 
    99 { 
    100         VertexContainer::iterator it, it_end = mesh->mVertices.end(); 
    101  
    102         const float angle = 30.0f * PI / 180.0f; 
    103         const Matrix4x4 rot = RotationYMatrix(angle); 
    104  
    105         for (it = mesh->mVertices.begin(); it != it_end; ++ it) 
    106         { 
    107                 (*it) = rot * (*it);         
    108         } 
    109 } 
    110110 
    111111 
Note: See TracChangeset for help on using the changeset viewer.