Changeset 2350 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 05/03/07 23:23:31 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r2347 r2350 693 693 AssociateViewCellsWithObjects(*tData.mSampledObjects); 694 694 695 EvalSubdivisionCandidate2(*frontCandidate, true, false);696 cout << "\nfc2: " << frontCandidate->GetPriority() << endl;697 695 EvalSubdivisionCandidate(*frontCandidate, true, false); 698 cout << "fc1: " << frontCandidate->GetPriority() << endl;699 696 EvalSubdivisionCandidate(*backCandidate, true, false); 700 697 … … 789 786 790 787 791 void BvHierarchy::EvalSubdivisionCandidate 2(BvhSubdivisionCandidate &splitCandidate,788 void BvHierarchy::EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitCandidate, 792 789 const bool computeSplitPlane, 793 790 const bool preprocessViewCells) … … 890 887 } 891 888 892 //cout << "pvol: " << parentVol << " front: " << volFront << " back: " << volBack << " diff: " << parentVol - volFront - volBack << endl;893 894 889 895 890 ///////////////////// … … 936 931 const int backTri = (int)splitCandidate.mBackObjects.size(); 937 932 938 if (totalTri - frontTri - backTri != 0)939 cout << "big error!!!" << endl;940 933 941 934 // compute render cost decrease in the view cells which can see the object … … 980 973 oldRenderCost += oldRc * vc->GetVolume() / viewSpaceVol; 981 974 newRenderCost += newRc * vc->GetVolume() / viewSpaceVol; 982 //cout << "old rc=" << oldRenderCost << " new rc " << newRenderCost << endl; 983 } 984 985 986 const float dummyFrontVol = EvalViewCellsVolume(splitCandidate.mSampledFrontObjects) / viewSpaceVol; 987 const float dummyBackVol = EvalViewCellsVolume(splitCandidate.mSampledBackObjects) / viewSpaceVol; 988 const float dummyParentVol = EvalViewCellsVolume(leaf->mObjects) / viewSpaceVol; 989 990 const int dummyNumFrontViewCells = CountViewCells(splitCandidate.mSampledFrontObjects); 991 const int dummyNumBackViewCells = CountViewCells(splitCandidate.mSampledBackObjects); 992 const int dummyPvs = CountViewCells(*tData.mSampledObjects); 993 994 const int dummyPvsEntriesIncr = - dummyPvs + dummyNumFrontViewCells + dummyNumBackViewCells; 995 996 const float relfrontCost = dummyFrontVol * (float)splitCandidate.mFrontObjects.size(); 997 const float relBackCost = dummyBackVol * (float)splitCandidate.mBackObjects.size(); 998 const float relParentCost = dummyParentVol * (float)leaf->mObjects.size(); 999 1000 // compute global decrease in render cost 1001 const float dummyNewRenderCost = relfrontCost + relBackCost; 1002 const float dummyRenderCostDecr = relParentCost - dummyNewRenderCost; 1003 975 } 1004 976 1005 977 … … 1011 983 splitCandidate.SetRenderCostDecrease(renderCostDecr); 1012 984 1013 float pseudoOldRenderCost = parentVol * (float)leaf->mObjects.size() / viewSpaceVol; 1014 1015 //cout << "cor. entries: " << dummyPvsEntriesIncr << " entries: " << frontAndBackViewCells << endl; 1016 cout << "\nv1: " << renderCostDecr << " " << pseudoOldRenderCost << " " << newRenderCost << endl; 1017 cout << "v2: " << dummyRenderCostDecr << " " << relParentCost << " " << dummyNewRenderCost << endl; 985 const float pseudoOldRenderCost = parentVol * (float)leaf->mObjects.size() / viewSpaceVol; 1018 986 1019 987 // at last computed priority based on render cost reduction / memory increase 1020 988 const float priority = EvalPriority(splitCandidate, renderCostDecr, pseudoOldRenderCost); 1021 cout << "\nfc0: " << priority << endl;1022 const float priority2 = EvalPriority(splitCandidate, dummyRenderCostDecr, relParentCost);1023 splitCandidate.SetPriority(priority2);1024 1025 #if STORE_VIEWCELLS_WITH_BVH1026 if (preprocessViewCells)1027 ReleaseViewCells(*splitCandidate.mParentData.mSampledObjects);1028 #endif1029 1030 mEvalTimer.Exit();1031 }1032 1033 1034 void BvHierarchy::EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitCandidate,1035 const bool computeSplitPlane,1036 const bool preprocessViewCells)1037 {1038 mPlaneTimer.Entry();1039 1040 #if STORE_VIEWCELLS_WITH_BVH1041 if (preprocessViewCells) // fill view cells cache1042 AssociateViewCellsWithObjects(*splitCandidate.mParentData.mSampledObjects);1043 #endif1044 1045 if (computeSplitPlane)1046 {1047 splitCandidate.mFrontObjects.clear();1048 splitCandidate.mBackObjects.clear();1049 splitCandidate.mSampledFrontObjects.clear();1050 splitCandidate.mSampledBackObjects.clear();1051 1052 const bool sufficientSamples =1053 splitCandidate.mParentData.mNumRays > mMinRaysForVisibility;1054 1055 //if (!sufficientSamples) cout << splitCandidate.mParentData.mNumRays << " ";1056 1057 const bool useVisibiliyBasedHeuristics =1058 !mUseSah &&1059 (mHierarchyManager->GetViewSpaceSubdivisionType() ==1060 HierarchyManager::KD_BASED_VIEWSPACE_SUBDIV) &&1061 sufficientSamples;1062 1063 // compute best object partition1064 const float ratio = SelectObjectPartition(splitCandidate.mParentData,1065 splitCandidate.mFrontObjects,1066 splitCandidate.mBackObjects,1067 useVisibiliyBasedHeuristics);1068 1069 // cost ratio violated?1070 const bool maxCostRatioViolated = mTermMaxCostRatio < ratio;1071 const int previousMisses = splitCandidate.mParentData.mMaxCostMisses;1072 1073 splitCandidate.SetMaxCostMisses(maxCostRatioViolated ?1074 previousMisses + 1 : previousMisses);1075 1076 StoreSampledObjects(splitCandidate.mSampledFrontObjects, splitCandidate.mFrontObjects);1077 StoreSampledObjects(splitCandidate.mSampledBackObjects, splitCandidate.mBackObjects);1078 }1079 1080 mPlaneTimer.Exit();1081 1082 mEvalTimer.Entry();1083 1084 const BvhTraversalData &tData = splitCandidate.mParentData;1085 BvhLeaf *leaf = tData.mNode;1086 1087 // avg contribution of a ray to a pvs1088 const float pvs = (float)CountViewCells(*tData.mSampledObjects);1089 //const float avgRayContri = AvgRayContribution((int)pvs, tData.mNumRays);1090 const float avgRaysPerObject = AvgRaysPerObject((int)pvs, tData.mNumRays);1091 1092 // high avg ray contri, the result is influenced by undersampling1093 splitCandidate.SetAvgRaysPerObject(avgRaysPerObject);1094 const float viewSpaceVol = GetViewSpaceVolume();1095 1096 const float oldVolume = EvalViewCellsVolume(*tData.mSampledObjects) / viewSpaceVol;1097 const float oldRatio = (tData.mVolume > 0) ? oldVolume / tData.mVolume : 1;1098 const float parentVol = tData.mCorrectedVolume * oldRatio;1099 1100 // this leaf is a pvs entry in all the view cells1101 // that see one of the objects.1102 splitCandidate.mVolumeFrontViewCells = EvalViewCellsVolume(splitCandidate.mSampledFrontObjects) / viewSpaceVol;1103 splitCandidate.mVolumeBackViewCells = EvalViewCellsVolume(splitCandidate.mSampledBackObjects) / viewSpaceVol;1104 1105 splitCandidate.mNumFrontViewCells = CountViewCells(splitCandidate.mSampledFrontObjects);1106 splitCandidate.mNumBackViewCells = CountViewCells(splitCandidate.mSampledBackObjects);1107 1108 splitCandidate.mCorrectedFrontVolume =1109 mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeFrontViewCells, parentVol, avgRaysPerObject);1110 1111 splitCandidate.mCorrectedBackVolume =1112 mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeBackViewCells, parentVol, avgRaysPerObject);1113 1114 #if 01115 const float relfrontCost = splitCandidate.mCorrectedFrontVolume * splitCandidate.mFrontObjects.size();1116 const float relBackCost = splitCandidate.mCorrectedBackVolume * splitCandidate.mBackObjects.size();1117 const float relParentCost = parentVol * leaf->mObjects.size();1118 #else1119 const float relfrontCost = splitCandidate.mVolumeFrontViewCells * splitCandidate.mFrontObjects.size();1120 const float relBackCost = splitCandidate.mVolumeBackViewCells * splitCandidate.mBackObjects.size();1121 const float relParentCost = oldVolume * leaf->mObjects.size();1122 #endif1123 // compute global decrease in render cost1124 const float newRenderCost = relfrontCost + relBackCost;1125 const float renderCostDecr = relParentCost - newRenderCost;1126 1127 splitCandidate.SetRenderCostDecrease(renderCostDecr);1128 1129 // increase in pvs entries1130 const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate,1131 avgRaysPerObject,1132 (int)pvs,1133 splitCandidate.mNumFrontViewCells,1134 splitCandidate.mNumBackViewCells);1135 1136 splitCandidate.SetPvsEntriesIncr(pvsEntriesIncr);1137 1138 #ifdef GTP_DEBUG1139 Debug << "old render cost: " << oldRenderCost << endl;1140 Debug << "new render cost: " << newRenderCost << endl;1141 Debug << "render cost decrease: " << renderCostDecr << endl;1142 #endif1143 1144 float priority = EvalPriority(splitCandidate,1145 renderCostDecr,1146 relParentCost);1147 1148 // compute global decrease in render cost1149 989 splitCandidate.SetPriority(priority); 1150 990 -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r2347 r2350 579 579 const bool preprocessViewCells); 580 580 581 void EvalSubdivisionCandidate2(BvhSubdivisionCandidate &splitData,582 const bool computeSplitPlane,583 const bool preprocessViewCells);584 585 581 /** Returns vector of leaves. 586 582 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r2347 r2350 31 31 #define HACK_PERFORMANCE 1 32 32 33 #define HAS_TO_BE_REDONE 034 33 35 34 ///////////// … … 849 848 splitCandidate.mBackPvs = (float)sData.mBackObjects; 850 849 851 #if HAS_TO_BE_REDONE852 850 return (int)(splitCandidate.mCorrectedFrontPvs + splitCandidate.mCorrectedBackPvs - correctedOldPvs); 853 #else854 return sData.mFrontObjects + sData.mBackObjects - sData.mTotalObjects;855 #endif856 851 } 857 852 … … 1627 1622 sc.mBackRenderCost = sData.mBackRenderCost; 1628 1623 1629 #if HAS_TO_BE_REDONE // undersampling evalution does not work yet1630 1631 1624 const float oldRenderCost = penaltyOld * pOverall; 1632 1625 const float newRenderCost = sc.mCorrectedFrontRenderCost * pFront + 1633 1626 sc.mCorrectedBackRenderCost * pBack; 1634 1627 1635 #else1636 1637 const float oldRenderCost = sData.mTotalRenderCost * pOverall;1638 const float newRenderCost = sData.mFrontRenderCost * pFront + sData.mBackRenderCost * pBack;1639 1640 #endif1641 1628 1642 1629 // the normalized old render cost is needed for the priority
Note: See TracChangeset
for help on using the changeset viewer.