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/VspTree.cpp

    r1610 r1633  
    694694        if (!LocalTerminationCriteriaMet(tData) && !globalCriteriaMet) 
    695695        {        
     696                /////////// 
    696697                //-- continue subdivision 
     698 
    697699                VspTraversalData tFrontData; 
    698700                VspTraversalData tBackData; 
     
    714716                if (1) EvalSubdivisionStats(*sc); 
    715717                 
     718                ///////////// 
    716719                //-- evaluate new split candidates for global greedy cost heuristics 
    717720 
     
    728731                tQueue.Push(frontCandidate); 
    729732                tQueue.Push(backCandidate); 
    730                  
    731                 // delete old leaf node 
    732                 //DEL_PTR(tData.mNode); 
     733 
     734                // note: leaf is not destroyed because it is needed to collect  
     735                // dirty candidates in hierarchy manager 
    733736        } 
    734737 
     
    825828         
    826829        splitCandidate.SetPriority(priority); 
     830} 
     831 
     832 
     833float VspTree::EvalPriority(const VspSubdivisionCandidate &splitCandidate) const 
     834{ 
     835        // compute global decrease in render cost 
     836        float oldRenderCost; 
     837        const float renderCostDecr = EvalRenderCostDecrease(splitCandidate.mSplitPlane,  
     838                                                                                                                splitCandidate.mParentData, 
     839                                                                                                                oldRenderCost); 
     840     
     841#if 0 
     842        const float priority = (float)-splitCandidate.mParentData.mDepth; 
     843#else 
     844        // take render cost of node into account  
     845        // otherwise danger of being stuck in a local minimum!! 
     846        const float factor = mRenderCostDecreaseWeight; 
     847        const float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
     848#endif 
     849         
     850        return priority; 
    827851} 
    828852 
     
    28722896void VspTree::CollectDirtyCandidate(const VssRay &ray,  
    28732897                                                                        const bool isTermination, 
    2874                                                                         vector<SubdivisionCandidate *> &dirtyList) const 
     2898                                                                        vector<SubdivisionCandidate *> &dirtyList, 
     2899                                                                        const bool onlyUnmailed) const 
    28752900{ 
    28762901 
     
    28822907         
    28832908        if (!obj) return; 
    2884  
     2909         
     2910        SubdivisionCandidate *candidate = NULL; 
     2911                 
    28852912        switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 
    28862913        { 
     
    28922919                        { 
    28932920                                leaf->Mail(); 
    2894                                 dirtyList.push_back(leaf->mSubdivisionCandidate); 
     2921                                candidate = leaf->mSubdivisionCandidate; 
    28952922                        } 
    28962923                        break; 
     
    29032930                        { 
    29042931                                leaf->Mail(); 
    2905                                  // a candidate still attached to this node 
    2906                                 if (leaf->GetSubdivisionCandidate()) 
    2907                                 { 
    2908                                         dirtyList.push_back(leaf->GetSubdivisionCandidate()); 
    2909                                 } 
     2932                                candidate = leaf->GetSubdivisionCandidate(); 
    29102933                        } 
    29112934                        break; 
    29122935                } 
    29132936        default: 
     2937                cerr << "not implemented yet" << endl; 
     2938                candidate = NULL; 
    29142939                break; 
    29152940        } 
     2941 
     2942        // is this leaf still a split candidate? 
     2943        if (candidate && (!onlyUnmailed || !candidate->Mailed())) 
     2944        { 
     2945                candidate->Mail(); 
     2946                dirtyList.push_back(candidate); 
     2947        } 
    29162948} 
    29172949 
    29182950 
    29192951void VspTree::CollectDirtyCandidates(VspSubdivisionCandidate *sc,  
    2920                                                                          vector<SubdivisionCandidate *> &dirtyList) 
     2952                                                                         vector<SubdivisionCandidate *> &dirtyList, 
     2953                                                                         const bool onlyUnmailed) 
    29212954{ 
    29222955        VspTraversalData &tData = sc->mParentData; 
     
    29332966                VssRay *ray = (*rit).mRay; 
    29342967                 
    2935                 CollectDirtyCandidate(*ray, true, dirtyList); 
    2936                 CollectDirtyCandidate(*ray, false, dirtyList); 
     2968                CollectDirtyCandidate(*ray, true, dirtyList, onlyUnmailed); 
     2969        CollectDirtyCandidate(*ray, false, dirtyList, onlyUnmailed); 
    29372970        } 
    29382971} 
Note: See TracChangeset for help on using the changeset viewer.