Changeset 611


Ignore:
Timestamp:
02/10/06 13:04:39 (18 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
5 edited

Legend:

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

    r607 r611  
    19121912                                        optBool, 
    19131913                    "vsp_bsp_usePolygonSplitIfAvailable=", 
    1914                                         "true"); 
     1914                                        "false"); 
    19151915 
    19161916        RegisterOption("VspBspTree.Termination.AxisAligned.minRays", 
  • 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); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r610 r611  
    99#include "VssRay.h" 
    1010#include "ViewCell.h" 
     11 
     12 
    1113 
    1214class ViewCell; 
     
    430432#endif 
    431433#if 1 
     434                        return (float) (-mDepth); // for regular grid 
     435#endif 
     436#if 0 
    432437                        return mProbability; 
    433438#endif 
     
    958963 
    959964        int mTimeStamp; 
     965 
     966        float mTotalCost; 
     967        int mTotalPvsSize; 
     968 
     969        //int mSplits; 
     970        ofstream  mSubdivisionStats; 
    960971 
    961972private: 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r610 r611  
    426426                                                          prop, 
    427427                                                          geom); 
    428  
     428#if OCTREE_HACK 
     429tData.mAxis = 0; 
     430#endif 
    429431        // first node is kd node, i.e. an axis aligned box 
    430432        if (1) 
     
    528530                VspBspTraversalData tFrontData; 
    529531                VspBspTraversalData tBackData; 
    530  
     532#if OCTREE_HACK 
     533                //Debug << "new axis:" << (tData.mAxis + 1) % 3 << endl; 
     534 
     535                tFrontData.mAxis = (tData.mAxis + 1) % 3; 
     536                tBackData.mAxis = (tData.mAxis + 1) % 3; 
     537#endif 
    531538                // create new interior node and two leaf nodes 
    532539                // or return leaf as it is (if maxCostRatio missed) 
     
    537544                        if (1) 
    538545                        { 
    539                                 float cFront = tFrontData.mPvs * tFrontData.mProbability; 
    540                                 float cBack = tBackData.mPvs * tBackData.mProbability; 
    541                                 float cData = tData.mPvs * tData.mProbability;; 
     546                                float cFront = (float)tFrontData.mPvs * tFrontData.mProbability; 
     547                                float cBack = (float)tBackData.mPvs * tBackData.mProbability; 
     548                                float cData = (float)tData.mPvs * tData.mProbability;; 
    542549 
    543550                float costDecr =  
    544551                                        (cFront + cBack - cData) / mBox.GetVolume(); 
    545  
    546                                 int pvsFront = tFrontData.mPvs * tFrontData.mProbability; 
    547                                 int pvsBack = tBackData.mPvs * tBackData.mProbability; 
    548                                 int pvsData = tData.mPvs * tData.mProbability;; 
    549552 
    550553                                mTotalCost += costDecr; 
     
    979982                        box.Include((*ri).ExtrapTermination()); 
    980983        } 
    981  
     984#if OCTREE_HACK 
     985        //Debug << "choosing axis:" << tData.mAxis << endl; 
     986        const int sAxis = tData.mAxis; 
     987#else 
    982988        const int sAxis = mUseRandomAxis ? Random(3) : box.Size().DrivingAxis(); 
    983  
     989#endif 
    984990        for (axis = 0; axis < 3; ++ axis) 
    985991        { 
     
    11301136 
    11311137        // cost ratio miss 
    1132         if (!mUsePolygonSplitIfAvailable || data.mPolygons->empty()) 
     1138        if (mUsePolygonSplitIfAvailable && !data.mPolygons->empty()) 
    11331139        { 
    11341140                frontData.mIsKdNode = backData.mIsKdNode = false; 
     
    11831189        // cost ratio miss 
    11841190        if (lowestCost > mTermMaxCostRatio) 
     1191        { 
    11851192                return false; 
     1193        } 
    11861194 
    11871195        return true; 
     
    16291637        if (data.mDepth >= mTermMaxDepth) 
    16301638                ++ mBspStats.maxDepthNodes; 
     1639 
    16311640        // accumulate rays to compute rays /  leaf 
    16321641        mBspStats.accumRays += (int)data.mRays->size(); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r610 r611  
    2828struct BspRay; 
    2929 
    30  
     30#define OCTREE_HACK 0 
    3131/** 
    3232        This is a view space partitioning specialised BSPtree.   
     
    6464                /// if this node is a kd-node (i.e., boundaries are axis aligned 
    6565                bool mIsKdNode; 
     66#if OCTREE_HACK // OCTREE HACK 
     67                int mAxis; 
     68#endif 
    6669                /// bounding box of current view space. 
    6770                ///AxisAlignedBox3 mBbox; 
     
    124127                float GetCost() const 
    125128                { 
    126 #if 1 
     129#if 0 
    127130                        return mPvs * mProbability; 
    128131#endif 
    129 #if 0 
     132#if 1 
    130133                        return (float) (-mDepth); // for regular grid 
    131134#endif 
     
    708711        int mTotalPvsSize; 
    709712 
    710         int mSplits; 
     713        //int mSplits; 
    711714 
    712715        ofstream mSubdivsionStats; 
Note: See TracChangeset for help on using the changeset viewer.