Changeset 2227 for GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
- Timestamp:
- 03/11/07 02:17:58 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r2224 r2227 634 634 635 635 636 static float AvgRaysPerObject(const int pvs, const int nRays) 637 { 638 return (float)nRays / ((float)pvs + Limits::Small); 639 } 640 641 636 642 void BvHierarchy::EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitCandidate, 637 643 const bool computeSplitPlane, … … 689 695 // avg contribution of a ray to a pvs 690 696 const float pvs = (float)CountViewCells(*tData.mSampledObjects); 691 const float avgRayContri = AvgRayContribution((int)pvs, tData.mNumRays); 697 //const float avgRayContri = AvgRayContribution((int)pvs, tData.mNumRays); 698 const float avgRaysPerObject = AvgRaysPerObject((int)pvs, tData.mNumRays); 692 699 693 700 // high avg ray contri, the result is influenced by undersampling 694 splitCandidate.SetAvgRay Contribution(avgRayContri);701 splitCandidate.SetAvgRaysPerObject(avgRaysPerObject); 695 702 const float viewSpaceVol = GetViewSpaceVolume(); 696 703 … … 699 706 const float parentVol = tData.mCorrectedVolume * oldRatio; 700 707 708 //cout << "h " << avgRaysPerObject << " "; 701 709 // this leaf is a pvs entry in all the view cells 702 710 // that see one of the objects. … … 708 716 709 717 splitCandidate.mCorrectedFrontVolume = 710 mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeFrontViewCells, parentVol, avgRay Contri);718 mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeFrontViewCells, parentVol, avgRaysPerObject); 711 719 712 720 splitCandidate.mCorrectedBackVolume = 713 mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeBackViewCells, parentVol, avgRay Contri);721 mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeBackViewCells, parentVol, avgRaysPerObject); 714 722 715 723 const float relfrontCost = splitCandidate.mCorrectedFrontVolume * … … 727 735 // increase in pvs entries 728 736 const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate, 729 avgRay Contri,737 avgRaysPerObject, 730 738 (int)pvs, 731 739 splitCandidate.mNumFrontViewCells, … … 737 745 { 738 746 cout << "bvh volume cost" 739 << " avg ray contri: " << avgRayContri<< " ratio: " << oldRatio747 << " avg rays per object: " << avgRaysPerObject << " ratio: " << oldRatio 740 748 << " parent: " << parentVol << " old vol: " << oldVolume 741 749 << " frontvol: " << splitCandidate.mVolumeFrontViewCells << " corr. " << splitCandidate.mCorrectedFrontVolume … … 766 774 767 775 int BvHierarchy::EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate, 768 const float avgRay Contri,776 const float avgRaysPerObjects, 769 777 const int numParentViewCells, 770 778 const int numFrontViewCells, … … 780 788 781 789 splitCandidate.mCorrectedFrontPvs = 782 mHierarchyManager->EvalCorrectedPvs((float)frontViewCells, parentPvs, avgRay Contri);790 mHierarchyManager->EvalCorrectedPvs((float)frontViewCells, parentPvs, avgRaysPerObjects); 783 791 splitCandidate.mCorrectedBackPvs = 784 mHierarchyManager->EvalCorrectedPvs((float)backViewCells, parentPvs, avgRay Contri);792 mHierarchyManager->EvalCorrectedPvs((float)backViewCells, parentPvs, avgRaysPerObjects); 785 793 786 794 if (0) 787 795 cout << "bvh pvs" 788 << " avg ray contri: " << avgRay Contri<< " ratio: " << oldPvsRatio796 << " avg ray contri: " << avgRaysPerObjects << " ratio: " << oldPvsRatio 789 797 << " parent: " << parentPvs << " " << " old vol: " << oldPvsSize 790 798 << " frontpvs: " << frontViewCells << " corr. " << splitCandidate.mCorrectedFrontPvs … … 1014 1022 #endif 1015 1023 1016 #if 11017 1024 1018 1025 float BvHierarchy::EvalSah(const BvhTraversalData &tData, … … 1111 1118 ar = rbox.SurfaceArea(); 1112 1119 1120 #if BOUND_RENDERCOST 1113 1121 const float sum = noValidSplit ? 1e25f : objectsLeft * al + objectsRight * ar; 1114 1122 #else 1123 const float rcLeft = std::max(objectsLeft, MIN_RENDERCOST); 1124 const float rcRight = std::max(objectsRight, MIN_RENDERCOST); 1125 1126 const float sum = noValidSplit ? 1e25f : objectsLeft * al + objectsRight * ar; 1127 1128 #endif 1115 1129 /*cout << "pos=" << (*cit).mPos << "\t q=(" << objectsLeft << "," << objectsRight <<")\t r=(" 1116 1130 << lbox.SurfaceArea() << "," << rbox.SurfaceArea() << ")" << endl; … … 1153 1167 } 1154 1168 1155 #else 1156 1157 float BvHierarchy::EvalSah (const BvhTraversalData &tData,1158 1159 1160 1169 1170 1171 float BvHierarchy::EvalSahWithTigherBbox(const BvhTraversalData &tData, 1172 const int axis, 1173 ObjectContainer &objectsFront, 1174 ObjectContainer &objectsBack) 1161 1175 { 1162 1176 // go through the lists, count the number of objects left and right … … 1294 1308 } 1295 1309 1296 #endif1297 1310 1298 1311 static bool PrepareOutput(const int axis, … … 1423 1436 const bool noValidSplit = (nObjectsRight <= Limits::Small); 1424 1437 1438 #if BOUND_RENDERCOST 1425 1439 // the heuristics 1426 1440 const float sum = noValidSplit ? 1427 1441 1e25f : volLeft * (float)nObjectsLeft + volRight * (float)nObjectsRight; 1428 1442 #else 1443 const float rcLeft = max(nObjectsLeft, MIN_RENDERCOST); 1444 const float rcRight = max(nObjectsRight, MIN_RENDERCOST); 1445 1446 // the heuristics 1447 const float sum = noValidSplit ? 1448 1e25f : volLeft * (float)rcLeft + volRight * (float)rcRight; 1449 1450 #endif 1451 1429 1452 #ifdef GTP_DEBUG 1430 1453 if (printStats) … … 1842 1865 float BvHierarchy::EvalAbsCost(const ObjectContainer &objects) 1843 1866 { 1867 float result; 1844 1868 #if USE_BETTER_RENDERCOST_EST 1845 1869 ObjectContainer::const_iterator oit, oit_end = objects.end(); … … 1847 1871 for (oit = objects.begin(); oit != oit_end; ++ oit) 1848 1872 { 1849 objRenderCost += ViewCellsManager::GetRendercost(*oit);1873 result += ViewCellsManager::GetRendercost(*oit); 1850 1874 } 1851 1875 #else 1852 re turn(float)objects.size();1876 result = (float)objects.size(); 1853 1877 #endif 1878 1879 #if BOUND_RENDERCOST 1880 result = max(result, MIN_RENDERCOST); 1881 #endif 1882 1883 return result; 1854 1884 } 1855 1885 … … 1875 1905 /////////////// 1876 1906 //-- render cost heuristics 1907 1877 1908 const float objRenderCost = EvalAbsCost(objects); 1878 1909
Note: See TracChangeset
for help on using the changeset viewer.