Changeset 729


Ignore:
Timestamp:
04/06/06 18:37:31 (18 years ago)
Author:
mattausch
Message:

added cost flexible render cost measurements

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r728 r729  
    6969} 
    7070 
    71  
     71/// Fast computation of merged pvs size 
    7272int ComputeMergedPvsSize(const ObjectPvs &pvs1, const ObjectPvs &pvs2) 
    7373{ 
     74        // add first pvs 
    7475        int pvs = pvs1.GetSize(); 
    7576 
    76         // compute new pvs size 
    7777        ObjectPvsMap::const_iterator it, it_end =  pvs1.mEntries.end(); 
    7878 
    7979        Intersectable::NewMail(); 
    8080 
     81        // mail all objects in first pvs 
    8182        for (it = pvs1.mEntries.begin(); it != it_end; ++ it) 
    8283        { 
     
    8687        it_end = pvs2.mEntries.end(); 
    8788 
     89        // look if they are in second pvs 
    8890        for (it = pvs2.mEntries.begin(); it != it_end; ++ it) 
    8991        { 
     
    9496 
    9597        return pvs; 
     98} 
     99 
     100// computet render cost of merge 
     101float ViewCellsTree::ComputeMergedPvsCost(const ObjectPvs &pvs1, const ObjectPvs &pvs2) const 
     102{ 
     103        float renderCost = 0; 
     104 
     105        // compute new pvs size 
     106        ObjectPvsMap::const_iterator it, it_end =  pvs1.mEntries.end(); 
     107 
     108        Intersectable::NewMail(); 
     109 
     110        // first mail all objects in first pvs 
     111        for (it = pvs1.mEntries.begin(); it != it_end; ++ it) 
     112        { 
     113                Intersectable *obj = (*it).first; 
     114 
     115                obj->Mail(); 
     116                renderCost += mViewCellsManager->EvalRenderCost(obj); 
     117        } 
     118 
     119        it_end = pvs2.mEntries.end(); 
     120 
     121         
     122        for (it = pvs2.mEntries.begin(); it != it_end; ++ it) 
     123        { 
     124                Intersectable *obj = (*it).first; 
     125 
     126                // test if object already considered     
     127                if (!obj->Mailed()) 
     128                { 
     129                        renderCost += mViewCellsManager->EvalRenderCost(obj); 
     130                } 
     131        } 
     132 
     133        return renderCost; 
    96134} 
    97135 
     
    12121250{ 
    12131251        //-- compute pvs difference 
    1214         const int newPvs =  
     1252        const float newPvs =  
     1253#if 0 
    12151254                ComputeMergedPvsSize(mc.mLeftViewCell->GetPvs(),  
    12161255                                                         mc.mRightViewCell->GetPvs()); 
    1217                          
    1218         const float newPenalty =  
    1219                 EvalPvsPenalty(newPvs, 
    1220                                            mViewCellsManager->GetMinPvsSize(), 
    1221                                            mViewCellsManager->GetMaxPvsSize()); 
     1256#else 
     1257                ComputeMergedPvsCost(mc.mLeftViewCell->GetPvs(),  
     1258                                                         mc.mRightViewCell->GetPvs()); 
     1259#endif 
     1260 
     1261        const float newPenalty = EvalPvsPenalty(newPvs, 
     1262                                                                                        mViewCellsManager->GetMinPvsSize(), 
     1263                                                                                        mViewCellsManager->GetMaxPvsSize()); 
    12221264 
    12231265        ViewCell *vc1 = mc.mLeftViewCell; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r728 r729  
    320320        */ 
    321321        void UpdateViewCellsStats(ViewCell *vc, ViewCellsStatistics &vcStat); 
    322          
     322 
    323323 
    324324        /** Get costs resulting from each merge step. */ 
    325325        void GetCostFunction(vector<float> &costFunction); 
    326326   
    327  
    328327        /** Returns optimal set of view cells for a given number of view cells. 
    329328        */ 
     
    396395 
    397396        ////////////////////////////////////////////////////////////// 
    398         //                 merge options                            // 
     397        //                 merge related stuff                      // 
    399398        ////////////////////////////////////////////////////////////// 
    400          
     399 
     400        /** Computes render cost of the merged pvs. 
     401        */ 
     402        float ComputeMergedPvsCost(const ObjectPvs &pvs1, const ObjectPvs &pvs2) const; 
    401403 
    402404        /** Returns cost of this leaf according to current heuristics. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r728 r729  
    565565                                ++ smallerCost; 
    566566                } 
    567                  
     567                // note: can remove already found view cells 
     568                //swap(neighborhood[bestViewCellIdx], neighborhood.back()); 
     569                //neighborhood.pop_back(); 
     570         
     571 
    568572                outstream << "#RenderCost: " << currentRenderCost << endl; 
    569573                outstream << "#ViewCells: " << smallerCost << endl;              
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r728 r729  
    17071707                                                                                 const VspBspTraversalData &data) const 
    17081708{ 
    1709         int pvsFront = 0; 
    1710         int pvsBack = 0; 
    1711         int totalPvs = 0; 
     1709        float pvsFront = 0; 
     1710        float pvsBack = 0; 
     1711        float totalPvs = 0; 
    17121712 
    17131713        // probability that view point lies in back / front node 
     
    17501750                pBack = pOverall - pFront; 
    17511751 
     1752                // something is wrong with the volume 
    17521753                if ((pFront < 0.0) || (pBack < 0.0)) 
    17531754                { 
     
    17971798        float cost = 0; 
    17981799 
    1799         int totalPvs = 0; 
    1800         int pvsFront = 0; 
    1801         int pvsBack = 0; 
     1800        float totalPvs = 0; 
     1801        float pvsFront = 0; 
     1802        float pvsBack = 0; 
    18021803         
    18031804        // probability that view point lies in back / front node 
     
    18551856                pBack = pOverall - pFront; 
    18561857                 
    1857                 // precision issues possible for unbalanced split => don't take this split! 
     1858                // HACK: precision issues possible for unbalanced split => don't take this split! 
    18581859                if (1 &&  
    18591860                        (!splitSuccessFull || (pFront <= 0) || (pBack <= 0) ||  
     
    19992000                                                                                   float &pBack) const 
    20002001{ 
    2001         int pvsTotal = 0; 
    2002         int pvsFront = 0; 
    2003         int pvsBack = 0; 
     2002        float pvsTotal = 0; 
     2003        float pvsFront = 0; 
     2004        float pvsBack = 0; 
    20042005         
    20052006        // create unique ids for pvs heuristics 
     
    20722073void VspBspTree::AddObjToPvs(Intersectable *obj, 
    20732074                                                         const int cf, 
    2074                                                          int &frontPvs, 
    2075                                                          int &backPvs, 
    2076                                                          int &totalPvs) const 
     2075                                                         float &frontPvs, 
     2076                                                         float &backPvs, 
     2077                                                         float &totalPvs) const 
    20772078{ 
    20782079        if (!obj) 
     
    20842085                (obj->mMailbox != sFrontAndBackId)) 
    20852086        { 
    2086                 ++ totalPvs; 
     2087                totalPvs += mViewCellsManager->EvalRenderCost(obj); 
    20872088        } 
    20882089 
     
    20962097                        (obj->mMailbox != sFrontAndBackId)) 
    20972098                { 
    2098                         ++ frontPvs; 
     2099                        frontPvs += mViewCellsManager->EvalRenderCost(obj); 
    20992100                 
    21002101                        if (obj->mMailbox == sBackId) 
     
    21102111                        (obj->mMailbox != sFrontAndBackId)) 
    21112112                { 
    2112                         ++ backPvs; 
     2113                        backPvs += mViewCellsManager->EvalRenderCost(obj);; 
    21132114                 
    21142115                        if (obj->mMailbox == sFrontId) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r727 r729  
    587587        void AddObjToPvs(Intersectable *obj,  
    588588                                         const int cf,  
    589                                          int &frontPvs,  
    590                                          int &backPvs,  
    591                                          int &totalPvs) const; 
     589                                         float &frontPvs,  
     590                                         float &backPvs,  
     591                                         float &totalPvs) const; 
    592592         
    593593        /** Computes PVS size induced by the rays. 
Note: See TracChangeset for help on using the changeset viewer.