Changeset 654


Ignore:
Timestamp:
02/19/06 20:15:02 (18 years ago)
Author:
mattausch
Message:

removed bug in split queue

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

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/default.env

    r652 r654  
    1313#;../data/vienna/vienna-plane.x3d 
    1414#       filename ../data/vienna/viewcells-25-sel.x3d 
    15 #       filename ../data/atlanta/atlanta2.x3d 
     15        filename ../data/atlanta/atlanta2.x3d 
    1616#       filename ../data/soda/soda.dat 
    17         filename ../data/soda/soda5.dat 
     17#       filename ../data/soda/soda5.dat 
    1818} 
    1919 
     
    2525        type vss 
    2626#       type rss 
    27         detectEmptyViewSpace true 
     27        detectEmptyViewSpace false 
    2828} 
    2929 
     
    3636        loadInitialSamples  false 
    3737        storeInitialSamples false 
    38         useViewSpaceBox true 
     38        useViewSpaceBox false 
    3939#       testBeamSampling true 
    4040} 
     
    184184        maxStaticMemory 40 
    185185 
    186         exportToFile false 
    187         loadFromFile true 
     186        exportToFile true 
     187        loadFromFile false 
    188188 
    189189        #type kdTree 
     
    213213                useRaysForMerge false 
    214214                refine false 
    215                 compress true 
    216                 merge false 
     215                compress false 
     216                merge true 
    217217        } 
    218218 
     
    288288VspBspTree { 
    289289        Construction { 
    290                 samples 50000 
     290                samples 300000 
    291291                epsilon 0.0005 
    292292                randomize false 
     
    301301        # pvs                  = 1024 
    302302         
    303         splitPlaneStrategy 1024 
     303        splitPlaneStrategy 1026 
    304304         
    305305        # maximal candidates for split planes 
     
    330330                maxCostRatio            1.8 
    331331                missTolerance           6 
    332                  
    333                 maxViewCells            100 
     332                globalCostMissTolerance 4 
     333                minGlobalCostRatio      0.0000001 
     334                maxViewCells            40000 
    334335         
    335336                # used for pvs criterium 
     
    420421                minProbability 0.00001 
    421422                maxRayContribution 9999 
    422                 maxViewCells    1000 
     423                maxViewCells    10000 
    423424 
    424425                # used for pvs criterium 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r612 r654  
    18111811/************************************************************************************/ 
    18121812 
     1813        RegisterOption("VspBspTree.Termination.minGlobalCostRatio", 
     1814                                        optFloat, 
     1815                                        "vsp_bsp_term_min_global_cost_ratio", 
     1816                                        "0.0001"); 
     1817 
     1818        RegisterOption("VspBspTree.Termination.globalCostMissTolerance", 
     1819                                        optInt, 
     1820                                        "vsp_bsp_term_global_cost_miss_tolerance", 
     1821                                        "4"); 
    18131822 
    18141823        RegisterOption("VspBspTree.Termination.minPolygons", 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r651 r654  
    414414                } 
    415415        } 
    416 Debug << "here22" << endl; 
     416 
    417417         
    418418        if (viewCellId >= 0) // valid view cell 
     
    427427                BspViewCell *viewCell = dynamic_cast<BspViewCell *>(*vit); 
    428428 
    429                 Debug << "here44" << endl; 
    430  
     429         
    431430                if (viewCell->GetId() == viewCellId) 
    432431                { 
     
    447446                        mVspBspTree->PropagateUpValidity(leaf); 
    448447                } 
    449         }Debug << "here33" << endl; 
     448        } 
    450449} 
    451450 
     
    496495void ViewCellsParseHandlers::StartViewCellLeaf(AttributeList& attributes) 
    497496{ 
    498         Debug << "here111" << endl; 
    499497        BspViewCell *viewCell = new BspViewCell(); 
    500498 
     
    518516void ViewCellsParseHandlers::StartViewCellInterior(AttributeList& attributes) 
    519517{ 
    520         Debug << "here222" << endl; 
    521518        ViewCellInterior* interior = new ViewCellInterior(); 
    522519         
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r653 r654  
    9191        environment->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 
    9292 
    93         // HACK 
    94         mTermMinPolygons = 25; 
     93        environment->GetFloatValue("VspBspTree.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); 
     94        environment->GetIntValue("VspBspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 
     95 
     96        // HACK//mTermMinPolygons = 25; 
    9597 
    9698        //-- factors for bsp tree split plane heuristics 
     
    389391        mBspStats.polys = (int)polys.size(); 
    390392 
     393        mGlobalCostMisses = 0; 
     394 
    391395        cout << "finished" << endl; 
    392396 
     
    395399                  << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl << endl; 
    396400 
    397         Construct(polys, rays); 
     401        if (0) 
     402                ConstructWithSplitQueue(polys, rays); 
     403        else 
     404                Construct(polys, rays); 
    398405 
    399406        // clean up polygons 
     
    496503                                  << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
    497504 
    498                 if (mBspStats.Leaves() == nLeaves) 
     505                if (mBspStats.Leaves() >= nLeaves) 
    499506                { 
    500507                        nLeaves += 500; 
     
    523530 
    524531 
    525 void VspBspTree::ConstructWithSplitQueueQueue(const PolygonContainer &polys,  
     532void VspBspTree::ConstructWithSplitQueue(const PolygonContainer &polys,  
    526533                                                                                          RayInfoContainer *rays) 
    527534{ 
     
    551558        tQueue.push(splitCandidate); 
    552559 
    553  
    554560        mTotalCost = tData.mPvs * tData.mProbability / mBox.GetVolume(); 
    555561        mTotalPvsSize = tData.mPvs; 
     
    558564                        << "#ViewCells\n1\n" <<  endl 
    559565                        << "#RenderCostDecrease\n0\n" << endl  
     566                        << "#dummy\n0\n" << endl 
    560567                        << "#TotalRenderCost\n" << mTotalCost << endl 
    561568                        << "#AvgRenderCost\n" << mTotalPvsSize << endl; 
     
    583590            tQueue.pop();                
    584591 
     592                // cost ratio of cost decrease / totalCost 
     593                float costRatio = splitCandidate.GetCost() / mTotalCost; 
     594 
     595                Debug << "cost ratio: " << costRatio << endl; 
     596 
     597                if (costRatio < mTermMinGlobalCostRatio) 
     598                {Debug << "here1 cost ratio: " << costRatio << " max " << mTermMinGlobalCostRatio << endl; 
     599                        ++ mGlobalCostMisses; 
     600                } 
    585601                if (0 && !mOutOfMemory) 
    586602                { 
     
    601617                                  << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
    602618 
    603                 if (mBspStats.Leaves() == nLeaves) 
     619                if (mBspStats.Leaves() >= nLeaves) 
    604620                { 
    605621                        nLeaves += 500; 
     
    627643 
    628644 
    629 bool VspBspTree::TerminationCriteriaMet(const VspBspTraversalData &data) const 
     645bool VspBspTree::LocalTerminationCriteriaMet(const VspBspTraversalData &data) const 
    630646{ 
    631647        return 
     
    633649                 (data.mPvs <= mTermMinPvs)   || 
    634650                 (data.mProbability <= mTermMinProbability) || 
    635                  (mBspStats.Leaves() >= mMaxViewCells) || 
    636 #if 0 
    637                  (((int)data.mPolygons->size() <= mTermMinPolygons) && !data.mPolygons->empty())|| 
    638 #endif 
    639651                 (data.GetAvgRayContribution() > mTermMaxRayContribution) || 
    640652                 (data.mDepth >= mTermMaxDepth)); 
     
    642654 
    643655 
     656bool VspBspTree::GlobalTerminationCriteriaMet(const VspBspTraversalData &data) const 
     657{ 
     658        return 
     659                (mOutOfMemory  
     660                || (mBspStats.Leaves() >= mMaxViewCells)  
     661                || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
     662                 ); 
     663} 
     664 
     665 
     666 
    644667BspNode *VspBspTree::Subdivide(VspBspTraversalQueue &tQueue, 
    645668                                                           VspBspTraversalData &tData) 
     
    647670        BspNode *newNode = tData.mNode; 
    648671 
    649         if (!mOutOfMemory && !TerminationCriteriaMet(tData)) 
     672        if (!LocalTerminationCriteriaMet(tData) && !GlobalTerminationCriteriaMet(tData)) 
    650673        { 
    651674                PolygonContainer coincident; 
     
    786809        BspNode *newNode = tData.mNode; 
    787810 
    788         if (!mOutOfMemory && !TerminationCriteriaMet(tData)) 
     811        if (!LocalTerminationCriteriaMet(tData) && !GlobalTerminationCriteriaMet(tData)) 
    789812        { 
    790813                PolygonContainer coincident; 
     
    801824                // create new interior node and two leaf node 
    802825                const Plane3 splitPlane = splitCandidate.mSplitPlane; 
    803                          
     826                                 
    804827                newNode = SubdivideNode(splitPlane, tData, tFrontData, tBackData, coincident); 
    805  
     828                 
    806829#if 0 // TODO 
    807                         if (splitAxis < 3) 
    808                                 ++ mBspStats.splits[splitAxis]; 
    809                         else 
    810                                 ++ mBspStats.polySplits; 
    811  
    812                         tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && splitAxis < 3); 
    813                         // how often was max cost ratio missed in this branch? 
    814                         tFrontData.mMaxCostMisses = maxCostMisses; 
    815                         tBackData.mMaxCostMisses = maxCostMisses; 
     830                if (splitAxis < 3) 
     831                        ++ mBspStats.splits[splitAxis]; 
     832                else 
     833                        ++ mBspStats.polySplits; 
     834 
     835                tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && splitAxis < 3); 
     836                // how often was max cost ratio missed in this branch? 
     837                tFrontData.mMaxCostMisses = maxCostMisses; 
     838                tBackData.mMaxCostMisses = maxCostMisses; 
     839 
    816840#endif 
    817841                if (1) 
     
    829853                        mSubdivisionStats  
    830854                                        << "#ViewCells\n" << mBspStats.Leaves() << endl 
    831                                         << "#RenderCostDecrease\n" << -costDecr << endl  
     855                                        << "#RenderCostDecrease\n" << -costDecr << endl 
     856                                        << "#dummy\n" << splitCandidate.GetCost() << endl 
    832857                                        << "#TotalRenderCost\n" << mTotalCost << endl 
    833858                                        << "#AvgRenderCost\n" << (float)mTotalPvsSize / (float)mBspStats.Leaves() << endl; 
     
    838863                VspBspSplitCandidate backCandidate; 
    839864 
    840                 EvalSplitCandidate(tData, frontCandidate); 
    841                 EvalSplitCandidate(tData, backCandidate); 
    842  
     865                EvalSplitCandidate(tFrontData, frontCandidate); 
     866                EvalSplitCandidate(tBackData, backCandidate); 
     867         
    843868                tQueue.push(frontCandidate); 
    844869                tQueue.push(backCandidate); 
     
    847872                DEL_PTR(tData.mNode); 
    848873        } 
     874 
    849875 
    850876        //-- terminate traversal and create new view cell 
     
    904930 
    905931        BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 
     932 
     933        // compute locally best split plane 
    906934        SelectPlane(splitData.mSplitPlane, leaf, tData, frontData, backData, splitAxis); 
    907935 
     
    910938        DEL_PTR(backData.mGeometry); 
    911939         
     940        // compute global decrease in render cost 
    912941        splitData.mRenderCost = EvalRenderCostDecrease(splitData.mSplitPlane, tData); 
    913942        splitData.mParentData = tData; 
     
    966995                { 
    967996                        frontData.mProbability = frontData.mGeometry->GetVolume(); 
    968                         backData.mProbability =  tData.mProbability - frontData.mProbability; 
     997                        backData.mProbability = tData.mProbability - frontData.mProbability; 
    969998                } 
    970999        } 
     
    15901619        int pvsFront = 0; 
    15911620        int pvsBack = 0; 
    1592         int totalPvs = data.mPvs; 
     1621        int totalPvs = 0; 
    15931622 
    15941623        // probability that view point lies in back / front node 
     
    16491678        const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 
    16501679 
    1651         return oldRenderCost - newRenderCost; 
     1680        //Debug << "decrease: " << oldRenderCost - newRenderCost << endl; 
     1681        return (oldRenderCost - newRenderCost) / mBox.GetVolume(); 
    16521682} 
    16531683 
     
    18601890        if (!obj) 
    18611891                return; 
    1862          
     1892        // new object 
    18631893        if ((obj->mMailbox != sFrontId) && 
    18641894                (obj->mMailbox != sBackId) && 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r653 r654  
    6464                /// if this node is a kd-node (i.e., boundaries are axis aligned 
    6565                bool mIsKdNode; 
     66 
     67 
    6668#if OCTREE_HACK // OCTREE HACK 
    6769                int mAxis; 
     
    398400                                                                 const VspBspTraversalData &data) const; 
    399401 
    400         void ConstructWithSplitQueueQueue(const PolygonContainer &polys, RayInfoContainer *rays); 
     402        void ConstructWithSplitQueue(const PolygonContainer &polys, RayInfoContainer *rays); 
    401403 
    402404 
     
    585587        /** Returns true if tree can be terminated. 
    586588        */ 
    587         inline bool TerminationCriteriaMet(const VspBspTraversalData &data) const; 
     589        inline bool LocalTerminationCriteriaMet(const VspBspTraversalData &data) const; 
     590 
     591        inline bool GlobalTerminationCriteriaMet(const VspBspTraversalData &data) const; 
    588592 
    589593        /** Computes accumulated ray lenght of this rays. 
     
    706710        int mTermMinPolygons; 
    707711 
     712        float mTermMinGlobalCostRatio; 
     713        int mTermGlobalCostMissTolerance; 
     714 
     715        int mGlobalCostMisses; 
     716 
    708717        //-- termination criteria for axis aligned split 
    709718 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r651 r654  
    531531  if (mUseViewSpaceBox) 
    532532  { 
    533           if (1) 
     533          if (0) 
     534          { 
    534535                  mViewSpaceBox = box; 
     536          } 
    535537          else 
    536538          { 
Note: See TracChangeset for help on using the changeset viewer.