Changeset 581


Ignore:
Timestamp:
02/02/06 10:03:10 (18 years ago)
Author:
mattausch
Message:

added function for pvs compression

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
7 edited

Legend:

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

    r580 r581  
    180180        } 
    181181 
     182        active 150 
     183 
    182184        exportToFile false 
    183185        loadFromFile false 
     
    203205                renderCostWeight 0.5 
    204206                maxCostRatio 0.1 
    205                 minViewCells 110 
     207                minViewCells 1 
    206208                avgCostMaxDeviation 0.8 
    207209                maxMergesPerPass 500  
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r580 r581  
    12061206                        "bspTree"); 
    12071207 
     1208        RegisterOption("ViewCells.active", 
     1209                                        optInt, 
     1210                                        "1000"); 
     1211 
    12081212        RegisterOption("ViewCells.Construction.samples", 
    12091213                                        optInt, 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h

    r573 r581  
    112112}; 
    113113 
     114 
    114115template <typename T> 
    115116int Pvs<T>::Diff(const Pvs<T> &b) 
     
    134135 
    135136        mEntries = a.mEntries; 
    136         // todo: copy all elements instead of inserting 
    137         //for (it = a.mEntries.begin(); it != a.mEntries.end(); ++ it) 
    138         //      mEntries.insert(*it); 
    139137         
    140138        for (it = b.mEntries.begin(); it != b.mEntries.end(); ++ it) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r580 r581  
    2222        bool operator() (T v1, T v2) const 
    2323        { 
    24                 return (v1->GetTimeStamp() > v2->GetTimeStamp()); 
     24                return (v1->GetTimeStamp() < v2->GetTimeStamp()); 
    2525        } 
    2626}; 
     
    220220 
    221221 
     222 
    222223/************************************************************************/ 
    223224/*                class ViewCellInterior implementation                 */ 
     
    471472        //-- use priority queue to merge leaf pairs 
    472473 
    473         while (!mMergeQueue.empty() && (realNumViewCells > mMergeMinViewCells) && 
    474                    (mMergeQueue.top().GetRenderCost() < mMergeMaxCostRatio * totalCost)) 
     474        while (!mMergeQueue.empty() && (realNumViewCells > mMergeMinViewCells)) 
    475475        { 
    476476                //-- reset merge queue if the ratio of current expected cost / real expected cost 
    477477                //   too small or after a given number of merges 
    478                 if(0) 
    479478                if ((mergedPerPass > maxMergesPerPass) || 
    480479                        (avgCostMaxDeviation > mAvgRenderCost / realAvgRenderCost)) 
     
    611610        if ((int)viewCells.size() > 1) 
    612611        { 
     612                Debug << "here888" << endl; 
    613613                ViewCellInterior *root = new ViewCellInterior(); 
     614 
     615                root->SetTimeStamp(mergeStats.merged + 1); 
    614616 
    615617                ViewCellContainer::const_iterator it, it_end = viewCells.end(); 
     
    621623        else if ((int)viewCells.size() == 1) 
    622624        { 
     625                Debug << "here555" << endl; 
    623626                mRoot = viewCells[0]; 
    624627        } 
    625628 
     629        // TODO delete because makes no sense here 
    626630        mergeStats.expectedRenderCost = realExpectedCost; 
    627631        mergeStats.deviation = mDeviation; 
     
    640644        //TODO: should return sample contributions? 
    641645        return mergeStats.merged; 
     646} 
     647 
     648 
     649ViewCell *ViewCellsTree::GetRoot() 
     650{ 
     651        return mRoot; 
    642652} 
    643653 
     
    12171227{ 
    12181228        stack<ViewCell *> tstack; 
    1219  
    1220  
    1221 } 
    1222  
    1223  
    1224 void  ViewCellsTree::CollectBestViewCellSet(ViewCellContainer &viewCells, const int numViewCells) 
     1229         
     1230        while (!tstack.empty()) 
     1231        { 
     1232                ViewCell *viewCell = tstack.top(); 
     1233                tstack.pop(); 
     1234 
     1235                if (viewCell->IsLeaf()) 
     1236                { 
     1237                         
     1238                } 
     1239                else 
     1240                { 
     1241                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(viewCell);                         
     1242                        ComputeCommonPvs(interior); 
     1243                } 
     1244        } 
     1245} 
     1246 
     1247 
     1248void ViewCellsTree::CollectBestViewCellSet(ViewCellContainer &viewCells,  
     1249                                                                                   const int numViewCells) 
    12251250{ 
    12261251        TraversalQueue tqueue; 
    1227  
     1252        tqueue.push(mRoot); 
     1253        Debug << "here34 " << numViewCells << endl; 
    12281254        while (!tqueue.empty()) 
    12291255        { 
    12301256                ViewCell *vc = tqueue.top(); 
    1231  
    12321257                tqueue.pop(); 
     1258                Debug << "here7 " << vc->GetTimeStamp() << endl; 
     1259                if (vc->IsLeaf()) 
     1260                { 
     1261                        Debug << "here6" << endl; 
     1262                        viewCells.push_back(vc); 
     1263                } 
     1264                else if (viewCells.size() + tqueue.size() < numViewCells) 
     1265                {       Debug << "here4" << endl; 
     1266                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     1267 
     1268                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     1269 
     1270                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
     1271                        { 
     1272                                tqueue.push(*it); 
     1273                        } 
     1274                } 
     1275        } 
     1276} 
     1277         
     1278 
     1279void ViewCellsTree::ComputeCommonPvs(ViewCellInterior *interior) 
     1280{ 
     1281        Intersectable::NewMail(); 
     1282 
     1283        ViewCellContainer::const_iterator cit, cit_end = interior->mChildren.end(); 
     1284 
     1285        ObjectPvsMap::const_iterator oit; 
     1286 
     1287        // mail all objects in the leaf sets 
     1288        for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 
     1289        { 
     1290                ViewCell *vc = *cit; 
     1291 
     1292                ObjectPvsMap::const_iterator oit_end = vc->GetPvs().mEntries.end(); 
     1293 
     1294                for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
     1295                { 
     1296                        if (!(*oit).first->Mailed()) 
     1297                                (*oit).first->Mail(); 
     1298                         
     1299                        (*oit).first->IncMail(); 
     1300                } 
     1301        } 
     1302 
     1303        interior->GetPvs().mEntries.clear(); 
     1304    cit_end = interior->mChildren.end(); 
     1305         
     1306        // only the objects which are present in all leaf pvs  
     1307        // should remain in the parent pvs 
     1308 
     1309        for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 
     1310        { 
     1311                ViewCell *vc = *cit; 
     1312 
     1313                ObjectPvsMap::const_iterator oit_end = vc->GetPvs().mEntries.end(); 
     1314 
     1315                for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
     1316                { 
     1317                        if ((*oit).first->Mailed((int)interior->mChildren.size())) 
     1318                        {        
     1319                                interior->GetPvs().AddSample((*oit).first, (*oit).second.mSumPdf); 
     1320                                //(*oit)->remove(); 
     1321                        } 
     1322                } 
     1323        } 
     1324 
     1325        // delete all the objects from the leaf sets which were moved 
     1326        // to parent pvs 
     1327        ObjectPvsMap::const_iterator oit_end = interior->GetPvs().mEntries.end(); 
     1328 
     1329        for (oit = interior->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
     1330        { 
     1331                for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 
     1332                { 
     1333                        (*cit)->GetPvs().RemoveSample((*oit).first, Limits::Infinity); 
     1334                } 
    12331335        } 
    12341336} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h

    r580 r581  
    293293        void CollectBestViewCellSet(ViewCellContainer &viewCells, const int numViewCells); 
    294294 
     295        /** Root of view cells tree. 
     296        */ 
     297        ViewCell *GetRoot(); 
     298 
    295299protected: 
    296300 
     
    350354                                                           const int numNewViewCells); 
    351355 
    352  
    353  
    354356        /** merge queue must be reset after some time because expected value 
    355357                may not be valid. 
     
    360362        */ 
    361363        int UpdateMergedViewCells(ViewCellContainer &viewCells); 
     364 
     365        void ComputeCommonPvs(ViewCellInterior *interior); 
    362366 
    363367 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r580 r581  
    5353 
    5454        environment->GetIntValue("ViewCells.Construction.samplesPerPass", mSamplesPerPass); 
    55  
    5655        environment->GetBoolValue("ViewCells.exportToFile", mExportViewCells); 
    57  
    5856        environment->GetBoolValue("ViewCells.PostProcess.useRaysForMerge", mUseRaysForMerge); 
     57         
     58        environment->GetIntValue("ViewCells.active", mNumActiveViewCells); 
    5959 
    6060        mMinPvsSize = emptyViewCells ? 1 : 0; 
     
    234234 
    235235  return true; 
     236} 
     237 
     238 
     239bool ViewCellsManager::ViewCellsTreeConstructed() const 
     240{ 
     241        return mViewCellsTree->GetRoot(); 
    236242} 
    237243 
     
    684690} 
    685691 
     692 
    686693int ViewCellsManager::GetMinPvsSize() const 
    687694{ 
     
    20662073void VspBspViewCellsManager::CollectViewCells() 
    20672074{ 
    2068         mVspBspTree->CollectViewCells(mViewCells, true); 
     2075        // view cells tree constructed 
     2076        if (!ViewCellsTreeConstructed()) 
     2077        { 
     2078                mVspBspTree->CollectViewCells(mViewCells, true); 
     2079        } 
     2080        else  
     2081        { 
     2082                // we can use the view cells tree hierarchy to get the right set 
     2083                mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumActiveViewCells); 
     2084        } 
     2085 
    20692086} 
    20702087 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r580 r581  
    339339        ViewCellsTree *GetViewCellsTree(); 
    340340 
    341         virtual void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates) = 0; 
    342  
     341        virtual void CollectMergeCandidates(const VssRayContainer &rays,  
     342                                                                                vector<MergeCandidate> &candidates) = 0; 
     343 
     344         
    343345 
    344346protected: 
     347 
     348        /** 
     349                if the view cells tree was already constructed or not. 
     350        */ 
     351        bool ViewCellsTreeConstructed() const; 
    345352 
    346353        int CastPassSamples(const int samplesPerPass,  
     
    421428        int mMinPvsSize; 
    422429        float mMaxPvsRatio; 
     430 
     431        int mNumActiveViewCells; 
    423432 
    424433        ViewCellsStatistics mViewCellsStats; 
Note: See TracChangeset for help on using the changeset viewer.