Changeset 880


Ignore:
Timestamp:
05/03/06 01:13:24 (18 years ago)
Author:
mattausch
Message:

added filter to online stuff (not fully working, too slow
)

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

Legend:

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

    r870 r880  
    196196        GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager; 
    197197 
    198         /** Used to assign Ogre meshes to view cell entries. 
    199         */ 
     198        /// Used to assign Ogre meshes to view cell entries. 
    200199        GtpVisibilityPreprocessor::ObjectContainer mObjects; 
    201200 
    202         GtpVisibilityPreprocessor::ViewCell *mOldViewCell; 
     201        GtpVisibilityPreprocessor::ViewCell *mElementaryViewCell; 
    203202        GtpVisibilityPreprocessor::ViewCell *mCurrentViewCell; 
    204203 
    205         /** If view cells are used. 
    206         */ 
     204        /// If view cells are used. 
    207205        bool mUseViewCells; 
     206 
     207        /// if the view cells are filtered 
     208        bool mUseVisibilityFilter; 
    208209}; 
    209210 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp

    r868 r880  
    144144        { 
    145145                mSavedNode = node; 
    146             //dynamic_cast<Octree *>(node)->_getCullBounds(&mBox); 
     146            //static_cast<Octree *>(node)->_getCullBounds(&mBox); 
    147147                mBox = static_cast<Octree *>(node)->_getWorldAABB(); 
    148148        } 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp

    r870 r880  
    4545mIsHierarchicalCulling(false), 
    4646mViewCellsLoaded(false), 
     47mUseViewCells(false), 
     48mUseVisibilityFilter(false), 
    4749mCurrentViewCell(NULL), 
    48 mOldViewCell(NULL), 
    49 mUseViewCells(false) 
     50mElementaryViewCell(NULL) 
    5051{ 
    5152        mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 
     
    9192        OGRE_DELETE(mHierarchyInterface); 
    9293        CLEAR_CONTAINER(mObjects); 
     94        OGRE_DELETE(mCurrentViewCell); 
    9395} 
    9496//----------------------------------------------------------------------- 
     
    514516        if (key == "UseViewCells") 
    515517        {  
    516                 if (mViewCellsLoaded) 
    517                 { 
    518                         mUseViewCells = *static_cast<const bool *>(val); 
    519                          
    520                         if (mUseViewCells) 
    521                         { 
    522                                 SetObjectsVisible(false); 
    523                                 mCurrentViewCell = mOldViewCell = NULL; 
    524                         } 
    525                         else 
    526                         { 
    527                                 SetObjectsVisible(true); 
    528                         } 
    529                 } 
    530  
    531                 return true; 
    532         } 
     518                mUseViewCells = *static_cast<const bool *>(val); 
     519 
     520                // reset view cell 
     521                OGRE_DELETE(mCurrentViewCell); 
     522                if (mUseViewCells) 
     523                        mCurrentViewCell =  mViewCellsManager->GenerateViewCell(); 
     524                mElementaryViewCell = NULL; 
     525                // if using view cells, all objects are set to false initially 
     526                SetObjectsVisible(!mUseViewCells); 
     527                 
     528                return true; 
     529        } 
     530        if (key == "UseVisibilityFilter") 
     531        { 
     532                mUseVisibilityFilter = *static_cast<const bool *>(val); 
     533                // set null =>recomputation of the pvs 
     534        mElementaryViewCell = NULL; 
     535                return true; 
     536        } 
     537 
    533538        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 
    534539                setOption(key, val) || OctreeSceneManager::setOption(key, val); 
     
    864869                        // Also render any objects which have receive shadows disabled 
    865870                        OctreeSceneManager::renderObjects(pPriorityGrp->_getSolidPassesNoShadow(), true); 
    866                  
    867                         /*std::stringstream d;  
     871#if 0            
     872                        std::stringstream d;  
    868873                        d << " solid size: " << (int)pPriorityGrp->_getSolidPasses().size() 
    869874                                << " solid no shadow size: " << (int)pPriorityGrp->_getSolidPassesNoShadow().size() 
    870875                                << "difspec size: " << (int)pPriorityGrp->_getSolidPassesDiffuseSpecular().size() 
    871876                                << " decal size: " << (int)pPriorityGrp->_getSolidPassesDecal().size(); 
    872                         LogManager::getSingleton().logMessage(d.str());*/ 
     877                        LogManager::getSingleton().logMessage(d.str()); 
     878#endif 
    873879                } 
    874880        } 
     
    10271033void VisibilityOctreeSceneManager::applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc,  
    10281034                                                                                                        const bool load) 
    1029 {       GtpVisibilityPreprocessor::Debug << "here9 " << endl; 
    1030         // NOTE: should not happen, rather apply view cell representing unbounded space then 
    1031         if (!vc) return; 
     1035{       // NOTE: should not happen, rather apply view cell representing unbounded space then 
     1036        if (!vc)  
     1037        {        
     1038                // set everything visible for savety 
     1039                SetObjectsVisible(true); 
     1040 
     1041                return; 
     1042        } 
    10321043 
    10331044        GtpVisibilityPreprocessor::ObjectPvsMap::const_iterator oit, 
     
    10411052                OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance*>((*oit).first); 
    10421053                omi->GetMesh()->setVisible(load); 
    1043                 GtpVisibilityPreprocessor::Debug << "here45 " << omi->GetId() << endl; 
     1054                //GtpVisibilityPreprocessor::Debug << "here45 " << omi->GetId() << endl; 
    10441055        } 
    10451056} 
     
    10481059{ 
    10491060        // for OGRE 1.2 
    1050 #ifdef OGRE12 
    1051         MovableObjectIterator mit = getMovableObjectIterator("Entity"); 
    1052 #else 
     1061//#ifdef OGRE12 
     1062        //MovableObjectIterator mit = getMovableObjectIterator("Entity"); 
     1063#if 0 
    10531064        EntityIterator eit = getEntityIterator(); 
    10541065 
     
    10601071        } 
    10611072 
     1073#else 
     1074        GtpVisibilityPreprocessor::ObjectContainer::iterator it, it_end = mObjects.end(); 
     1075 
     1076        for (it = mObjects.begin(); it != it_end; ++ it) 
     1077        { 
     1078                OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it); 
     1079                Entity *ent = omi->GetMesh(); 
     1080                ent->setVisible(visible); 
     1081        } 
    10621082#endif 
    10631083} 
     
    10891109void VisibilityOctreeSceneManager::updatePvs(Camera *cam) 
    10901110{ 
    1091         Ogre::LogManager::getSingleton().logMessage("here196"); 
    10921111        if (mViewCellsLoaded && mUseViewCells) 
    10931112        { 
    1094                 GtpVisibilityPreprocessor::ViewCell *vc =  
    1095                         mViewCellsManager->GetViewCell(OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition())); 
    1096  
    1097                 std::stringstream d; d << "pos " << cam->getDerivedPosition() << "vc: " << vc; 
    1098                 Ogre::LogManager::getSingleton().logMessage(d.str()); 
    1099  
    1100                 // view cell changed => unload old objects and load new objects 
    1101                 if (vc != mCurrentViewCell) 
    1102                 { 
    1103                         //-- unload old pvs 
    1104                         if (mOldViewCell) 
    1105                         { 
    1106                                 const bool load = false; 
    1107  
    1108                                 applyViewCellPvs(mOldViewCell, load); 
    1109                                 Ogre::LogManager::getSingleton().logMessage("here16"); 
    1110                         } 
    1111  
    1112                         mOldViewCell = mCurrentViewCell; 
    1113  
    1114                         //-- load new pvs 
    1115                         mCurrentViewCell = vc; 
    1116                         const bool load = true; 
    1117  
    1118                         applyViewCellPvs(mCurrentViewCell, load); 
    1119                         Ogre::LogManager::getSingleton().logMessage("here106"); 
    1120                 } 
     1113                const GtpVisibilityPreprocessor::Vector3 viewPoint =  
     1114                        OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition()); 
     1115 
     1116                GtpVisibilityPreprocessor::ViewCell *newElementary =  
     1117                        mViewCellsManager->GetViewCell(viewPoint); 
     1118 
     1119                // elementary view cell did not change => apply same pvs 
     1120                if (mElementaryViewCell == newElementary) 
     1121                        return; 
     1122 
     1123                mElementaryViewCell = newElementary; 
     1124 
     1125                //-- unload old pvs 
     1126                applyViewCellPvs(mCurrentViewCell, false); 
     1127 
     1128 
     1129                //-- the new view cell 
     1130                 
     1131                GtpVisibilityPreprocessor::ViewCell *viewCell; 
     1132 
     1133                 
     1134                if (mUseVisibilityFilter) 
     1135                { 
     1136                        //-- compute new filtered cell 
     1137                        GtpVisibilityPreprocessor::PrVs prvs; 
     1138                        mViewCellsManager->GetPrVS(viewPoint, prvs); 
     1139                        viewCell = prvs.mViewCell; 
     1140                } 
     1141                else 
     1142                { 
     1143                        viewCell = newElementary; 
     1144                } 
     1145                         
     1146                //-- load new pvs 
     1147                applyViewCellPvs(viewCell, true); 
     1148 
     1149                // store pvs 
     1150                mCurrentViewCell->SetPvs(viewCell->GetPvs()); 
     1151 
     1152                // delete merge tree of filtered view cell 
     1153                if (mUseVisibilityFilter) 
     1154                        mViewCellsManager->DeleteLocalMergeTree(viewCell); 
    11211155        } 
    11221156} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r870 r880  
    174174{ 
    175175        return mPvs; 
     176} 
     177 
     178 
     179void ViewCell::SetPvs(const ObjectPvs &pvs) 
     180{ 
     181        mPvs = pvs; 
    176182} 
    177183 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r860 r880  
    117117 
    118118        ObjectPvs &GetPvs(); 
     119 
     120        void SetPvs(const ObjectPvs &pvs); 
    119121 
    120122        /** Type of view cells. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r879 r880  
    49594959        Vector3 bsize = mViewSpaceBox.Size(); 
    49604960        const Vector3 viewPoint(mViewSpaceBox.Center()); 
    4961         float w = Magnitude(mViewSpaceBox.Size())*mFilterWidth; 
     4961        float w = Magnitude(mViewSpaceBox.Size()) * mFilterWidth; 
    49624962        const Vector3 width = Vector3(w); 
    49634963         
     
    49804980 
    49814981                exporter->SetForcedMaterial(RgbColor(0,1,0)); 
    4982                 ExportViewCellGeometry(exporter,  GetViewCell(viewPoint)); 
     4982                ExportViewCellGeometry(exporter, GetViewCell(viewPoint)); 
    49834983 
    49844984                //exporter->ResetForcedMaterial(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r879 r880  
    4343  ViewCell *mViewCell; 
    4444 
    45   // input parameter is the render budget for the PrVS 
     45  // input parameter is the render budget for the PrVs 
    4646  float mRenderBudget; 
    4747 
     
    467467                                                                                ViewCellContainer &viewCells) const; 
    468468 
     469        /** Tests the visibility filter functionality. 
     470        */ 
    469471        virtual void TestFilter(const ObjectContainer &objects) {}; 
    470472 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r870 r880  
    300300                                  lower_bound(mObjects->begin(), mObjects->end(), (Intersectable *)&dummyInst, ilt); 
    301301                                 
    302                                 Intersectable *obj = *oit; 
    303                                  
    304                                 if (obj->GetId() == objId) 
     302                                                         
     303                                if ((oit != mObjects->end()) && ((*oit)->GetId() == objId)) 
    305304                                { 
    306                                   // $$JB we should store a float a per object which corresponds 
    307                                   // to sumof pdfs, i.e. its relative visibility 
    308                                   // temporarily set to 1.0f 
    309                                         viewCell->GetPvs().AddSample(obj, 1.0f);                                 
     305                                        // $$JB we should store a float a per object which corresponds 
     306                                        // to sumof pdfs, i.e. its relative visibility 
     307                                        // temporarily set to 1.0f 
     308                                        viewCell->GetPvs().AddSample(*oit, 1.0f);                                
    310309                                } 
    311310                                else 
    312311                                { 
    313                                         Debug << "error: object does not exist" << endl; 
     312                                        Debug << "error: object with id " << objId << " does not exist" << endl; 
    314313                                } 
    315314                        } 
Note: See TracChangeset for help on using the changeset viewer.