Changeset 1662 for GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
- Timestamp:
- 10/22/06 09:03:24 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1654 r1662 25 25 #define PROBABILIY_IS_BV_VOLUME 1 26 26 #define USE_FIXEDPOINT_T 0 27 //#define COUNT_ORIGIN_OBJECTS 0 27 28 #define USE_VOLUMES_FOR_HEURISTICS 1 29 28 30 29 31 int BvhNode::sMailId = 10000; //2147483647; … … 261 263 Environment::GetSingleton()->GetBoolValue("BvHierarchy.Construction.useGlobalSorting", mUseGlobalSorting); 262 264 265 mUseBboxAreaForSah = true; 263 266 264 267 ///////////// … … 432 435 // decrease the weighted average cost of the subdivisoin 433 436 mTotalCost -= sc->GetRenderCostDecrease(); 437 mPvsEntries += sc->GetPvsEntriesIncr(); 434 438 435 439 // subdivision statistics … … 527 531 //-- surface area heuristics 528 532 529 // if (objects.empty())530 // return 0.0f;531 532 533 const AxisAlignedBox3 box = EvalBoundingBox(leaf->mObjects); 533 534 const float area = box.SurfaceArea(); … … 814 815 int objectsLeft = 0, objectsRight = (int)tData.mNode->mObjects.size(); 815 816 816 AxisAlignedBox3box = tData.mNode->GetBoundingBox();817 818 float minBox =box.Min(axis);819 float maxBox =box.Max(axis);820 float boxArea =box.SurfaceArea();817 const AxisAlignedBox3 nodeBbox = tData.mNode->GetBoundingBox(); 818 819 const float minBox = nodeBbox.Min(axis); 820 const float maxBox = nodeBbox.Max(axis); 821 const float boxArea = nodeBbox.SurfaceArea(); 821 822 822 823 float minSum = 1e20f; … … 828 829 SortableEntryContainer::const_iterator currentPos = 829 830 mSubdivisionCandidates->begin(); 830 831 832 // we keep track of both borders of the bounding boxes => 833 // store the events in descending order 831 834 832 vector<float> bordersRight; 835 bordersRight.resize(mSubdivisionCandidates->size()); 836 837 SortableEntryContainer::reverse_iterator rcit = 838 mSubdivisionCandidates->rbegin(), rcit_end = mSubdivisionCandidates->rend(); 839 840 vector<float>::reverse_iterator rbit = bordersRight.rbegin(); 841 842 for (; rcit != rcit_end; ++ rcit, ++ rbit) 843 { 844 Intersectable *obj = (*rcit).mObject; 845 const AxisAlignedBox3 box = obj->GetBox(); 846 847 if (box.Min(axis) < minBorder) 848 { 849 minBorder = box.Min(axis); 850 } 851 852 (*rbit) = minBorder; 853 } 833 834 if (mUseBboxAreaForSah) 835 { 836 // we keep track of both borders of the bounding boxes => 837 // store the events in descending order 838 839 bordersRight.resize(mSubdivisionCandidates->size()); 840 841 SortableEntryContainer::reverse_iterator rcit = 842 mSubdivisionCandidates->rbegin(), rcit_end = mSubdivisionCandidates->rend(); 843 844 vector<float>::reverse_iterator rbit = bordersRight.rbegin(); 845 846 for (; rcit != rcit_end; ++ rcit, ++ rbit) 847 { 848 Intersectable *obj = (*rcit).mObject; 849 const AxisAlignedBox3 obox = obj->GetBox(); 850 851 if (obox.Min(axis) < minBorder) 852 { 853 minBorder = obox.Min(axis); 854 } 855 856 (*rbit) = minBorder; 857 } 858 } 859 860 // temporary surface areas 861 float al = 0; 862 float ar = boxArea; 854 863 855 864 vector<float>::const_iterator bit = bordersRight.begin(); … … 863 872 -- objectsRight; 864 873 865 AxisAlignedBox3 lbox = box;866 AxisAlignedBox3 rbox = box;867 868 874 const AxisAlignedBox3 obox = obj->GetBox(); 869 875 870 // the borders of the bounding boxes have changed 871 if (obox.Max(axis) > maxBorder) 872 { 873 maxBorder = obox.Max(axis); 874 } 875 876 minBorder = (*bit); 877 878 lbox.SetMax(axis, maxBorder); 879 rbox.SetMin(axis, minBorder); 880 881 const float al = lbox.SurfaceArea(); 882 const float ar = rbox.SurfaceArea(); 876 if (mUseBboxAreaForSah) 877 { 878 AxisAlignedBox3 lbox = nodeBbox; 879 AxisAlignedBox3 rbox = nodeBbox; 880 881 // the borders of the bounding boxes have changed 882 if (obox.Max(axis) > maxBorder) 883 { 884 maxBorder = obox.Max(axis); 885 } 886 887 minBorder = (*bit); 888 889 lbox.SetMax(axis, maxBorder); 890 rbox.SetMin(axis, minBorder); 891 892 al = lbox.SurfaceArea(); 893 ar = rbox.SurfaceArea(); 894 } 895 else 896 { 897 // just add up areas of the object bbs 898 // (as we are not sampling volumetric visibility, 899 // this should provide better heuristics 900 const float area = obox.SurfaceArea(); 901 902 al += area; 903 ar -= area; 904 } 883 905 884 906 const float sum = objectsLeft * al + objectsRight * ar; … … 1151 1173 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 1152 1174 { 1153 vol += (*vit)->GetVolume(); 1175 #if USE_VOLUMES_FOR_HEURISTICS 1176 const float volIncr = (*vit)->GetVolume(); 1177 #else 1178 const float volIncr = 1.0f; 1179 #endif 1180 vol += volIncr; 1154 1181 } 1155 1182 … … 1185 1212 // view cells can also be seen from left child node 1186 1213 ViewCell *viewCell = *vit; 1187 1214 #if USE_VOLUMES_FOR_HEURISTICS 1188 1215 const float vol = viewCell->GetVolume(); 1189 1216 #else 1217 const float vol = 1.0f; 1218 #endif 1190 1219 if (!viewCell->Mailed()) 1191 1220 { … … 1352 1381 << "#Leaves\n" << mBvhStats.Leaves() << endl 1353 1382 << "#RenderCostDecrease\n" << costDecr << endl 1354 << "#TotalRenderCost\n" << mTotalCost << endl; 1383 << "#TotalRenderCost\n" << mTotalCost << endl 1384 << "#EntriesInPvs\n" << mPvsEntries << endl; 1355 1385 } 1356 1386 … … 1881 1911 const float viewSpaceVol = mViewCellsManager->GetViewSpaceBox().GetVolume(); 1882 1912 mTotalCost = (float)objects.size() * prop / viewSpaceVol; 1913 mPvsEntries = CountViewCells(objects); 1883 1914 1884 1915 PrintSubdivisionStats(*oSubdivisionCandidate);
Note: See TracChangeset
for help on using the changeset viewer.