Changeset 1449 for GTP


Ignore:
Timestamp:
09/21/06 19:14:24 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
14 edited

Legend:

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

    r1444 r1449  
    525525                (0 
    526526                || (mBvhStats.Leaves() >= mTermMaxLeaves) 
    527                 || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
     527                || (mBvhStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
    528528                //|| mOutOfMemory  
    529529                ); 
     
    532532        { 
    533533                Debug << "bvh global termination criteria met:" << endl; 
    534                 Debug << "cost misses: " << mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 
     534                Debug << "cost misses: " << mBvhStats.mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 
    535535                Debug << "leaves: " << mBvhStats.Leaves() << " " << mTermMaxLeaves << endl; 
    536536        } 
     
    16231623void BvHierarchy::CreateRoot(const ObjectContainer &objects) 
    16241624{ 
     1625        /////// 
    16251626        //-- create new root 
     1627 
    16261628        AxisAlignedBox3 box = EvalBoundingBox(objects); 
    16271629        BvhLeaf *bvhleaf = new BvhLeaf(box, NULL, (int)objects.size()); 
     
    16611663 
    16621664        mBvhStats.nodes = 1; 
    1663         mGlobalCostMisses = 0; 
     1665         
    16641666         
    16651667        // store pointer to this tree 
     
    16991701         
    17001702 
    1701         //////////////////////////////////////////////////// 
     1703        /////////////////// 
    17021704        //-- add first candidate for object space partition      
    17031705 
     
    18471849                maxRayContriNodes * 100 / (double)Leaves() << endl; 
    18481850 
     1851        app << "#N_PGLOBALCOSTMISSES ( Global cost misses )\n" << mGlobalCostMisses << endl; 
     1852 
    18491853        app << "========== END OF BvHierarchy statistics ==========\n"; 
    18501854} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1408 r1449  
    8888                rayRefs = 0; 
    8989                maxRayContriNodes = 0; 
     90                mGlobalCostMisses = 0; 
    9091        } 
    9192 
     
    109110        /// nodes termination because of max cost ratio; 
    110111        int maxCostNodes; 
    111  
    112         /////////////////////////// 
     112        // global cost ratio violations 
     113        int mGlobalCostMisses; 
     114 
     115        ////////////////// 
    113116        // nodes with minimum objects 
    114117        int minObjectsNodes; 
     
    799802 
    800803 
    801         //////////////////////////////// 
     804        //////////////////// 
    802805        //-- local termination criteria 
    803806 
     
    816819 
    817820 
    818         //////////////////////////////////// 
     821        //////////////////// 
    819822        //-- global termination criteria 
    820823 
    821824        float mTermMinGlobalCostRatio; 
    822825        int mTermGlobalCostMissTolerance; 
    823         int mGlobalCostMisses; 
     826         
    824827 
    825828        /// maximal number of view cells 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1444 r1449  
    24642464                                        "-1"); 
    24652465 
     2466        RegisterOption("Hierarchy.Construction.useMultiLevelConstruction", 
     2467                                        optBool, 
     2468                                        "hierarchy_construction_use_multilevel_construction=", 
     2469                                        "false"); 
     2470 
    24662471        ////////////////////////////////////////////////////////////////////////////////// 
    24672472} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1444 r1449  
    106106                "Hierarchy.Construction.repairQueue", mRepairQueue); 
    107107 
     108        Environment::GetSingleton()->GetBoolValue( 
     109                "Hierarchy.Construction.useMultiLevelConstruction", mUseMultiLevelConstruction); 
     110 
     111         mUseMultiLevelConstruction; 
    108112        Debug << "******** Hierachy Manager Parameters ***********" << endl; 
    109113        Debug << "max leaves: " << mTermMaxLeaves << endl; 
     
    113117        Debug << "min depth for object space subdivision: " << mMinDepthForObjectSpaceSubdivion << endl; 
    114118        Debug << "repair queue: " << mRepairQueue << endl; 
     119        Debug << endl; 
    115120} 
    116121 
     
    234239                (0 
    235240                || (mHierarchyStats.Leaves() >= mTermMaxLeaves)  
    236                 || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
    237                 ||(candidate->GlobalTerminationCriteriaMet()) 
     241                || (mHierarchyStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
     242                || (candidate->GlobalTerminationCriteriaMet()) 
    238243                ); 
    239244 
     
    242247                Debug << "hierarchy global termination criteria met:" << endl; 
    243248                Debug << "leaves: " << mHierarchyStats.Leaves() << " " << mTermMaxLeaves << endl; 
    244                 Debug << "cost misses: " << mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 
     249                Debug << "cost misses: " << mHierarchyStats.mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 
    245250        } 
    246251        return terminationCriteriaMet; 
     
    252257                                                                 AxisAlignedBox3 *forcedViewSpace) 
    253258{ 
     259        if (mUseMultiLevelConstruction) 
     260        { 
     261                ConstructMultiLevel(sampleRays, objects, forcedViewSpace); 
     262        } 
     263        else 
     264        { 
     265                ConstructInterleaved(sampleRays, objects, forcedViewSpace); 
     266        } 
     267} 
     268 
     269 
     270void HierarchyManager::ConstructInterleaved(const VssRayContainer &sampleRays, 
     271                                                                                        const ObjectContainer &objects, 
     272                                                                                        AxisAlignedBox3 *forcedViewSpace) 
     273{ 
    254274        mHierarchyStats.Reset(); 
    255275        mHierarchyStats.Start(); 
    256          
     276        mHierarchyStats.nodes = 2; // two nodes for view space and object space 
     277 
    257278        mTotalCost = (float)objects.size(); 
    258279        Debug << "setting total cost to " << mTotalCost << endl; 
     
    287308 
    288309        // process object space candidates 
    289         RunConstruction(sampleRays, objects, forcedViewSpace); 
     310        RunConstruction(mRepairQueue, sampleRays, objects, forcedViewSpace); 
    290311         
    291312        cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     
    342363 
    343364        cout << "preparing bv hierarchy construction ... " << endl; 
    344         mBvHierarchy->CreateRoot(objects); 
     365                mBvHierarchy->CreateRoot(objects); 
    345366 
    346367        // compute first candidate 
     
    390411                if (costRatio < mTermMinGlobalCostRatio) 
    391412                { 
    392                         ++ mGlobalCostMisses; 
     413                        ++ mHierarchyStats.mGlobalCostMisses; 
    393414                } 
    394415 
     
    484505 
    485506 
    486 void HierarchyManager::RunConstruction(const VssRayContainer &sampleRays, 
     507void HierarchyManager::RunConstruction(const bool repairQueue, 
     508                                                                           const VssRayContainer &sampleRays, 
    487509                                                                           const ObjectContainer &objects, 
    488510                                                                           AxisAlignedBox3 *forcedViewSpace) 
    489511{ 
    490         mHierarchyStats.nodes = 0; 
    491         mGlobalCostMisses = 0; 
    492  
    493512        int i = 0; 
    494513        while (!FinishedConstruction()) 
     
    511530                        // reevaluate candidates affected by the split for view space splits,  
    512531                        // this would be object space splits and other way round 
    513                         if (mRepairQueue) RepairQueue(); 
     532                        if (repairQueue) RepairQueue(); 
    514533                } 
    515534 
     
    548567                DEL_PTR(mCurrentCandidate); 
    549568        } 
     569} 
     570 
     571 
     572 
     573void HierarchyManager::RunConstruction(const bool repairQueue) 
     574{ 
     575        int i = 0; 
     576        while (!FinishedConstruction()) 
     577        { 
     578                mCurrentCandidate = NextSubdivisionCandidate();     
     579                         
     580                /////////////////// 
     581                //-- subdivide leaf node 
     582 
     583                if (ApplySubdivisionCandidate(mCurrentCandidate)) 
     584                { 
     585                        cout << mCurrentCandidate->Type() << " "; 
     586                        if (0) cout << "subdividing candidate " << ++ i << " of type "  
     587                                                << mCurrentCandidate->Type() << endl; 
     588                        mHierarchyStats.nodes += 2; 
     589 
     590                        // subdivision successful 
     591                        EvalSubdivisionStats(*mCurrentCandidate); 
     592                 
     593                        // reevaluate candidates affected by the split for view space splits,  
     594                        // this would be object space splits and other way round 
     595                        if (repairQueue) RepairQueue(); 
     596                } 
     597 
     598                DEL_PTR(mCurrentCandidate); 
     599        } 
     600} 
     601 
     602 
     603void HierarchyManager::ResetObjectSpaceSubdivision(const ObjectContainer &objects) 
     604{ 
     605        Debug << "old bv hierarchy: " << mBvHierarchy->mBvhStats << endl; 
     606        mHierarchyStats.nodes -= mBvHierarchy->mBvhStats.nodes; 
     607        mHierarchyStats.mGlobalCostMisses = 0; // hack: reset global cost misses 
     608        DEL_PTR(mBvHierarchy); 
     609        mBvHierarchy = new BvHierarchy(); 
     610        mBvHierarchy->mHierarchyManager = this; 
     611} 
     612 
     613 
     614void HierarchyManager::ConstructMultiLevel(const VssRayContainer &sampleRays,                                                                                     
     615                                                                                   const ObjectContainer &objects, 
     616                                                                                   AxisAlignedBox3 *forcedViewSpace) 
     617{ 
     618        mHierarchyStats.Reset(); 
     619        mHierarchyStats.Start(); 
     620 
     621        mHierarchyStats.nodes = 2; 
     622         
     623 
     624        mTotalCost = (float)objects.size(); 
     625        Debug << "setting total cost to " << mTotalCost << endl; 
     626 
     627        const long startTime = GetTime(); 
     628        cout << "Constructing view space / object space tree ... \n"; 
     629         
     630        // compute view space bounding box 
     631        mVspTree->ComputeBoundingBox(sampleRays, forcedViewSpace); 
     632 
     633        // use sah for evaluating object space construction for the first run 
     634        mSavedViewSpaceSubdivisionType = mViewSpaceSubdivisionType; 
     635        mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 
     636 
     637        // start with object space subdivision 
     638        PrepareObjectSpaceSubdivision(sampleRays, objects); 
     639         
     640        // process object space candidates 
     641        RunConstruction(false); 
     642 
     643        ///////////////// 
     644    // now do view space subdivison on the sah bvh nodes 
     645        mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
     646        PrepareViewSpaceSubdivision(sampleRays, objects); 
     647         
     648        // process view space candidates 
     649        RunConstruction(false); 
     650         
     651        // again run object space subdivision on the view cells 
     652        ResetObjectSpaceSubdivision(objects); 
     653        PrepareObjectSpaceSubdivision(sampleRays, objects); 
     654 
     655        // process object space candidates 
     656        RunConstruction(false); 
     657         
     658        cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     659 
     660#if _DEBUG 
     661        cout << "view space: " << GetViewSpaceBox() << endl; 
     662        cout << "object space:  " << GetObjectSpaceBox() << endl; 
     663#endif 
     664 
     665        mHierarchyStats.Stop(); 
     666        mVspTree->mVspStats.Stop(); 
     667        FinishObjectSpaceSubdivision(objects); 
    550668} 
    551669 
     
    863981 
    864982        app << "#N_PMAXDEPTH ( Maximal reached depth )\n" << maxDepth << endl; 
     983 
     984        app << "#N_GLOBALCOSTMISSES ( Global cost misses )\n" << mGlobalCostMisses << endl; 
    865985         
    866986        app << "========== END OF Hierarchy statistics ==========\n"; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1421 r1449  
    7272        /// accumulated depth 
    7373        int accumDepth; 
    74  
     74        /// time spent for queue repair 
    7575        float repairTime; 
     76        // global cost ratio violations 
     77        int mGlobalCostMisses; 
    7678 
    7779        // Constructor 
     
    8890        double AvgDepth() const { return accumDepth / (double)Leaves();} 
    8991 
    90         void Reset()  
    91         { 
     92        void Reset() 
     93        { 
     94                mGlobalCostMisses = 0; 
    9295                nodes = 0; 
    9396                maxDepth = 0; 
     
    247250 
    248251        void RunConstruction( 
     252                const bool repairQueue, 
    249253                const VssRayContainer &sampleRays, 
    250254                const ObjectContainer &objects, 
    251255                AxisAlignedBox3 *forcedViewSpace); 
    252  
     256         
     257        void RunConstruction(const bool repairQueue); 
     258                 
    253259        bool ApplySubdivisionCandidate(SubdivisionCandidate *sc); 
    254260 
     
    306312        int GetObjectSpaceSubdivisionDepth() const; 
    307313 
     314        void ConstructInterleaved( 
     315                const VssRayContainer &sampleRays, 
     316                const ObjectContainer &objects, 
     317                AxisAlignedBox3 *forcedViewSpace); 
     318 
     319        void ConstructMultiLevel( 
     320                const VssRayContainer &sampleRays, 
     321                const ObjectContainer &objects, 
     322                AxisAlignedBox3 *forcedViewSpace); 
     323 
     324        void ResetObjectSpaceSubdivision(const ObjectContainer &objects); 
     325 
    308326protected: 
    309327 
     
    329347        SubdivisionCandidate *mCurrentCandidate; 
    330348 
     349        //////// 
    331350        //-- global criteria 
    332351        float mTermMinGlobalCostRatio; 
    333352        int mTermGlobalCostMissTolerance; 
    334         int mGlobalCostMisses; 
    335  
     353         
    336354        /// keeps track of cost during subdivision 
    337355        float mTotalCost; 
     
    348366 
    349367        bool mStartWithObjectSpace; 
     368 
     369        bool mUseMultiLevelConstruction; 
    350370}; 
    351371 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r1420 r1449  
    735735} 
    736736 
     737 
     738 
    737739/********************************************************/ 
    738740/*                      MeshInstance implementation             */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h

    r1379 r1449  
    7979        /// accumulated number of rays refs 
    8080        int accumRays; 
    81         /// potentially visible objects from this leaf 
     81        /// overall potentially visible objects 
    8282        int pvs; 
    83  
    8483        // accumulated depth (used to compute average) 
    8584        int accumDepth; 
     85        // global cost ratio violations 
     86        int mGlobalCostMisses; 
     87 
    8688 
    8789        // Constructor 
     
    111113                maxDepthNodes = 0; 
    112114                minPvsNodes = 0; 
    113          
    114115                minProbabilityNodes = 0; 
    115116                maxCostNodes = 0; 
    116  
    117117                contributingSamples = 0; 
    118118                sampleContributions = 0; 
    119  
    120119                maxPvs = 0; 
    121120                invalidLeaves = 0; 
    122121                objectRefs = 0; 
    123  
    124122                maxObjectRefs = 0; 
     123                mGlobalCostMisses = 0; 
    125124        } 
    126125 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r1415 r1449  
    690690          t1 = GetTime(); 
    691691           
    692           GenerateRays(mRssSamplesPerPass*ratios[0], RSS_BASED_DISTRIBUTION, rays); 
     692          GenerateRays(int(mRssSamplesPerPass*ratios[0]), RSS_BASED_DISTRIBUTION, rays); 
    693693 
    694694          rays.NormalizePdf((float)rays.size()); 
     
    711711          if (ratios[1]!=0.0f) { 
    712712                t1 = GetTime(); 
    713                 GenerateRays(mRssSamplesPerPass*ratios[1], SPATIAL_BOX_BASED_DISTRIBUTION, rays); 
     713                GenerateRays(int(mRssSamplesPerPass*ratios[1]), SPATIAL_BOX_BASED_DISTRIBUTION, rays); 
    714714                CastRays(rays, tmpVssRays); 
    715715                castRays += (int)rays.size(); 
     
    733733          if (ratios[2]!=0.0f) { 
    734734                t1 = GetTime(); 
    735                 GenerateRays(mRssSamplesPerPass*ratios[2], DIRECTION_BASED_DISTRIBUTION, rays); 
     735                GenerateRays(int(mRssSamplesPerPass*ratios[2]), DIRECTION_BASED_DISTRIBUTION, rays); 
    736736                CastRays(rays, tmpVssRays); 
    737737                castRays += (int)rays.size(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h

    r1291 r1449  
    207207        int accumRays; 
    208208        int pvs; 
     209        // global cost ratio violations 
     210        int mGlobalCostMisses; 
    209211 
    210212        // Constructor 
     
    227229                for (int i = 0; i < 3; ++ i) 
    228230                        splits[i] = 0; 
    229                  
     231         
     232                mGlobalCostMisses = 0; 
    230233                maxDepth = 0; 
    231234                minDepth = 99999; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1444 r1449  
    49244924        if (0 && mExportViewCells) 
    49254925        { 
    4926                 cout << "here5" << endl; 
    49274926                char filename[100]; 
    49284927                Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1418 r1449  
    474474        mBspStats.nodes = 1; 
    475475        mBspStats.polys = (int)polys.size(); 
    476         mGlobalCostMisses = 0; 
     476        mBspStats.mGlobalCostMisses = 0; 
    477477 
    478478 
     
    676676                //Debug << "cost ratio: " << costRatio << endl; 
    677677                if (costRatio < mTermMinGlobalCostRatio) 
    678                         ++ mGlobalCostMisses; 
    679                  
     678                { 
     679                        ++ mBspStats.mGlobalCostMisses; 
     680                } 
     681 
    680682                if (0 && !mOutOfMemory) 
    681683                { 
    682684                        float mem = GetMemUsage(); 
    683  
    684685                        if (mem > mMaxMemory) 
    685686                        { 
     
    693694 
    694695                if (r == mRoot) 
     696                { 
    695697                        Debug << "VSP BSP tree construction time spent at root: " 
    696698                                  << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
     699                } 
    697700 
    698701                if (mBspStats.Leaves() >= nLeaves) 
     
    753756                || mOutOfMemory  
    754757                || (mBspStats.Leaves() >= mMaxViewCells)  
    755                 || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
     758                || (mBspStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
    756759                 ); 
    757760} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r1288 r1449  
    774774        float mAxisAlignedSplitBorder; 
    775775 
    776  
     776        /////////// 
    777777        //-- global terminatino criteria 
    778  
    779778        float mTermMinGlobalCostRatio; 
    780779        int mTermGlobalCostMissTolerance; 
    781         int mGlobalCostMisses; 
    782  
     780         
    783781        /// maximal number of view cells 
    784782        int mMaxViewCells; 
     
    795793         
    796794 
    797  
     795        ////////// 
    798796        //-- axis aligned split criteria 
    799797 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1444 r1449  
    127127        app << "#N_INVALIDLEAVES (number of invalid leaves )\n" << invalidLeaves << endl; 
    128128 
    129         app << "#N_RAYS (number of rays / leaf)\n" << AvgRays() << endl; 
    130          
     129        app << "#AVGRAYS (number of rays / leaf)\n" << AvgRays() << endl; 
     130         
     131        app << "#N_GLOBALCOSTMISSES ( Global cost misses )\n" << mGlobalCostMisses << endl; 
    131132 
    132133        app << "========== END OF VspTree statistics ==========\n"; 
     
    561562                // || mOutOfMemory 
    562563                || (mVspStats.Leaves() >= mMaxViewCells) 
    563         || (mGlobalCostMisses >= mTermGlobalCostMissTolerance)  
     564        || (mVspStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance)  
    564565                ); 
    565566 
     
    567568        { 
    568569                Debug << "vsp global termination criteria met:" << endl; 
    569                 Debug << "cost misses: " << mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 
     570                Debug << "cost misses: " << mVspStats.mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 
    570571                Debug << "leaves: " << mVspStats.Leaves() << " " <<  mMaxViewCells << endl; 
    571572        } 
     
    26772678        // initialise termination criteria 
    26782679        mTermMinProbability *= mBoundingBox.GetVolume(); 
    2679         mGlobalCostMisses = 0; 
    2680  
    26812680        // get clipped rays 
    26822681        PreprocessRays(sampleRays, rays); 
    26832682 
     2683        /// collect pvs from rays 
    26842684        const int pvsSize = EvalPvsSize(rays); 
    26852685         
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h

    r1379 r1449  
    8282        /// accumulated number of rays refs 
    8383        int accumRays; 
     84        /// overall pvs size 
    8485        int pvs; 
    8586        // accumulated depth (used to compute average) 
    8687        int accumDepth; 
     88        // global cost ratio violations 
     89        int mGlobalCostMisses; 
    8790 
    8891        // Constructor 
     
    124127                accumRays = 0; 
    125128                maxObjectRefs = 0; 
     129                mGlobalCostMisses = 0; 
    126130        } 
    127131 
     
    10021006        float mTermMinGlobalCostRatio; 
    10031007        int mTermGlobalCostMissTolerance; 
    1004         int mGlobalCostMisses; 
     1008         
    10051009 
    10061010        /// maximal number of view cells 
Note: See TracChangeset for help on using the changeset viewer.