Changeset 1649


Ignore:
Timestamp:
10/19/06 16:14:29 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
6 edited

Legend:

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

    r1643 r1649  
    2525#define PROBABILIY_IS_BV_VOLUME 1 
    2626#define USE_FIXEDPOINT_T 0 
    27 #define COUNT_ORIGIN_OBJECTS 0 
     27//#define COUNT_ORIGIN_OBJECTS 0 
    2828 
    2929int BvhNode::sMailId = 10000; //2147483647; 
     
    10691069        const float ratio = newRenderCost / oldRenderCost; 
    10701070 
    1071 #ifdef _DEBUG 
     1071//#ifdef _DEBUG 
    10721072        Debug << "\n§§§§ bvh eval const decrease §§§§" << endl 
    10731073                  << "back pvs: " << (int)objectsBack.size() << " front pvs: " << (int)objectsFront.size() << " total pvs: " << nTotalObjects << endl  
     
    10751075                  << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl 
    10761076                  << "render cost decrease: " << oldRenderCost / viewSpaceVol - newRenderCost / viewSpaceVol << endl; 
    1077 #endif 
     1077//#endif 
    10781078 
    10791079        return ratio; 
     
    13261326                        } 
    13271327                } 
    1328  
    1329                 if (COUNT_ORIGIN_OBJECTS && ray->mOriginObject) 
     1328#if COUNT_ORIGIN_OBJECTS 
     1329                if (ray->mOriginObject) 
    13301330                { 
    13311331                        ray->mOriginObject->mVssRays.push_back(ray); 
     
    13371337                        } 
    13381338                } 
     1339#endif 
    13391340        } 
    13401341 
     
    15091510                for (vit = tmpViewCells.begin(); vit != vit_end; ++ vit) 
    15101511                { 
    1511                         //VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit); 
    15121512                        ViewCell *vc = *vit; 
    15131513 
     
    18831883 
    18841884        PrintSubdivisionStats(*oSubdivisionCandidate); 
    1885  
     1885         
    18861886        return oSubdivisionCandidate; 
    18871887} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1643 r1649  
    25272527                                        "-1"); 
    25282528 
     2529        RegisterOption("Hierarchy.Termination.maxMemory", 
     2530                                        optFloat, 
     2531                                        "hierarchy_construction_max_memory=", 
     2532                                        "1"); 
     2533 
    25292534        RegisterOption("Hierarchy.Construction.useMultiLevel", 
    25302535                                        optBool, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1643 r1649  
    112112                "Hierarchy.Construction.minStepsOfSameType", mMinStepsOfSameType); 
    113113         
    114  
    115114        char subdivisionStatsLog[100]; 
    116115        Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats", subdivisionStatsLog); 
     
    119118        Environment::GetSingleton()->GetBoolValue( 
    120119                "Hierarchy.Construction.recomputeSplitPlaneOnRepair", mRecomputeSplitPlaneOnRepair); 
     120 
     121        Environment::GetSingleton()->GetFloatValue( 
     122                "Hierarchy.Termination.maxMemory", mTermMaxMemory); 
    121123 
    122124        Debug << "******** Hierachy Manager Options ***********" << endl; 
     
    129131        Debug << "recompute split plane on repair: " << mRecomputeSplitPlaneOnRepair << endl; 
    130132        Debug << "minimal number of steps from same type: " << mMinStepsOfSameType << endl; 
     133        Debug << "maximal allowed memory: " << mTermMaxMemory << endl; 
    131134 
    132135        switch (mConstructionType) 
     
    233236void HierarchyManager::EvalSubdivisionStats() 
    234237{ 
    235         // TODO 
    236         const float objectSpaceMem = GetObjectSpaceMemUsage(); 
    237         const float viewSpaceMem = mVspTree->GetMemUsage(); 
     238        // question: should I also add the mem usage of the hierarchies? 
     239        const float objectSpaceMem = 0;//GetObjectSpaceMemUsage(); 
     240        const float viewSpaceMem = 0;//mVspTree->GetMemUsage(); 
    238241         
    239242        // calculate cost in MB 
     
    274277                (0 
    275278                || (mHierarchyStats.Leaves() >= mTermMaxLeaves)  
     279                || (mHierarchyStats.mMemory >= mTermMaxMemory) 
     280                || candidate->GlobalTerminationCriteriaMet() 
     281                //|| (mHierarchyStats.mRenderCostDecrease < mMinRenderCostDecrease) 
    276282                //|| (mHierarchyStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
    277                 || (candidate->GlobalTerminationCriteriaMet()) 
    278                 //|| (mHierarchyStats.mRenderCostDecrease < mMinRenderCostDecrease) 
    279283                ); 
    280284 
    281 #if _DEBUG 
     285//#if _DEBUG 
    282286        if (terminationCriteriaMet) 
    283287        { 
     
    285289                Debug << "leaves: " << mHierarchyStats.Leaves() << " " << mTermMaxLeaves << endl; 
    286290                Debug << "cost misses: " << mHierarchyStats.mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 
    287         } 
    288 #endif 
     291                Debug << "memory: " << mHierarchyStats.mMemory << " " << mTermMaxMemory << endl; 
     292        } 
     293//#endif 
    289294 
    290295        return terminationCriteriaMet; 
     
    466471        mVspTree->mVspStats.Stop(); 
    467472 
    468         FinishObjectSpaceSubdivision(objects); 
     473        FinishObjectSpaceSubdivision(objects, !mUseMultiLevelConstruction); 
    469474} 
    470475 
     
    534539        mHierarchyStats.Stop(); 
    535540        mVspTree->mVspStats.Stop(); 
    536         FinishObjectSpaceSubdivision(objects); 
     541         
     542        FinishObjectSpaceSubdivision(objects, !mUseMultiLevelConstruction); 
    537543} 
    538544 
     
    551557 
    552558        mHierarchyStats.mTotalCost = mVspTree->mTotalCost; 
     559        mHierarchyStats.mPvsEntries = mVspTree->EvalPvsEntriesSize(*viewSpaceRays); 
     560 
    553561        cout << "\nreseting cost for vsp, new total cost: " << mHierarchyStats.mTotalCost << endl; 
    554562 
     
    650658{ 
    651659        const bool terminationCriteriaMet = GlobalTerminationCriteriaMet(sc); 
    652  
    653660        const bool success = sc->Apply(splitQueue, terminationCriteriaMet); 
    654661 
     
    842849        { 
    843850                SubdivisionCandidate *sc = NextSubdivisionCandidate(mTQueue);     
    844                 cout << "p=" << sc->GetPriority() << " "; 
    845  
     851                 
    846852                //////// 
    847853                //-- subdivide leaf node of either type 
    848854        ApplySubdivisionCandidate(sc, mTQueue, repairQueue); 
    849         //cout << "\nhere45 " << sc->GetPriority() << " " << sc->GetRenderCostDecrease() << " " << mObjectSpaceSubdivisionType << " " << mViewSpaceSubdivisionType << endl; 
    850855                 
    851856                DEL_PTR(sc); 
     
    904909                        cout << "\nreseting bv hierarchy" << endl; 
    905910                        Debug << "old bv hierarchy:\n " << mBvHierarchy->mBvhStats << endl; 
    906  
     911                         
    907912                        mBvHierarchy->Initialise(objects); 
    908  
     913         
    909914                        // rather use this: remove previous nodes and add the two new ones 
    910915                        //mHierarchyStats.mNodes -= mBvHierarchy->mBvhStats.nodes + 2; 
    911916                        mHierarchyStats.mNodes = 2; 
    912917 
     918                        //firstCandidate = mBvHierarchy->PrepareConstruction(sampleRays, objects); 
    913919                        firstCandidate = mBvHierarchy->Reset(sampleRays, objects); 
    914                  
     920 
    915921                        mHierarchyStats.mTotalCost = mBvHierarchy->mTotalCost; 
    916922                        mHierarchyStats.mRenderCostDecrease = 0; 
     
    918924                        // bug!! pvs entries cab be much higher at this stage 
    919925                        // (if view space was already subdivided) 
    920                         mHierarchyStats.mPvsEntries = 1; 
     926                        mHierarchyStats.mPvsEntries = mBvHierarchy->CountViewCells(objects); 
    921927                        mHierarchyStats.mMemory = sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 
    922928 
    923929                        // evaluate stats before first subdivision 
    924930                        EvalSubdivisionStats(); 
     931                        cout << "finished bv hierarchy preparation" << endl; 
    925932                } 
    926933                break; 
     
    941948                                                                                                                                  AxisAlignedBox3 *forcedViewSpace) 
    942949{ 
    943         ViewCellsManager *vc = mVspTree->mViewCellsManager; 
     950        ViewCellsManager *vm = mVspTree->mViewCellsManager; 
    944951 
    945952        // HACK: rather not destroy vsp tree 
    946953        DEL_PTR(mVspTree); 
    947954        mVspTree = new VspTree(); 
     955 
    948956        mVspTree->mHierarchyManager = this; 
     957        mVspTree->mViewCellsManager = vm; 
    949958 
    950959        mVspTree->Initialise(sampleRays, forcedViewSpace); 
    951960         
    952         SubdivisionCandidate *vsc =  
    953                 PrepareViewSpaceSubdivision(sampleRays, objects); 
     961        SubdivisionCandidate *vsc = PrepareViewSpaceSubdivision(sampleRays, objects); 
    954962         
    955963        mHierarchyStats.mNodes = 2; 
    956         // bug!! pvs entries could be much higher at this stage 
    957         mHierarchyStats.mPvsEntries = 1; 
     964         
    958965        mHierarchyStats.mRenderCostDecrease = 0; 
    959966 
     
    9931000        mTQueue.Push(osc); 
    9941001 
    995         //////////////////////////7 
     1002        ////////////////////////// 
    9961003 
    9971004 
     
    10211028 
    10221029                cout << "iteration " << i << " of " << limit << " finished" << endl; 
    1023  
    10241030                mSubdivisionStats.close(); 
    10251031 
     
    10301036                mSubdivisionStats.open(subdivisionStatsLog); 
    10311037 
     1038 
    10321039                ///////////////// 
    10331040                // subdivide view space with respect to the objects 
    10341041 
    1035                 SubdivisionCandidate *vspVc = ResetViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); 
     1042                SubdivisionCandidate *vspVc =  
     1043                        ResetViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); 
    10361044                mTQueue.Push(vspVc); 
    10371045 
     
    10431051 
    10441052                cout << "iteration " << i << " of " << limit << " finished" << endl; 
    1045  
    10461053                mSubdivisionStats.close(); 
    10471054 
     
    10651072        //mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 
    10661073 
    1067         // set the number of leaves 'evaluated' from the previous methods 
    1068         // we go for the same numbers, but we try to optimize both 
    1069         // subdivisions 
    1070         switch (mObjectSpaceSubdivisionType) 
    1071         { 
    1072         case BV_BASED_OBJ_SUBDIV: 
    1073                 mBvHierarchy->mTermMaxLeaves = mBvHierarchy->mBvhStats.Leaves(); 
    1074                 break; 
    1075         case KD_BASED_OBJ_SUBDIV: 
    1076                 mOspTree->mTermMaxLeaves = mOspTree->mOspStats.Leaves(); 
    1077         default: 
    1078                 break; 
    1079         } 
    1080          
    1081         mVspTree->mMaxViewCells = mVspTree->mVspStats.Leaves(); 
    1082  
    10831074        const long startTime = GetTime(); 
    10841075        const int limit = mNumMultiLevels; 
     
    10881079 
    10891080        int steps = 0; 
     1081 
     1082        int maxViewSpaceLeaves = mVspTree->mVspStats.Leaves(); 
     1083        int maxObjectSpaceLeaves; 
     1084         
     1085        // set the number of leaves 'evaluated' from the previous methods 
     1086        // we go for the same numbers, but we try to optimize both subdivisions 
     1087        switch (mObjectSpaceSubdivisionType) 
     1088        { 
     1089        case BV_BASED_OBJ_SUBDIV: 
     1090                maxObjectSpaceLeaves = mBvHierarchy->mBvhStats.Leaves(); 
     1091                break; 
     1092        case KD_BASED_OBJ_SUBDIV: 
     1093                maxObjectSpaceLeaves = mOspTree->mOspStats.Leaves(); 
     1094        default: 
     1095                maxObjectSpaceLeaves = 0; 
     1096                break; 
     1097        } 
    10901098 
    10911099        // This method subdivides view space / object space  
     
    11031111                SubdivisionCandidate *ospVc =  
    11041112                        ResetObjectSpaceSubdivision(sampleRays, objects); 
     1113         
     1114                // set the number of leaves 'evaluated' from the previous methods 
     1115                // we go for the same numbers, but we try to optimize both subdivisions 
     1116                mBvHierarchy->mTermMaxLeaves = maxObjectSpaceLeaves; 
    11051117                mTQueue.Push(ospVc); 
    11061118 
     
    11091121 
    11101122                cout << "iteration " << steps << " of " << limit << " finished" << endl; 
    1111  
    11121123                mSubdivisionStats.close(); 
    11131124 
     
    11231134                SubdivisionCandidate *vspVc =  
    11241135                        ResetViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); 
     1136 
     1137                mVspTree->mMaxViewCells = maxViewSpaceLeaves; 
    11251138                mTQueue.Push(vspVc); 
    11261139 
     
    11291142 
    11301143                cout << "iteration " << steps << " of " << limit << " finished" << endl; 
    1131  
    11321144                mSubdivisionStats.close(); 
    11331145 
     
    14401452 
    14411453 
    1442 void HierarchyManager::FinishObjectSpaceSubdivision(const ObjectContainer &objects) const 
     1454void HierarchyManager::FinishObjectSpaceSubdivision(const ObjectContainer &objects, const bool removeRayRefs) const 
    14431455{ 
    14441456        switch (mObjectSpaceSubdivisionType) 
     
    14521464                { 
    14531465                        mBvHierarchy->mBvhStats.Stop(); 
    1454                         RemoveRayRefs(objects); 
     1466                        if (removeRayRefs) 
     1467                                RemoveRayRefs(objects); 
    14551468                        break; 
    14561469                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1642 r1649  
    4242class Exporter; 
    4343 
    44  
     44#define COUNT_ORIGIN_OBJECTS 1 
    4545 
    4646/** View space / object space hierarchy statistics. 
     
    376376        /** After the suddivision has ended, do some final tasks. 
    377377        */ 
    378         void FinishObjectSpaceSubdivision(const ObjectContainer &objects) const; 
     378        void FinishObjectSpaceSubdivision(const ObjectContainer &objects, const bool removeRayRefs = true) const; 
    379379 
    380380        /** Returns depth of object space subdivision. 
     
    487487        /// maximum number of leaves 
    488488        int mTermMaxLeaves; 
     489        /// Maximal allowed memory consumption. 
     490        float mTermMaxMemory; 
    489491 
    490492        //////////////////// 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1640 r1649  
    2727 
    2828// should not count origin object for sampling because it disturbs heuristics 
    29 #define SAMPLE_ORIGIN_OBJECTS 0 
     29#define SAMPLE_ORIGIN_OBJECTS 1 
    3030 
    3131// $$JB HACK 
     
    19141914 
    19151915                        if (ray.mTerminationObject)  
    1916                           {                      
    1917                                  
    1918  
    1919                           if (viewcell->GetPvs().GetSampleContribution(obj, 
    1920                                                                                                                    ray.mPdf, 
    1921                                                                                                                    contribution)) 
     1916                        {                        
     1917                                if (viewcell->GetPvs().GetSampleContribution(obj, 
     1918                                        ray.mPdf, 
     1919                                        contribution)) 
    19221920                                { 
    1923                                   ++ ray.mPvsContribution; 
    1924                                   ray.mRelativePvsContribution += contribution; 
     1921                                        ++ ray.mPvsContribution; 
     1922                                        ray.mRelativePvsContribution += contribution; 
    19251923                                } 
    19261924                        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1640 r1649  
    2828 
    2929#define USE_FIXEDPOINT_T 0 
    30 #define COUNT_ORIGIN_OBJECTS 0 
     30 
    3131 
    3232///////////// 
     
    10311031                        sc += contribution; 
    10321032                } 
    1033  
     1033#if COUNT_ORIGIN_OBJECTS 
    10341034                obj = ray->mOriginObject; 
    10351035 
     
    10461046                        sc += contribution; 
    10471047                } 
    1048  
     1048#endif 
    10491049                if (madeContrib) 
    10501050                { 
     
    11671167                 
    11681168                pvsSize += PrepareHeuristics(*ray, true); 
     1169#if COUNT_ORIGIN_OBJECTS 
    11691170                pvsSize += PrepareHeuristics(*ray, false); 
     1171#endif 
    11701172        } 
    11711173 
     
    12401242        if (ci.type == SortableEntry::ERayMin) 
    12411243        { 
     1244#if COUNT_ORIGIN_OBJECTS 
    12421245                pvsLeft += EvalMinEventContribution(*ray, true); 
     1246#else 
    12431247                pvsLeft += EvalMinEventContribution(*ray, false); 
     1248#endif 
    12441249        } 
    12451250        else // eval changes in pvs causes by max event  
    12461251        { 
     1252#if COUNT_ORIGIN_OBJECTS 
    12471253                pvsRight -= EvalMaxEventContribution(*ray, true); 
     1254#else 
    12481255                pvsRight -= EvalMaxEventContribution(*ray, false); 
     1256#endif 
    12491257        } 
    12501258} 
     
    22062214        { 
    22072215                VssRay *ray = (*rit).mRay; 
    2208  
     2216#if COUNT_ORIGIN_OBJECTS 
    22092217                pvsSize += EvalContributionToPvs(*ray, true); 
     2218#else 
    22102219                pvsSize += EvalContributionToPvs(*ray, false); 
     2220#endif 
    22112221        } 
    22122222         
     
    22832293        { 
    22842294                VssRay *ray = (*rit).mRay; 
    2285  
     2295#if COUNT_ORIGIN_OBJECTS 
    22862296                pvsSize += EvalPvsEntriesContribution(*ray, true); 
     2297#else 
    22872298                pvsSize += EvalPvsEntriesContribution(*ray, false); 
     2299#endif 
    22882300        } 
    22892301 
     
    24892501                                ++ hits; 
    24902502                        } 
    2491 #if 0 
    2492                         leaf->mRays.push_back(RayInfo(new VssRay(origin, termination, NULL, NULL, 0))); 
    2493 #endif 
     2503 
    24942504                        // get the next node from the stack 
    24952505                        if (tStack.empty()) 
Note: See TracChangeset for help on using the changeset viewer.