Changeset 648


Ignore:
Timestamp:
02/16/06 16:21:26 (18 years ago)
Author:
mattausch
Message:

removed problems with bsp due to polygons equal to scene box faces. removing
this polyogns in a preprocessing step. also using this for vsp bsp tree, because it
is generally a good thing.

Location:
GTP/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp

    r639 r648  
    282282 
    283283        // Use 512x512 texture in GL since we can't go higher than the window res 
    284         mSceneMgr->setShadowTextureSettings(512, 2); 
     284        mSceneMgr->setShadowTextureSettings(1024, 2); 
    285285 
    286286        mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5)); 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/default.env

    r646 r648  
    2525        type vss 
    2626#       type rss 
    27         detectEmptyViewSpace false 
     27        detectEmptyViewSpace true 
    2828} 
    2929 
     
    331331                missTolerance           6 
    332332                 
    333                 maxViewCells            50000 
     333                maxViewCells            10000 
    334334                 
    335335                # used for pvs criterium 
     
    354354BspTree { 
    355355        Construction { 
    356                 samples 50000 
     356                samples 500000 
    357357                epsilon 0.005 
    358358        } 
     
    420420                minProbability 0.00001 
    421421                maxRayContribution 9999 
    422                 maxViewCells    5000 
     422                maxViewCells    10000 
    423423 
    424424                # used for pvs criterium 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp

    r645 r648  
    224224 
    225225        //TODO: remove for performance 
    226 #if 1 
     226#if 0 
    227227        if (1) 
    228228        { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r644 r648  
    512512 
    513513        //-- use priority queue to merge leaf pairs 
    514 // HACK 
    515514 
    516515        //const float maxAvgCost = 350; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r647 r648  
    318318        Debug << "splitting polygons of node " << this << " with plane " << mPlane << endl; 
    319319#endif 
     320 
    320321        PolygonContainer::const_iterator it, it_end = polys.end(); 
    321322 
     
    331332                        case Polygon3::COINCIDENT: 
    332333                                coincident.push_back(poly); 
    333                                 Debug << "!!!Coincident: " << poly->GetSupportingPlane() << endl; 
    334334                                break;                   
    335335                        case Polygon3::FRONT_SIDE:       
    336336                                frontPolys.push_back(poly); 
    337                                 Debug << "!!!front: " << poly->GetSupportingPlane() << endl; 
    338337                                break; 
    339338                        case Polygon3::BACK_SIDE: 
    340                                 Debug << "!!!back: " << poly->GetSupportingPlane() << endl; 
    341339                                backPolys.push_back(poly); 
    342340                                break; 
     
    710708        // preprocess: throw out polygons coincident to the view space box (not needed) 
    711709        PolygonContainer boxPolys; 
    712         mBox.ExtractPolygons(boxPolys); 
     710        mBox.ExtractPolys(boxPolys); 
    713711        vector<Plane3> boxPlanes; 
    714         PolygonContainer::const_iterator pit, pit_end = polys->end(); 
    715  
    716         for (pit = polys->begin(); pit != pit_end; ++ pit) 
    717         { 
    718                  
    719         } 
    720 } 
     712 
     713        PolygonContainer::iterator pit, pit_end = boxPolys.end(); 
     714 
     715        // extract planes of box 
     716        // TODO: can be done more elegantly than first extracting polygons 
     717        // and take their planes 
     718        for (pit = boxPolys.begin(); pit != pit_end; ++ pit) 
     719        { 
     720                boxPlanes.push_back((*pit)->GetSupportingPlane()); 
     721        } 
     722 
     723        pit_end = polys.end(); 
     724 
     725        for (pit = polys.begin(); pit != pit_end; ++ pit) 
     726        { 
     727                vector<Plane3>::const_iterator bit, bit_end = boxPlanes.end(); 
     728                 
     729                for (bit = boxPlanes.begin(); (bit != bit_end) && (*pit); ++ bit) 
     730                { 
     731                        const int cf = (*pit)->ClassifyPlane(*bit, mEpsilon); 
     732 
     733                        if (cf == Polygon3::COINCIDENT) 
     734                        { 
     735                                DEL_PTR(*pit); 
     736                                //Debug << "coincident!!" << endl; 
     737                        } 
     738                } 
     739        } 
     740 
     741        // remove deleted entries 
     742        for (int i = 0; i < (int)polys.size(); ++ i) 
     743        { 
     744                while (!polys[i] && (i < (int)polys.size())) 
     745                { 
     746                        swap(polys[i], polys.back()); 
     747                        polys.pop_back(); 
     748                } 
     749        } 
     750} 
     751 
     752 
    721753 
    722754void BspTree::Construct(const RayContainer &sampleRays, 
     
    794826        } 
    795827 
    796         PreprocessPolygons(); 
     828        // throw out bad polygons 
     829        PreprocessPolygons(*polys); 
    797830 
    798831        mStat.polys = (int)polys->size(); 
     
    838871        } 
    839872 
     873        PreprocessPolygons(*polys); 
    840874        Debug << "tree has " << (int)polys->size() << " polys, " << (int)sampleRays.size() << " rays" << endl; 
    841875        Construct(polys, rays); 
     
    9911025        { 
    9921026                int pvsData = tData.mPvs; 
     1027 
    9931028                float cData = (float)pvsData * tData.mProbability; 
    994  
    9951029                float cFront = (float)tFrontData.mPvs * tFrontData.mProbability; 
    9961030                float cBack = (float)tBackData.mPvs * tBackData.mProbability; 
    997                  
    998                 Debug << "front pvs: " << tFrontData.mPvs << " p: " << tFrontData.mProbability << endl; 
    999                 Debug << "back pvs: " << tBackData.mPvs << " p: " << tBackData.mProbability << endl; 
    1000                 Debug << "pvs: " << pvsData << " p: " << tData.mProbability << endl; 
    1001  
    1002                 Debug << "data: " << cData << " front: " << cFront << " back: " << cBack << endl; 
    1003                 Debug << "cost ratio: " << (cFront + cBack) / cData << endl; 
    1004  
    1005                 if (((cFront + cBack) / cData > 1) || (tFrontData.mProbability == 0) || (tBackData.mProbability == 0)) 
    1006                 { 
    1007                         Debug << "ERROR!!" << endl; 
    1008  
    1009                         vector<Plane3> halfSpaces; 
    1010                         ExtractHalfSpaces(interior, halfSpaces); 
    1011          
    1012                         for (int i = 0; i < (int)halfSpaces.size(); ++ i) 
    1013                                 Debug << halfSpaces[i] << endl; 
    1014  
    1015                         Debug << "geom:\n" << *tData.mGeometry << endl; 
    1016                         Debug << "fgeom:\n" << *tFrontData.mGeometry << endl; 
    1017                         Debug << "bgeom:\n" << *tBackData.mGeometry << endl; 
    1018                 } 
    10191031 
    10201032                float costDecr = (cFront + cBack - cData) / mBox.GetVolume(); 
    1021  
    10221033                 
    10231034                mTotalCost += costDecr; 
     
    11041115         
    11051116         
    1106 //#ifdef _DEBUG 
     1117#ifdef _DEBUG 
    11071118        Debug << interior << endl; 
    1108         Debug << interior->GetPlane() << endl; 
    1109 //#endif 
     1119#endif 
    11101120         
    11111121 
     
    11481158                        frontData.mProbability = frontData.mGeometry->GetVolume(); 
    11491159                        backData.mProbability = tData.mProbability - frontData.mProbability; 
    1150  
    1151                         Debug << "************" << endl; 
    1152                         Debug << "plane: " << interior->mPlane << endl; 
    1153                         Debug << "box: " << mBox << endl; 
    1154                         Debug << "all: " << tData.mProbability << " f: " << frontData.mProbability << " b: " << backData.mProbability << endl; 
    1155                         Debug << "real back: " << backData.mGeometry->GetVolume() << endl; 
    1156                         Debug << "data geom: " << tData.mGeometry->mPolys.size() << " f: " << frontData.mGeometry->mPolys.size() << " b: " << backData.mGeometry->mPolys.size() << endl; 
    11571160                } 
    11581161        } 
     
    14971500                        SplitPlaneCost(poly->GetSupportingPlane(), data); 
    14981501 
    1499                 Debug << "supporting plane: " << poly->GetSupportingPlane() << endl; 
    1500  
    15011502                if (candidateCost < lowestCost) 
    15021503                { 
     
    15221523        Debug << "plane lowest cost: " << lowestCost << endl; 
    15231524#endif 
    1524         Debug << "choosen plane: " << bestPlane << endl; 
    1525  
     1525         
    15261526        return bestPlane; 
    15271527} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h

    r647 r648  
    876876                                  int &contributingSamples); 
    877877 
    878  
     878        /** Preprocesses polygons and throws out all polygons which are coincident to 
     879                the view space box faces (they can be problematic). 
     880        */ 
    879881        void PreprocessPolygons(PolygonContainer &polys); 
    880882 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r643 r648  
    332332                        AddMeshToPolygons(obj->GetMesh(), polys, obj); 
    333333                        ++ numObj; 
     334 
    334335                        //-- compute bounding box 
    335336                        if (!forcedBoundingBox) 
     
    381382        else  
    382383                mTermMinProbability *= mBox.GetVolume(); 
     384 
     385        // throw out unnecessary polygons 
     386        PreprocessPolygons(polys); 
    383387 
    384388        mBspStats.polys = (int)polys.size(); 
     
    19941998 
    19951999 
     2000void VspBspTree::PreprocessPolygons(PolygonContainer &polys) 
     2001{ 
     2002        // preprocess: throw out polygons coincident to the view space box (not needed) 
     2003        PolygonContainer boxPolys; 
     2004        mBox.ExtractPolys(boxPolys); 
     2005        vector<Plane3> boxPlanes; 
     2006 
     2007        PolygonContainer::iterator pit, pit_end = boxPolys.end(); 
     2008 
     2009        // extract planes of box 
     2010        // TODO: can be done more elegantly than first extracting polygons 
     2011        // and take their planes 
     2012        for (pit = boxPolys.begin(); pit != pit_end; ++ pit) 
     2013        { 
     2014                boxPlanes.push_back((*pit)->GetSupportingPlane()); 
     2015        } 
     2016 
     2017        pit_end = polys.end(); 
     2018 
     2019        for (pit = polys.begin(); pit != pit_end; ++ pit) 
     2020        { 
     2021                vector<Plane3>::const_iterator bit, bit_end = boxPlanes.end(); 
     2022                 
     2023                for (bit = boxPlanes.begin(); (bit != bit_end) && (*pit); ++ bit) 
     2024                { 
     2025                        const int cf = (*pit)->ClassifyPlane(*bit, mEpsilon); 
     2026 
     2027                        if (cf == Polygon3::COINCIDENT) 
     2028                        { 
     2029                                DEL_PTR(*pit); 
     2030                                //Debug << "coincident!!" << endl; 
     2031                        } 
     2032                } 
     2033        } 
     2034 
     2035        // remove deleted entries 
     2036        for (int i = 0; i < (int)polys.size(); ++ i) 
     2037        { 
     2038                while (!polys[i] && (i < (int)polys.size())) 
     2039                { 
     2040                        swap(polys[i], polys.back()); 
     2041                        polys.pop_back(); 
     2042                } 
     2043        } 
     2044} 
     2045 
     2046 
    19962047float VspBspTree::AccumulatedRayLength(const RayInfoContainer &rays) const 
    19972048{ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r639 r648  
    601601        int CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates); 
    602602         
    603          
     603        /** Preprocesses polygons and throws out all polygons which are coincident to 
     604                the view space box faces (they can be problematic). 
     605        */ 
     606        void PreprocessPolygons(PolygonContainer &polys); 
    604607         
    605608        /** Propagates valid flag up the tree. 
Note: See TracChangeset for help on using the changeset viewer.