Changeset 1707 for GTP/trunk/Lib


Ignore:
Timestamp:
11/01/06 23:20:53 (18 years ago)
Author:
mattausch
Message:

worked on full render cost evaluation
warning: some change sin render cost evaluation for pvs which could have bugs

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/todo_i3d

    r1685 r1707  
    1 1) implement the computed value for ratio drc /dmem 
    2 2) try soda scene using more samples to avoid samples 
    313) test object space subdivision as postprocess 
    42        do view space subdivison on objects 
     
    97                visibility based heuristics + sah for undersampling 
    108 
     9check sah if implemented right!! (bounding volume!!) 
     10 
    11114) implement full evaluation framework 
    1212 
    13135) rerun vienna tests 
     14 
     156) check if memory was computed right!! 
     16 
     177) include tree sizes in memory computation + plots 
     18 
     198) include cost of bvh in drc / rmem heuristics 
     20 
     219) check undersampling in visualization 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1705 r1707  
    15061506 
    15071507 
    1508 void BvHierarchy::CollectLeaves(vector<BvhLeaf *> &leaves) const 
     1508void BvHierarchy::CollectLeaves(BvhNode *root, vector<BvhLeaf *> &leaves) const 
    15091509{ 
    15101510        stack<BvhNode *> nodeStack; 
    1511         nodeStack.push(mRoot); 
     1511        nodeStack.push(root); 
    15121512 
    15131513        while (!nodeStack.empty())  
     
    17631763 
    17641764 
    1765 BvhIntersectable *BvHierarchy::GetOrCreateBvhIntersectable(BvhNode *node) 
     1765BvhIntersectable *BvHierarchy::GetOrCreateBvhIntersectable(BvhLeaf *node) 
    17661766{ 
    17671767        // search nodes 
    1768         std::map<BvhNode *, BvhIntersectable *>::const_iterator  
     1768        std::map<BvhLeaf *, BvhIntersectable *>::const_iterator  
    17691769                it = mBvhIntersectables.find(node); 
    17701770 
     
    21512151 
    21522152 
     2153void BvHierarchy::SetActive(BvhNode *node) const 
     2154{ 
     2155        vector<BvhLeaf *> leaves; 
     2156 
     2157        // sets the pointers to the currently active view cells 
     2158        CollectLeaves(node, leaves); 
     2159 
     2160        vector<BvhLeaf *>::const_iterator bit, bit_end = leaves.end(); 
     2161 
     2162        for (bit = leaves.begin(); bit != bit_end; ++ bit) 
     2163        { 
     2164                (*bit)->SetActiveNode(node); 
     2165        } 
     2166} 
     2167 
     2168 
    21532169BvhNode *BvHierarchy::SubdivideAndCopy(SplitQueue &tQueue,  
    21542170                                                                           SubdivisionCandidate *splitCandidate) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1706 r1707  
    310310        virtual void CollectObjects(ObjectContainer &objects); 
    311311 
    312         /** returns level of the hierarchy that is "active" right now. 
     312        /** Returns level of the hierarchy that is "active" right now. 
    313313        */ 
    314314        BvhNode *GetActiveNode() 
    315315        { 
    316316                return mActiveNode; 
     317        } 
     318 
     319        /** Returns level of the hierarchy that is "active" right now. 
     320        */ 
     321        void SetActiveNode(BvhNode *node) 
     322        { 
     323                mActiveNode = node; 
    317324        } 
    318325 
     
    331338        SubdivisionCandidate *mSubdivisionCandidate; 
    332339 
    333          
     340        /// the active node which will be accounted for in the pvs 
    334341        BvhNode *mActiveNode; 
    335342}; 
    336343 
    337344 
    338 typedef map<BvhNode *, BvhIntersectable *> BvhIntersectableMap; 
     345typedef map<BvhLeaf *, BvhIntersectable *> BvhIntersectableMap; 
    339346 
    340347 
     
    516523                                                                  bool computeSplitPlane = true); 
    517524 
    518         /** Returns list of leaves with pvs smaller than 
    519                 a certain threshold. 
    520                 @param onlyUnmailed if only the unmailed leaves should be considered 
    521                 @param maxPvs the maximal pvs of a leaf to be added (-1 means unlimited) 
    522         */ 
    523         void CollectLeaves(vector<BvhLeaf *> &leaves) const; 
     525        /** Returns vector of leaves. 
     526        */ 
     527        void CollectLeaves(BvhNode *root, vector<BvhLeaf *> &leaves) const; 
    524528 
    525529        /** Returns bounding box of the whole tree (= bbox of root node) 
     
    564568        bool Export(OUT_STREAM &stream); 
    565569 
    566         /** Returns or creates a new intersectable for use in a kd based pvs. 
    567                 The OspTree is responsible for destruction of the intersectable. 
    568         */ 
    569         BvhIntersectable *GetOrCreateBvhIntersectable(BvhNode *node); 
     570        /** Returns or creates a new intersectable for use in a bv based pvs. 
     571                The hierarchy is responsible for destruction of the intersectable. 
     572        */ 
     573        BvhIntersectable *GetOrCreateBvhIntersectable(BvhLeaf *node); 
    570574 
    571575        /** Collects rays associated with the objects. 
     
    586590        */ 
    587591        ViewCellsTree *GetViewCellsTree() const { return mViewCellsTree; } 
     592         
    588593        /** See Get 
    589594        */ 
     
    593598        */ 
    594599        float GetMemUsage() const; 
     600 
     601        /** Sets this node to be an active node. 
     602        */ 
     603        void SetActive(BvhNode *node) const; 
    595604 
    596605 
     
    603612 
    604613        static float EvalAbsCost(const ObjectContainer &objects); 
     614 
    605615 
    606616protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp

    r1701 r1707  
    110110{ 
    111111        vector<BvhLeaf *> leaves; 
    112         bvHierarchy.CollectLeaves(leaves); 
     112        bvHierarchy.CollectLeaves(bvHierarchy.GetRoot(), leaves); 
    113113 
    114114        mUseForcedMaterial = true; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1706 r1707  
    2121#include "OspTree.h" 
    2222#include "BvHierarchy.h" 
     23#include "ViewCell.h" 
    2324 
    2425 
     
    16831684        // reinstall old bv refs 
    16841685        vector<BvhLeaf *> leaves; 
    1685         mBvHierarchy->CollectLeaves(leaves); 
     1686        mBvHierarchy->CollectLeaves(mBvHierarchy->GetRoot(), leaves); 
    16861687        vector<BvhLeaf *>::const_iterator bit, bit_end = leaves.end(); 
    16871688 
     
    17881789{ 
    17891790public: 
    1790         enum {VSP_NODE, BVH_NODE}; 
     1791        enum {VSP_NODE, BVH_NODE, VIEW_CELL}; 
    17911792 
    17921793        virtual float GetMergeCost() const = 0; 
     
    18501851 
    18511852 
     1853class ViewCellWrapper: public HierarchyNodeWrapper 
     1854{ 
     1855public: 
     1856 
     1857        ViewCellWrapper(ViewCell *vc): mViewCell(vc) {} 
     1858         
     1859        int Type()  const { return VIEW_CELL; } 
     1860 
     1861        float GetMergeCost() const { return mViewCell->GetMergeCost(); }; 
     1862 
     1863        bool IsLeaf() const { return mViewCell->IsLeaf(); } 
     1864 
     1865        void PushChildren(HierarchyNodeQueue &tQueue) 
     1866        { 
     1867                if (!mViewCell->IsLeaf()) 
     1868                { 
     1869                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(mViewCell); 
     1870 
     1871                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     1872 
     1873                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
     1874                        { 
     1875                                tQueue.push(new ViewCellWrapper(*it)); 
     1876                        } 
     1877                } 
     1878        } 
     1879 
     1880        ViewCell *mViewCell; 
     1881}; 
     1882 
     1883 
    18521884void HierarchyManager::CollectBestSet(const int maxSplits, 
    18531885                                                                          const float maxMemoryCost, 
    1854                                                                           vector<VspNode *> &vspNodes, 
     1886                                //                                        vector<VspNode *> &vspNodes, 
     1887                                                                          ViewCellContainer &viewCells, 
    18551888                                                                          vector<BvhNode *> &bvhNodes) 
    18561889{ 
    18571890        HierarchyNodeQueue tqueue; 
    1858         tqueue.push(new VspNodeWrapper(mVspTree->GetRoot())); 
     1891        //tqueue.push(new VspNodeWrapper(mVspTree->GetRoot())); 
     1892        tqueue.push(new ViewCellWrapper(mVspTree->mViewCellsTree->GetRoot())); 
    18591893        tqueue.push(new BvhNodeWrapper(mBvHierarchy->GetRoot())); 
    18601894         
     
    18691903                // because of the priority queue, this will be the optimal set of v 
    18701904                if (nodeWrapper->IsLeaf() ||  
    1871                         ((vspNodes.size() + bvhNodes.size() + tqueue.size() + 1) >= maxSplits) || 
     1905                        ((viewCells.size() + bvhNodes.size() + tqueue.size() + 1) >= maxSplits) || 
    18721906                        (memCost > maxMemoryCost) 
    18731907                        ) 
     
    18751909                        if (nodeWrapper->Type() == HierarchyNodeWrapper::VSP_NODE) 
    18761910                        { 
    1877                                 VspNodeWrapper *vspNodeWrapper = dynamic_cast<VspNodeWrapper *>(nodeWrapper); 
    1878                                 vspNodes.push_back(vspNodeWrapper->mNode); 
     1911                                ViewCellWrapper *viewCellWrapper = dynamic_cast<ViewCellWrapper *>(nodeWrapper); 
     1912                                viewCells.push_back(viewCellWrapper->mViewCell); 
    18791913                        } 
    18801914                        else 
     
    19001934                                                                                 int &pvsEntries) 
    19011935{ 
     1936        //vector<VspNode *> vspNodes; 
     1937        ViewCellContainer viewCells; 
     1938        vector<BvhNode *> bvhNodes; 
     1939 
     1940    CollectBestSet(maxSplits, maxMemoryCost, viewCells, bvhNodes); 
     1941 
     1942        vector<BvhNode *>::const_iterator bit, bit_end = bvhNodes.end(); 
     1943         
     1944        for (bit = bvhNodes.begin(); bit != bit_end; ++ bit) 
     1945        { 
     1946                mBvHierarchy->SetActive(*bit); 
     1947        } 
     1948 
     1949        //vector<VspNode *>::const_iterator vit, vit_end = vspNodes.end(); 
     1950 
     1951        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
     1952 
     1953        int numEntries = 0; 
     1954        float pvsCost = 0.0f; 
     1955 
     1956        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
     1957        { 
     1958                ViewCell *vc = *vit; 
     1959                ObjectPvs pvs; 
     1960                mVspTree->mViewCellsTree->GetPvs(vc, pvs); 
     1961 
     1962                BvhNode::NewMail(); 
     1963 
     1964                // hack: should not be done here 
     1965                ObjectPvsMap::const_iterator oit, oit_end = pvs.mEntries.end(); 
     1966 
     1967                for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit) 
     1968                { 
     1969                        BvhIntersectable *intersect = dynamic_cast<BvhIntersectable *>((*oit).first); 
     1970                        BvhLeaf *leaf = intersect->GetItem(); 
     1971                        BvhNode *activeNode = leaf->GetActiveNode(); 
     1972 
     1973                        if (!activeNode->Mailed()) 
     1974                        { 
     1975                                activeNode->Mail(); 
     1976 
     1977                                ++ numEntries; 
     1978                                pvsCost += mBvHierarchy->EvalAbsCost(leaf->mObjects); 
     1979                        } 
     1980                } 
     1981        } 
     1982 
    19021983        /*TraversalQueue tqueue; 
    19031984        tqueue.push(mRoot); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1706 r1707  
    452452        void CollectBestSet(const int maxSplits, 
    453453                                                const float maxMemoryCost, 
    454                                                 vector<VspNode *> &vspNodes, 
     454                                                //vector<VspNode *> &vspNodes, 
     455                                                ViewCellContainer &viewCells, 
    455456                                                vector<BvhNode *> &bvhNodes); 
    456457 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h

    r1694 r1707  
    1212struct VssRayContainer; 
    1313class KdNode; 
    14 class BvhNode; 
     14//class BvhNode; 
     15class BvhLeaf; 
     16class Ray; 
     17 
    1518struct Face; 
    16 class Ray; 
    1719struct Triangle3; 
    18   class KdTree; 
     20 
     21class KdTree; 
    1922 
    2023 
     
    166169typedef map<KdNode *, KdIntersectable *> KdIntersectableMap; 
    167170 
    168 class BvhIntersectable: public IntersectableWrapper<BvhNode *> 
    169 { 
    170 public: 
    171         BvhIntersectable(BvhNode *item): 
    172         IntersectableWrapper<BvhNode *>(item) {} 
     171class BvhIntersectable: public IntersectableWrapper<BvhLeaf *> 
     172{ 
     173public: 
     174        BvhIntersectable(BvhLeaf *item): 
     175        IntersectableWrapper<BvhLeaf *>(item) {} 
    173176 
    174177        int Type() const 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp

    r1703 r1707  
    7979        We eliminate already accounted bvh nodes and objects using mailboxing.  
    8080*/ 
    81 static int EvalBvhNodeContribution(BvhIntersectable *bvhobj) 
     81static float EvalBvhNodeContribution(BvhIntersectable *bvhobj) 
    8282{ 
    83         BvhNode *node= bvhobj->GetItem(); 
     83        BvhLeaf *leaf = bvhobj->GetItem(); 
     84        BvhNode *node = leaf->GetActiveNode(); 
    8485 
    8586        // early exit 
    86         if (node->IsLeaf())      
     87        if (node == leaf)        
    8788        { 
    8889                // objects already accounted for 
    89                 if (node->Mailed()) 
     90                if (leaf->Mailed()) 
    9091                        return 0; 
    9192 
    92                 node->Mail(); 
    93                 BvhLeaf *leaf = dynamic_cast<BvhLeaf *>(node); 
    94                 return (int)leaf->mObjects.size(); 
     93                leaf->Mail(); 
     94                return BvHierarchy::EvalAbsCost(leaf->mObjects); 
    9595        }                         
    9696 
    9797        // compute leaf pvs 
    98         int pvs = 0; 
     98        float pvs = 0; 
    9999        stack<BvhNode *> tStack; 
    100         tStack.push(bvhobj->GetItem()); 
     100        tStack.push(node); 
    101101 
    102102        while (!tStack.empty()) 
    103103        { 
    104                 BvhNode *node = tStack.top(); 
     104                node = tStack.top(); 
    105105                tStack.pop(); 
    106106 
     
    112112                        if (node->IsLeaf()) 
    113113                        { 
    114                                 BvhLeaf *leaf = dynamic_cast<BvhLeaf *>(node); 
     114                                leaf = dynamic_cast<BvhLeaf *>(node); 
    115115 
    116116                                // add #objects exclusivly in this node 
     
    132132 
    133133 
    134 int ObjectPvs::CountObjectsInPvs() const 
     134float ObjectPvs::EvalPvsCost() const 
    135135{ 
    136         int pvs = 0; 
     136        float pvs = 0; 
    137137 
    138138        Intersectable::NewMail(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r1706 r1707  
    529529                but the individual contributions of the entries are summed up. 
    530530        */ 
    531         int CountObjectsInPvs() const; 
     531        float EvalPvsCost() const; 
    532532}; 
    533533 
  • GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj

    r1501 r1707  
    206206                                Name="VCLinkerTool" 
    207207                                AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib Preprocessor.lib RTScene.lib RTWorld.lib QtCore4.lib qtmain.lib QtOpenGL4.lib Qt3Support4.lib QtTest4.lib QtGui4.lib QtGlRenderer.lib" 
    208                                 OutputFile="../bin/release/Preprocessor.exe" 
     208                                OutputFile="../bin/release/Preprocessor2.exe" 
    209209                                LinkIncremental="1" 
    210210                                AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\Preprocessing\lib\release;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\MultiLevelRayTracing\RTScene\Release;..\MultiLevelRayTracing\RTWorld\Release;&quot;$(QTDIR)\lib&quot;;.\QtGlRenderer\Release" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1706 r1707  
    503503                                tstack.push(*it); 
    504504                        } 
    505                          
    506505                } 
    507506        } 
     
    930929                const int upper = mViewCellsManager->GetMaxPvsSize(); 
    931930 
    932                 const float penalty = EvalPvsPenalty((*vit)->GetPvs().CountObjectsInPvs(), lower, upper); 
     931                const float penalty = EvalPvsPenalty((*vit)->GetPvs().EvalPvsCost(), lower, upper); 
    933932                 
    934933                mDeviation += fabs(mAvgRenderCost - penalty); 
     
    10231022        vc->Mail(); 
    10241023 
    1025         const int pvs1 = left->GetPvs().CountObjectsInPvs(); 
    1026         const int pvs2 = right->GetPvs().CountObjectsInPvs(); 
     1024        const float pvs1 = left->GetPvs().EvalPvsCost(); 
     1025        const float pvs2 = right->GetPvs().EvalPvsCost(); 
    10271026 
    10281027 
     
    10301029        mMergedViewCells.push_back(vc); 
    10311030 
    1032         pvsDiff = vc->GetPvs().CountObjectsInPvs() - pvs1 - pvs2; 
     1031        pvsDiff = vc->GetPvs().EvalPvsCost() - pvs1 - pvs2; 
    10331032 
    10341033 
     
    10381037                // set scalars 
    10391038                mViewCellsManager->UpdateScalarPvsSize(left,  
    1040                                 left->GetPvs().CountObjectsInPvs(),  
     1039                                left->GetPvs().EvalPvsCost(),  
    10411040                                left->GetPvs().GetSize()); 
    10421041                         
     
    10491048                // set scalars 
    10501049                mViewCellsManager->UpdateScalarPvsSize(right,  
    1051                         right->GetPvs().CountObjectsInPvs(),  
     1050                        right->GetPvs().EvalPvsCost(),  
    10521051                        right->GetPvs().GetSize()); 
    10531052 
     
    13361335        if (1) 
    13371336        { 
    1338                 const float penalty = EvalPvsPenalty(vc->GetPvs().CountObjectsInPvs(), lower, upper); 
     1337                const float penalty = EvalPvsPenalty(vc->GetPvs().EvalPvsCost(), lower, upper); 
    13391338                return fabs(mAvgRenderCost - penalty) / (float)mNumActiveViewCells; 
    13401339        } 
     
    13491348        if (mUseAreaForPvs) 
    13501349        { 
    1351                 return vc->GetPvs().CountObjectsInPvs() * vc->GetArea(); 
    1352         } 
    1353  
    1354         return vc->GetPvs().CountObjectsInPvs() * vc->GetVolume(); 
     1350                return vc->GetPvs().EvalPvsCost() * vc->GetArea(); 
     1351        } 
     1352 
     1353        return vc->GetPvs().EvalPvsCost() * vc->GetVolume(); 
    13551354} 
    13561355 
     
    17951794        if (vc->IsLeaf()) 
    17961795        { 
    1797                 return vc->GetPvs().CountObjectsInPvs(); 
    1798         } 
    1799          
    1800         // interior nodes: pvs is either stored as a scalar or 
    1801         // has to be reconstructed from the leaves 
     1796                return vc->GetPvs().EvalPvsCost(); 
     1797        } 
     1798         
     1799        // interior nodes: pvs is either stored as a  
     1800        // scalar or has to be reconstructed from the leaves 
    18021801        // the stored pvs size is the valid pvs size => just return scalar 
    18031802        if (vc->mPvsSizeValid) 
     
    18331832        } 
    18341833 
    1835         return newPvs.CountObjectsInPvs(); 
     1834        return newPvs.EvalPvsCost(); 
    18361835} 
    18371836 
     
    20022001        switch (mViewCellsStorage) 
    20032002        { 
    2004         case PVS_IN_LEAVES: //-- store pvs only in leaves 
     2003        case PVS_IN_LEAVES:  
     2004                // pvs is stored only in leaves 
    20052005                pvsSize = GetPvsSizeForLeafStorage(vc);                  
    20062006                break; 
     
    20122012                // pvs is stored consistently in the tree up to the root 
    20132013                // just return pvs size  
    2014                 pvsSize = vc->GetPvs().CountObjectsInPvs();      
     2014                pvsSize = vc->GetPvs().EvalPvsCost();    
    20152015                break; 
    20162016        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r1679 r1707  
    183183                return a->mPvsSize < b->mPvsSize; 
    184184#else 
    185                 return a->GetPvs().CountObjectsInPvs() < b->GetPvs().CountObjectsInPvs(); 
     185                return a->GetPvs().EvalPvsCost() < b->GetPvs().EvalPvsCost(); 
    186186#endif 
    187187        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r1686 r1707  
    20252025                  << "#polygons: " << (int)data.mPolygons->size() << " (max: " << mTermMinPolys << "), " 
    20262026                  << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), "  
    2027                   << "#pvs: " << leaf->GetViewCell()->GetPvs().CountObjectsInPvs() << "=, " 
     2027                  << "#pvs: " << leaf->GetViewCell()->GetPvs().EvalPvsCost() << "=, " 
    20282028                  << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 
    20292029#endif 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1705 r1707  
    10771077 
    10781078/// Returns index of the best view cells of the neighborhood 
    1079 int GetBestViewCellIdx(ViewCell *root, const ViewCellContainer &neighborhood) 
     1079static int GetBestViewCellIdx(ViewCell *root, const ViewCellContainer &neighborhood) 
    10801080{ 
    10811081        int bestViewCellIdx = 0; 
     
    12371237{ 
    12381238 
    1239         if ((vc->GetPvs().CountObjectsInPvs() > maxPvsSize) || 
    1240                 (vc->GetPvs().CountObjectsInPvs() < minPvsSize)) 
     1239        if ((vc->GetPvs().EvalPvsCost() > maxPvsSize) || 
     1240                (vc->GetPvs().EvalPvsCost() < minPvsSize)) 
    12411241        { 
    12421242                return false; 
     
    15101510        { 
    15111511                ViewCell *vc = *it; 
    1512                 totalRenderCost += vc->GetPvs().CountObjectsInPvs() * vc->GetVolume(); 
    1513                 totalPvs += (int)vc->GetPvs().CountObjectsInPvs(); 
     1512                totalRenderCost += vc->GetPvs().EvalPvsCost() * vc->GetVolume(); 
     1513                totalPvs += (int)vc->GetPvs().EvalPvsCost(); 
    15141514        } 
    15151515 
     
    15301530                ViewCell *vc = *it; 
    15311531 
    1532                 float renderCost = vc->GetPvs().CountObjectsInPvs() * vc->GetVolume(); 
     1532                float renderCost = vc->GetPvs().EvalPvsCost() * vc->GetVolume(); 
    15331533                float dev; 
    15341534 
    15351535                if (1) 
    1536                         dev = fabs(avgRenderCost - (float)vc->GetPvs().CountObjectsInPvs()); 
     1536                        dev = fabs(avgRenderCost - (float)vc->GetPvs().EvalPvsCost()); 
    15371537                else 
    15381538                        dev = fabs(expectedRenderCost - renderCost); 
     
    16431643 
    16441644        // update pvs size 
    1645         UpdateScalarPvsSize(vc, vc->GetPvs().CountObjectsInPvs(), vc->GetPvs().GetSize()); 
     1645        UpdateScalarPvsSize(vc, vc->GetPvs().EvalPvsCost(), vc->GetPvs().GetSize()); 
    16461646 
    16471647        return vc; 
     
    21552155 
    21562156 
     2157void ViewCellsManager::SetViewCellActive(ViewCell *vc) const 
     2158{ 
     2159        ViewCellContainer leaves; 
     2160        // sets the pointers to the currently active view cells 
     2161        mViewCellsTree->CollectLeaves(vc, leaves); 
     2162 
     2163        ViewCellContainer::const_iterator lit, lit_end = leaves.end(); 
     2164        for (lit = leaves.begin(); lit != lit_end; ++ lit) 
     2165        { 
     2166                dynamic_cast<ViewCellLeaf *>(*lit)->SetActiveViewCell(vc); 
     2167        } 
     2168} 
     2169 
     2170 
    21572171void ViewCellsManager::SetViewCellsActive() 
    21582172{ 
    2159         // collect leaf view cells and set the pointers to the currently 
    2160         // active view cells 
     2173        // collect leaf view cells and set the pointers to  
     2174        // the currently active view cells 
    21612175        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
    21622176 
    21632177        for (it = mViewCells.begin(); it != it_end; ++ it) 
    21642178        { 
    2165                 ViewCellContainer leaves; 
    2166                 mViewCellsTree->CollectLeaves(*it, leaves); 
    2167  
    2168                 ViewCellContainer::const_iterator lit, lit_end = leaves.end(); 
    2169                 for (lit = mViewCells.begin(); lit != lit_end; ++ lit) 
    2170                 { 
    2171                         dynamic_cast<ViewCellLeaf *>(*lit)->SetActiveViewCell(*it); 
    2172                 } 
     2179                SetViewCellActive(*it); 
    21732180        } 
    21742181} 
     
    25702577                // we assume that pvs is explicitly stored in leaves 
    25712578                pvs = root->GetPvs(); 
    2572                 UpdateScalarPvsSize(root, pvs.CountObjectsInPvs(), pvs.GetSize()); 
     2579                UpdateScalarPvsSize(root, pvs.EvalPvsCost(), pvs.GetSize()); 
    25732580                 
    25742581                return; 
     
    26372644         
    26382645        // set new pvs size 
    2639         UpdateScalarPvsSize(interior, pvs.CountObjectsInPvs(), pvs.GetSize()); 
     2646        UpdateScalarPvsSize(interior, pvs.EvalPvsCost(), pvs.GetSize()); 
    26402647         
    26412648#else  
     
    57205727        { 
    57215728                ViewCell *vc = *vit; 
    5722                 int pvs = vc->GetPvs().CountObjectsInPvs(); 
     5729                int pvs = vc->GetPvs().EvalPvsCost(); 
    57235730                float vol = vc->GetVolume(); 
    57245731                rc += pvs * vol; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1703 r1707  
    573573        void ResetViewCells(); 
    574574         
     575        /** Sets this view cell to active. 
     576        */ 
     577        void SetViewCellActive(ViewCell *vc) const; 
     578 
    575579        /** Collects the view cells in the view cell container. 
    576580        */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp

    r1571 r1707  
    222222 
    223223                                mForcedMaterial.mDiffuseColor.b = 1.0f; 
    224                                 const float importance = (float)leaf->GetViewCell()->GetPvs().CountObjectsInPvs() / (float)maxPvs; 
     224                                const float importance = (float)leaf->GetViewCell()->GetPvs().EvalPvsCost() / (float)maxPvs; 
    225225 
    226226                                mForcedMaterial.mDiffuseColor.r = importance; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1632 r1707  
    829829                // update scalar pvs size lookup 
    830830                ObjectPvs &pvs = viewCell->GetPvs(); 
    831                 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 
     831                mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.EvalPvsCost(), pvs.GetSize()); 
    832832         
    833833 
     
    974974                ObjectPvs &pvs = viewCell->GetPvs(); 
    975975                mViewCellsManager->UpdateScalarPvsSize(viewCell,  
    976                                                                                            pvs.CountObjectsInPvs(),  
     976                                                                                           pvs.EvalPvsCost(),  
    977977                                                                                           pvs.GetSize()); 
    978978 
     
    23912391                        if (leaf->TreeValid() &&  
    23922392                                (!onlyUnmailed || !leaf->Mailed()) && 
    2393                                 ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().CountObjectsInPvs() <= maxPvsSize))) 
     2393                                ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().EvalPvsCost() <= maxPvsSize))) 
    23942394                        { 
    23952395                                leaves.push_back(leaf); 
     
    24682468                  << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 
    24692469                  << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 
    2470                   << "#pvs: " << leaf->GetViewCell()->GetPvs().CountObjectsInPvs() << "), " 
     2470                  << "#pvs: " << leaf->GetViewCell()->GetPvs().EvalPvsCost() << "), " 
    24712471                  << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 
    24722472#endif 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1698 r1707  
    654654                // update scalar pvs size value 
    655655                ObjectPvs &pvs = viewCell->GetPvs(); 
    656                 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 
     656                mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.EvalPvsCost(), pvs.GetSize()); 
    657657 
    658658                mVspStats.contributingSamples += conSamp; 
     
    768768                // update scalar pvs size value 
    769769                ObjectPvs &pvs = viewCell->GetPvs(); 
    770                 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 
     770                mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.EvalPvsCost(), pvs.GetSize()); 
    771771 
    772772                mVspStats.contributingSamples += conSamp; 
     
    18031803                        if (leaf->TreeValid() &&  
    18041804                                (!onlyUnmailed || !leaf->Mailed()) && 
    1805                                 ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().CountObjectsInPvs() <= maxPvsSize))) 
     1805                                ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().EvalPvsCost() <= maxPvsSize))) 
    18061806                        { 
    18071807                                leaves.push_back(leaf); 
     
    18801880                  << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 
    18811881                  << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 
    1882                   << "#pvs: " << leaf->GetViewCell()->GetPvs().CountObjectsInPvs() << "), " 
     1882                  << "#pvs: " << leaf->GetViewCell()->GetPvs().EvalPvsCost() << "), " 
    18831883                  << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 
    18841884#endif 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp

    r1545 r1707  
    247247                                mForcedMaterial.mDiffuseColor.b = 1.0f; 
    248248                                const float importance =  
    249                                         (float)leaf->GetViewCell()->GetPvs().CountObjectsInPvs() / (float)maxPvs; 
     249                                        (float)leaf->GetViewCell()->GetPvs().EvalPvsCost() / (float)maxPvs; 
    250250 
    251251                                mForcedMaterial.mDiffuseColor.r = importance; 
Note: See TracChangeset for help on using the changeset viewer.