Ignore:
Timestamp:
10/17/06 20:32:06 (18 years ago)
Author:
mattausch
Message:

worked on gradient method for vsposp

File:
1 edited

Legend:

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

    r1624 r1633  
    509509 
    510510        const float renderCostDecr = oldRenderCost - newRenderCost; 
    511         const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate); 
    512  
     511         
    513512#ifdef _DEBUG 
    514513        Debug << "old render cost: " << oldRenderCost << endl; 
     
    516515        Debug << "render cost decrease: " << renderCostDecr << endl; 
    517516#endif 
    518  
    519         splitCandidate.SetRenderCostDecrease(renderCostDecr); 
    520         splitCandidate.SetPvsEntriesIncr(EvalPvsEntriesIncr(splitCandidate)); 
    521517 
    522518#if 1 
     
    529525#endif 
    530526 
     527        splitCandidate.SetRenderCostDecrease(renderCostDecr); 
     528 
     529        // increase in pvs entries 
     530        const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate); 
     531        splitCandidate.SetPvsEntriesIncr(pvsEntriesIncr); 
     532 
    531533        // compute global decrease in render cost 
    532534        splitCandidate.SetPriority(priority); 
     535} 
     536 
     537 
     538float BvHierarchy::EvalPriority(const BvhSubdivisionCandidate &splitCandidate) const 
     539{ 
     540        BvhLeaf *leaf = splitCandidate.mParentData.mNode; 
     541 
     542        const float oldRenderCost = EvalRenderCost(leaf->mObjects); 
     543 
     544        // compute global decrease in render cost 
     545        const float newRenderCost =  
     546                EvalRenderCost(splitCandidate.mFrontObjects) + 
     547                EvalRenderCost(splitCandidate.mBackObjects); 
     548 
     549        const float renderCostDecr = oldRenderCost - newRenderCost; 
     550 
     551#ifdef _DEBUG 
     552        Debug << "old render cost: " << oldRenderCost << endl; 
     553        Debug << "new render cost: " << newRenderCost << endl; 
     554        Debug << "render cost decrease: " << renderCostDecr << endl; 
     555#endif 
     556 
     557#if 1 
     558        // take render cost of node into account  
     559        // otherwise danger of being stuck in a local minimum!! 
     560        const float factor = mRenderCostDecreaseWeight; 
     561        const float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
     562#else 
     563        const float priority = (float)-splitCandidate.mParentData.mDepth; 
     564#endif 
     565 
     566        return priority; 
    533567} 
    534568 
     
    569603                ); 
    570604 
    571         if (1 && terminationCriteriaMet) 
     605#ifdef _DEBUG 
     606        if (terminationCriteriaMet) 
    572607        { 
    573608                Debug << "bvh global termination criteria met:" << endl; 
     
    575610                Debug << "leaves: " << mBvhStats.Leaves() << " " << mTermMaxLeaves << endl; 
    576611        } 
    577  
     612#endif 
    578613        return terminationCriteriaMet;  
    579614} 
     
    15291564 
    15301565void BvHierarchy::CollectDirtyCandidates(BvhSubdivisionCandidate *sc,  
    1531                                                                                  vector<SubdivisionCandidate *> &dirtyList) 
     1566                                                                                 vector<SubdivisionCandidate *> &dirtyList,  
     1567                                                                                 const bool onlyUnmailed) 
    15321568{ 
    15331569        BvhTraversalData &tData = sc->mParentData; 
     
    15351571         
    15361572        ViewCellContainer viewCells; 
    1537         CollectViewCells(node->mObjects, viewCells); 
     1573        ViewCell::NewMail(); 
     1574        CollectViewCells(node->mObjects, viewCells, true); 
     1575 
    15381576        if (0) cout << "collected " << (int)viewCells.size() << " dirty candidates" << endl; 
    1539  
     1577         
    15401578        // split candidates handling  
    15411579        // these view cells  are thrown into dirty list 
     
    15441582        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    15451583        { 
    1546                 VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit); 
     1584        VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit); 
    15471585                VspLeaf *leaf = vc->mLeaves[0]; 
     1586         
    15481587                SubdivisionCandidate *candidate = leaf->GetSubdivisionCandidate(); 
    15491588                 
    1550                 if (candidate) // is this leaf still a split candidate? 
    1551                 { 
     1589                // is this leaf still a split candidate? 
     1590                if (candidate && (!onlyUnmailed || !candidate->Mailed())) 
     1591                { 
     1592                        candidate->Mail(); 
    15521593                        dirtyList.push_back(candidate); 
    15531594                } 
Note: See TracChangeset for help on using the changeset viewer.