Changeset 1168


Ignore:
Timestamp:
07/28/06 09:37:05 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
11 edited

Legend:

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

    r1143 r1168  
    1717 
    1818 
    19 int ObjectPvs::CountPvs() const 
     19int ObjectPvs::CountObjectsInPvs() const 
    2020{ 
    2121        int pvs = 0; 
     
    3131 
    3232                // found kd node 
    33                 // the pvs is the sum of the objects in the leaves in the subtree 
    34                 // We eliminate already accounted kd nodes and objects 
    35                 // using mailboxing.  
     33                // the pvs is the number od different objects in the node leaves 
     34                // We eliminate already accounted kd nodes and objects using mailboxing.  
    3635                if (obj->Type() == Intersectable::KD_INTERSECTABLE) 
    3736                { 
     
    4746                                tStack.pop(); 
    4847 
    49                                 // already processed node (objects in pvs) 
    50                                 if (node->Mailed()) 
    51                                         continue; 
     48                                // already processed node (= objects in pvs)? 
     49                                if (!node->Mailed()) 
     50                                { 
     51                                        node->Mail(); 
    5252 
    53                                 node->Mail(); 
     53                                        if (node->IsLeaf()) 
     54                                        { 
     55                                                KdLeaf *leaf = dynamic_cast<KdLeaf *>(node); 
     56                         
     57                                                // add #objects exclusivly in this node 
     58                                                pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 
    5459 
    55                                 if (node->IsLeaf()) 
    56                                 { 
    57                                         KdLeaf *leaf = dynamic_cast<KdLeaf *>(node); 
    58  
    59                                         pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 
    60  
    61                                         // Objects already accounted for can only be found among those 
    62                                         // which are referenced in more than one leaf 
    63                                         ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 
    64                                         for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 
    65                                         { 
    66                                                 Intersectable *object = *oit;                                            
     60                                                // Objects already accounted for can only be found among those 
     61                                                // which are referenced in more than one leaf 
     62                                                ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 
    6763                                                 
    68                                                 if (!object->Mailed()) 
     64                                                for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 
    6965                                                { 
    70                                                         object->Mail(); 
    71                                                         ++ pvs; 
     66                                                        Intersectable *object = *oit;                                            
     67                             
     68                                                        if (!object->Mailed()) 
     69                                                        { 
     70                                                                object->Mail(); 
     71                                                                ++ pvs; 
     72                                                        } 
    7273                                                } 
    7374                                        } 
    74                                 } 
    75                                 else 
    76                                 { 
    77                                         KdInterior *interior = dynamic_cast<KdInterior *>(node); 
     75                                        else // traverse tree 
     76                                        { 
     77                                                KdInterior *interior = dynamic_cast<KdInterior *>(node); 
    7878 
    79                                         tStack.push(interior->mFront); 
    80                                         tStack.push(interior->mBack); 
     79                                                tStack.push(interior->mFront); 
     80                                                tStack.push(interior->mBack); 
     81                                        } 
    8182                                } 
    8283                        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r1141 r1168  
    421421{ 
    422422public: 
    423         /** Counts pvs. Different to GetSize(), not 
     423        /** Counts object int the pvs. Different to GetSize(), not 
    424424                only the raw container size is returned, 
    425425                but the individual contributions of the entries are summed up. 
    426426        */ 
    427         int CountPvs() const; 
     427        int CountObjectsInPvs() const; 
    428428}; 
    429429 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1166 r1168  
    254254 
    255255        // update pvs size scalar 
    256         mPvsSize = mPvs.GetSize(); 
    257         mPvsSizeValid = true; 
     256        //mPvsSize = mPvs.GetSize(); 
     257        mPvsSizeValid = false; // recompute pvs size 
    258258 
    259259        return result; 
     
    886886                const int upper = mViewCellsManager->GetMaxPvsSize(); 
    887887 
    888                 const float penalty = EvalPvsPenalty((*vit)->GetPvs().CountPvs(), lower, upper); 
     888                const float penalty = EvalPvsPenalty((*vit)->GetPvs().CountObjectsInPvs(), lower, upper); 
    889889                 
    890890                mDeviation += fabs(mAvgRenderCost - penalty); 
     
    978978        vc->Mail(); 
    979979 
    980         const int pvs1 = left->GetPvs().CountPvs(); 
    981         const int pvs2 = right->GetPvs().CountPvs(); 
     980        const int pvs1 = left->GetPvs().CountObjectsInPvs(); 
     981        const int pvs2 = right->GetPvs().CountObjectsInPvs(); 
    982982 
    983983 
     
    985985        mMergedViewCells.push_back(vc); 
    986986 
    987         pvsDiff = vc->GetPvs().CountPvs() - pvs1 - pvs2; 
     987        pvsDiff = vc->GetPvs().CountObjectsInPvs() - pvs1 - pvs2; 
    988988 
    989989 
     
    991991        if (mViewCellsStorage == PVS_IN_LEAVES) 
    992992        { 
    993                 left->mPvsSize = left->GetPvs().GetSize();  
    994                 left->mPvsSizeValid = true; 
    995                  
     993                // set scalars 
     994                mViewCellsManager->UpdateScalarPvsSize(left,  
     995                        left->GetPvs().CountObjectsInPvs(),  
     996                        left->GetPvs().GetSize()); 
     997                         
    996998                // remove pvs, we don't store interior pvss 
    997999                if (!left->IsLeaf()) 
     
    10001002                } 
    10011003 
    1002                 right->mPvsSize = right->GetPvs().CountPvs();  
     1004                // set scalars 
     1005                mViewCellsManager->UpdateScalarPvsSize(right,  
     1006                        right->GetPvs().CountObjectsInPvs(),  
     1007                        right->GetPvs().GetSize()); 
     1008 
    10031009                right->mPvsSizeValid = true; 
    10041010                 
     
    12851291        if (1) 
    12861292        { 
    1287                 const float penalty = EvalPvsPenalty(vc->GetPvs().CountPvs(), lower, upper); 
     1293                const float penalty = EvalPvsPenalty(vc->GetPvs().CountObjectsInPvs(), lower, upper); 
    12881294                return fabs(mAvgRenderCost - penalty) / (float)mNumActiveViewCells; 
    12891295        } 
     
    12981304        if (mUseAreaForPvs) 
    12991305        { 
    1300                 return vc->GetPvs().CountPvs() * vc->GetArea(); 
    1301         } 
    1302  
    1303         return vc->GetPvs().CountPvs() * vc->GetVolume(); 
     1306                return vc->GetPvs().CountObjectsInPvs() * vc->GetArea(); 
     1307        } 
     1308 
     1309        return vc->GetPvs().CountObjectsInPvs() * vc->GetVolume(); 
    13041310} 
    13051311 
     
    14691475        const int rootEntries = GetPvsEntries(mRoot); 
    14701476 
     1477        Debug << "******** Export stats **********" << endl; 
    14711478        /*Debug << "vsb volume: " << vol << endl; 
    14721479        Debug << "root volume: " << mRoot->GetVolume() << endl; 
     
    15171524 
    15181525                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
    1519  
     1526Debug << "\nhere92" << endl; 
    15201527                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
    15211528                        { 
     1529                                Debug << "here15" << endl; 
    15221530                                ViewCell *vc = *it; 
     1531 
    15231532                                const int pvsSize = GetPvsSize(vc); 
    15241533                                const int pvsEntries = GetPvsEntries(vc); 
     
    15321541                        } 
    15331542 
    1534                  
     1543Debug << "\nhere1005" << endl; 
    15351544                        const float costDecr = (parentCost - childCost) / vol; 
    15361545 
     
    16551664} 
    16561665 
     1666 
    16571667// TODO matt: implement this function for different storing methods 
    16581668void ViewCellsTree::GetPvs(ViewCell *vc, ObjectPvs &pvs) const 
     
    17081718int ViewCellsTree::GetPvsSizeForLeafStorage(ViewCell *vc) const 
    17091719{ 
    1710         int pvsSize = 0; 
    1711  
    17121720        // pvs is always stored directly in leaves 
    17131721        if (vc->IsLeaf()) 
    17141722        { 
    1715                 pvsSize = vc->GetPvs().CountPvs(); 
    1716                 //int pvsSize1 = vc->GetPvs().GetSize(); 
    1717                 //Debug << "entries num: " << pvsSize1 << " size: "" << pvsSize << endl; 
    1718         } 
    1719         else // interior node 
    1720         { 
    1721                 // interior nodes: pvs is either stored as a scalar or 
    1722                 // has to be reconstructed from the leaves 
    1723  
    1724                 // the stored pvs size is the valid pvs size => just return scalar 
    1725                 if (vc->mPvsSizeValid) 
    1726                 { 
    1727                         pvsSize = vc->mPvsSize; 
    1728                 } 
    1729                  
    1730                 // if no valid pvs size stored as a scalar =>  
    1731                 // compute current pvs size of interior from it's leaf nodes 
    1732                 ViewCellContainer leaves; 
    1733                 CollectLeaves(vc, leaves); 
    1734  
    1735                 ViewCellContainer::const_iterator it, it_end = leaves.end(); 
    1736  
    1737                 Intersectable::NewMail(); 
    1738  
    1739                 // sum different intersectables 
    1740                 for (it = leaves.begin(); it != it_end; ++ it) 
    1741                 { 
    1742                         pvsSize = GetPvsSizeForLeafStorage(*it); 
    1743                 } 
    1744         } 
    1745  
    1746         return pvsSize; 
     1723                return vc->GetPvs().CountObjectsInPvs(); 
     1724        } 
     1725         
     1726        // interior node 
     1727         
     1728        // interior nodes: pvs is either stored as a scalar or 
     1729        // has to be reconstructed from the leaves 
     1730 
     1731        // the stored pvs size is the valid pvs size => just return scalar 
     1732        if (vc->mPvsSizeValid) 
     1733        { 
     1734                Debug << "here5"<<endl; 
     1735                return vc->mPvsSize; 
     1736        } 
     1737         
     1738        Debug << "here2"<<endl; 
     1739 
     1740        // if no valid pvs size stored as a scalar =>  
     1741        // compute current pvs size of interior from it's leaf nodes 
     1742        ViewCellContainer leaves; 
     1743        CollectLeaves(vc, leaves); 
     1744 
     1745        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     1746 
     1747        Intersectable::NewMail(); 
     1748        ObjectPvs newPvs; 
     1749 
     1750        // sum different intersectables 
     1751        for (it = leaves.begin(); it != it_end; ++ it) 
     1752        { 
     1753                ObjectPvsMap::iterator oit, oit_end = (*it)->GetPvs().mEntries.end(); 
     1754 
     1755                for (oit = (*it)->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
     1756                { 
     1757                        Intersectable *intersect = (*oit).first; 
     1758 
     1759                        if (!intersect->Mailed()) 
     1760                        { 
     1761                                intersect->Mail(); 
     1762                                newPvs.AddSample(intersect, (*oit).second.mSumPdf); 
     1763                        } 
     1764                } 
     1765        } 
     1766 
     1767        return newPvs.CountObjectsInPvs(); 
    17471768} 
    17481769 
     
    17501771int ViewCellsTree::GetEntriesInPvsForLeafStorage(ViewCell *vc) const 
    17511772{ 
    1752         int pvsSize = 0; 
    1753  
    17541773        // pvs is always stored directly in leaves 
    17551774        if (vc->IsLeaf()) 
    17561775        { 
    1757                 pvsSize = vc->GetPvs().GetSize(); 
    1758         } 
    1759         else // interior node 
    1760         { 
    1761                 // interior nodes: pvs is either stored as a scalar or 
    1762                 // has to be reconstructed from the leaves 
    1763  
    1764                 // the stored pvs size is the valid pvs size => just return scalar 
    1765                 if (vc->mPvsSizeValid) 
    1766                 { 
    1767                         pvsSize = vc->mEntriesInPvs; 
    1768                 } 
    1769                  
    1770                 // if no valid pvs size stored as a scalar =>  
    1771                 // compute current pvs size of interior from it's leaf nodes 
    1772                 ViewCellContainer leaves; 
    1773                 CollectLeaves(vc, leaves); 
    1774  
    1775                 ViewCellContainer::const_iterator it, it_end = leaves.end(); 
    1776  
    1777                 Intersectable::NewMail(); 
    1778  
    1779                 // sum different intersectables 
    1780                 for (it = leaves.begin(); it != it_end; ++ it) 
    1781                 { 
    1782                         pvsSize = GetEntriesInPvsForLeafStorage(*it); 
     1776                return vc->GetPvs().GetSize(); 
     1777        } 
     1778         
     1779        // interior node 
     1780 
     1781        // interior nodes: pvs is either stored as a scalar or 
     1782        // has to be reconstructed from the leaves 
     1783 
     1784        // the stored pvs size is the valid pvs size => just return scalar 
     1785        if (vc->mPvsSizeValid) 
     1786        { 
     1787                return vc->mEntriesInPvs; 
     1788        } 
     1789         
     1790        int pvsSize = 0; 
     1791 
     1792        // if no valid pvs size stored as a scalar =>  
     1793        // compute current pvs size of interior from it's leaf nodes 
     1794        ViewCellContainer leaves; 
     1795        CollectLeaves(vc, leaves); 
     1796 
     1797        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     1798        Intersectable::NewMail(); 
     1799 
     1800        // sum different intersectables 
     1801        for (it = leaves.begin(); it != it_end; ++ it) 
     1802        { 
     1803                ObjectPvsMap::iterator oit, oit_end = (*it)->GetPvs().mEntries.end(); 
     1804 
     1805                for (oit = (*it)->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
     1806                { 
     1807                        Intersectable *intersect = (*oit).first; 
     1808 
     1809                        if (!intersect->Mailed()) 
     1810                        { 
     1811                                intersect->Mail(); 
     1812                                ++ pvsSize; 
     1813                        } 
    17831814                } 
    17841815        } 
     
    19161947                // pvs is stored consistently in the tree up to the root 
    19171948                // just return pvs size  
    1918                 pvsSize = vc->GetPvs().CountPvs();       
     1949                pvsSize = vc->GetPvs().CountObjectsInPvs();      
    19191950                break; 
    19201951        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r1166 r1168  
    206206                return a->mPvsSize < b->mPvsSize; 
    207207#else 
    208                 return a->GetPvs().CountPvs() < b->GetPvs().CountPvs(); 
     208                return a->GetPvs().CountObjectsInPvs() < b->GetPvs().CountObjectsInPvs(); 
    209209#endif 
    210210        } 
     
    288288        /// is up to date and corresponding to the real pvs size 
    289289        bool mPvsSizeValid; 
    290          
    291  
    292290}; 
    293291 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r1141 r1168  
    19481948                  << "#polygons: " << (int)data.mPolygons->size() << " (max: " << mTermMinPolys << "), " 
    19491949                  << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), "  
    1950                   << "#pvs: " << leaf->GetViewCell()->GetPvs().CountPvs() << "=, " 
     1950                  << "#pvs: " << leaf->GetViewCell()->GetPvs().CountObjectsInPvs() << "=, " 
    19511951                  << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 
    19521952#endif 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1166 r1168  
    310310                                Ray *pray = (*it)->mPiercingRays[0]; 
    311311                                Debug << "view cell " << (*it)->GetId() << " not empty, pvs: "  
    312                                           << (*it)->GetPvs().CountPvs() << " " << (int)pray->intersections.size() << endl; 
     312                                          << (*it)->GetPvs().CountObjectsInPvs() << " " << (int)pray->intersections.size() << endl; 
    313313 
    314314                                exporter->ExportRays((*it)->mPiercingRays); 
     
    12001200{ 
    12011201 
    1202         if ((vc->GetPvs().CountPvs() > maxPvsSize) || 
    1203                 (vc->GetPvs().CountPvs() < minPvsSize)) 
     1202        if ((vc->GetPvs().CountObjectsInPvs() > maxPvsSize) || 
     1203                (vc->GetPvs().CountObjectsInPvs() < minPvsSize)) 
    12041204        { 
    12051205                return false; 
     
    14171417        { 
    14181418                ViewCell *vc = *it; 
    1419                 totalRenderCost += vc->GetPvs().CountPvs() * vc->GetVolume(); 
    1420                 totalPvs += (int)vc->GetPvs().CountPvs(); 
     1419                totalRenderCost += vc->GetPvs().CountObjectsInPvs() * vc->GetVolume(); 
     1420                totalPvs += (int)vc->GetPvs().CountObjectsInPvs(); 
    14211421        } 
    14221422 
     
    14351435                ViewCell *vc = *it; 
    14361436 
    1437                 float renderCost = vc->GetPvs().CountPvs() * vc->GetVolume(); 
     1437                float renderCost = vc->GetPvs().CountObjectsInPvs() * vc->GetVolume(); 
    14381438                float dev; 
    14391439 
    14401440                if (1) 
    1441                         dev = fabs(avgRenderCost - (float)vc->GetPvs().CountPvs()); 
     1441                        dev = fabs(avgRenderCost - (float)vc->GetPvs().CountObjectsInPvs()); 
    14421442                else 
    14431443                        dev = fabs(expectedRenderCost - renderCost); 
     
    15681568 
    15691569 
    1570 // fast way of merging 2 view cells 
     1570/** fast way of merging 2 view cells. 
     1571*/ 
    15711572ViewCellInterior *ViewCellsManager::MergeViewCells(ViewCell *left, ViewCell *right) const 
    15721573{ 
     
    15961597 
    15971598        // update pvs size 
    1598         vc->mPvsSize = vc->GetPvs().CountPvs(); 
    1599         vc->mPvsSizeValid = true; 
     1599        UpdateScalarPvsSize(vc, vc->GetPvs().CountObjectsInPvs(), vc->GetPvs().GetSize()); 
    16001600 
    16011601        return vc; 
     
    22142214 
    22152215 
    2216 void ViewCellsManager::UpdateScalarPvsSize(ViewCell *vc, const int pvsSize, const int entriesInPvs) const 
     2216void ViewCellsManager::UpdateScalarPvsSize(ViewCell *vc,  
     2217                                                                                   const int pvsSize,  
     2218                                                                                   const int entriesInPvs) const 
    22172219{ 
    22182220        vc->mPvsSize = pvsSize; 
     
    24662468 
    24672469 
     2470void ViewCellsManager::UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) 
     2471{ 
     2472        // terminate traversal 
     2473        if (root->IsLeaf()) 
     2474        {  
     2475                // we assume that pvs is explicitly stored in leaves 
     2476                pvs = root->GetPvs(); 
     2477                UpdateScalarPvsSize(root, pvs.CountObjectsInPvs(), pvs.GetSize()); 
     2478                 
     2479                return; 
     2480        } 
     2481         
     2482        //-- interior node => propagate pvs up 
     2483        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root); 
     2484        interior->GetPvs().Clear(); 
     2485        pvs.Clear(); 
     2486        vector<ObjectPvs> pvsList; 
     2487 
     2488        ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end(); 
     2489 
     2490        for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit) 
     2491        { 
     2492                ObjectPvs objPvs; 
     2493                 
     2494                //-- recursivly compute child pvss 
     2495                UpdatePvsForEvaluation(*vit, objPvs); 
     2496 
     2497                // store pvs in vector 
     2498                pvsList.push_back(objPvs); 
     2499        } 
     2500 
     2501#if 1 
     2502        Intersectable::NewMail(); 
     2503 
     2504        //-- faster way of computing pvs: 
     2505        //   construct merged pvs by adding  
     2506        //   and only those of the next pvs which were not mailed. 
     2507        //   note: sumpdf is not correct!! 
     2508        vector<ObjectPvs>::iterator oit = pvsList.begin(); 
     2509 
     2510        for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ oit) 
     2511        { 
     2512            ObjectPvsMap::iterator pit, pit_end = (*oit).mEntries.end(); 
     2513         
     2514                for (pit = (*oit).mEntries.begin(); pit != pit_end; ++ pit) 
     2515                { 
     2516                        Intersectable *intersect = (*pit).first; 
     2517 
     2518                        if (!intersect->Mailed()) 
     2519                        { 
     2520                                pvs.AddSample(intersect, (*pit).second.mSumPdf); 
     2521                                intersect->Mail(); 
     2522                        } 
     2523                } 
     2524        } 
     2525 
     2526        // store pvs in this node 
     2527        if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS) 
     2528        { 
     2529                interior->SetPvs(pvs); 
     2530        } 
     2531         
     2532        // set new pvs size 
     2533        UpdateScalarPvsSize(interior, pvs.CountObjectsInPvs(), pvs.GetSize()); 
     2534         
     2535 
     2536#else 
     2537 
     2538        // really merge cells: slow put sumpdf is correct 
     2539        viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 
     2540        viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); 
     2541#endif 
     2542} 
     2543 
    24682544/*******************************************************************/ 
    24692545/*               BspViewCellsManager implementation                */ 
     
    31933269 
    31943270 
    3195 void BspViewCellsManager::UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) 
    3196 { 
    3197         // terminate traversal 
    3198         if (root->IsLeaf()) 
    3199         { 
    3200                 pvs = root->GetPvs(); 
    3201                 UpdateScalarPvsSize(root, pvs.CountPvs(), pvs.GetSize()); 
    3202                  
    3203                 return; 
    3204         } 
    3205  
    3206         ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root); 
    3207         ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end(); 
    3208  
    3209         vector<ObjectPvs> pvsList; 
    3210          
    3211          
    3212         for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit) 
    3213         { 
    3214                 ObjectPvs objPvs; 
    3215                  
    3216                 //-- recursivly compute child pvss 
    3217                 UpdatePvsForEvaluation(*vit, objPvs); 
    3218  
    3219                 // store pvs in vector 
    3220                 pvsList.push_back(objPvs); 
    3221         } 
    3222  
    3223 #if 1 
    3224         Intersectable::NewMail(); 
    3225  
    3226         //-- faster way of computing pvs: 
    3227         //   construct merged pvs by adding  
    3228         //   and only those of the next pvs which were not mailed. 
    3229         //   note: sumpdf is not correct!! 
    3230         vector<ObjectPvs>::iterator oit = pvsList.begin(); 
    3231  
    3232         for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ oit) 
    3233         { 
    3234                  
    3235         ObjectPvsMap::iterator pit, pit_end = (*oit).mEntries.end(); 
    3236          
    3237                 for (pit = (*oit).mEntries.begin(); pit != pit_end; ++ pit) 
    3238                 { 
    3239                          
    3240                         Intersectable *intersect = (*pit).first; 
    3241  
    3242                         if (!intersect->Mailed()) 
    3243                         { 
    3244                                 pvs.AddSample(intersect, (*pit).second.mSumPdf); 
    3245                                 intersect->Mail(); 
    3246                         } 
    3247                 } 
    3248         } 
    3249  
    3250         // store pvs in this node 
    3251         if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS) 
    3252         { 
    3253                 interior->SetPvs(pvs); 
    3254         } 
    3255          
    3256         // set correct pvs size for interior 
    3257         UpdateScalarPvsSize(interior, pvs.CountPvs(), pvs.GetSize()); 
    3258  
    3259 #else 
    3260         // really merge cells: slow nut sumpdf is correct 
    3261         ViewCellInterior *viewCellInterior = new ViewCellInterior(); 
    3262  
    3263         viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 
    3264         viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); 
    3265 #endif 
    3266  
    3267 } 
    3268  
    32693271/************************************************************************/ 
    32703272/*                   KdViewCellsManager implementation                  */ 
     
    40754077 
    40764078 
    4077  
    4078 void VspBspViewCellsManager::UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) 
    4079 { 
    4080         // terminate traversal 
    4081         if (root->IsLeaf()) 
    4082         { 
    4083                 pvs = root->GetPvs(); 
    4084                 UpdateScalarPvsSize(root, pvs.CountPvs(), pvs.GetSize()); 
    4085                  
    4086                 return; 
    4087         } 
    4088          
    4089         //-- interior node => propagate pvs up 
    4090         ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root); 
    4091         interior->GetPvs().Clear(); 
    4092         pvs.Clear(); 
    4093         vector<ObjectPvs> pvsList; 
    4094  
    4095         ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end(); 
    4096  
    4097         for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit) 
    4098         { 
    4099                 ObjectPvs objPvs; 
    4100                  
    4101                 //-- recursivly compute child pvss 
    4102                 UpdatePvsForEvaluation(*vit, objPvs); 
    4103  
    4104                 // store pvs in vector 
    4105                 pvsList.push_back(objPvs); 
    4106         } 
    4107  
    4108 #if 1 
    4109  
    4110         Intersectable::NewMail(); 
    4111  
    4112         //-- faster way of computing pvs: 
    4113         //   construct merged pvs by adding  
    4114         //   and only those of the next pvs which were not mailed. 
    4115         //   note: sumpdf is not correct!! 
    4116         vector<ObjectPvs>::iterator oit = pvsList.begin(); 
    4117  
    4118         for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ oit) 
    4119         { 
    4120             ObjectPvsMap::iterator pit, pit_end = (*oit).mEntries.end(); 
    4121          
    4122                 for (pit = (*oit).mEntries.begin(); pit != pit_end; ++ pit) 
    4123                 { 
    4124                         Intersectable *intersect = (*pit).first; 
    4125  
    4126                         if (!intersect->Mailed()) 
    4127                         { 
    4128                                 pvs.AddSample(intersect, (*pit).second.mSumPdf); 
    4129                                 intersect->Mail(); 
    4130                         } 
    4131                 } 
    4132         } 
    4133  
    4134         // store pvs in this node 
    4135         if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS) 
    4136         { 
    4137                 interior->SetPvs(pvs); 
    4138         } 
    4139          
    4140         // set new pvs size 
    4141         UpdateScalarPvsSize(interior, pvs.CountPvs(), pvs.GetSize()); 
    4142          
    4143  
    4144 #else 
    4145  
    4146         // really merge cells: slow but sumpdf is correct 
    4147         viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 
    4148         viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); 
    4149 #endif 
    4150  
    4151 } 
    4152  
    4153  
    41544079bool VspBspViewCellsManager::GetViewPoint(Vector3 &viewPoint) const 
    41554080{ 
     
    46464571                 
    46474572                const int pvsVc = mViewCellsTree->GetPvsEntries(vc); 
    4648                 const int pvs2 = (*vit).second.GetSize(); 
    4649  
    4650         m.mDiffuseColor.r = (float) (pvsVc - pvs2); 
     4573                const int pvsPtSamples = (*vit).second.GetSize(); 
     4574 
     4575        m.mDiffuseColor.r = (float) (pvsVc - pvsPtSamples); 
    46514576                m.mDiffuseColor.b = 1.0f; 
    46524577                //exporter->SetForcedMaterial(m); 
     
    51535078 
    51545079        return viewCellInterior; 
    5155 } 
    5156  
    5157  
    5158  
    5159 void VspOspViewCellsManager::UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) 
    5160 { 
    5161         // terminate traversal 
    5162         if (root->IsLeaf()) 
    5163         {  
    5164                 // we assume that pvs is explicitly stored in leaves 
    5165                 pvs = root->GetPvs(); 
    5166                 UpdateScalarPvsSize(root, pvs.CountPvs(), pvs.GetSize()); 
    5167                  
    5168                 return; 
    5169         } 
    5170          
    5171         //-- interior node => propagate pvs up 
    5172         ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root); 
    5173         interior->GetPvs().Clear(); 
    5174         pvs.Clear(); 
    5175         vector<ObjectPvs> pvsList; 
    5176  
    5177         ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end(); 
    5178  
    5179         for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit) 
    5180         { 
    5181                 ObjectPvs objPvs; 
    5182                  
    5183                 //-- recursivly compute child pvss 
    5184                 UpdatePvsForEvaluation(*vit, objPvs); 
    5185  
    5186                 // store pvs in vector 
    5187                 pvsList.push_back(objPvs); 
    5188         } 
    5189  
    5190 #if 1 
    5191         Intersectable::NewMail(); 
    5192  
    5193         //-- faster way of computing pvs: 
    5194         //   construct merged pvs by adding  
    5195         //   and only those of the next pvs which were not mailed. 
    5196         //   note: sumpdf is not correct!! 
    5197         vector<ObjectPvs>::iterator oit = pvsList.begin(); 
    5198  
    5199         for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ oit) 
    5200         { 
    5201             ObjectPvsMap::iterator pit, pit_end = (*oit).mEntries.end(); 
    5202          
    5203                 for (pit = (*oit).mEntries.begin(); pit != pit_end; ++ pit) 
    5204                 { 
    5205                         Intersectable *intersect = (*pit).first; 
    5206  
    5207                         if (!intersect->Mailed()) 
    5208                         { 
    5209                                 pvs.AddSample(intersect, (*pit).second.mSumPdf); 
    5210                                 intersect->Mail(); 
    5211                         } 
    5212                 } 
    5213         } 
    5214  
    5215         // store pvs in this node 
    5216         if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS) 
    5217         { 
    5218                 interior->SetPvs(pvs); 
    5219         } 
    5220          
    5221         // set new pvs size 
    5222         UpdateScalarPvsSize(interior, pvs.CountPvs(), pvs.GetSize()); 
    5223          
    5224  
    5225 #else 
    5226  
    5227         // really merge cells: slow put sumpdf is correct 
    5228         viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 
    5229         viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); 
    5230 #endif 
    52315080} 
    52325081 
     
    55205369                                exporter->ExportRays(vcRays, RgbColor(1, 1, 0)); 
    55215370                        } 
    5522  
    5523                 } 
    5524                  
     5371                } 
    55255372 
    55265373                //-- export view cell geometry 
     
    57975644                        if (ray.mTerminationObject)  
    57985645                        { 
     5646                                // todo: maybe not correct for kd node pvs 
    57995647                                if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 
    58005648                                        ray.mPdf, contribution)) 
     
    58525700#if SAMPLE_ORIGIN_OBJECTS 
    58535701                                 if (ray.mOriginObject) 
    5854                                          viewcell->AddPvsSample(ray.mOriginObject, ray.mPdf, ray.mPvsContribution); 
     5702                                 { 
     5703                                         if (!mStoreKdPvs) 
     5704                                         { 
     5705                                                 viewcell->AddPvsSample(ray.mOriginObject, ray.mPdf, ray.mPvsContribution); 
     5706                                         } 
     5707                                         else 
     5708                                         { 
     5709                                                 /// get current leaf the point 
     5710                                                KdLeaf *leaf = mOspTree->GetLeaf(ray.mOrigin); 
     5711                                                KdIntersectable *entry = mOspTree->GetOrCreateKdIntersectable(leaf); 
     5712 
     5713                                                viewcell->AddPvsSample(entry, ray.mPdf, ray.mRelativePvsContribution); 
     5714                                         } 
     5715                                 } 
    58555716#endif 
    58565717                        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1160 r1168  
    579579        /** Updates pvs of all view cells for statistical evaluation after some more sampling 
    580580        */ 
    581         virtual void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) = 0; 
     581        void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs); 
    582582 
    583583         
     
    736736        ViewCell *ConstructSpatialMergeTree(BspNode *root); 
    737737 
    738         /** Updates the pvs in the view cells tree. 
    739         */ 
    740         void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs); 
    741  
    742  
     738         
    743739protected: 
    744740 
     
    815811protected: 
    816812 
    817         virtual void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) {}; 
    818813        /** Collects view cells from a hierarchy. 
    819814        */ 
     
    924919        ViewCell *ConstructSpatialMergeTree(BspNode *root); 
    925920 
    926         void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs); 
    927  
    928  
    929921        /// HACK for testing visibility filter functionality 
    930922        void TestFilter(const ObjectContainer &objects); 
    931  
    932923 
    933924        /** Visualization of the pvs difference to exact visubility using  
     
    10401031        ViewCell *ConstructSpatialMergeTree(VspNode *root); 
    10411032 
    1042         void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs); 
    1043  
    10441033        /** Exports visualization of the PVS. 
    10451034        */ 
     
    10481037 
    10491038 
     1039        ///////////////////////////////////////// 
    10501040        /// the view space partition tree. 
    10511041        VspTree *mVspTree; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp

    r1166 r1168  
    262262 
    263263                                mForcedMaterial.mDiffuseColor.b = 1.0f; 
    264                                 const float importance = (float)leaf->GetViewCell()->GetPvs().CountPvs() / (float)maxPvs; 
     264                                const float importance = (float)leaf->GetViewCell()->GetPvs().CountObjectsInPvs() / (float)maxPvs; 
    265265 
    266266                                mForcedMaterial.mDiffuseColor.r = importance; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1160 r1168  
    843843                // update scalar pvs size lookup 
    844844                ObjectPvs &pvs = viewCell->GetPvs(); 
    845                 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountPvs(), pvs.GetSize()); 
     845                mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 
    846846         
    847847 
     
    984984                // update scalar pvs size value 
    985985                ObjectPvs &pvs = viewCell->GetPvs(); 
    986                 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountPvs(), pvs.GetSize()); 
     986                mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 
    987987 
    988988                mBspStats.contributingSamples += conSamp; 
     
    24192419                        if (leaf->TreeValid() &&  
    24202420                                (!onlyUnmailed || !leaf->Mailed()) && 
    2421                                 ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().CountPvs() <= maxPvsSize))) 
     2421                                ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().CountObjectsInPvs() <= maxPvsSize))) 
    24222422                        { 
    24232423                                leaves.push_back(leaf); 
     
    24962496                  << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 
    24972497                  << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 
    2498                   << "#pvs: " << leaf->GetViewCell()->GetPvs().CountPvs() << "), " 
     2498                  << "#pvs: " << leaf->GetViewCell()->GetPvs().CountObjectsInPvs() << "), " 
    24992499                  << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 
    25002500#endif 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp

    r1166 r1168  
    610610                // update scalar pvs size value 
    611611                ObjectPvs &pvs = viewCell->GetPvs(); 
    612                 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountPvs(), pvs.GetSize()); 
     612                mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 
    613613 
    614614                mVspStats.contributingSamples += conSamp; 
     
    725725                // update scalar pvs size value 
    726726                ObjectPvs &pvs = viewCell->GetPvs(); 
    727                 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountPvs(), pvs.GetSize()); 
     727                mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 
    728728 
    729729                mVspStats.contributingSamples += conSamp; 
     
    17971797                        if (leaf->TreeValid() &&  
    17981798                                (!onlyUnmailed || !leaf->Mailed()) && 
    1799                                 ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().CountPvs() <= maxPvsSize))) 
     1799                                ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().CountObjectsInPvs() <= maxPvsSize))) 
    18001800                        { 
    18011801                                leaves.push_back(leaf); 
     
    18741874                  << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 
    18751875                  << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 
    1876                   << "#pvs: " << leaf->GetViewCell()->GetPvs().CountPvs() << "), " 
     1876                  << "#pvs: " << leaf->GetViewCell()->GetPvs().CountObjectsInPvs() << "), " 
    18771877                  << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 
    18781878#endif 
     
    44964496                mTotalCost -= splitCandidate->GetRenderCostDecrease(); 
    44974497 
    4498                 //-- subdivide leaf node 
    4499                 SubdivideSplitCandidate(splitCandidate); 
    4500                  
    45014498                // cost ratio of cost decrease / totalCost 
    45024499                const float costRatio = splitCandidate->GetRenderCostDecrease() / mTotalCost; 
     
    45064503                          << splitCandidate->GetRenderCostDecrease()  
    45074504                          << " cost ratio: " << costRatio << endl << endl; 
     4505 
     4506                //-- subdivide leaf node 
     4507                SubdivideSplitCandidate(splitCandidate); 
    45084508 
    45094509                if (costRatio < mTermMinGlobalCostRatio) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp

    r1141 r1168  
    298298                                mForcedMaterial.mDiffuseColor.b = 1.0f; 
    299299                                const float importance =  
    300                                         (float)leaf->GetViewCell()->GetPvs().CountPvs() / (float)maxPvs; 
     300                                        (float)leaf->GetViewCell()->GetPvs().CountObjectsInPvs() / (float)maxPvs; 
    301301 
    302302                                mForcedMaterial.mDiffuseColor.r = importance; 
Note: See TracChangeset for help on using the changeset viewer.