Changeset 1649 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/19/06 16:14:29 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1643 r1649 25 25 #define PROBABILIY_IS_BV_VOLUME 1 26 26 #define USE_FIXEDPOINT_T 0 27 #define COUNT_ORIGIN_OBJECTS 027 //#define COUNT_ORIGIN_OBJECTS 0 28 28 29 29 int BvhNode::sMailId = 10000; //2147483647; … … 1069 1069 const float ratio = newRenderCost / oldRenderCost; 1070 1070 1071 #ifdef _DEBUG1071 //#ifdef _DEBUG 1072 1072 Debug << "\n§§§§ bvh eval const decrease §§§§" << endl 1073 1073 << "back pvs: " << (int)objectsBack.size() << " front pvs: " << (int)objectsFront.size() << " total pvs: " << nTotalObjects << endl … … 1075 1075 << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl 1076 1076 << "render cost decrease: " << oldRenderCost / viewSpaceVol - newRenderCost / viewSpaceVol << endl; 1077 #endif1077 //#endif 1078 1078 1079 1079 return ratio; … … 1326 1326 } 1327 1327 } 1328 1329 if ( COUNT_ORIGIN_OBJECTS &&ray->mOriginObject)1328 #if COUNT_ORIGIN_OBJECTS 1329 if (ray->mOriginObject) 1330 1330 { 1331 1331 ray->mOriginObject->mVssRays.push_back(ray); … … 1337 1337 } 1338 1338 } 1339 #endif 1339 1340 } 1340 1341 … … 1509 1510 for (vit = tmpViewCells.begin(); vit != vit_end; ++ vit) 1510 1511 { 1511 //VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit);1512 1512 ViewCell *vc = *vit; 1513 1513 … … 1883 1883 1884 1884 PrintSubdivisionStats(*oSubdivisionCandidate); 1885 1885 1886 1886 return oSubdivisionCandidate; 1887 1887 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1643 r1649 2527 2527 "-1"); 2528 2528 2529 RegisterOption("Hierarchy.Termination.maxMemory", 2530 optFloat, 2531 "hierarchy_construction_max_memory=", 2532 "1"); 2533 2529 2534 RegisterOption("Hierarchy.Construction.useMultiLevel", 2530 2535 optBool, -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1643 r1649 112 112 "Hierarchy.Construction.minStepsOfSameType", mMinStepsOfSameType); 113 113 114 115 114 char subdivisionStatsLog[100]; 116 115 Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats", subdivisionStatsLog); … … 119 118 Environment::GetSingleton()->GetBoolValue( 120 119 "Hierarchy.Construction.recomputeSplitPlaneOnRepair", mRecomputeSplitPlaneOnRepair); 120 121 Environment::GetSingleton()->GetFloatValue( 122 "Hierarchy.Termination.maxMemory", mTermMaxMemory); 121 123 122 124 Debug << "******** Hierachy Manager Options ***********" << endl; … … 129 131 Debug << "recompute split plane on repair: " << mRecomputeSplitPlaneOnRepair << endl; 130 132 Debug << "minimal number of steps from same type: " << mMinStepsOfSameType << endl; 133 Debug << "maximal allowed memory: " << mTermMaxMemory << endl; 131 134 132 135 switch (mConstructionType) … … 233 236 void HierarchyManager::EvalSubdivisionStats() 234 237 { 235 // TODO236 const float objectSpaceMem = GetObjectSpaceMemUsage();237 const float viewSpaceMem = mVspTree->GetMemUsage();238 // question: should I also add the mem usage of the hierarchies? 239 const float objectSpaceMem = 0;//GetObjectSpaceMemUsage(); 240 const float viewSpaceMem = 0;//mVspTree->GetMemUsage(); 238 241 239 242 // calculate cost in MB … … 274 277 (0 275 278 || (mHierarchyStats.Leaves() >= mTermMaxLeaves) 279 || (mHierarchyStats.mMemory >= mTermMaxMemory) 280 || candidate->GlobalTerminationCriteriaMet() 281 //|| (mHierarchyStats.mRenderCostDecrease < mMinRenderCostDecrease) 276 282 //|| (mHierarchyStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 277 || (candidate->GlobalTerminationCriteriaMet())278 //|| (mHierarchyStats.mRenderCostDecrease < mMinRenderCostDecrease)279 283 ); 280 284 281 #if _DEBUG285 //#if _DEBUG 282 286 if (terminationCriteriaMet) 283 287 { … … 285 289 Debug << "leaves: " << mHierarchyStats.Leaves() << " " << mTermMaxLeaves << endl; 286 290 Debug << "cost misses: " << mHierarchyStats.mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 287 } 288 #endif 291 Debug << "memory: " << mHierarchyStats.mMemory << " " << mTermMaxMemory << endl; 292 } 293 //#endif 289 294 290 295 return terminationCriteriaMet; … … 466 471 mVspTree->mVspStats.Stop(); 467 472 468 FinishObjectSpaceSubdivision(objects );473 FinishObjectSpaceSubdivision(objects, !mUseMultiLevelConstruction); 469 474 } 470 475 … … 534 539 mHierarchyStats.Stop(); 535 540 mVspTree->mVspStats.Stop(); 536 FinishObjectSpaceSubdivision(objects); 541 542 FinishObjectSpaceSubdivision(objects, !mUseMultiLevelConstruction); 537 543 } 538 544 … … 551 557 552 558 mHierarchyStats.mTotalCost = mVspTree->mTotalCost; 559 mHierarchyStats.mPvsEntries = mVspTree->EvalPvsEntriesSize(*viewSpaceRays); 560 553 561 cout << "\nreseting cost for vsp, new total cost: " << mHierarchyStats.mTotalCost << endl; 554 562 … … 650 658 { 651 659 const bool terminationCriteriaMet = GlobalTerminationCriteriaMet(sc); 652 653 660 const bool success = sc->Apply(splitQueue, terminationCriteriaMet); 654 661 … … 842 849 { 843 850 SubdivisionCandidate *sc = NextSubdivisionCandidate(mTQueue); 844 cout << "p=" << sc->GetPriority() << " "; 845 851 846 852 //////// 847 853 //-- subdivide leaf node of either type 848 854 ApplySubdivisionCandidate(sc, mTQueue, repairQueue); 849 //cout << "\nhere45 " << sc->GetPriority() << " " << sc->GetRenderCostDecrease() << " " << mObjectSpaceSubdivisionType << " " << mViewSpaceSubdivisionType << endl;850 855 851 856 DEL_PTR(sc); … … 904 909 cout << "\nreseting bv hierarchy" << endl; 905 910 Debug << "old bv hierarchy:\n " << mBvHierarchy->mBvhStats << endl; 906 911 907 912 mBvHierarchy->Initialise(objects); 908 913 909 914 // rather use this: remove previous nodes and add the two new ones 910 915 //mHierarchyStats.mNodes -= mBvHierarchy->mBvhStats.nodes + 2; 911 916 mHierarchyStats.mNodes = 2; 912 917 918 //firstCandidate = mBvHierarchy->PrepareConstruction(sampleRays, objects); 913 919 firstCandidate = mBvHierarchy->Reset(sampleRays, objects); 914 920 915 921 mHierarchyStats.mTotalCost = mBvHierarchy->mTotalCost; 916 922 mHierarchyStats.mRenderCostDecrease = 0; … … 918 924 // bug!! pvs entries cab be much higher at this stage 919 925 // (if view space was already subdivided) 920 mHierarchyStats.mPvsEntries = 1;926 mHierarchyStats.mPvsEntries = mBvHierarchy->CountViewCells(objects); 921 927 mHierarchyStats.mMemory = sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 922 928 923 929 // evaluate stats before first subdivision 924 930 EvalSubdivisionStats(); 931 cout << "finished bv hierarchy preparation" << endl; 925 932 } 926 933 break; … … 941 948 AxisAlignedBox3 *forcedViewSpace) 942 949 { 943 ViewCellsManager *v c= mVspTree->mViewCellsManager;950 ViewCellsManager *vm = mVspTree->mViewCellsManager; 944 951 945 952 // HACK: rather not destroy vsp tree 946 953 DEL_PTR(mVspTree); 947 954 mVspTree = new VspTree(); 955 948 956 mVspTree->mHierarchyManager = this; 957 mVspTree->mViewCellsManager = vm; 949 958 950 959 mVspTree->Initialise(sampleRays, forcedViewSpace); 951 960 952 SubdivisionCandidate *vsc = 953 PrepareViewSpaceSubdivision(sampleRays, objects); 961 SubdivisionCandidate *vsc = PrepareViewSpaceSubdivision(sampleRays, objects); 954 962 955 963 mHierarchyStats.mNodes = 2; 956 // bug!! pvs entries could be much higher at this stage 957 mHierarchyStats.mPvsEntries = 1; 964 958 965 mHierarchyStats.mRenderCostDecrease = 0; 959 966 … … 993 1000 mTQueue.Push(osc); 994 1001 995 ////////////////////////// 71002 ////////////////////////// 996 1003 997 1004 … … 1021 1028 1022 1029 cout << "iteration " << i << " of " << limit << " finished" << endl; 1023 1024 1030 mSubdivisionStats.close(); 1025 1031 … … 1030 1036 mSubdivisionStats.open(subdivisionStatsLog); 1031 1037 1038 1032 1039 ///////////////// 1033 1040 // subdivide view space with respect to the objects 1034 1041 1035 SubdivisionCandidate *vspVc = ResetViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); 1042 SubdivisionCandidate *vspVc = 1043 ResetViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); 1036 1044 mTQueue.Push(vspVc); 1037 1045 … … 1043 1051 1044 1052 cout << "iteration " << i << " of " << limit << " finished" << endl; 1045 1046 1053 mSubdivisionStats.close(); 1047 1054 … … 1065 1072 //mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 1066 1073 1067 // set the number of leaves 'evaluated' from the previous methods1068 // we go for the same numbers, but we try to optimize both1069 // subdivisions1070 switch (mObjectSpaceSubdivisionType)1071 {1072 case BV_BASED_OBJ_SUBDIV:1073 mBvHierarchy->mTermMaxLeaves = mBvHierarchy->mBvhStats.Leaves();1074 break;1075 case KD_BASED_OBJ_SUBDIV:1076 mOspTree->mTermMaxLeaves = mOspTree->mOspStats.Leaves();1077 default:1078 break;1079 }1080 1081 mVspTree->mMaxViewCells = mVspTree->mVspStats.Leaves();1082 1083 1074 const long startTime = GetTime(); 1084 1075 const int limit = mNumMultiLevels; … … 1088 1079 1089 1080 int steps = 0; 1081 1082 int maxViewSpaceLeaves = mVspTree->mVspStats.Leaves(); 1083 int maxObjectSpaceLeaves; 1084 1085 // set the number of leaves 'evaluated' from the previous methods 1086 // we go for the same numbers, but we try to optimize both subdivisions 1087 switch (mObjectSpaceSubdivisionType) 1088 { 1089 case BV_BASED_OBJ_SUBDIV: 1090 maxObjectSpaceLeaves = mBvHierarchy->mBvhStats.Leaves(); 1091 break; 1092 case KD_BASED_OBJ_SUBDIV: 1093 maxObjectSpaceLeaves = mOspTree->mOspStats.Leaves(); 1094 default: 1095 maxObjectSpaceLeaves = 0; 1096 break; 1097 } 1090 1098 1091 1099 // This method subdivides view space / object space … … 1103 1111 SubdivisionCandidate *ospVc = 1104 1112 ResetObjectSpaceSubdivision(sampleRays, objects); 1113 1114 // set the number of leaves 'evaluated' from the previous methods 1115 // we go for the same numbers, but we try to optimize both subdivisions 1116 mBvHierarchy->mTermMaxLeaves = maxObjectSpaceLeaves; 1105 1117 mTQueue.Push(ospVc); 1106 1118 … … 1109 1121 1110 1122 cout << "iteration " << steps << " of " << limit << " finished" << endl; 1111 1112 1123 mSubdivisionStats.close(); 1113 1124 … … 1123 1134 SubdivisionCandidate *vspVc = 1124 1135 ResetViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); 1136 1137 mVspTree->mMaxViewCells = maxViewSpaceLeaves; 1125 1138 mTQueue.Push(vspVc); 1126 1139 … … 1129 1142 1130 1143 cout << "iteration " << steps << " of " << limit << " finished" << endl; 1131 1132 1144 mSubdivisionStats.close(); 1133 1145 … … 1440 1452 1441 1453 1442 void HierarchyManager::FinishObjectSpaceSubdivision(const ObjectContainer &objects ) const1454 void HierarchyManager::FinishObjectSpaceSubdivision(const ObjectContainer &objects, const bool removeRayRefs) const 1443 1455 { 1444 1456 switch (mObjectSpaceSubdivisionType) … … 1452 1464 { 1453 1465 mBvHierarchy->mBvhStats.Stop(); 1454 RemoveRayRefs(objects); 1466 if (removeRayRefs) 1467 RemoveRayRefs(objects); 1455 1468 break; 1456 1469 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1642 r1649 42 42 class Exporter; 43 43 44 44 #define COUNT_ORIGIN_OBJECTS 1 45 45 46 46 /** View space / object space hierarchy statistics. … … 376 376 /** After the suddivision has ended, do some final tasks. 377 377 */ 378 void FinishObjectSpaceSubdivision(const ObjectContainer &objects ) const;378 void FinishObjectSpaceSubdivision(const ObjectContainer &objects, const bool removeRayRefs = true) const; 379 379 380 380 /** Returns depth of object space subdivision. … … 487 487 /// maximum number of leaves 488 488 int mTermMaxLeaves; 489 /// Maximal allowed memory consumption. 490 float mTermMaxMemory; 489 491 490 492 //////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1640 r1649 27 27 28 28 // should not count origin object for sampling because it disturbs heuristics 29 #define SAMPLE_ORIGIN_OBJECTS 029 #define SAMPLE_ORIGIN_OBJECTS 1 30 30 31 31 // $$JB HACK … … 1914 1914 1915 1915 if (ray.mTerminationObject) 1916 { 1917 1918 1919 if (viewcell->GetPvs().GetSampleContribution(obj, 1920 ray.mPdf, 1921 contribution)) 1916 { 1917 if (viewcell->GetPvs().GetSampleContribution(obj, 1918 ray.mPdf, 1919 contribution)) 1922 1920 { 1923 1924 1921 ++ ray.mPvsContribution; 1922 ray.mRelativePvsContribution += contribution; 1925 1923 } 1926 1924 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1640 r1649 28 28 29 29 #define USE_FIXEDPOINT_T 0 30 #define COUNT_ORIGIN_OBJECTS 0 30 31 31 32 32 ///////////// … … 1031 1031 sc += contribution; 1032 1032 } 1033 1033 #if COUNT_ORIGIN_OBJECTS 1034 1034 obj = ray->mOriginObject; 1035 1035 … … 1046 1046 sc += contribution; 1047 1047 } 1048 1048 #endif 1049 1049 if (madeContrib) 1050 1050 { … … 1167 1167 1168 1168 pvsSize += PrepareHeuristics(*ray, true); 1169 #if COUNT_ORIGIN_OBJECTS 1169 1170 pvsSize += PrepareHeuristics(*ray, false); 1171 #endif 1170 1172 } 1171 1173 … … 1240 1242 if (ci.type == SortableEntry::ERayMin) 1241 1243 { 1244 #if COUNT_ORIGIN_OBJECTS 1242 1245 pvsLeft += EvalMinEventContribution(*ray, true); 1246 #else 1243 1247 pvsLeft += EvalMinEventContribution(*ray, false); 1248 #endif 1244 1249 } 1245 1250 else // eval changes in pvs causes by max event 1246 1251 { 1252 #if COUNT_ORIGIN_OBJECTS 1247 1253 pvsRight -= EvalMaxEventContribution(*ray, true); 1254 #else 1248 1255 pvsRight -= EvalMaxEventContribution(*ray, false); 1256 #endif 1249 1257 } 1250 1258 } … … 2206 2214 { 2207 2215 VssRay *ray = (*rit).mRay; 2208 2216 #if COUNT_ORIGIN_OBJECTS 2209 2217 pvsSize += EvalContributionToPvs(*ray, true); 2218 #else 2210 2219 pvsSize += EvalContributionToPvs(*ray, false); 2220 #endif 2211 2221 } 2212 2222 … … 2283 2293 { 2284 2294 VssRay *ray = (*rit).mRay; 2285 2295 #if COUNT_ORIGIN_OBJECTS 2286 2296 pvsSize += EvalPvsEntriesContribution(*ray, true); 2297 #else 2287 2298 pvsSize += EvalPvsEntriesContribution(*ray, false); 2299 #endif 2288 2300 } 2289 2301 … … 2489 2501 ++ hits; 2490 2502 } 2491 #if 0 2492 leaf->mRays.push_back(RayInfo(new VssRay(origin, termination, NULL, NULL, 0))); 2493 #endif 2503 2494 2504 // get the next node from the stack 2495 2505 if (tStack.empty())
Note: See TracChangeset
for help on using the changeset viewer.