Changeset 1727


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

implemented several accelleration svhemes for the gradient method

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/vsposp_typical.env

    r1692 r1727  
    198198 
    199199        # maximum number of tests per node 
    200         maxTests 100000 
     200        maxTests 30000 
    201201} 
    202202 
     
    219219        useCostHeuristics true 
    220220        splitUseOnlyDrivingAxis false 
     221 
     222        maxTests 30000 
    221223} 
    222224 
     
    260262                # minimal steps of same type: for interleaved, this is only valid for the first few splits 
    261263                minStepsOfSameType 100 
     264 
     265                # maximal number of repairs 
     266                maxRepairs 1000 
    262267        } 
    263268 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/vsposp_typical.sh

    r1703 r1727  
    2020#SCENE=vienna 
    2121 
    22 LOG_PREFIX=../scripts/tests/i3d/$SCENE-heur 
     22LOG_PREFIX=../scripts/tests/gi/$SCENE-3 
    2323 
    2424ENVIRONMENT=$SCENE.env 
     
    6161 echo "$SCENE $METHOD" 
    6262 
    63  # $PROGRAM $ENVIRONMENT \ 
     63# $PROGRAM $ENVIRONMENT \ 
    6464  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    6565  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     
    7878 
    7979############################################################################ 
    80 OBJ_SPLITS=3000 
     80OBJ_SPLITS=700 
    8181 
    8282  METHOD=sequential-$OBJ_SPLITS 
    8383  echo "$SCENE $METHOD" 
    8484 
    85  $PROGRAM $ENVIRONMENT \ 
     85  
     86$PROGRAM $ENVIRONMENT \ 
    8687  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    8788  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     
    100101  echo "$SCENE $METHOD" 
    101102 
    102  $PROGRAM $ENVIRONMENT \ 
     103# $PROGRAM $ENVIRONMENT \ 
    103104  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    104105  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     
    112113 
    113114############################################################################ 
    114 OBJ_SPLITS=1000 
     115OBJ_SPLITS=4000 
    115116 
    116117  METHOD=sequential-$OBJ_SPLITS 
    117118  echo "$SCENE $METHOD" 
    118119 
    119  $PROGRAM $ENVIRONMENT \ 
     120# $PROGRAM $ENVIRONMENT \ 
    120121  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    121122  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1723 r1727  
    287287        Environment::GetSingleton()->GetFloatValue( 
    288288                "BvHierarchy.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
    289          
    290289        Environment::GetSingleton()->GetBoolValue( 
    291290                "BvHierarchy.Construction.useGlobalSorting", mUseGlobalSorting); 
    292  
    293291        Environment::GetSingleton()->GetIntValue("BvHierarchy.minRaysForVisibility", mMinRaysForVisibility); 
    294          
     292        Environment::GetSingleton()->GetIntValue("BvHierarchy.maxTests", mMaxTests); 
     293 
    295294        //mUseBboxAreaForSah = false; 
    296295        mUseBboxAreaForSah = true; 
     
    11831182#endif 
    11841183 
    1185         /////////////////////////////////////////////////// 
     1184        /////////////////////// 
    11861185        //-- the sweep heuristics 
    11871186        //-- traverse through events and find best split plane 
     
    13201319 
    13211320 
    1322 float BvHierarchy::PrepareHeuristics(const BvhTraversalData &tData, const int axis) 
     1321float BvHierarchy::PrepareHeuristics(const BvhTraversalData &tData,  
     1322                                                                         const int axis) 
    13231323{        
    13241324        BvhLeaf *leaf = tData.mNode; 
     
    13281328        PrepareLocalSubdivisionCandidates(tData, axis); 
    13291329         
     1330        VssRayContainer rays; 
     1331        rays.reserve(tData.mNumRays); 
     1332        CollectRays(tData.mNode->mObjects, rays); 
     1333 
     1334        const float prop = (float)mMaxTests / (float)tData.mNumRays; 
     1335 
     1336        VssRay::NewMail(); 
     1337 
     1338        // only use a subset of the rays 
     1339        VssRayContainer::const_iterator rit, rit_end = rays.end(); 
     1340 
     1341        for (rit = rays.begin(); rit != rit_end; ++ rit) 
     1342        { 
     1343                if ((mMaxTests >= tData.mNumRays) || (Random(1.0f) < prop)) 
     1344                { 
     1345                        (*rit)->Mail(); 
     1346                } 
     1347        } 
     1348         
    13301349        // collect and mark the view cells as belonging to front pvs 
    13311350        ViewCellContainer viewCells; 
    1332         CollectViewCells(tData.mNode->mObjects, viewCells, true); 
     1351        CollectViewCells(tData.mNode->mObjects, viewCells, true, true); 
    13331352                         
    13341353        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
     
    13611380        const bool useMailboxing = false; 
    13621381 
    1363         CollectViewCells(obj, viewCells, useMailboxing); 
     1382        CollectViewCells(obj, viewCells, useMailboxing, true, true); 
    13641383 
    13651384        // classify view cells and compute volume contri accordingly 
     
    16661685void BvHierarchy::CollectViewCells(const ObjectContainer &objects,  
    16671686                                                                   ViewCellContainer &viewCells, 
    1668                                                                    const bool setCounter) const 
    1669 { 
    1670         // no view cells yet 
    1671         if (0 && mHierarchyManager->GetViewSpaceSubdivisionType() ==  
    1672                 HierarchyManager::NO_VIEWSPACE_SUBDIV) 
    1673                 return; 
    1674  
     1687                                                                   const bool setCounter, 
     1688                                                                   const bool onlyMailedRays) const 
     1689{ 
    16751690        ViewCell::NewMail(); 
    16761691        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
     
    16791694        for (oit = objects.begin(); oit != oit_end; ++ oit) 
    16801695        { 
    1681                 CollectViewCells(*oit, viewCells, true, setCounter); 
     1696                // always use only mailed objects 
     1697                CollectViewCells(*oit, viewCells, true, setCounter, onlyMailedRays); 
    16821698        } 
    16831699} 
     
    16871703                                                                   ViewCellContainer &viewCells, 
    16881704                                                                   const bool useMailBoxing, 
    1689                                                                    const bool setCounter) const 
     1705                                                                   const bool setCounter, 
     1706                                                                   const bool onlyMailedRays) const 
    16901707{ 
    16911708        VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 
     
    16941711        { 
    16951712                VssRay *ray = (*rit); 
     1713 
     1714                if (onlyMailedRays && !ray->Mailed()) 
     1715                        continue; 
     1716 
     1717                ray->Mail(); 
     1718 
    16961719                ViewCellContainer tmpViewCells; 
    1697          
    16981720                mHierarchyManager->mVspTree->GetViewCells(*ray, tmpViewCells); 
    16991721 
     
    17841806        ViewCellContainer viewCells; 
    17851807        ViewCell::NewMail(); 
    1786         CollectViewCells(node->mObjects, viewCells, true); 
     1808        CollectViewCells(node->mObjects, viewCells, true, false); 
    17871809 
    17881810        if (0) cout << "collected " << (int)viewCells.size() << " dirty candidates" << endl; 
     
    19651987 
    19661988        ViewCellContainer viewCells; 
    1967         CollectViewCells(objects, viewCells); 
     1989        // here we have to account for all view cells that can  
     1990        // be seen from the objects 
     1991        CollectViewCells(objects, viewCells, false, false); 
    19681992 
    19691993        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1718 r1727  
    783783        void CollectViewCells(const ObjectContainer &objects,  
    784784                                                  ViewCellContainer &viewCells, 
    785                                                   const bool setCounter = false) const; 
     785                                                  const bool setCounter, 
     786                                                  const bool onlyMailedRays) const; 
    786787 
    787788        /** Counts the view cells of this object. note: only 
     
    799800                                                  ViewCellContainer &viewCells,  
    800801                                                  const bool useMailBoxing, 
    801                                                   const bool setCounter = false) const; 
     802                                                  const bool setCounter, 
     803                                                  const bool onlyMailedRays) const; 
    802804 
    803805        /** Evaluates increase in pvs size. 
     
    951953 
    952954        int mMinRaysForVisibility; 
     955 
     956        int mMaxTests; 
    953957}; 
    954958 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1723 r1727  
    24582458                                   "bvh_use_cost_heuristics=", 
    24592459                                   "true"); 
    2460  
    24612460         
    24622461        RegisterOption("BvHierarchy.useSah", 
     
    24852484                                        "0"); 
    24862485 
     2486        RegisterOption("BvHierarchy.maxTests", 
     2487                                        optInt, 
     2488                                        "bvh_max_tests=", 
     2489                                        "50000"); 
     2490 
    24872491 
    24882492        /*******************************************************************/ 
     
    25742578                                        "hierarchy_construction_levels=", 
    25752579                                        "4"); 
    2576          
     2580 
     2581        RegisterOption("Hierarchy.Construction.maxRepairs", 
     2582                                        optInt, 
     2583                                        "hierarchy_construction_maxRepairs=", 
     2584                                        "1000"); 
     2585 
    25772586        RegisterOption("Hierarchy.Construction.minStepsOfSameType", 
    25782587                                        optInt, 
  • 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(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1723 r1727  
    625625        bool mConsiderMemory2; 
    626626 
     627        int mMaxRepairs; 
     628 
    627629        int mTimeStamp; 
    628630        friend VspTree; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h

    r1695 r1727  
    9393        } 
    9494 
     95        inline bool IsDirty() const 
     96        { 
     97                return mDirty; 
     98        } 
    9599 
    96100        ////////// 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1715 r1727  
    13331333        RayInfoContainer usedRays; 
    13341334 
    1335         if (mMaxTests < rays.size()) 
     1335        if (mMaxTests < (int)rays.size()) 
    13361336        { 
    13371337                GetRayInfoSets(rays, mMaxTests, usedRays); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1715 r1727  
    462462        Environment::GetSingleton()->GetIntValue("VspTree.maxTests", mMaxTests); 
    463463 
    464         Environment::GetSingleton()->GetFloatValue("VspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
     464        Environment::GetSingleton()-> 
     465                GetFloatValue("VspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
    465466         
    466467        // if only the driving axis is used for axis aligned split 
     
    12541255{ 
    12551256        // get subset of rays 
    1256         RayInfoContainer usedRays; 
     1257        RayInfoContainer randomRays; 
     1258        randomRays.reserve(mMaxTests); 
     1259 
     1260        RayInfoContainer *usedRays; 
    12571261 
    12581262        if (mMaxTests < (int)tData.mRays->size()) 
    12591263        { 
    1260                 GetRayInfoSets(*tData.mRays, mMaxTests, usedRays); 
     1264                GetRayInfoSets(*tData.mRays, mMaxTests, randomRays); 
     1265                usedRays = &randomRays; 
    12611266        } 
    12621267        else 
    12631268        { 
    1264                 usedRays = *tData.mRays; 
     1269                usedRays = tData.mRays; 
    12651270        } 
    12661271 
     
    12731278        const float maxBand = minBox + mMaxBand * sizeBox; 
    12741279 
    1275         SortSubdivisionCandidates(usedRays, axis, minBand, maxBand); 
     1280        SortSubdivisionCandidates(*usedRays, axis, minBand, maxBand); 
    12761281 
    12771282        // prepare the sweep 
    12781283        // note: returns pvs size => no need t give pvs size as function parameter 
    1279         const int pvsSize = PrepareHeuristics(usedRays); 
     1284        const int pvsSize = PrepareHeuristics(*usedRays); 
    12801285 
    12811286        // go through the lists, count the number of objects left and right 
Note: See TracChangeset for help on using the changeset viewer.