Ignore:
Timestamp:
02/10/06 13:04:39 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r610 r611  
    262262 
    263263        environment->GetFloatValue("BspTree.Construction.epsilon", mEpsilon); 
    264          
     264 
     265        mSubdivisionStats.open("subdivisionStats.log"); 
     266 
    265267    Debug << "BSP max depth: " << mTermMaxDepth << endl; 
    266268        Debug << "BSP min PVS: " << mTermMinPvs << endl; 
     
    841843                                                   geom); 
    842844 
     845        mTotalCost = tData.mPvs * tData.mProbability / mBox.GetVolume(); 
     846        mTotalPvsSize = tData.mPvs; 
     847         
     848        mSubdivisionStats  
     849                        << "#ViewCells\n1\n" <<  endl 
     850                        << "#RenderCostDecrease\n0\n" << endl  
     851                        << "#TotalRenderCost\n" << mTotalCost << endl 
     852                        << "#AvgRenderCost\n" << mTotalPvsSize << endl; 
     853 
    843854        tStack.push(tData); 
    844855 
     856        // used for intermediate time measurements and progress 
     857        long interTime = GetTime();      
     858        int nleaves = 500; 
     859 
    845860        mStat.Start(); 
    846         cout << "Contructing bsp tree ... "; 
     861        cout << "Contructing bsp tree ...\n"; 
    847862        long startTime = GetTime(); 
    848863        while (!tStack.empty())  
     
    858873            Debug << "BSP tree construction time spent at root: "  
    859874                                  << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 
     875 
     876                if (mStat.Leaves() >= nleaves) 
     877                { 
     878                        nleaves += 500; 
     879                         
     880                        cout << "leaves=" << mStat.Leaves() << endl; 
     881                        Debug << "needed " 
     882                                  << TimeDiff(interTime, GetTime())*1e-3  
     883                                  << " secs to create 500 leaves" << endl; 
     884                        interTime = GetTime(); 
     885                } 
    860886        } 
    861887 
     
    937963                                                           new BoundedRayContainer(), 0, 0, new BspNodeGeometry()); 
    938964 
     965        int pvsData = tData.mPvs; 
     966        float cData = (float)tData.mPvs * tData.mProbability; 
     967 
    939968        // create new interior node and two leaf nodes 
    940969        BspInterior *interior =  
    941970                SubdivideNode(tData, tFrontData, tBackData, coincident); 
    942971 
     972 
     973        if (1) 
     974        { 
     975                float cFront = (float)tFrontData.mPvs * tFrontData.mProbability; 
     976                float cBack = (float)tBackData.mPvs * tBackData.mProbability; 
     977                 
     978                float costDecr =  
     979                        (cFront + cBack - cData) / mBox.GetVolume(); 
     980 
     981                 
     982                mTotalCost += costDecr; 
     983                mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - pvsData; 
     984 
     985                mSubdivisionStats  
     986                        << "#ViewCells\n" << mStat.Leaves() << endl 
     987                        << "#RenderCostDecrease\n" << -costDecr << endl  
     988                        << "#TotalRenderCost\n" << mTotalCost << endl 
     989                        << "#AvgRenderCost\n" << mTotalPvsSize / mStat.Leaves() << endl; 
     990        } 
    943991 
    944992        // extract view cells from coincident polygons according to plane normal 
     
    10061054        BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 
    10071055 
    1008         long startTime; 
    1009         if (0) 
    1010         { 
    1011                 Debug << "*********************" << endl; 
    1012                 startTime = GetTime(); 
    1013         } 
     1056         
    10141057         
    10151058        // select subdivision plane 
     
    10171060                new BspInterior(SelectPlane(leaf, tData));  
    10181061         
    1019         if (0) 
    1020         { 
    1021                 Debug << "time used for split plane selection: "  
    1022                           << TimeDiff(startTime, GetTime()) * 1e-3 << "s" << endl; 
    1023         } 
     1062         
    10241063#ifdef _DEBUG 
    10251064        Debug << interior << endl; 
     
    10271066         
    10281067 
    1029         if (0) 
    1030         { 
    1031                 Debug << "number of rays: " << (int)tData.mRays->size() << endl; 
    1032                 Debug << "number of polys: " << (int)tData.mPolygons->size() << endl; 
    1033  
    1034                 startTime = GetTime(); 
    1035         }        
    1036          
    10371068        // subdivide rays into front and back rays 
    10381069        SplitRays(interior->mPlane, *tData.mRays, *frontData.mRays, *backData.mRays); 
    10391070         
    1040         if (0) 
    1041         { 
    1042                 Debug << "time used for rays splitting: " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
    1043                 startTime = GetTime(); 
    1044         } 
     1071         
    10451072 
    10461073        // subdivide polygons with plane 
     
    10511078                                                                          coincident); 
    10521079 
    1053         if (0) 
    1054         { 
    1055                 Debug << "time used for polygon splitting: " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
    1056         } 
     1080         
    10571081 
    10581082    // compute pvs 
     
    10701094         
    10711095                 
    1072                 frontData.mProbability = frontData.mGeometry->GetVolume(); 
    1073                 backData.mProbability = backData.mGeometry->GetVolume(); 
    1074         } 
    1075  
    1076         // compute accumulated ray length 
    1077         //frontData.mAccRayLength = AccumulatedRayLength(*frontData.mRays); 
    1078         //backData.mAccRayLength = AccumulatedRayLength(*backData.mRays); 
     1096                if (mUseAreaForPvs) 
     1097                { 
     1098                        frontData.mProbability = frontData.mGeometry->GetArea(); 
     1099                        backData.mProbability = backData.mGeometry->GetArea(); 
     1100                } 
     1101                else 
     1102                { 
     1103                        frontData.mProbability = frontData.mGeometry->GetVolume(); 
     1104                        backData.mProbability = tData.mProbability - frontData.mProbability; 
     1105                } 
     1106        } 
    10791107 
    10801108        //-- create front and back leaf 
     
    15821610inline void BspTree::GenerateUniqueIdsForPvs() 
    15831611{ 
    1584         Intersectable::NewMail(); sBackId = ViewCell::sMailId; 
    1585         Intersectable::NewMail(); sFrontId = ViewCell::sMailId; 
    1586         Intersectable::NewMail(); sFrontAndBackId = ViewCell::sMailId; 
     1612        ViewCell::NewMail(); sBackId = ViewCell::sMailId; 
     1613        ViewCell::NewMail(); sFrontId = ViewCell::sMailId; 
     1614        ViewCell::NewMail(); sFrontAndBackId = ViewCell::sMailId; 
    15871615} 
    15881616 
     
    18951923                return 0; 
    18961924 
    1897         Intersectable::NewMail(); 
     1925        ViewCell::NewMail(); 
    18981926 
    18991927        Vector3 entp = ray.Extrap(mint); 
Note: See TracChangeset for help on using the changeset viewer.