Changeset 474


Ignore:
Timestamp:
12/21/05 10:53:47 (18 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r473 r474  
    153153         
    154154        height 5.0 
    155         maxViewCells 5000 
     155        maxViewCells 3000 
    156156         
    157157        PostProcessing { 
     
    236236         
    237237        # maximal candidates for split planes 
    238         maxPolyCandidates 50 
    239         maxRayCandidates 50 
     238        maxPolyCandidates 100 
     239        maxRayCandidates 100 
    240240         
    241241        # maximal tested rays for split cost heuristics 
     
    251251        Termination { 
    252252                # parameters used for autopartition 
    253                 minRays                 100 
     253                minRays                 10 
    254254                minPolygons             -1 
    255255                maxDepth                30 
    256                 minPvs                  100 
    257                 minArea                 0.01 
     256                minPvs                  20 
     257                minArea                 0.0001 
    258258                maxRayContribution      0.005 
    259259                maxCostRatio            0.9 
    260                 missTolerance           1 
     260                missTolerance           3 
    261261                #maxAccRayLength        100 
    262262                 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r473 r474  
    344344 
    345345        app << "#N_SPLITS ( Number of splits )\n" << splits << "\n"; 
    346  
    347         app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maximum depth )\n"  
    348                 <<      maxDepthNodes * 100 / (double)Leaves() << endl; 
    349346 
    350347        app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maximum depth )\n"  
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r473 r474  
    268268        const int limit = min(mConstructionSamples, (int)sourceRays.size()); 
    269269 
    270         Debug << "size: " << sourceRays.size() << " limit " << limit << endl; 
    271270        VssRayContainer::const_iterator it, it_end = sourceRays.end(); 
    272271         
     
    478477 
    479478        } 
    480  
    481479 
    482480        cout << "starting post processing using " << mPostProcessSamples << " samples ... "; 
     
    14221420 
    14231421        GetRaySets(rays, constructionRays, savedRays); 
    1424         Debug << "rays " << rays.size() << " construction rays " << constructionRays.size() << endl; 
     1422         
    14251423        mVspBspTree->Construct(constructionRays); 
    1426          
    14271424        mVspBspTree->CollectViewCells(mViewCells); 
    14281425         
     
    16311628        bool exportGeometry = false; 
    16321629 
    1633         Debug << "here344" << endl; 
    16341630        environment->GetBoolValue("VspBspTree.Visualization.exportRays", exportRays); 
    16351631        environment->GetBoolValue("VspBspTree.Visualization.exportGeometry", exportGeometry); 
     
    16871683                        ObjectPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 
    16881684 
    1689                         exporter->SetWireframe(); 
    1690                         //exporter->SetFilled(); 
     1685                        //exporter->SetWireframe(); 
     1686                        exporter->SetFilled(); 
    16911687 
    16921688                        Material m;//= RandomMaterial(); 
     
    18431839                } 
    18441840        } 
    1845         Debug << "here222211" << endl; 
    18461841} 
    18471842 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r473 r474  
    3838mRoot(NULL), 
    3939mPvsUseArea(true), 
    40 mNumCriteria(0) 
     40mCostNormalizer(Limits::Small) 
    4141{ 
    4242        mRootCell = new BspViewCell(); 
     
    9191        Debug << "max polygon candidates: " << mMaxPolyCandidates << endl; 
    9292        Debug << "max plane candidates: " << mMaxRayCandidates << endl; 
    93  
     93         
    9494        Debug << "Split plane strategy: "; 
    9595        if (mSplitPlaneStrategy & RANDOM_POLYGON) 
     96        { 
    9697                Debug << "random polygon "; 
    97  
     98        } 
    9899        if (mSplitPlaneStrategy & AXIS_ALIGNED) 
    99100        { 
    100                 ++ mNumCriteria; 
    101101                Debug << "axis aligned "; 
    102102        } 
    103103        if (mSplitPlaneStrategy & LEAST_RAY_SPLITS) 
    104104        { 
    105                 ++ mNumCriteria; 
     105                mCostNormalizer += mLeastRaySplitsFactor; 
    106106                Debug << "least ray splits "; 
    107107        } 
    108108        if (mSplitPlaneStrategy & BALANCED_RAYS) 
    109109        { 
    110                 ++ mNumCriteria; 
     110                mCostNormalizer += mBalancedRaysFactor; 
    111111                Debug << "balanced rays "; 
    112112        } 
    113113        if (mSplitPlaneStrategy & PVS) 
    114114        { 
    115                 ++ mNumCriteria; 
     115                mCostNormalizer += mPvsFactor; 
    116116                Debug << "pvs"; 
    117117        } 
     
    273273        } 
    274274 
     275        mTermMinArea *= mBox.SurfaceArea(); // normalize 
    275276        mStat.polys = (int)polys.size(); 
    276277 
     
    315316 
    316317            tStack.pop(); 
    317  
    318318                // subdivide leaf node 
    319319                BspNode *r = Subdivide(tStack, tData); 
     
    412412                ++ maxCostMisses; 
    413413 
    414                 /*if (maxCostMisses >= mTermMissTolerance) 
     414                if (maxCostMisses >= mTermMissTolerance) 
    415415                { 
    416416                        // terminate branch because of max cost 
    417417                        ++ mStat.maxCostNodes;  
    418418            return leaf; 
    419                 }*/ 
     419                } 
    420420        } 
    421421 
     
    471471                                                                           mEpsilon); 
    472472         
    473                 // area is normalized with view space area 
    474                 frontData.mArea = frontData.mGeometry->GetArea() / mBox.SurfaceArea(); 
    475                 backData.mArea = backData.mGeometry->GetArea() / mBox.SurfaceArea(); 
     473                frontData.mArea = frontData.mGeometry->GetArea(); 
     474                backData.mArea = backData.mGeometry->GetArea(); 
    476475        } 
    477476 
     
    810809                const int candidateIdx = (int)RandomValue(0, (Real)(-- maxIdx)); 
    811810                //Debug << "current Idx: " << maxIdx << " cand idx " << candidateIdx << endl; 
    812  
     811                 
    813812                Polygon3 *poly = (*data.mPolygons)[candidateIdx]; 
    814                  
     813 
    815814                // swap candidate to the end to avoid testing same plane 
    816815                std::swap((*data.mPolygons)[maxIdx], (*data.mPolygons)[candidateIdx]); 
    817  
     816         
    818817                //Polygon3 *poly = (*data.mPolygons)[(int)RandomValue(0, (int)polys.size() - 1)]; 
    819818 
     
    829828        } 
    830829         
    831         //Debug << "lowest: " << lowestCost << endl; 
    832  
    833830        //-- choose candidate planes extracted from rays 
    834         // we use different methods chosen with 
    835         // equal probability 
     831        //-- different methods are available 
    836832        for (int i = 0; i < mMaxRayCandidates; ++ i) 
    837833        { 
    838834                plane = ChooseCandidatePlane3(*data.mRays); 
    839  
    840835                const float candidateCost = SplitPlaneCost(plane, data); 
    841836 
     
    846841                } 
    847842        } 
     843 
     844#ifdef _DEBUG 
     845        Debug << "plane lowest cost: " << lowestCost << endl; 
     846#endif 
    848847 
    849848        // cost ratio miss 
    850849        if (lowestCost > mTermMaxCostRatio) 
    851850                return false; 
    852  
    853 #ifdef _DEBUG 
    854         Debug << "plane lowest cost: " << lowestCost << endl; 
    855 #endif 
    856851 
    857852        return true; 
     
    10111006        { 
    10121007                const float oldCost = pOverall * (float)data.mPvs + Limits::Small; 
    1013  
    1014                 cost += mPvsFactor * (frontPvs * pFront + (backPvs * pBack)) / oldCost; 
    1015  
    1016                 // give penalty to unbalanced split 
    1017                 if (0) 
    1018                 if (((pFront * 0.2 + Limits::Small) > pBack) ||  
    1019                         (pFront < (pBack * 0.2 + Limits::Small))) 
    1020                         cost += 0.5; 
     1008                cost += mPvsFactor * (frontPvs * pFront + backPvs * pBack) / oldCost; 
     1009 
     1010                //cost += mPvsFactor * 0.5 * (frontPvs * pFront + backPvs * pBack) / oldCost; 
     1011                //Debug << "new cost: " << cost << " over" << frontPvs * pFront + backPvs * pBack << " old cost " << oldCost << endl; 
     1012         
     1013                if (0) // give penalty to unbalanced split 
     1014                        if (((pFront * 0.2 + Limits::Small) > pBack) ||  
     1015                                (pFront < (pBack * 0.2 + Limits::Small))) 
     1016                                        cost += 0.5; 
    10211017        } 
    10221018 
    10231019#ifdef _DEBUG 
    1024 //      Debug << "totalpvs: " << pvs << " ptotal: " << pOverall 
    1025 //                << " frontpvs: " << frontPvs << " pFront: " << pFront  
    1026 //                << " backpvs: " << backPvs << " pBack: " << pBack << endl << endl; 
     1020        Debug << "totalpvs: " << data.mPvs << " ptotal: " << pOverall 
     1021                  << " frontpvs: " << frontPvs << " pFront: " << pFront  
     1022                  << " backpvs: " << backPvs << " pBack: " << pBack << endl << endl; 
    10271023#endif 
    1028  
    1029         // normalize by number of criteria 
    1030         return cost / (float)(mNumCriteria + Limits::Small); 
     1024         
     1025        // normalize cost by sum of linear factors 
     1026        return cost / (float)mCostNormalizer; 
    10311027} 
    10321028 
     
    11181114        if (data.mDepth < mStat.minDepth) 
    11191115                mStat.minDepth = data.mDepth; 
    1120  
     1116         
     1117        if (data.mDepth >= mTermMaxDepth) 
     1118                ++ mStat.maxDepthNodes; 
     1119 
     1120        if (data.mPvs < mTermMinPvs) 
     1121                ++ mStat.minPvsNodes; 
     1122 
     1123        if ((int)data.mRays->size() < mTermMinRays) 
     1124                ++ mStat.minRaysNodes; 
     1125 
     1126        if (data.GetAvgRayContribution() > mTermMaxRayContribution) 
     1127                ++ mStat.maxRayContribNodes; 
     1128         
     1129        if (data.mArea <= mTermMinArea)  
     1130        { 
     1131                //Debug << "area: " << data.mArea / mBox.SurfaceArea() << " min area: " << mTermMinArea / mBox.SurfaceArea() << endl; 
     1132                ++ mStat.minAreaNodes; 
     1133        } 
    11211134        // accumulate depth to compute average depth 
    11221135        mStat.accumDepth += data.mDepth; 
    1123          
    1124  
    1125         if (data.mDepth >= mTermMaxDepth) 
    1126                 ++ mStat.maxDepthNodes; 
    1127  
    1128         if (data.mPvs < mTermMinPvs) 
    1129                 ++ mStat.minPvsNodes; 
    1130  
    1131         if ((int)data.mRays->size() < mTermMinRays) 
    1132                 ++ mStat.minRaysNodes; 
    1133  
    1134         if (data.GetAvgRayContribution() > mTermMaxRayContribution) 
    1135                 ++ mStat.maxRayContribNodes; 
    1136          
    1137         if (data.mGeometry->GetArea() <= mTermMinArea)  
    1138                 ++ mStat.minAreaNodes; 
    11391136 
    11401137#ifdef _DEBUG 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r473 r474  
    112112                {} 
    113113 
     114                /** Returns cost of the traversal data. 
     115                */ 
     116                float GetCost() const 
     117                { 
     118#if 0 
     119                        return mPvs * mArea; 
     120#endif 
     121#if 1 
     122                        return (float)(mPvs * (int)mRays->size()); 
     123#endif 
     124#if 0 
     125                        return (float)mPvs; 
     126#endif 
     127#if 0 
     128                        return mArea * (float)mRays->size(); 
     129#endif 
     130                } 
     131 
    114132                friend bool operator<(const VspBspTraversalData &a, const VspBspTraversalData &b) 
    115133                { 
    116 #if 0 
    117                         return a.mPvs * a.mArea < b.mPvs * b.mArea; 
    118 #endif 
    119 #if 1 
    120                         return a.mPvs * (int)a.mRays->size() < b.mPvs * (int)b.mRays->size(); 
    121 #endif 
    122 #if 0 
    123                         return a.mPvs < b.mPvs; 
    124 #endif 
    125 #if 0 
    126                         return  
    127                                 a.mPvs / (float)(a.mRays->size() + Limits::Small()) 
    128                                 > 
    129                                 b.mPvs / (float)(b.mRays->size() + Limits::Small()); 
    130 #endif 
    131 #if 0 
    132                         return a.mPvs * (int)a.mRays->size() <  b.mPvs * (int)b.mRays->size(); 
    133 #endif 
     134                        return a.GetCost() < b.GetCost(); 
    134135                } 
    135136    }; 
     
    544545        /// maximal number of test rays used to evaluate candidate split plane 
    545546        int mMaxTests; 
    546         /// number of different bsp split plane criteria 
    547         int mNumCriteria; 
     547        /// normalizes different bsp split plane criteria 
     548        float mCostNormalizer; 
    548549        /// maximal number of view cells 
    549550        int mMaxViewCells; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h

    r473 r474  
    477477#if 0 
    478478                        return 
    479                                 leafa->rays.size()*a.mBox.GetVolume() 
     479                                leafa->rays.size() * a.mBox.GetVolume() 
    480480                                < 
    481                                 leafb->rays.size()*b.mBox.GetVolume(); 
     481                                leafb->rays.size() * b.mBox.GetVolume(); 
    482482#endif 
    483483#if 1 
    484484                        return 
    485                                 leafa->GetPvsSize()*a.mBox.GetVolume() 
     485                                leafa->GetPvsSize() * a.mBox.GetVolume() 
    486486                                < 
    487                                 leafb->GetPvsSize()*b.mBox.GetVolume(); 
     487                                leafb->GetPvsSize() * b.mBox.GetVolume(); 
    488488#endif 
    489489#if 0 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp

    r473 r474  
    165165  if (!use2dSampling) { 
    166166        Vector3 normal; 
    167         int i = RandomValue(0, mObjects.size()-1); 
     167        int i = (int)RandomValue(0, (Real)((int)mObjects.size()-1)); 
    168168        Intersectable *object = mObjects[i]; 
    169169        object->GetRandomSurfacePoint(point, normal); 
     
    561561 
    562562        mViewCellsManager->Visualize(mObjects, storedRays); 
    563  
    564         Debug << "here2" << endl; 
    565563  } 
    566564 
     
    569567   
    570568  mRenderSimulator->RenderScene(); 
    571   Debug << "here3" << endl; 
     569   
    572570  SimulationStatistics ss; 
    573571  mRenderSimulator->GetStatistics(ss); 
    574   Debug << "here244" << endl; 
     572   
    575573  cout << " finished" << endl; 
    576574  cout << ss << endl; 
     
    579577  delete vssTree; 
    580578 
    581   Debug << "here4" << endl; 
    582579  return true; 
    583580} 
Note: See TracChangeset for help on using the changeset viewer.