Ignore:
Timestamp:
09/14/06 18:55:38 (18 years ago)
Author:
mattausch
Message:

debugged global sorting, worked on object-viewspace subdivision

File:
1 edited

Legend:

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

    r1344 r1370  
    9595                "Hierarchy.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 
    9696 
     97        Environment::GetSingleton()->GetBoolValue( 
     98                "Hierarchy.Construction.startWithObjectSpace", mStartWithObjectSpace); 
     99 
    97100        Environment::GetSingleton()->GetIntValue( 
    98101                "Hierarchy.Termination.maxLeaves", mTermMaxLeaves); 
     
    103106        Environment::GetSingleton()->GetIntValue( 
    104107                "Hierarchy.Construction.minDepthForOsp", mMinDepthForObjectSpaceSubdivion); 
     108 
     109        Environment::GetSingleton()->GetIntValue( 
     110                "Hierarchy.Construction.minDepthForVsp", mMinDepthForViewSpaceSubdivion); 
    105111         
    106112        Environment::GetSingleton()->GetBoolValue( 
     
    125131 
    126132 
     133int HierarchyManager::GetObjectSpaceSubdivisionType() const 
     134{ 
     135        return mObjectSpaceSubdivisionType; 
     136} 
     137 
     138 
     139int HierarchyManager::GetViewSpaceSubdivisionType() const 
     140{ 
     141        return mViewSpaceSubdivisionType; 
     142} 
     143 
     144 
    127145void HierarchyManager::SetViewCellsManager(ViewCellsManager *vcm) 
    128146{ 
     
    220238        mObjectSpaceSubdivisionType = NO_OBJ_SUBDIV; 
    221239 
     240        mSavedViewSpaceSubdivisionType = mViewSpaceSubdivisionType; 
     241        mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 
     242 
    222243        // start with view space subdivison: prepare vsp tree for traversal 
    223244        if (StartViewSpaceSubdivision()) 
     
    238259         
    239260        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     261 
    240262        mHierarchyStats.Stop(); 
    241263        mVspTree->mVspStats.Stop(); 
     264        FinishObjectSpaceSubdivision(); 
     265 
     266        mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 
     267        mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
    242268} 
    243269 
     
    247273                                                                                                   AxisAlignedBox3 *forcedViewSpace) 
    248274{ 
     275        cout << "starting view space hierarchy construction ... " << endl; 
     276 
    249277        RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 
    250278        SubdivisionCandidate *vsc =  
     
    291319                                                                          const ObjectContainer &objects) 
    292320{ 
     321        cout << "starting osp tree construction ... " << endl; 
     322 
    293323        RayInfoContainer *objectSpaceRays = new RayInfoContainer(); 
    294  
    295         cout << "starting osp tree construction ... " << endl; 
    296324 
    297325        // start with one big kd cell - all objects can be seen from everywhere 
     
    342370 
    343371 
     372int HierarchyManager::GetObjectSpaceSubdivisionDepth() const 
     373{ 
     374        int maxDepth = 0; 
     375 
     376        if (mObjectSpaceSubdivisionType == KD_BASED_OBJ_SUBDIV) 
     377        { 
     378                maxDepth = mOspTree->mOspStats.maxDepth; 
     379        } 
     380        else if (mObjectSpaceSubdivisionType == BV_BASED_OBJ_SUBDIV) 
     381        { 
     382                maxDepth = mBvHierarchy->mBvhStats.maxDepth; 
     383        } 
     384 
     385        return maxDepth; 
     386} 
     387 
     388 
    344389bool HierarchyManager::StartObjectSpaceSubdivision() const 
    345390{ 
    346         const bool ospDepthReached =  
    347                 (mMinDepthForObjectSpaceSubdivion <= mVspTree->mVspStats.maxDepth); 
    348      
    349         return !ObjectSpaceSubdivisionConstructed() &&  
    350                    (mTQueue.Empty() || ((mConstructionType == INTERLEAVED) && ospDepthReached)); 
     391        // view space construction already started 
     392        if (ObjectSpaceSubdivisionConstructed()) 
     393                return false; 
     394 
     395        // start immediately with object space subdivision? 
     396        if (mStartWithObjectSpace) 
     397                return true; 
     398 
     399        // is the queue empty again? 
     400        if (ViewSpaceSubdivisionConstructed() && mTQueue.Empty()) 
     401                return true; 
     402 
     403        // has the depth for subdivision been reached? 
     404        return  
     405                ((mConstructionType == INTERLEAVED) &&  
     406                 (mMinDepthForObjectSpaceSubdivion <= mVspTree->mVspStats.maxDepth)); 
    351407} 
    352408 
     
    354410bool HierarchyManager::StartViewSpaceSubdivision() const 
    355411{ 
    356         const bool vspDepthReached =  
    357                 (mMinDepthForObjectSpaceSubdivion <= mVspTree->mVspStats.maxDepth); 
    358      
    359         return !ViewSpaceSubdivisionConstructed() &&  
    360                    (mTQueue.Empty() || ((mConstructionType == INTERLEAVED) && vspDepthReached)); 
     412        // view space construction already started 
     413        if (ViewSpaceSubdivisionConstructed()) 
     414                return false; 
     415 
     416        // start immediately with view space subdivision? 
     417        if (!mStartWithObjectSpace) 
     418                return true; 
     419 
     420        // is the queue empty again? 
     421        if (ObjectSpaceSubdivisionConstructed() && mTQueue.Empty()) 
     422                return true; 
     423 
     424        // has the depth for subdivision been reached? 
     425        return  
     426                ((mConstructionType == INTERLEAVED) &&  
     427                 (mMinDepthForViewSpaceSubdivion <= GetObjectSpaceSubdivisionDepth())); 
    361428} 
    362429 
     
    384451                } 
    385452                 
     453                /////////////////////////// 
    386454                //-- subdivide leaf node 
    387455                if (ApplySubdivisionCandidate(mCurrentCandidate)) 
     
    420488 
    421489                        cout << "starting view space subdivision at depth "  
    422                                  << mVspTree->mVspStats.maxDepth << " ("  
    423                                  << mMinDepthForObjectSpaceSubdivion << ") " << endl; 
     490                                 << GetObjectSpaceSubdivisionDepth() << " ("  
     491                                 << mMinDepthForViewSpaceSubdivion << ") " << endl; 
    424492 
    425493                        PrepareViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); 
     
    432500                DEL_PTR(mCurrentCandidate); 
    433501        } 
    434  
    435         mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 
    436502} 
    437503 
     
    632698                { 
    633699                        BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj); 
    634                         return mBvHierarchy->AddLeafToPvs(leaf, vc, pdf, contribution); 
     700                        BvhIntersectable *bvhObj = mBvHierarchy->GetOrCreateBvhIntersectable(leaf); 
     701                         
     702                        return vc->AddPvsSample(bvhObj, pdf, contribution); 
    635703                } 
    636704        default: 
     
    647715        stream << mVspTree->GetStatistics() << endl; 
    648716        stream << "\nobject space:" << endl << endl; 
     717 
    649718        switch (mObjectSpaceSubdivisionType) 
    650719        { 
     
    726795 
    727796 
    728 } 
     797void HierarchyManager::FinishObjectSpaceSubdivision() const 
     798{ 
     799        switch (mObjectSpaceSubdivisionType) 
     800        { 
     801        case KD_BASED_OBJ_SUBDIV: 
     802                { 
     803                        mOspTree->mOspStats.Stop(); 
     804                        break; 
     805                } 
     806        case BV_BASED_OBJ_SUBDIV: 
     807                { 
     808                        mBvHierarchy->mBvhStats.Stop(); 
     809                        break; 
     810                } 
     811        default: 
     812                break; 
     813        } 
     814} 
     815 
     816} 
Note: See TracChangeset for help on using the changeset viewer.