Ignore:
Timestamp:
08/22/06 22:48:02 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r1237 r1259  
    2020#include "VspTree.h" 
    2121#include "OspTree.h" 
     22#include "BvHierarchy.h" 
    2223 
    2324 
     
    3334 
    3435 
    35 HierarchyManager::HierarchyManager(VspTree &vspTree, OspTree &ospTree): 
    36 mVspTree(vspTree), mOspTree(ospTree) 
    37 { 
    38         // cross references 
    39         mVspTree.mOspTree = &ospTree; 
    40         mOspTree.mVspTree = &vspTree; 
    41  
     36HierarchyManager::HierarchyManager(VspTree &vspTree, OspTree &ospTree) 
     37//:mVspTree(vspTree), mOspTree(ospTree) 
     38{ 
    4239        char subdivisionStatsLog[100]; 
    4340        Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats",  
     
    6360{ 
    6461        SubdivisionCandidate *vsc =  
    65                 mVspTree.PrepareConstruction(sampleRays, forcedViewSpace, viewSpaceRays); 
     62                mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, viewSpaceRays); 
    6663        mTQueue.Push(vsc); 
    6764 
    6865        SubdivisionCandidate *osc =  
    69                 mOspTree.PrepareConstruction(sampleRays, objects, forcedViewSpace, objectSpaceRays); 
     66                mOspTree->PrepareConstruction(sampleRays, objects, forcedViewSpace, objectSpaceRays); 
    7067 
    7168        mTQueue.Push(osc); 
     
    7875 
    7976        //mTotalCost -= costDecr; 
    80         // mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - tData.mPvs; 
    81  
    82         AddSubdivisionStats(mOspTree.mOspStats.Leaves() + mVspTree.mVspStats.Leaves(), 
     77        //mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - tData.mPvs; 
     78 
     79        AddSubdivisionStats(mOspTree->mOspStats.Leaves() + mVspTree->mVspStats.Leaves(), 
    8380                                                costDecr, 
    8481                                                mTotalCost 
     
    116113        PrepareConstruction(sampleRays, objects, forcedViewSpace, *viewSpaceRays, *objectSpaceRays); 
    117114 
    118         mVspTree.mVspStats.Reset(); 
    119         mVspTree.mVspStats.Start(); 
     115        mVspTree->mVspStats.Reset(); 
     116        mVspTree->mVspStats.Start(); 
    120117 
    121118        cout << "Constructing view space / object space tree ... \n"; 
     
    126123        cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 
    127124 
    128         mVspTree.mVspStats.Stop(); 
     125        mVspTree->mVspStats.Stop(); 
    129126} 
    130127 
     
    139136        if (vspSplit) 
    140137        { 
    141                 VspNode *n = mVspTree.Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 
     138                VspNode *n = mVspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 
    142139        } 
    143140        else 
    144141        { 
    145                 KdNode *n = mOspTree.Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 
     142                KdNode *n = mOspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 
    146143        } 
    147144         
     
    209206        // during view space partition 
    210207        const bool savedCountMethod = mVspTree.mUseKdPvsForHeuristics; 
    211         const bool savedStoreMethod = mVspTree.mStoreKdPvs; 
     208        const bool savedStoreMethod = mVspTree.mStoreObjectPvs; 
    212209         
    213210        mVspTree.mUseKdPvsForHeuristics = false; 
    214         mVspTree.mStoreKdPvs = false; 
     211        mVspTree.mStoreObjectPvs = false; 
    215212#endif 
    216213 
    217214        SubdivisionCandidate *vsc =  
    218                 mVspTree.PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 
     215                mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 
    219216 
    220217        // add to queue 
     
    224221        cout << "starting vsp contruction ... " << endl; 
    225222 
    226         mVspTree.mVspStats.Reset(); 
    227         mVspTree.mVspStats.Start(); 
     223        mVspTree->mVspStats.Reset(); 
     224        mVspTree->mVspStats.Start(); 
    228225 
    229226        int i = 0; 
     
    238235 
    239236        cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 
    240         mVspTree.mVspStats.Stop(); 
    241          
     237        mVspTree->mVspStats.Stop(); 
    242238 
    243239 
     
    255251        // compute first candidate 
    256252        SubdivisionCandidate *osc = 
    257                 mOspTree.PrepareConstruction(sampleRays, objects, forcedViewSpace, *objectSpaceRays); 
     253                mOspTree->PrepareConstruction(sampleRays, objects, forcedViewSpace, *objectSpaceRays); 
    258254 
    259255        Debug << "reseting cost, new total cost: " << mTotalCost << endl; 
    260         mTotalCost = mOspTree.mTotalCost; 
     256        mTotalCost = mOspTree->mTotalCost; 
    261257 
    262258    mTQueue.Push(osc); 
    263259 
    264         mOspTree.mOspStats.Reset(); 
    265         mOspTree.mOspStats.Start(); 
     260        mOspTree->mOspStats.Reset(); 
     261        mOspTree->mOspStats.Start(); 
    266262 
    267263        startTime = GetTime(); 
     
    272268        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    273269 
    274         mOspTree.mOspStats.Stop(); 
    275  
    276         float rc = mOspTree.EvalRenderCost(sampleRays); 
     270        mOspTree->mOspStats.Stop(); 
     271 
     272        float rc = mOspTree->EvalRenderCost(sampleRays); 
    277273 
    278274        Debug << "here47 My render cost evalulation: " << rc << endl; 
     
    280276#if 0 
    281277        // reset parameters 
    282         mVspTree.mUseKdPvsForHeuristics = savedCountMethod; 
    283         mVspTree.mStoreKdPvs = savedStoreMethod; 
     278        mVspTree->mUseKdPvsForHeuristics = savedCountMethod; 
     279        mVspTree->mStoreObjectPvs = savedStoreMethod; 
    284280#endif 
    285281} 
     
    290286                                                                  AxisAlignedBox3 *forcedViewSpace) 
    291287{ 
    292         // only view space partition 
     288        // construct only view space partition 
    293289        // object kd tree is taken for osp 
    294290 
    295         mVspTree.mVspStats.Reset(); 
    296         mVspTree.mVspStats.Start(); 
     291        mVspTree->mVspStats.Reset(); 
     292        mVspTree->mVspStats.Start(); 
    297293 
    298294        RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 
    299295         
    300296        SubdivisionCandidate *sc =  
    301                 mVspTree.PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 
     297                mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 
    302298 
    303299        mTQueue.Push(sc); 
     
    310306 
    311307        cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 
    312         mVspTree.mVspStats.Stop(); 
     308        mVspTree->mVspStats.Stop(); 
    313309} 
    314310 
     
    320316 
    321317 
    322 void HierarchyManager::CollectDirtyCandidates(vector<SubdivisionCandidate *> &dirtyList) 
     318void HierarchyManager::CollectObjectSpaceDirtyList(SubdivisionCandidateContainer &dirtyList) 
     319{ 
     320        switch (mObjectSpaceSubdivisonType) 
     321        { 
     322        case KD_BASED_OBJ_SUBDIV: 
     323                { 
     324                        OspTree::OspSubdivisionCandidate *sc =  
     325                                dynamic_cast<OspTree::OspSubdivisionCandidate *>(mCurrentCandidate); 
     326 
     327                        mOspTree->CollectDirtyCandidates(sc, dirtyList); 
     328                        break; 
     329                } 
     330        case BV_BASED_OBJ_SUBDIV: 
     331                { 
     332                        BvHierarchy::BvhSubdivisionCandidate *sc =  
     333                                dynamic_cast<BvHierarchy::BvhSubdivisionCandidate *>(mCurrentCandidate); 
     334 
     335                        mBvHierarchy->CollectDirtyCandidates(sc, dirtyList); 
     336                        break; 
     337                } 
     338        default: 
     339                break; 
     340        } 
     341} 
     342 
     343 
     344void HierarchyManager::CollectViewSpaceDirtyList(SubdivisionCandidateContainer &dirtyList) 
     345{ 
     346        VspTree::VspSubdivisionCandidate *sc =  
     347                dynamic_cast<VspTree::VspSubdivisionCandidate *>(mCurrentCandidate); 
     348 
     349        mVspTree->CollectDirtyCandidates(sc, dirtyList); 
     350} 
     351 
     352 
     353void HierarchyManager::CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList) 
    323354{        
    324355        // we have either a object space or view space split 
    325356        if (mCurrentCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) 
    326357        { 
    327                 VspTree::VspSubdivisionCandidate *sc =  
    328                         dynamic_cast<VspTree::VspSubdivisionCandidate *>(mCurrentCandidate); 
    329  
    330                 mVspTree.CollectDirtyCandidates(sc, dirtyList); 
     358                CollectViewSpaceDirtyList(dirtyList); 
    331359        } 
    332360        else // object space split 
    333         {                        
    334                 OspTree::OspSubdivisionCandidate *sc =  
    335                         dynamic_cast<OspTree::OspSubdivisionCandidate *>(mCurrentCandidate); 
    336  
    337                 mOspTree.CollectDirtyCandidates(sc, dirtyList); 
     361        {        
     362                CollectObjectSpaceDirtyList(dirtyList); 
    338363        } 
    339364} 
     
    380405} 
    381406 
    382 } 
     407 
     408} 
Note: See TracChangeset for help on using the changeset viewer.