Changeset 1288


Ignore:
Timestamp:
08/28/06 03:42:51 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj

    r1276 r1288  
    8787                                OmitFramePointers="TRUE" 
    8888                                EnableFiberSafeOptimizations="TRUE" 
    89                                 OptimizeForProcessor="3" 
     89                                OptimizeForProcessor="0" 
    9090                                OptimizeForWindowsApplication="TRUE" 
    9191                                AdditionalIncludeDirectories=""$(OGRE_PATH)\PlugIns\OctreeSceneManager\include";"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\Dependencies\include\CEGUI";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include";"$(OGRE_PATH)\OgreMain\include";"$(OGRE_PATH)\Dependencies\include";..\include;..\..\..\OnlineCullingCHC\include;..\..\..\Preprocessing\src" 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj

    r1239 r1288  
    6262                        <Tool 
    6363                                Name="VCCLCompilerTool" 
     64                                GlobalOptimizations="TRUE" 
     65                                FavorSizeOrSpeed="1" 
     66                                OmitFramePointers="TRUE" 
    6467                                OptimizeForWindowsApplication="TRUE" 
    6568                                AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\Preprocessing\src" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1287 r1288  
    196196 
    197197        //-- termination criteria for autopartition 
    198         Environment::GetSingleton()->GetIntValue("OspTree.Termination.maxDepth", mTermMaxDepth); 
    199         Environment::GetSingleton()->GetIntValue("OspTree.Termination.maxLeaves", mTermMaxLeaves); 
    200         Environment::GetSingleton()->GetIntValue("OspTree.Termination.minObjects", mTermMinObjects); 
    201         Environment::GetSingleton()->GetFloatValue("OspTree.Termination.minProbability", mTermMinProbability); 
    202          
    203         Environment::GetSingleton()->GetIntValue("OspTree.Termination.missTolerance", mTermMissTolerance); 
     198        Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.maxDepth", mTermMaxDepth); 
     199        Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.maxLeaves", mTermMaxLeaves); 
     200        Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.minObjects", mTermMinObjects); 
     201        Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.minProbability", mTermMinProbability); 
     202         
     203        Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.missTolerance", mTermMissTolerance); 
    204204         
    205205        //-- max cost ratio for early tree termination 
    206         Environment::GetSingleton()->GetFloatValue("OspTree.Termination.maxCostRatio", mTermMaxCostRatio); 
    207  
    208         Environment::GetSingleton()->GetFloatValue("OspTree.Termination.minGlobalCostRatio", 
     206        Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.maxCostRatio", mTermMaxCostRatio); 
     207 
     208        Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.minGlobalCostRatio", 
    209209                mTermMinGlobalCostRatio); 
    210          
     210        Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 
    211211 
    212212        //-- factors for bsp tree split plane heuristics 
    213         Environment::GetSingleton()->GetFloatValue("OspTree.Termination.ct_div_ci", mCtDivCi); 
     213        Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.ct_div_ci", mCtDivCi); 
    214214 
    215215        //-- partition criteria 
    216         Environment::GetSingleton()->GetFloatValue("OspTree.Construction.epsilon", mEpsilon); 
     216        Environment::GetSingleton()->GetFloatValue("BvHierarchy.Construction.epsilon", mEpsilon); 
    217217 
    218218        // if only the driving axis is used for axis aligned split 
    219         Environment::GetSingleton()->GetBoolValue("OspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
    220         Environment::GetSingleton()->GetFloatValue("OspTree.maxStaticMemory", mMaxMemory); 
    221         Environment::GetSingleton()->GetBoolValue("OspTree.useCostHeuristics", mUseCostHeuristics); 
     219        Environment::GetSingleton()->GetBoolValue("BvHierarchy.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
     220        Environment::GetSingleton()->GetFloatValue("BvHierarchy.maxStaticMemory", mMaxMemory); 
     221        Environment::GetSingleton()->GetBoolValue("BvHierarchy.useCostHeuristics", mUseCostHeuristics); 
    222222 
    223223 
    224224        char subdivisionStatsLog[100]; 
    225         Environment::GetSingleton()->GetStringValue("OspTree.subdivisionStats", subdivisionStatsLog); 
     225        Environment::GetSingleton()->GetStringValue("BvHierarchy.subdivisionStats", subdivisionStatsLog); 
    226226        mSubdivisionStats.open(subdivisionStatsLog); 
    227227 
    228         Environment::GetSingleton()->GetFloatValue("OspTree.Construction.splitBorder", mSplitBorder); 
    229         Environment::GetSingleton()->GetFloatValue("OspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
     228        Environment::GetSingleton()->GetFloatValue("BvHierarchy.Construction.splitBorder", mSplitBorder); 
     229        Environment::GetSingleton()->GetFloatValue( 
     230                "BvHierarchy.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
    230231         
    231232 
     
    279280        // add the new nodes to the tree 
    280281        BvhInterior *node = new BvhInterior(tData.mBoundingBox, leaf->GetParent()); 
    281  
    282         cout << "here55 " << tData.mBoundingBox << " | " << node->GetBoundingBox() << endl; 
     282        //cout << "bbox: " << tData.mBoundingBox << endl; 
     283 
    283284 
    284285        //-- the front and back traversal data is filled with the new values 
     
    288289        frontData.mBoundingBox = ComputeBoundingBox(frontObjects, &(tData.mBoundingBox)); 
    289290        backData.mBoundingBox = ComputeBoundingBox(backObjects, &(tData.mBoundingBox)); 
    290         //RemoveParentViewCellsPvs(leaf, *tData.mRays); 
    291  
     291         
    292292        ///////////// 
    293293        //-- create front and back leaf 
     
    317317        ++ mBvhStats.splits; 
    318318 
    319         //UpdateViewCellsPvs(front, *frontData.mRays); 
    320         //UpdateViewCellsPvs(back, *backData.mRays); 
    321319 
    322320        //////////////////////////////////// 
    323  
    324         //ProcessMultipleRefs(front); 
    325     //ProcessMultipleRefs(back); 
    326321 
    327322        frontData.mNode = front; 
     
    346341                                                                const bool globalCriteriaMet) 
    347342{ 
    348         BvhSubdivisionCandidate *sc = dynamic_cast<BvhSubdivisionCandidate *>(splitCandidate); 
     343        BvhSubdivisionCandidate *sc =  
     344                dynamic_cast<BvhSubdivisionCandidate *>(splitCandidate); 
    349345        BvhTraversalData &tData = sc->mParentData; 
    350346 
     
    410406        } 
    411407         
    412         //-- cleanup 
    413         tData.Clear(); 
     408        tData.Clear(); // cleanup 
    414409         
    415410        return newNode; 
     
    425420                                                        splitCandidate.mBackObjects); 
    426421         
    427         const bool success = ratio < mTermMaxCostRatio; 
    428  
    429422        BvhLeaf *leaf = splitCandidate.mParentData.mNode; 
    430423 
     424        // cost ratio violated? 
     425        const bool maxCostRatioViolated = ratio < mTermMaxCostRatio; 
     426 
     427        splitCandidate.mMaxCostMisses = maxCostRatioViolated ?  
     428                splitCandidate.mParentData.mMaxCostMisses :  
     429                splitCandidate.mParentData.mMaxCostMisses + 1; 
     430 
    431431        const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 
    432  
    433432        const float oldRenderCost =  
    434433                splitCandidate.mParentData.mProbability * (float)leaf->mObjects.size() / viewSpaceVol; 
     
    443442        const float renderCostDecr = oldRenderCost - newRenderCost; 
    444443 
    445         Debug << "!!render cost decr: " << renderCostDecr << endl; 
     444        //Debug << "render cost decr: " << renderCostDecr << endl; 
    446445        splitCandidate.SetRenderCostDecrease(renderCostDecr); 
    447446 
     
    458457        // compute global decrease in render cost 
    459458        splitCandidate.SetPriority(priority); 
    460  
    461         splitCandidate.mMaxCostMisses =  
    462                 success ? splitCandidate.mParentData.mMaxCostMisses :  
    463         splitCandidate.mParentData.mMaxCostMisses + 1; 
    464459} 
    465460 
     
    468463{ 
    469464        // matt: TODO 
    470         return (  
    471                 //(data.mNode->mObjects.size() < mTermMinObjects) || 
    472                 //(data.mProbability <= mTermMinProbability) || 
    473                 (data.mDepth >= mTermMaxDepth) 
     465        return ( 0 
     466                || (data.mNode->mObjects.size() < mTermMinObjects) 
     467                || (data.mProbability <= mTermMinProbability) 
     468                || (data.mDepth >= mTermMaxDepth) 
    474469                 ); 
    475470} 
     
    479474{ 
    480475        // matt: TODO 
    481         return ( 
    482                 (mBvhStats.Leaves() >= mTermMaxLeaves) 
    483                 //mOutOfMemory ||  
    484                 //(mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
     476        return (0 
     477                || (mBvhStats.Leaves() >= mTermMaxLeaves) 
     478                || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
     479                //|| mOutOfMemory  
    485480                ); 
    486481} 
     
    498493        ++ mBvhStats.maxDepthNodes; 
    499494                //Debug << "new max depth: " << mVspStats.maxDepthNodes << endl; 
     495        } 
     496 
     497        if (data.mDepth < mTermMaxDepth) 
     498        { 
     499        ++ mBvhStats.minDepthNodes; 
    500500        } 
    501501 
     
    506506        mBvhStats.accumDepth += data.mDepth; 
    507507  
    508         //      if ((int)(leaf->mObjects.size()) < mTermMinCost) 
    509         //     ++ mOspStats.minCostNodes; 
     508        if ((int)(leaf->mObjects.size()) < mTermMinObjects) 
     509             ++ mBvhStats.minObjectsNodes; 
    510510  
    511511        if ((int)(leaf->mObjects.size()) > mBvhStats.maxObjectRefs) 
     
    914914 
    915915 
    916 void BvHierarchy::ClassifyViewCells(const ViewCellContainer &viewCells,  
    917                                                                         const bool isFront) const 
    918 { 
    919         int mailed = 0; 
    920         ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    921  
    922         // mail view cell 
    923         for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    924         { 
    925                 ViewCell *vc = *vit; 
    926  
    927                 if (isFront) 
    928                 { 
    929                         if (!vc->Mailed()) 
    930                         { 
    931                                 vc->Mail(); 
    932                                 //Debug << " " << vc->mMailBox << endl; 
    933                                 ++ mailed; 
    934                         } 
    935                 } 
    936                 else 
    937                 { 
    938                         if (vc->Mailed()) 
    939                         { 
    940                                 vc->Mail(2); 
    941                                 //Debug << " " << vc->mMailBox << endl; 
    942                                 ++ mailed; 
    943                         } 
    944                         else if (!vc->Mailed(1) && !vc->Mailed(2)) 
    945                         { 
    946                                 vc->Mail(1); 
    947                                 //Debug << " " << vc->mMailBox << endl; 
    948                                 ++ mailed; 
    949                         } 
    950  
    951                 } 
    952         }                                
    953  
    954         Debug << "mailed " << mailed << " view cells " << endl; 
    955 } 
    956  
    957  
    958916float BvHierarchy::EvalRenderCost(const BvhTraversalData &tData, 
    959917                                                                  const ObjectContainer &objectsFront, 
     
    982940        return newRenderCost; 
    983941} 
    984  
    985  
    986 /*float BvHierarchy::EvalRenderCostDecrease(const BvhTraversalData &tData, 
    987                                                                                   const ObjectContainer &objectsFront, 
    988                                                                                   const ObjectContainer &objectsBack, 
    989                                                                                   float &normalizedOldRenderCost) const 
    990 { 
    991         BvhLeaf *leaf = tData.mNode; 
    992  
    993         // probability that view point lies in a view cell which sees this node 
    994         float pOverall = 0; 
    995         float pFront = 0; 
    996         float pBack = 0; 
    997         float pFrontAndBack = 0; 
    998  
    999         const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 
    1000          
    1001         ViewCellContainer collectedViewCells; 
    1002         ViewCellContainer viewCellsFront, viewCellsBack; 
    1003  
    1004         // the view cells seen from the front bv 
    1005          
    1006     CollectViewCells(objectsFront, viewCellsFront); 
    1007         // the view cells seen from the back bv 
    1008         CollectViewCells(objectsBack, viewCellsBack); 
    1009         // the view cells seen from both bvs 
    1010         // note: could be evaluated simpler 
    1011         CollectViewCells(leaf->mObjects, collectedViewCells); 
    1012  
    1013  
    1014         // sum up volume seen from the objects of left and right children 
    1015         // => the volume is the weight for the render cost equation 
    1016          
    1017         ViewCell::NewMail(3); 
    1018         ClassifyViewCells(viewCellsFront, true); 
    1019         ClassifyViewCells(viewCellsBack, false); 
    1020  
    1021         ViewCellContainer::const_iterator vit, vit_end = collectedViewCells.end(); 
    1022  
    1023         // evaluate view cells volume contribution with respect to the mail id 
    1024         for (vit = collectedViewCells.begin(); vit != vit_end; ++ vit) 
    1025         { 
    1026                 ViewCell *vc = *vit; 
    1027                 if (vc->Mailed()) 
    1028                         pFront += vc->GetVolume(); 
    1029                 else if (vc->Mailed(1)) 
    1030                         pBack += vc->GetVolume(); 
    1031                 else if (vc->Mailed(2)) 
    1032                         pFrontAndBack += vc->GetVolume(); 
    1033         } 
    1034  
    1035         const int totalObjects = (int)leaf->mObjects.size(); 
    1036         const int nObjectsFront = (int)objectsFront.size(); 
    1037         const int nObjectsBack = (int)objectsBack.size(); 
    1038  
    1039         // these are non-overlapping sets 
    1040         pOverall = pFront + pBack + pFrontAndBack; 
    1041  
    1042         //-- pvs rendering heuristics 
    1043         const float oldRenderCost = pOverall * totalObjects; 
    1044         const float newRenderCost = nObjectsFront * pFront +  
    1045                                                                 nObjectsBack * pBack +  
    1046                                                                 totalObjects * pFrontAndBack; 
    1047  
    1048         // normalize volume with view space volume 
    1049         const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol; 
    1050  
    1051         Debug << "\n(((( eval render cost decrease ))))" << endl 
    1052                   << "back objects: " << nObjectsBack << " front objects " << nObjectsFront << " total objects: " << totalObjects << endl  
    1053                   << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol  
    1054                   << " front and back p " << pFrontAndBack / viewSpaceVol << " p: " << pOverall / viewSpaceVol << endl 
    1055                   << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl 
    1056                   << "render cost decrease: " << renderCostDecrease << endl; 
    1057  
    1058         normalizedOldRenderCost = oldRenderCost / viewSpaceVol; 
    1059  
    1060         return renderCostDecrease; 
    1061 }*/ 
    1062942 
    1063943 
     
    14691349#endif 
    14701350 
    1471         // create osp traversal data 
     1351        // create bvh traversal data 
    14721352        BvhTraversalData oData(bvhleaf, 0, mBoundingBox, prop); 
    14731353 
     
    15031383void BvhStatistics::Print(ostream &app) const 
    15041384{ 
    1505         app << "=========== OspTree statistics ===============\n"; 
     1385        app << "=========== BvHierarchy statistics ===============\n"; 
    15061386 
    15071387        app << setprecision(4); 
     
    15171397        app << "#AXIS_ALIGNED_SPLITS (number of axis aligned splits)\n" << splits << endl; 
    15181398 
    1519          
     1399        app << "#N_PMINDEPTHLEAVES ( Percentage of leaves at minimum depth )\n"  
     1400                <<      minDepthNodes * 100 / (double)Leaves() << endl; 
     1401 
    15201402        app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maximum depth )\n"  
    15211403                <<      maxDepthNodes * 100 / (double)Leaves() << endl; 
    15221404 
    1523         app << "#N_PMINPVSLEAVES  ( Percentage of leaves with mininimal PVS )\n"  
    1524                 << minPvsNodes * 100 / (double)Leaves() << endl; 
    1525  
    15261405        app << "#N_MAXCOSTNODES  ( Percentage of leaves with terminated because of max cost ratio )\n" 
    15271406                << maxCostNodes * 100 / (double)Leaves() << endl; 
     
    15301409                << minProbabilityNodes * 100 / (double)Leaves() << endl; 
    15311410 
     1411        app << "#N_PMINOBJECTSLEAVES  ( Percentage of leaves with mininum objects )\n" 
     1412                << minObjectsNodes * 100 / (double)Leaves() << endl; 
     1413 
    15321414        app << "#N_PMAXDEPTH ( Maximal reached depth )\n" << maxDepth << endl; 
    15331415 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1287 r1288  
    5555        // minimum depth nodes 
    5656        int minDepthNodes; 
    57         // max depth nodes 
    58         int minPvsNodes; 
    59         // nodes with minimum PVS 
    60         int minRaysNodes; 
    61         // max ray contribution nodes 
    62         int maxRayContribNodes; 
     57        // nodes with minimum objects 
     58        int minObjectsNodes; 
    6359        // minimum area nodes 
    6460        int minProbabilityNodes; 
     
    9995                accumDepth = 0; 
    10096        maxDepthNodes = 0; 
    101                 minPvsNodes = 0; 
    102                 minRaysNodes = 0; 
    103                 maxRayContribNodes = 0; 
     97                minObjectsNodes = 0; 
    10498                minProbabilityNodes = 0; 
    10599                maxCostNodes = 0; 
     
    699693        bool IsObjectInLeaf(BvhLeaf *, Intersectable *object) const; 
    700694 
    701         /** Classifies view cells using the mail id. 
    702                 0 = front bv, 1 = back bv, 2 = both bvs 
    703         */ 
    704         void ClassifyViewCells( 
    705                 const ViewCellContainer &objects,  
    706                 const bool isFront) const; 
    707  
    708695        SubdivisionCandidate *PrepareConstruction( 
    709696                const VssRayContainer &sampleRays, 
    710697                const ObjectContainer &objects 
    711                 //,AxisAlignedBox3 *forcedObjectSpace 
    712698                ); 
    713699 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1287 r1288  
    22372237 
    22382238 
    2239 /***************************************************************************/ 
    2240 /*               Object space partition tree related options               */ 
    2241 /***************************************************************************/ 
    2242  
     2239 
     2240/***********************************************************************/ 
     2241/*           Object space partition tree related options               */ 
     2242/***********************************************************************/ 
    22432243 
    22442244        RegisterOption("OspTree.Construction.randomize", 
    2245                 optBool, 
    2246                 "osp_construction_randomize=", 
    2247                 "false"); 
     2245                                        optBool, 
     2246                                        "osp_construction_randomize=", 
     2247                                        "false"); 
    22482248 
    22492249        RegisterOption("OspTree.Termination.maxDepth", 
     
    22652265                                        optFloat, 
    22662266                                        "osp_term_min_objects=", 
    2267                                         "0.0001"); 
     2267                                        "0.00001"); 
    22682268 
    22692269        RegisterOption("OspTree.Termination.missTolerance", 
    22702270                                        optInt, 
    22712271                                        "osp_term_miss_tolerance=", 
    2272                                         "4"); 
     2272                                        "8"); 
    22732273 
    22742274        RegisterOption("OspTree.Termination.maxCostRatio", 
     
    22932293         
    22942294        RegisterOption("OspTree.Construction.epsilon", 
    2295                                         optFloat, 
    2296                                         "osp_construction_epsilon=", 
    2297                                         "0.00001"); 
     2295                                   optFloat, 
     2296                                   "osp_construction_epsilon=", 
     2297                                   "0.00001"); 
    22982298         
    22992299        // if only the driving axis is used for axis aligned split 
    23002300        RegisterOption("OspTree.splitUseOnlyDrivingAxis",  
    2301                                         optBool,  
    2302                                         "osp_split_only_driving_axis=",  
    2303                                         "false"); 
     2301                                   optBool,  
     2302                                   "osp_split_only_driving_axis=",  
     2303                                   "false"); 
    23042304 
    23052305        RegisterOption("OspTree.maxStaticMemory",  
    2306                 optFloat,  
    2307                 "osp_max_static_mem=",  
    2308                 "8.0"); 
     2306                                   optFloat,  
     2307                                   "osp_max_static_mem=",  
     2308                                   "8.0"); 
    23092309 
    23102310        RegisterOption("OspTree.useCostHeuristics", 
    2311                 optBool, 
    2312                 "osp_use_cost_heuristics=", 
    2313                 "true"); 
     2311                                   optBool, 
     2312                                   "osp_use_cost_heuristics=", 
     2313                                   "true"); 
    23142314 
    23152315        RegisterOption("OspTree.subdivisionStats", 
     
    23242324 
    23252325        RegisterOption("OspTree.Construction.renderCostDecreaseWeight", 
    2326                         optFloat, 
    2327                         "osp_construction_render_cost_decrease_weight=", 
    2328                         "0.99"); 
    2329  
     2326                                   optFloat, 
     2327                                   "osp_construction_render_cost_decrease_weight=", 
     2328                                   "0.99"); 
     2329 
     2330 
     2331 
     2332/***********************************************************************/ 
     2333/*            Bounding Volume Hierarchy related options                */ 
     2334/***********************************************************************/ 
     2335 
     2336        RegisterOption("BvHierarchy.Construction.randomize", 
     2337                                        optBool, 
     2338                                        "bvh_construction_randomize=", 
     2339                                        "false"); 
     2340 
     2341        RegisterOption("BvHierarchy.Termination.maxDepth", 
     2342                                        optInt, 
     2343                                        "bvh_term_max_depth=", 
     2344                                        "30"); 
     2345         
     2346        RegisterOption("BvHierarchy.Termination.maxLeaves", 
     2347                                        optInt, 
     2348                                        "bvh_term_max_leaves=", 
     2349                                        "1000"); 
     2350         
     2351        RegisterOption("BvHierarchy.Termination.minObjects", 
     2352                                        optInt, 
     2353                                        "bvh_term_min_objects=", 
     2354                                        "1"); 
     2355 
     2356        RegisterOption("BvHierarchy.Termination.minProbability", 
     2357                                        optFloat, 
     2358                                        "bvh_term_min_objects=", 
     2359                                        "0.00001"); 
     2360 
     2361        RegisterOption("BvHierarchy.Termination.missTolerance", 
     2362                                        optInt, 
     2363                                        "osp_term_miss_tolerance=", 
     2364                                        "8"); 
     2365 
     2366        RegisterOption("BvHierarchy.Termination.maxCostRatio", 
     2367                                        optFloat, 
     2368                                        "bvh_term_max_cost_ratio=", 
     2369                                        "0.99"); 
     2370 
     2371        RegisterOption("BvHierarchy.Termination.minGlobalCostRatio", 
     2372                                        optFloat, 
     2373                                        "bvh_term_min_global_cost_ratio=", 
     2374                                        "0.00001"); 
     2375 
     2376        RegisterOption("BvHierarchy.Termination.globalCostMissTolerance", 
     2377                                        optInt, 
     2378                                        "bvh_term_global_cost_miss_tolerance=", 
     2379                                        "4"); 
     2380 
     2381        RegisterOption("BvHierarchy.Termination.ct_div_ci", 
     2382                                        optFloat, 
     2383                                        "bvh_term_ct_div_ci=", 
     2384                                        "0"); 
     2385         
     2386        RegisterOption("BvHierarchy.Construction.epsilon", 
     2387                                   optFloat, 
     2388                                   "bvh_construction_epsilon=", 
     2389                                   "0.00001"); 
     2390         
     2391        // if only the driving axis is used for axis aligned split 
     2392        RegisterOption("BvHierarchy.splitUseOnlyDrivingAxis",  
     2393                                   optBool,  
     2394                                   "bvh_split_only_driving_axis=",  
     2395                                   "false"); 
     2396 
     2397        RegisterOption("BvHierarchy.maxStaticMemory",  
     2398                                   optFloat,  
     2399                                   "bvh_max_static_mem=",  
     2400                                   "8.0"); 
     2401 
     2402        RegisterOption("BvHierarchy.useCostHeuristics", 
     2403                                   optBool, 
     2404                                   "bvh_use_cost_heuristics=", 
     2405                                   "true"); 
     2406 
     2407        RegisterOption("BvHierarchy.subdivisionStats", 
     2408                                        optString, 
     2409                                        "bvh_subdivision_stats=", 
     2410                                        "bvhSubdivisionStats.log"); 
     2411 
     2412        RegisterOption("BvHierarchy.Construction.splitBorder", 
     2413                                        optFloat, 
     2414                                        "bvh_construction_split_border=", 
     2415                                        "0.01"); 
     2416 
     2417        RegisterOption("BvHierarchy.Construction.renderCostDecreaseWeight", 
     2418                                   optFloat, 
     2419                                   "bvh_construction_render_cost_decrease_weight=", 
     2420                                   "0.99"); 
     2421 
     2422 
     2423/*******************************************************************/ 
     2424/*               Hierarchy Manager related options                 */ 
     2425/*******************************************************************/ 
    23302426 
    23312427        RegisterOption("Hierarchy.subdivisionStats", 
    2332                                         optString, 
    2333                                         "hierarchy_subdivision_stats=", 
    2334                                         "hierarchySubdivisionStats.log"); 
    2335  
     2428                           optString, 
     2429                                   "hierarchy_subdivision_stats=", 
     2430                                   "hierarchySubdivisionStats.log"); 
     2431 
     2432        RegisterOption("Hierarchy.type", 
     2433                           optString, 
     2434                                   "hierarchy_type=", 
     2435                                   "bvh"); 
     2436 
     2437        RegisterOption("Hierarchy.Termination.minGlobalCostRatio", 
     2438                                        optFloat, 
     2439                                        "hierarchy_term_min_global_cost_ratio=", 
     2440                                        "0.00001"); 
     2441 
     2442        RegisterOption("Hierarchy.Termination.globalCostMissTolerance", 
     2443                                        optInt, 
     2444                                        "hierarchy_term_global_cost_miss_tolerance=", 
     2445                                        "4"); 
     2446 
     2447        RegisterOption("Hierarchy.Termination.maxLeaves", 
     2448                                        optInt, 
     2449                                        "hierarchy_term_max_leaves=", 
     2450                                        "1000"); 
     2451         
    23362452        ////////////////////////////////////////////////////////////////////////////////// 
    23372453} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1287 r1288  
    6262                mVspTree->mHierarchyManager = this; 
    6363 
     64        ParseEnvironment(); 
     65} 
     66 
     67 
     68HierarchyManager::HierarchyManager(VspTree *vspTree, KdTree *kdTree):  
     69mObjectSpaceSubdivisonType(KD_BASED_OBJ_SUBDIV), 
     70mVspTree(vspTree),  
     71mBvHierarchy(NULL) 
     72{ 
     73        mOspTree = new OspTree(*kdTree); 
     74        mOspTree->mVspTree = mVspTree; 
     75 
     76        //mOspTree->mHierarchyManager = this; 
     77        Debug << "creating osp tree" << endl; 
     78 
     79        if (mVspTree) 
     80                mVspTree->mHierarchyManager = this; 
     81 
     82        ParseEnvironment(); 
     83} 
     84 
     85 
     86void HierarchyManager::ParseEnvironment() 
     87{ 
    6488        char subdivisionStatsLog[100]; 
    6589        Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats",  
    6690                subdivisionStatsLog); 
    6791        mSubdivisionStats.open(subdivisionStatsLog); 
    68 } 
    69  
    70  
    71 HierarchyManager::HierarchyManager(VspTree *vspTree, KdTree *kdTree):  
    72 mObjectSpaceSubdivisonType(KD_BASED_OBJ_SUBDIV), 
    73 mVspTree(vspTree),  
    74 mBvHierarchy(NULL) 
    75 { 
    76         mOspTree = new OspTree(*kdTree); 
    77         mOspTree->mVspTree = mVspTree; 
    78  
    79         //mOspTree->mHierarchyManager = this; 
    80         Debug << "creating osp tree" << endl; 
    81  
    82         if (mVspTree) 
    83                 mVspTree->mHierarchyManager = this; 
    84  
    85         char subdivisionStatsLog[100]; 
    86         Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats",  
    87                 subdivisionStatsLog); 
    88         mSubdivisionStats.open(subdivisionStatsLog); 
     92 
     93        Environment::GetSingleton()->GetFloatValue( 
     94                "Hierarchy.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); 
     95        Environment::GetSingleton()->GetIntValue( 
     96                "Hierarchy.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 
     97 
     98        //Debug << "max depth: " << mTermMaxDepth << endl; 
     99        Debug << "min global cost ratio: " << mTermMinGlobalCostRatio << endl; 
     100        Debug << "global cost miss tolerance: " << mTermGlobalCostMissTolerance << endl; 
    89101} 
    90102 
     
    183195bool HierarchyManager::GlobalTerminationCriteriaMet(SubdivisionCandidate *candidate) const 
    184196{ 
    185         // TODO matt: make virtual by creating superclasss for traveral data 
    186         return candidate->GlobalTerminationCriteriaMet(); 
     197        return (0 
     198                || (mHierarchyStats.Leaves() >= mMaxLeaves)  
     199                || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
     200                ||      candidate->GlobalTerminationCriteriaMet() 
     201                ); 
    187202} 
    188203 
     
    200215        mVspTree->mVspStats.Reset(); 
    201216        mVspTree->mVspStats.Start(); 
     217         
     218        mHierarchyStats.Reset(); 
     219        mHierarchyStats.Start(); 
    202220 
    203221        cout << "Constructing view space / object space tree ... \n"; 
     
    222240        { 
    223241                VspNode *n = mVspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 
     242 
     243                if (n->IsLeaf()) // local or global termination criteria failed 
     244                        return false; 
    224245        } 
    225246        else 
     
    228249                { 
    229250                        KdNode *n = mOspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 
     251 
     252                        if (n->IsLeaf()) // local or global termination criteria failed 
     253                                return false; 
    230254                } 
    231255                else if (mObjectSpaceSubdivisonType == BV_BASED_OBJ_SUBDIV) 
    232256                { 
    233257                        BvhNode *n = mBvHierarchy->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 
    234                 } 
    235         } 
    236          
    237         return !globalTerminationCriteriaMet; 
     258                        if (n->IsLeaf()) // local or global termination criteria failed 
     259                                return false; 
     260                } 
     261        } 
     262         
     263        return true;//!globalTerminationCriteriaMet; 
    238264} 
    239265 
     
    241267void HierarchyManager::RunConstruction(const bool repair) 
    242268{ 
    243         int numNodes = 0; 
     269        mHierarchyStats.nodes = 0; 
     270        mGlobalCostMisses = 0; 
    244271 
    245272        while (!FinishedConstruction()) 
     
    252279                const float costRatio = splitCandidate->GetRenderCostDecrease() / mTotalCost; 
    253280 
     281                Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 
    254282                if (costRatio < mTermMinGlobalCostRatio) 
    255283                        ++ mGlobalCostMisses; 
    256          
    257                 /*Debug << "\n**********" << endl 
    258                           << "total cost: " << mTotalCost << " render cost decr: "  
    259                           << splitCandidate->GetRenderCostDecrease()  
    260                           << " cost ratio: " << costRatio << endl << endl;*/ 
    261284 
    262285                //-- subdivide leaf node 
     
    264287                if (ApplySubdivisionCandidate(splitCandidate)) 
    265288                { 
     289                        mHierarchyStats.nodes += 2; 
     290 
    266291                        // subdivision successful 
    267292                        EvalSubdivisionStats(*splitCandidate); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1287 r1288  
    5959 
    6060 
     61 
     62/** View space partition statistics. 
     63*/ 
     64class HierarchyStatistics: public StatisticsBase 
     65{ 
     66public: 
     67 
     68        /// total number of nodes 
     69        int nodes; 
     70                 
     71        /// maximal reached depth 
     72        int maxDepth; 
     73         
     74        /// accumulated depth 
     75        int accumDepth; 
     76 
     77        // Constructor 
     78        HierarchyStatistics()  
     79        { 
     80                Reset(); 
     81        } 
     82 
     83        int Nodes() const {return nodes;} 
     84        int Interior() const { return nodes / 2; } 
     85        int Leaves() const { return (nodes / 2) + 1; } 
     86         
     87        // TODO: computation wrong 
     88        double AvgDepth() const { return accumDepth / (double)Leaves();} 
     89         
     90 
     91        void Reset()  
     92        { 
     93                nodes = 0; 
     94                maxDepth = 0; 
     95                accumDepth = 0; 
     96        } 
     97 
     98 
     99        void Print(ostream &app) const; 
     100 
     101        friend ostream &operator<<(ostream &s, const HierarchyStatistics &stat)  
     102        { 
     103                stat.Print(s); 
     104                return s; 
     105        }  
     106}; 
     107 
     108 
    61109typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue; 
    62110 
     
    213261                const ObjectContainer &objects); 
    214262 
     263        void ParseEnvironment(); 
     264 
     265 
    215266protected: 
    216267 
     
    235286        float mTotalCost; 
    236287 
     288        HierarchyStatistics mHierarchyStats; 
     289 
     290        int mMaxLeaves; 
    237291        ofstream mSubdivisionStats; 
    238292}; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp

    r1287 r1288  
    203203 
    204204        Environment::GetSingleton()->GetFloatValue("OspTree.Construction.splitBorder", mSplitBorder); 
    205         Environment::GetSingleton()->GetFloatValue("OspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
     205        Environment::GetSingleton()->GetFloatValue( 
     206                "OspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
    206207         
    207208 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1287 r1288  
    420420        else 
    421421        { 
    422                 //-- parse type of view cell container 
    423  
     422                // parse type of view cell container 
    424423                Environment::GetSingleton()->GetStringValue("ViewCells.type", buf);              
    425424            mViewCellsManager = CreateViewCellsManager(buf); 
     
    456455 
    457456 
     457HierarchyManager *Preprocessor::CreateHierarchyManager(const char *name) 
     458{ 
     459        HierarchyManager *hierarchyManager; 
     460 
     461        if (strcmp(name, "osp") == 0) 
     462        { 
     463                // HACK for testing if per kd evaluation works!! 
     464                const bool ishack = true; 
     465                if (ishack) 
     466                        hierarchyManager = new HierarchyManager(mVspTree, mKdTree); 
     467                else 
     468                        hierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::KD_BASED_OBJ_SUBDIV); 
     469        } 
     470        else if (strcmp(name, "bvh") == 0) 
     471        { 
     472                hierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::BV_BASED_OBJ_SUBDIV); 
     473        } 
     474 
     475        return hierarchyManager; 
     476} 
     477 
     478 
    458479ViewCellsManager *Preprocessor::CreateViewCellsManager(const char *name) 
    459480{ 
     
    481502        { 
    482503                mVspTree = new VspTree(); 
    483                                  
    484                 // HACK for testing if per kd evaluation works!! 
    485                 const bool ishack = true; 
    486  
    487                 /*if (ishack) 
    488                         mHierarchyManager = new HierarchyManager(mVspTree, mKdTree); 
    489                 else 
    490                         mHierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::KD_BASED_OBJ_SUBDIV); 
    491                 */ 
    492                 mHierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::BV_BASED_OBJ_SUBDIV); 
    493  
     504                char buf[100];           
     505                Environment::GetSingleton()->GetStringValue("Hierarchy.type", buf);      
     506 
     507                HierarchyManager *mHierarchyManager = CreateHierarchyManager(buf); 
    494508                mViewCellsManager = new VspOspViewCellsManager(vcTree, mHierarchyManager); 
    495509        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r1287 r1288  
    149149                                                VssRayContainer &vssRays); 
    150150 
    151   /** Returns a view cells manager with respect to the given name. 
     151  /** Returns a view cells manager of the given name. 
    152152  */ 
    153153  ViewCellsManager *CreateViewCellsManager(const char *name); 
     154  /** Returns a hierarchy manager of the given name. 
     155  */ 
     156  HierarchyManager *CreateHierarchyManager(const char *name); 
    154157    
    155158  GlRendererBuffer *GetRenderer() { return renderer;} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1233 r1288  
    672672 
    673673                // cost ratio of cost decrease / totalCost 
    674                 float costRatio = splitCandidate.GetPriority() / mTotalCost; 
     674                float costRatio = splitCandidate.mRenderCostDecr / mTotalCost; 
    675675 
    676676                //Debug << "cost ratio: " << costRatio << endl; 
    677  
    678677                if (costRatio < mTermMinGlobalCostRatio) 
    679678                        ++ mGlobalCostMisses; 
     
    10411040 
    10421041 
    1043 /* 
    1044 void VspBspTree::EvalSubdivisionCandidate(VspBspTraversalData &tData, 
    1045                                                                         VspBspSubdivisionCandidate &splitData) 
     1042void VspBspTree::EvalSubdivisionCandidate(VspBspSubdivisionCandidate &splitCandidate) 
    10461043{ 
    10471044        VspBspTraversalData frontData; 
    10481045        VspBspTraversalData backData; 
    1049  
    1050         BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 
    1051  
     1046         
     1047        BspLeaf *leaf = dynamic_cast<BspLeaf *>(splitCandidate.mParentData.mNode); 
     1048         
    10521049        // compute locally best split plane 
    1053     bool success = SelectPlane(splitData.mSplitPlane, leaf, tData,  
    1054                                                            frontData, backData, splitData.mSplitAxis); 
    1055  
    1056         // TODO: reuse 
    1057         delete frontData.mGeometry; 
    1058         delete backData.mGeometry; 
    1059          
    1060         // compute global decrease in render cost 
    1061         splitData.mPriority = EvalRenderCostDecrease(splitData.mSplitPlane, tData); 
    1062         splitData.mParentData = tData; 
    1063         splitData.mMaxCostMisses = success ? tData.mMaxCostMisses : tData.mMaxCostMisses + 1; 
    1064 } 
    1065 */ 
    1066  
    1067 void VspBspTree::EvalSubdivisionCandidate(VspBspSubdivisionCandidate &splitCandidate) 
    1068 { 
    1069         VspBspTraversalData frontData; 
    1070         VspBspTraversalData backData; 
    1071          
    1072         BspLeaf *leaf = dynamic_cast<BspLeaf *>(splitCandidate.mParentData.mNode); 
    1073          
    1074         // compute locally best split plane 
    1075     bool success = SelectPlane(splitCandidate.mSplitPlane, leaf, splitCandidate.mParentData,  
    1076                                                            frontData, backData, splitCandidate.mSplitAxis); 
     1050    const bool costRatioViolated =  
     1051                SelectPlane(splitCandidate.mSplitPlane,  
     1052                                        leaf,  
     1053                                        splitCandidate.mParentData,  
     1054                                        frontData,  
     1055                                        backData,  
     1056                                        splitCandidate.mSplitAxis); 
     1057 
     1058        // max cost threshold violated? 
     1059        splitCandidate.mMaxCostMisses = costRatioViolated ?  
     1060                splitCandidate.mParentData.mMaxCostMisses :  
     1061                splitCandidate.mParentData.mMaxCostMisses + 1; 
    10771062 
    10781063        float oldRenderCost; 
     
    11011086         
    11021087        splitCandidate.mPriority = priority; 
    1103  
    1104         // max cost threshold violated? 
    1105         splitCandidate.mMaxCostMisses =  
    1106                 success ? splitCandidate.mParentData.mMaxCostMisses : splitCandidate.mParentData.mMaxCostMisses + 1; 
    11071088} 
    11081089 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r1251 r1288  
    156156         
    157157         
    158         struct VspBspSubdivisionCandidate 
     158        class VspBspSubdivisionCandidate 
    159159        {   
    160                 /// the current split plane 
    161                 Plane3 mSplitPlane; 
    162                 /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned) 
    163                 int mSplitAxis; 
    164                 /// the number of misses of max cost ratio until this split 
    165                 int mMaxCostMisses; 
    166  
    167                 // parent data 
    168                 VspBspTraversalData mParentData; 
    169                 // prioriry of this split 
    170                 float mPriority; 
    171  
    172                 float mRenderCostDecr; 
     160        public: 
    173161 
    174162                VspBspSubdivisionCandidate(): mPriority(0), mRenderCostDecr(0)  
     
    189177#endif 
    190178                } 
     179 
     180                /// the current split plane 
     181                Plane3 mSplitPlane; 
     182                /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned) 
     183                int mSplitAxis; 
     184                /// the number of misses of max cost ratio until this split 
     185                int mMaxCostMisses; 
     186 
     187                /// parent data 
     188                VspBspTraversalData mParentData; 
     189                /// prioriry of this split 
     190                float mPriority; 
     191 
     192                float mRenderCostDecr; 
     193 
    191194 
    192195                friend bool operator<(const VspBspSubdivisionCandidate &a, const VspBspSubdivisionCandidate &b) 
Note: See TracChangeset for help on using the changeset viewer.