Ignore:
Timestamp:
10/23/06 01:36:17 (18 years ago)
Author:
mattausch
Message:

changed priority computation:
taking ratio render cost decrease / pvs size increase rather
then render cost decrease alone
this should rather emphasise object space splits, as they
seem to cost less memory.

File:
1 edited

Legend:

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

    r1663 r1664  
    2525#define PROBABILIY_IS_BV_VOLUME 1 
    2626#define USE_FIXEDPOINT_T 0 
    27  
    2827#define USE_VOLUMES_FOR_HEURISTICS 1 
    29  
    30 #define CONSIDER_MEMORY 1 
    3128 
    3229int BvhNode::sMailId = 10000; //2147483647; 
     
    429426                         
    430427                // create new interior node and two leaf node 
    431                 currentNode = SubdivideNode( 
    432                         *sc,  
    433                         tFrontData,  
    434                         tBackData); 
     428                currentNode = SubdivideNode(*sc, tFrontData, tBackData); 
    435429         
    436430                // decrease the weighted average cost of the subdivisoin 
     
    457451                tBackData.mNode->SetSubdivisionCandidate(backCandidate); 
    458452 
     453                //cout << "f: " << frontCandidate->GetPriority() << " b: " << backCandidate->GetPriority() << endl; 
    459454                tQueue.Push(frontCandidate); 
    460455                tQueue.Push(backCandidate); 
     
    466461        if (currentNode->IsLeaf()) 
    467462        { 
    468                 ////////////////////////////////////// 
     463                ///////////////////// 
    469464                //-- store additional info 
    470465                EvaluateLeafStats(tData); 
     
    530525#endif 
    531526 
    532 #if 1 
    533527        float priority; 
    534          
     528 
    535529        if (mHierarchyManager->GetViewSpaceSubdivisionType() ==  
    536530                HierarchyManager::NO_VIEWSPACE_SUBDIV) 
     
    551545                // take render cost of node into account  
    552546                // otherwise danger of being stuck in a local minimum!! 
    553                 #if CONSIDER_MEMORY 
    554                         const float priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr(); 
    555                 #else 
    556                         const float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
    557                 #endif 
    558         } 
    559  
    560 #else 
    561         const float priority = (float)-splitCandidate.mParentData.mDepth; 
    562 #endif 
     547                if (mHierarchyManager->mConsiderMemory) 
     548                { 
     549                        //cout << "here7 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 
     550                        //priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr();// / mBvhStats.Leaves(); 
     551                        priority = renderCostDecr / ((float)splitCandidate.GetPvsEntriesIncr() + 1.0f); 
     552                } 
     553                else 
     554                { 
     555                        priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
     556                } 
     557        } 
     558 
     559        // compute global decrease in render cost 
     560        splitCandidate.SetPriority(priority); 
     561} 
     562 
     563 
     564float BvHierarchy::EvalPriority(const BvhSubdivisionCandidate &splitCandidate) const 
     565{ 
     566        BvhLeaf *leaf = splitCandidate.mParentData.mNode; 
     567 
     568        const float oldRenderCost = EvalRenderCost(leaf->mObjects); 
    563569 
    564570        // compute global decrease in render cost 
    565         splitCandidate.SetPriority(priority); 
    566 } 
    567  
    568  
    569 float BvHierarchy::EvalPriority(const BvhSubdivisionCandidate &splitCandidate) const 
    570 { 
    571         BvhLeaf *leaf = splitCandidate.mParentData.mNode; 
    572  
    573         const float oldRenderCost = EvalRenderCost(leaf->mObjects); 
    574  
    575         // compute global decrease in render cost 
    576         const float newRenderCost =  
    577                 EvalRenderCost(splitCandidate.mFrontObjects) + 
    578                 EvalRenderCost(splitCandidate.mBackObjects); 
     571        const float newRenderCost = EvalRenderCost(splitCandidate.mFrontObjects) + 
     572                                                                EvalRenderCost(splitCandidate.mBackObjects); 
    579573 
    580574        const float renderCostDecr = oldRenderCost - newRenderCost; 
     
    586580#endif 
    587581 
    588 #if 1 
    589582        // take render cost of node into account  
    590583        // otherwise danger of being stuck in a local minimum!! 
    591584        const float factor = mRenderCostDecreaseWeight; 
     585         
     586        float priority; 
     587 
    592588        // $$ matt temp 
    593 #if CONSIDER_MEMORY 
    594         const float priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr(); 
    595 #else 
    596         const float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
    597 #endif 
    598 #else 
    599         const float priority = (float)-splitCandidate.mParentData.mDepth; 
    600 #endif 
     589        if (mHierarchyManager->mConsiderMemory) 
     590        { 
     591                //cout << "here5 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 
     592                //const float priority = factor * renderCostDecr - (1.0f - factor) * (float)splitCandidate.GetPvsEntriesIncr(); 
     593                priority = renderCostDecr / ((float)splitCandidate.GetPvsEntriesIncr() + 1.0f); 
     594        } 
     595        else 
     596        { 
     597                priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
     598        } 
    601599 
    602600        return priority; 
     
    620618                        || ((int)data.mNode->mObjects.size() <= mTermMinObjects) 
    621619                        //|| (data.mProbability <= mTermMinProbability) 
    622                         //|| (data.mNumRays <= mTermMinRays) 
     620                        || (data.mNumRays <= mTermMinRays) 
    623621                 ); 
    624622} 
     
    952950        cout << "\n\nobjects=(" << (int)objectsBack.size() << "," << (int)objectsFront.size() << " of "  
    953951                 << (int)tData.mNode->mObjects.size() << ")\t area=("  
    954                  << areaLeft << "," << areaRight << ")" << endl; 
    955         cout << "cost= " << minSum << endl; 
     952                 << areaLeft << "," << areaRight << ")" << endl 
     953                << "cost= " << minSum << endl; 
    956954#endif 
     955 
    957956  return ratio; 
    958957} 
Note: See TracChangeset for help on using the changeset viewer.