Ignore:
Timestamp:
11/09/06 03:35:58 (18 years ago)
Author:
mattausch
Message:

implemented several accelleration svhemes for the gradient method

File:
1 edited

Legend:

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

    r1723 r1727  
    149149                "Hierarchy.Termination.maxMemory", mTermMaxMemory); 
    150150 
     151        Environment::GetSingleton()->GetIntValue( 
     152                "Hierarchy.Construction.maxRepairs", mMaxRepairs); 
     153 
    151154        if (1 && mConsiderMemory2) 
    152155        { 
     
    177180        Debug << "min steps of same kind: " << mMinStepsOfSameType << endl; 
    178181        Debug << "max steps of same kind: " << mMaxStepsOfSameType << endl; 
     182        Debug << "max repairs: " << mMaxRepairs << endl; 
    179183 
    180184        switch (mConstructionType) 
     
    418422        const int maxSteps = mMaxStepsOfSameType; 
    419423 
    420         SubdivisionCandidate *osc = PrepareObjectSpaceSubdivision(sampleRays, objects); 
     424        SubdivisionCandidate *osc =  
     425                PrepareObjectSpaceSubdivision(sampleRays, objects); 
    421426        objectSpaceQueue.Push(osc); 
    422  
    423427 
    424428        ///////////////////////// 
     
    430434        // for first round, use sah splits. Once view space partition 
    431435        // has started, use render cost heuristics instead 
    432         ospSteps = RunConstruction(objectSpaceQueue, dirtyList, NULL, minSteps, maxSteps); 
     436        ospSteps = RunConstruction(objectSpaceQueue,  
     437                                                           dirtyList,  
     438                                                           NULL,  
     439                                                           minSteps,  
     440                                                           maxSteps); 
     441 
    433442        cout << "\n" << ospSteps << " object space partition steps taken" << endl; 
    434443 
     
    474483        { 
    475484                // decide upon next split type 
     485                if (viewSpaceQueue.Top()->IsDirty()) 
     486                        viewSpaceQueue.Top()->EvalCandidate(); 
     487 
     488                if (objectSpaceQueue.Top()->IsDirty()) 
     489                        objectSpaceQueue.Top()->EvalCandidate(); 
     490 
    476491                const float vspPriority = viewSpaceQueue.Top() ? viewSpaceQueue.Top()->GetPriority() : -1e20f; 
    477492                const float ospPriority = objectSpaceQueue.Top() ? objectSpaceQueue.Top()->GetPriority() : -1e20f; 
     
    489504                        SubdivisionCandidateContainer dirtyVspList; 
    490505 
    491                         // subdivide object space first 
    492                         // for first round, use sah splits. Once view space partition 
     506                        // subdivide object space first for first round,  
     507                        // use sah splits. Once view space partition 
    493508                        // has started, use render cost heuristics instead 
    494                         const int ospSteps =  
    495                                 RunConstruction(objectSpaceQueue, dirtyVspList, viewSpaceQueue.Top(), minSteps, maxSteps); 
     509                        const int ospSteps = RunConstruction(objectSpaceQueue,  
     510                                                                                                 dirtyVspList,  
     511                                                                                                 viewSpaceQueue.Top(),  
     512                                                                                                 minSteps,  
     513                                                                                                 maxSteps); 
    496514 
    497515                        cout << "\n" << ospSteps << " object space partition steps taken" << endl; 
     
    501519                        cout << "repairing queue ... " << endl; 
    502520                        RepairQueue(dirtyVspList, viewSpaceQueue, true); 
     521             
    503522                        cout << "\nrepaired " << (int)dirtyVspList.size() << " candidates" << endl; 
    504523                } 
     
    515534 
    516535                        // process view space candidates 
    517                         const int vspSteps =  
    518                                 RunConstruction(viewSpaceQueue, dirtyOspList, objectSpaceQueue.Top(), minSteps, maxSteps); 
     536                        const int vspSteps = RunConstruction(viewSpaceQueue,  
     537                                                                                                 dirtyOspList,  
     538                                                                                                 objectSpaceQueue.Top(),  
     539                                                                                                 minSteps,  
     540                                                                                                 maxSteps); 
    519541 
    520542                        cout << "\n" << vspSteps << " view space partition steps taken" << endl; 
     
    527549                        cout << "repairing queue ... " << endl; 
    528550                        RepairQueue(dirtyOspList, objectSpaceQueue, true); 
     551 
    529552                        cout << "repaired " << (int)dirtyOspList.size() << " candidates" << endl; 
    530553                } 
     
    965988        while (!splitQueue.Empty()) 
    966989        { 
     990                // reevaluate current candidate 
     991                if (splitQueue.Top()->IsDirty()) 
     992                        splitQueue.Top()->EvalCandidate(); 
     993                 
    967994                const float priority = splitQueue.Top()->GetPriority(); 
    968995                const float threshold = oldCandidate ? oldCandidate->GetPriority() : 1e20f; 
     
    9751002                } 
    9761003                 
    977                 SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue);  
    978                                  
    9791004                //////// 
    9801005                //-- subdivide leaf node of either type 
    9811006 
     1007                SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue);  
     1008                         
    9821009                const bool repairQueue = false; 
    9831010                const bool success = ApplySubdivisionCandidate(sc, splitQueue, repairQueue); 
     
    13231350        const long startTime = GetTime(); 
    13241351        if (0) cout << "repairing " << (int)dirtyList.size() << " candidates ... "; 
    1325          
     1352 
     1353        const float prop = (float)mMaxRepairs / (float)dirtyList.size(); 
    13261354 
    13271355        /////////////////////////// 
     
    13321360        for (sit = dirtyList.begin(); sit != sit_end; ++ sit) 
    13331361        { 
     1362                // only repair a certain number of candidates 
     1363                if ((mMaxRepairs < (int)dirtyList.size()) && (Random(1.0f) >= prop)) 
     1364                        continue; 
     1365 
    13341366                SubdivisionCandidate* sc = *sit; 
    13351367                const float rcd = sc->GetRenderCostDecrease(); 
Note: See TracChangeset for help on using the changeset viewer.