Changeset 585


Ignore:
Timestamp:
02/03/06 17:48:15 (18 years ago)
Author:
mattausch
Message:

fixed bug in compressing

Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
2 edited

Legend:

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

    r584 r585  
    5050 
    5151        return (float)pvs; 
     52} 
     53 
     54 
     55 
     56 
     57inline int CountDiffPvs(ViewCell *vc) 
     58{ 
     59        int count = 0; 
     60 
     61        ObjectPvsMap::const_iterator it, it_end = vc->GetPvs().mEntries.end(); 
     62        for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 
     63        { 
     64                if (!(*it).first->Mailed()) 
     65                { 
     66                        (*it).first->Mail(); 
     67                        ++ count; 
     68                } 
     69        } 
     70 
     71        return count; 
    5272} 
    5373 
     
    12571277 
    12581278        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     1279                 
    12591280                // compress child sets first 
    12601281                for (it = interior->mChildren.begin(); it != it_end; ++ it) 
     
    12631284                } 
    12641285 
     1286                // compress root node 
    12651287                PropagateUpVisibility(interior); 
    12661288        } 
     
    13411363 
    13421364                for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
    1343                 { 
    1344                         Debug << "mail: " << (*oit).first->mMailbox << endl; 
    1345  
     1365                {                
    13461366                        if ((*oit).first->Mailed((int)interior->mChildren.size())) 
    13471367                        {        
    1348                                 //Debug << "adding sample" << endl; 
    13491368                                interior->GetPvs().AddSample((*oit).first, (*oit).second.mSumPdf); 
    1350                                 //(*oit)->remove(); 
    13511369                        } 
    13521370                } 
     
    13661384                } 
    13671385        } 
    1368 } 
     1386 
     1387        int dummy = interior->GetPvs().GetSize(); 
     1388 
     1389        for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 
     1390        { 
     1391                dummy += (*cit)->GetPvs().GetSize(); 
     1392        } 
     1393 
     1394} 
     1395 
    13691396 
    13701397 
    13711398void ViewCellsTree::GetPvs(ViewCell *vc, ObjectPvs &pvs) const 
    13721399{ 
    1373         if (mIsCompressed) 
    1374         { 
    1375                 ObjectPvsMap::const_iterator oit, oit_end = vc->GetPvs().mEntries.end(); 
    1376  
    1377                 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
    1378                 { 
    1379                         pvs.AddSample((*oit).first, (*oit).second.mSumPdf); 
    1380                 } 
     1400        Intersectable::NewMail(); 
     1401 
     1402        if (!mIsCompressed) 
     1403                pvs = vc->GetPvs(); 
     1404 
     1405        int pvsSize = 0; 
     1406        ViewCell *root = vc; 
     1407         
     1408        // also add pvs from this view cell to root 
     1409        while (root->GetParent()) 
     1410        { 
     1411                root = root->GetParent(); 
     1412                pvs.AddPvs(root->GetPvs()); 
     1413        } 
     1414 
     1415        stack<ViewCell *> tstack; 
     1416        tstack.push(vc); 
     1417 
     1418        while (!tstack.empty()) 
     1419        { 
     1420                vc = tstack.top(); 
     1421                tstack.pop(); 
     1422 
     1423                pvs.AddPvs(vc->GetPvs()); 
    13811424 
    13821425                if (!vc->IsLeaf()) 
    13831426                { 
    13841427                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     1428 
    13851429                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
    13861430 
    13871431                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
    13881432                        { 
    1389                                 GetPvs(*it, pvs); 
    1390                         } 
    1391                 } 
    1392         } 
    1393         else 
    1394         { 
    1395                 pvs = vc->GetPvs(); 
     1433                                tstack.push(*it); 
     1434                        }                
     1435                } 
    13961436        } 
    13971437} 
     
    14001440int ViewCellsTree::GetPvsSize(ViewCell *vc) const 
    14011441{ 
    1402         int pvsSize = vc->GetPvs().GetSize(); 
    1403  
    1404         //Debug << "current size: " << pvsSize << endl; 
    1405         if (mIsCompressed && !vc->IsLeaf()) 
    1406         { 
    1407                 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
    1408  
    1409                 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
    1410  
    1411                 for (it = interior->mChildren.begin(); it != it_end; ++ it) 
    1412                 { 
    1413                         pvsSize += GetPvsSize(*it); 
     1442        Intersectable::NewMail(); 
     1443 
     1444        if (!mIsCompressed) 
     1445                return vc->GetPvs().GetSize(); 
     1446 
     1447        int pvsSize = 0; 
     1448        ViewCell *root = vc; 
     1449         
     1450        // also add pvs from this view cell to root 
     1451        while (root->GetParent()) 
     1452        { 
     1453                root = root->GetParent(); 
     1454                pvsSize += CountDiffPvs(root); 
     1455        } 
     1456 
     1457        stack<ViewCell *> tstack; 
     1458        tstack.push(vc); 
     1459 
     1460        Debug << "current size: " << pvsSize << endl; 
     1461 
     1462        while (!tstack.empty()) 
     1463        { 
     1464                vc = tstack.top(); 
     1465                tstack.pop(); 
     1466 
     1467                pvsSize += CountDiffPvs(vc); 
     1468 
     1469                if (!vc->IsLeaf()) 
     1470                { 
     1471                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     1472 
     1473                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     1474 
     1475                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
     1476                        { 
     1477                                tstack.push(*it); 
     1478                        }                
    14141479                } 
    14151480        } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r584 r585  
    23662366        RefineViewCells(postProcessRays, objects); 
    23672367 
    2368         ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 
    2369  
    2370         int pvsSize = 0; 
    2371         int numPvsEntries = 0; 
    2372  
    2373         int vidx = 0; 
    2374         for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 
    2375         { 
    2376                 const int vcPvs = mViewCellsTree->GetPvsSize(*vit); 
    2377                 const int pvsEntries = mViewCellsTree->GetNumPvsEntries(*vit); 
    2378  
    2379                 pvsSize += vcPvs; 
    2380                 numPvsEntries += pvsEntries; 
    2381                 Debug << "Viewcell " << vidx ++ << ": " << vcPvs << endl; 
    2382         } 
    2383  
    2384         Debug << "pvs size before compress: " << pvsSize << endl; 
    2385         Debug << "number of entries before compress: " << numPvsEntries << endl; 
     2368        int pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 
     2369        Debug << "number of entries before compress: " << pvsEntries << endl; 
    23862370 
    23872371        mViewCellsTree->CompressViewCellsPvs(); 
    23882372 
    2389         pvsSize = numPvsEntries = vidx = 0; 
    2390  
    2391         for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 
    2392         { 
    2393                 const int vcPvs = mViewCellsTree->GetPvsSize(*vit); 
    2394                 const int pvsEntries = mViewCellsTree->GetNumPvsEntries(*vit); 
    2395                  
    2396                 pvsSize += vcPvs; 
    2397                 numPvsEntries += pvsEntries; 
    2398                 Debug << "Viewcell " << vidx ++ << ": " << vcPvs << endl;        
    2399         } 
    2400  
    2401         Debug << "pvs size after compress: " << pvsSize << endl; 
    2402         Debug << "number of entries after compress: " << numPvsEntries << endl; 
     2373        pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 
     2374        Debug << "number of entries after compress: " << pvsEntries << endl; 
    24032375 
    24042376        if (1) 
Note: See TracChangeset for help on using the changeset viewer.