Ignore:
Timestamp:
11/13/06 21:25:40 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
8 edited

Legend:

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

    r1737 r1744  
    294294        //mMemoryConst = (float)(sizeof(VspLeaf) + sizeof(VspViewCell)); 
    295295        //mMemoryConst = (float)sizeof(BvhLeaf); 
    296 mMemoryConst = (float)sizeof(ObjectContainer); 
    297         cout << "bvh memcost: " << mMemoryConst << endl; 
     296        mMemoryConst = (float)sizeof(ObjectContainer); 
     297 
     298        /*cout << "bvh memcost: " << mMemoryConst << endl; 
    298299        cout << "triangle: " << sizeof(TriangleIntersectable) << endl; 
    299300        cout << "triangle: " << sizeof(Intersectable) << endl; 
     
    301302        cout << "triangle: " << sizeof(float) << endl; 
    302303        cout << "triangle: " << sizeof(int) << endl; 
    303  
     304*/ 
    304305    mUseBboxAreaForSah = true; 
    305306 
     
    327328        Debug << "minimal rays for visibility: " << mMinRaysForVisibility << endl; 
    328329        Debug << "bvh mem const: " << mMemoryConst << endl; 
    329  
     330cout << "here10 " << mRenderCostDecreaseWeight << endl; 
    330331        Debug << endl; 
    331332} 
     
    509510                EvaluateLeafStats(tData); 
    510511         
    511                 const bool mStoreRays = true; 
    512                 if (mStoreRays) 
    513                 { 
    514                         BvhLeaf *leaf = dynamic_cast<BvhLeaf *>(currentNode); 
    515                 //      CollectRays(leaf->mObjects, leaf->mVssRays); 
    516                 } 
    517                  
    518                 ////////////////////////////////////// 
    519                  
    520512                // this leaf is no candidate for splitting anymore 
    521513                // => detach subdivision candidate 
     
    598590                { 
    599591                        priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
    600                         if (mHierarchyManager->mConsiderMemory2) 
     592                        if (mHierarchyManager->mConsiderMemory) 
    601593                        { 
    602594                                priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mMemoryConst); 
     
    605597                else 
    606598                { 
    607                         if (!mHierarchyManager->mConsiderMemory2) 
     599                        if (!mHierarchyManager->mConsiderMemory) 
    608600                        { 
    609601                                priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
     
    619611        } 
    620612 
     613        //splitCandidate.SetOldCost(oldRenderCost); 
    621614        // compute global decrease in render cost 
    622615        splitCandidate.SetPriority(priority); 
     
    13561349         
    13571350        VssRayContainer rays; 
    1358         rays.reserve(tData.mNumRays); 
     1351        // maximal 2 objects share the same ray 
     1352        rays.reserve(tData.mNumRays * 2); 
    13591353        CollectRays(tData.mNode->mObjects, rays); 
    13601354 
    1361         const float prop = (float)mMaxTests / (float)tData.mNumRays; 
     1355        const float prop = (float)mMaxTests / ((float)tData.mNumRays + Limits::Small); 
    13621356 
    13631357        VssRay::NewMail(); 
    13641358 
     1359        //cout << "here7 " << tData.mNumRays << " " << rays.size() << endl; 
     1360        //cout << "here5 prop: " << prop << " " << mMaxTests << " " << tData.mNumRays << endl; 
    13651361        // only use a subset of the rays 
    13661362        VssRayContainer::const_iterator rit, rit_end = rays.end(); 
    13671363 
     1364        int nRays = 0; 
     1365 
    13681366        for (rit = rays.begin(); rit != rit_end; ++ rit) 
    13691367        { 
    1370                 if ((mMaxTests >= tData.mNumRays) || (Random(1.0f) < prop)) 
     1368                if ((mMaxTests >= (int)rays.size()) || (Random(1.0f) < prop)) 
    13711369                { 
    13721370                        (*rit)->Mail(); 
    1373                 } 
    1374         } 
    1375          
     1371                        ++ nRays; 
     1372                } 
     1373        } 
     1374         
     1375        //cout << "here99 " << nRays << " obj " << tData.mNode->mObjects.size() << endl; 
    13761376        // collect and mark the view cells as belonging to front pvs 
    13771377        ViewCellContainer viewCells; 
    13781378        CollectViewCells(tData.mNode->mObjects, viewCells, true, true); 
    1379                          
     1379         
    13801380        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    13811381        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
     
    14881488                                if (useVisibilityBasedHeuristics) 
    14891489                                { 
    1490                                         //cout << "v rays: " << tData.mNumRays << " " << endl; 
    14911490                                        /////////// 
    14921491                                        //-- heuristics using objects weighted by view cells volume 
     
    14981497                                } 
    14991498                                else 
    1500                                 {       //cout << "e rays: " << tData.mNumRays << " "; 
     1499                                {        
    15011500                                        ////////////////// 
    15021501                                        //-- view cells not constructed yet     => use surface area heuristic                    
     
    17101709 
    17111710 
    1712 void BvHierarchy::CollectViewCells(const ObjectContainer &objects,  
    1713                                                                    ViewCellContainer &viewCells, 
    1714                                                                    const bool setCounter, 
    1715                                                                    const bool onlyMailedRays) const 
     1711int BvHierarchy::CollectViewCells(const ObjectContainer &objects,  
     1712                                                                  ViewCellContainer &viewCells, 
     1713                                                                  const bool setCounter, 
     1714                                                                  const bool onlyMailedRays) const 
    17161715{ 
    17171716        ViewCell::NewMail(); 
    17181717        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
    17191718 
     1719        int numRays = 0; 
    17201720        // loop through all object and collect view cell pvs of this node 
    17211721        for (oit = objects.begin(); oit != oit_end; ++ oit) 
    17221722        { 
    17231723                // always use only mailed objects 
    1724                 CollectViewCells(*oit, viewCells, true, setCounter, onlyMailedRays); 
    1725         } 
    1726 } 
    1727  
    1728  
    1729 void BvHierarchy::CollectViewCells(Intersectable *obj,  
    1730                                                                    ViewCellContainer &viewCells, 
    1731                                                                    const bool useMailBoxing, 
    1732                                                                    const bool setCounter, 
    1733                                                                    const bool onlyMailedRays) const 
     1724                numRays += CollectViewCells(*oit, viewCells, true, setCounter, onlyMailedRays); 
     1725        } 
     1726        //cout << "here4 " << numRays << " boj: " << objects.size() << " " << onlyMailedRays << endl; 
     1727 
     1728        return numRays; 
     1729} 
     1730 
     1731 
     1732int BvHierarchy::CollectViewCells(Intersectable *obj,  
     1733                                                                  ViewCellContainer &viewCells, 
     1734                                                                  const bool useMailBoxing, 
     1735                                                                  const bool setCounter, 
     1736                                                                  const bool onlyMailedRays) const 
    17341737{ 
    17351738        VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 
     1739 
     1740        int numRays = 0; 
    17361741 
    17371742        for (rit = obj->GetOrCreateRays()->begin(); rit < rit_end; ++ rit) 
     
    17421747                        continue; 
    17431748 
    1744                 ray->Mail(); 
     1749                //ray->Mail(); 
     1750                ++ numRays; 
    17451751 
    17461752                ViewCellContainer tmpViewCells; 
     
    17741780                } 
    17751781        } 
     1782 
     1783        return numRays; 
    17761784} 
    17771785 
     
    18331841        ViewCellContainer viewCells; 
    18341842        ViewCell::NewMail(); 
    1835         CollectViewCells(node->mObjects, viewCells, true, false); 
    1836  
     1843        int numRays = CollectViewCells(node->mObjects, viewCells, true, false); 
     1844 
     1845        //cout << "here6 " << numRays << endl; 
    18371846        if (0) cout << "collected " << (int)viewCells.size() << " dirty candidates" << endl; 
    18381847         
     
    20152024 
    20162025        ViewCellContainer viewCells; 
    2017         // here we have to account for all view cells that can  
     2026         
     2027        // we have to account for all view cells that can  
    20182028        // be seen from the objects 
    2019         CollectViewCells(objects, viewCells, false, false); 
     2029        int numRays = CollectViewCells(objects, viewCells, false, false); 
    20202030 
    20212031        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1732 r1744  
    781781        /** Collect view cells which see this bvh leaf. 
    782782        */ 
    783         void CollectViewCells(const ObjectContainer &objects,  
    784                                                   ViewCellContainer &viewCells, 
    785                                                   const bool setCounter, 
    786                                                   const bool onlyMailedRays) const; 
     783        int CollectViewCells(const ObjectContainer &objects,  
     784                                                 ViewCellContainer &viewCells, 
     785                                                 const bool setCounter, 
     786                                                 const bool onlyUnmailedRays) const; 
    787787 
    788788        /** Counts the view cells of this object. note: only 
     
    797797        /** Collects view cells which see an object. 
    798798        */ 
    799         void CollectViewCells(Intersectable *object,  
    800                                                   ViewCellContainer &viewCells,  
    801                                                   const bool useMailBoxing, 
    802                                                   const bool setCounter, 
    803                                                   const bool onlyMailedRays) const; 
     799        int CollectViewCells(Intersectable *object,  
     800                                                 ViewCellContainer &viewCells,  
     801                                                 const bool useMailBoxing, 
     802                                                 const bool setCounter, 
     803                                                 const bool onlyUnmailedRays) const; 
    804804 
    805805        /** Evaluates increase in pvs size. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1727 r1744  
    25422542                                        optBool, 
    25432543                                        "hierarchy_construction_consider_memory=", 
    2544                                         "false"); 
    2545  
    2546         RegisterOption("Hierarchy.Construction.considerMemory2", 
    2547                                         optBool, 
    2548                                         "hierarchy_construction_consider_memory2=", 
    2549                                         "false"); 
     2544                                        "true"); 
    25502545 
    25512546        RegisterOption("Hierarchy.Construction.repairQueue", 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1743 r1744  
    9191                << "#FullMem\n" << mFullMemory << endl 
    9292                << "#RenderCostDecrease\n" << mRenderCostDecrease << endl 
     93                << "#Priority\n" << mPriority << endl 
    9394                << "#FpsPerMb\n" << FpsPerMb() << endl 
    9495                << endl; 
     
    142143        Environment::GetSingleton()->GetBoolValue( 
    143144                "Hierarchy.Construction.considerMemory", mConsiderMemory); 
    144  
    145         Environment::GetSingleton()->GetBoolValue( 
    146                 "Hierarchy.Construction.considerMemory2", mConsiderMemory2); 
    147145 
    148146        Environment::GetSingleton()->GetFloatValue( 
     
    166164        Debug << "maximal allowed memory: " << mTermMaxMemory << endl; 
    167165        Debug << "consider memory: " << mConsiderMemory << endl; 
    168         Debug << "consider memory2: " << mConsiderMemory << endl; 
    169166        Debug << "min steps of same kind: " << mMinStepsOfSameType << endl; 
    170167        Debug << "max steps of same kind: " << mMaxStepsOfSameType << endl; 
     
    266263{ 
    267264        SubdivisionCandidate *splitCandidate = splitQueue.Top(); 
    268  
    269         if (splitCandidate->IsDirty()) 
    270                 splitCandidate->EvalCandidate(); 
    271  
    272265        splitQueue.Pop(); 
    273266 
     
    287280                 
    288281        HierarchySubdivisionStats stats; 
     282 
    289283        stats.mNumSplits = mHierarchyStats.Leaves(); 
    290284        stats.mTotalRenderCost = mHierarchyStats.mTotalCost; 
     
    295289        stats.mViewSpaceSplits = mVspTree->mVspStats.Leaves(); 
    296290        stats.mObjectSpaceSplits = GetObjectSpaceSubdivisionLeaves(); 
    297          
     291        stats.mRenderCostDecrease = mHierarchyStats.mRenderCostDecrease; 
     292        stats.mPriority = mPriority; 
     293 
    298294        stats.Print(mSubdivisionStats); 
    299295} 
     
    740736        const bool success = sc->Apply(splitQueue, terminationCriteriaMet); 
    741737 
     738        if (sc->IsDirty()) 
     739                cout << "*******************************error!" << endl; 
     740 
    742741        if (!success) // split was not taken 
    743742        { 
     743                cout << "x"; 
    744744                return false; 
    745745        } 
    746746 
     747        //cout << "priority: " << sc->GetPriority() << " rc decr: " << sc->GetRenderCostDecrease() << " | "; 
    747748        /////////////// 
    748749        //-- split was successful => update stats and queue 
     
    750751    // cost ratio of cost decrease / totalCost 
    751752        const float costRatio = sc->GetRenderCostDecrease() / mHierarchyStats.mTotalCost; 
    752         //Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 
     753        //cout << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 
    753754         
    754755        if (costRatio < mTermMinGlobalCostRatio) 
     
    772773        mHierarchyStats.mMemory += (float)ObjectPvs::GetEntrySizeByte() * pvsEntriesIncr; 
    773774        mHierarchyStats.mRenderCostDecrease = sc->GetRenderCostDecrease(); 
     775         
     776        mPriority = sc->GetPriority(); 
    774777 
    775778        static float memoryCount = 0; 
     
    13911394        { 
    13921395                SubdivisionCandidate *candidate = NextSubdivisionCandidate(splitQueue); 
    1393                  // reevaluate local split plane and priority 
     1396                 
     1397                // reevaluate local split plane and priority 
    13941398                candidate->EvalCandidate(recomputeSplitPlane); 
    13951399                cout << "."; 
     
    19241928        subStats.mViewSpaceSplits = 0; 
    19251929        subStats.mObjectSpaceSplits = 0; 
    1926          
     1930        subStats.mRenderCostDecrease = 0; 
    19271931        subStats.Print(stats); 
    19281932 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1743 r1744  
    128128        int mObjectSpaceSplits; 
    129129 
     130        float mPriority; 
    130131 
    131132        float VspOspRatio() const { return (float)mViewSpaceSplits / (float)mObjectSpaceSplits; } 
     
    145146                mViewSpaceSplits = 0; 
    146147                mObjectSpaceSplits = 0; 
     148                mPriority = 0; 
    147149        } 
    148150 
     
    287289        inline bool ConsiderMemory() const { return mConsiderMemory; } 
    288290        //inline float GetMemoryConst() const { return mMemoryConst; } 
    289  
    290291         
    291292        void EvaluateSubdivision(const VssRayContainer &sampleRays,                                                                                       
     
    625626        bool mConsiderMemory; 
    626627 
    627         bool mConsiderMemory2; 
    628  
    629628        int mMaxRepairs; 
    630629 
     
    633632        friend OspTree; 
    634633        friend BvHierarchy; 
     634 
     635        float mPriority; 
     636 
    635637        friend ViewCellsParseHandlers; 
    636638 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r1742 r1744  
    121121 
    122122 
    123 /*template<typename T, typename S> 
    124 class PvsIterator 
    125 { 
    126         Next(PvsEntry<T, S>) 
    127 private: 
    128         typename vector<PvsEntry<T, S> >::iterator mItCurrent; 
    129         typename vector<PvsEntry<T, S> >::iterator mItEnd; 
    130 };*/ 
    131  
    132  
    133123template<typename T, typename S> 
    134124class PvsIterator 
     
    147137        } 
    148138 
    149         PvsEntry<T, S> Next() 
     139        const PvsEntry<T, S> &Next() 
    150140        { 
    151141                return *(mItCurrent ++); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1743 r1744  
    4242// HACK 
    4343const static bool SAMPLE_AFTER_SUBDIVISION = true; 
    44 const static bool CLAMP_TO_BOX = false; 
    45 //const static bool CLAMP_TO_BOX = true; 
     44//const static bool CLAMP_TO_BOX = false; 
     45const static bool CLAMP_TO_BOX = true; 
    4646 
    4747 
     
    119119 
    120120         
    121         ObjectPvs pvs1, pvs2, mergedPvs; 
     121        /*ObjectPvs pvs1, pvs2, mergedPvs; 
    122122 
    123123        pvs1.AddSample((Intersectable *)1, 1); 
     
    172172                cout << (int)entry.mObject << " " << entry.mData.mSumPdf << " x "; 
    173173        } 
    174  
     174*/ 
    175175        // sampling type for view cells construction samples 
    176176        if (strcmp(buf, "object") == 0) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1738 r1744  
    462462        Environment::GetSingleton()->GetIntValue("VspTree.maxTests", mMaxTests); 
    463463 
    464         Environment::GetSingleton()-> 
    465                 GetFloatValue("VspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
     464        Environment::GetSingleton()->GetFloatValue("VspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
    466465         
    467466        // if only the driving axis is used for axis aligned split 
     
    505504 
    506505        Debug << "vsp mem const: " << mMemoryConst << endl; 
    507  
     506cout << "here11 " << mRenderCostDecreaseWeight << endl; 
    508507        Debug << endl; 
    509508} 
     
    852851        { 
    853852                priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
    854                 if (mHierarchyManager->mConsiderMemory2) 
     853                if (mHierarchyManager->mConsiderMemory) 
    855854                { 
    856855                        priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mMemoryConst); 
     
    859858        else 
    860859        { 
    861                 if (!mHierarchyManager->mConsiderMemory2) 
     860                if (!mHierarchyManager->mConsiderMemory) 
    862861                { 
    863862                        priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
Note: See TracChangeset for help on using the changeset viewer.