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

added function for pvs compression

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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} 
Note: See TracChangeset for help on using the changeset viewer.