Changeset 474 for trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
- Timestamp:
- 12/21/05 10:53:47 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r473 r474 38 38 mRoot(NULL), 39 39 mPvsUseArea(true), 40 m NumCriteria(0)40 mCostNormalizer(Limits::Small) 41 41 { 42 42 mRootCell = new BspViewCell(); … … 91 91 Debug << "max polygon candidates: " << mMaxPolyCandidates << endl; 92 92 Debug << "max plane candidates: " << mMaxRayCandidates << endl; 93 93 94 94 Debug << "Split plane strategy: "; 95 95 if (mSplitPlaneStrategy & RANDOM_POLYGON) 96 { 96 97 Debug << "random polygon "; 97 98 } 98 99 if (mSplitPlaneStrategy & AXIS_ALIGNED) 99 100 { 100 ++ mNumCriteria;101 101 Debug << "axis aligned "; 102 102 } 103 103 if (mSplitPlaneStrategy & LEAST_RAY_SPLITS) 104 104 { 105 ++ mNumCriteria;105 mCostNormalizer += mLeastRaySplitsFactor; 106 106 Debug << "least ray splits "; 107 107 } 108 108 if (mSplitPlaneStrategy & BALANCED_RAYS) 109 109 { 110 ++ mNumCriteria;110 mCostNormalizer += mBalancedRaysFactor; 111 111 Debug << "balanced rays "; 112 112 } 113 113 if (mSplitPlaneStrategy & PVS) 114 114 { 115 ++ mNumCriteria;115 mCostNormalizer += mPvsFactor; 116 116 Debug << "pvs"; 117 117 } … … 273 273 } 274 274 275 mTermMinArea *= mBox.SurfaceArea(); // normalize 275 276 mStat.polys = (int)polys.size(); 276 277 … … 315 316 316 317 tStack.pop(); 317 318 318 // subdivide leaf node 319 319 BspNode *r = Subdivide(tStack, tData); … … 412 412 ++ maxCostMisses; 413 413 414 /*if (maxCostMisses >= mTermMissTolerance)414 if (maxCostMisses >= mTermMissTolerance) 415 415 { 416 416 // terminate branch because of max cost 417 417 ++ mStat.maxCostNodes; 418 418 return leaf; 419 } */419 } 420 420 } 421 421 … … 471 471 mEpsilon); 472 472 473 // area is normalized with view space area 474 frontData.mArea = frontData.mGeometry->GetArea() / mBox.SurfaceArea(); 475 backData.mArea = backData.mGeometry->GetArea() / mBox.SurfaceArea(); 473 frontData.mArea = frontData.mGeometry->GetArea(); 474 backData.mArea = backData.mGeometry->GetArea(); 476 475 } 477 476 … … 810 809 const int candidateIdx = (int)RandomValue(0, (Real)(-- maxIdx)); 811 810 //Debug << "current Idx: " << maxIdx << " cand idx " << candidateIdx << endl; 812 811 813 812 Polygon3 *poly = (*data.mPolygons)[candidateIdx]; 814 813 815 814 // swap candidate to the end to avoid testing same plane 816 815 std::swap((*data.mPolygons)[maxIdx], (*data.mPolygons)[candidateIdx]); 817 816 818 817 //Polygon3 *poly = (*data.mPolygons)[(int)RandomValue(0, (int)polys.size() - 1)]; 819 818 … … 829 828 } 830 829 831 //Debug << "lowest: " << lowestCost << endl;832 833 830 //-- choose candidate planes extracted from rays 834 // we use different methods chosen with 835 // equal probability 831 //-- different methods are available 836 832 for (int i = 0; i < mMaxRayCandidates; ++ i) 837 833 { 838 834 plane = ChooseCandidatePlane3(*data.mRays); 839 840 835 const float candidateCost = SplitPlaneCost(plane, data); 841 836 … … 846 841 } 847 842 } 843 844 #ifdef _DEBUG 845 Debug << "plane lowest cost: " << lowestCost << endl; 846 #endif 848 847 849 848 // cost ratio miss 850 849 if (lowestCost > mTermMaxCostRatio) 851 850 return false; 852 853 #ifdef _DEBUG854 Debug << "plane lowest cost: " << lowestCost << endl;855 #endif856 851 857 852 return true; … … 1011 1006 { 1012 1007 const float oldCost = pOverall * (float)data.mPvs + Limits::Small; 1013 1014 cost += mPvsFactor * (frontPvs * pFront + (backPvs * pBack)) / oldCost; 1015 1016 // give penalty to unbalanced split 1017 if (0) 1018 if (((pFront * 0.2 + Limits::Small) > pBack) || 1019 (pFront < (pBack * 0.2 + Limits::Small))) 1020 cost += 0.5; 1008 cost += mPvsFactor * (frontPvs * pFront + backPvs * pBack) / oldCost; 1009 1010 //cost += mPvsFactor * 0.5 * (frontPvs * pFront + backPvs * pBack) / oldCost; 1011 //Debug << "new cost: " << cost << " over" << frontPvs * pFront + backPvs * pBack << " old cost " << oldCost << endl; 1012 1013 if (0) // give penalty to unbalanced split 1014 if (((pFront * 0.2 + Limits::Small) > pBack) || 1015 (pFront < (pBack * 0.2 + Limits::Small))) 1016 cost += 0.5; 1021 1017 } 1022 1018 1023 1019 #ifdef _DEBUG 1024 // Debug << "totalpvs: " << pvs << " ptotal: " << pOverall1025 //<< " frontpvs: " << frontPvs << " pFront: " << pFront1026 //<< " backpvs: " << backPvs << " pBack: " << pBack << endl << endl;1020 Debug << "totalpvs: " << data.mPvs << " ptotal: " << pOverall 1021 << " frontpvs: " << frontPvs << " pFront: " << pFront 1022 << " backpvs: " << backPvs << " pBack: " << pBack << endl << endl; 1027 1023 #endif 1028 1029 // normalize by number of criteria1030 return cost / (float) (mNumCriteria + Limits::Small);1024 1025 // normalize cost by sum of linear factors 1026 return cost / (float)mCostNormalizer; 1031 1027 } 1032 1028 … … 1118 1114 if (data.mDepth < mStat.minDepth) 1119 1115 mStat.minDepth = data.mDepth; 1120 1116 1117 if (data.mDepth >= mTermMaxDepth) 1118 ++ mStat.maxDepthNodes; 1119 1120 if (data.mPvs < mTermMinPvs) 1121 ++ mStat.minPvsNodes; 1122 1123 if ((int)data.mRays->size() < mTermMinRays) 1124 ++ mStat.minRaysNodes; 1125 1126 if (data.GetAvgRayContribution() > mTermMaxRayContribution) 1127 ++ mStat.maxRayContribNodes; 1128 1129 if (data.mArea <= mTermMinArea) 1130 { 1131 //Debug << "area: " << data.mArea / mBox.SurfaceArea() << " min area: " << mTermMinArea / mBox.SurfaceArea() << endl; 1132 ++ mStat.minAreaNodes; 1133 } 1121 1134 // accumulate depth to compute average depth 1122 1135 mStat.accumDepth += data.mDepth; 1123 1124 1125 if (data.mDepth >= mTermMaxDepth)1126 ++ mStat.maxDepthNodes;1127 1128 if (data.mPvs < mTermMinPvs)1129 ++ mStat.minPvsNodes;1130 1131 if ((int)data.mRays->size() < mTermMinRays)1132 ++ mStat.minRaysNodes;1133 1134 if (data.GetAvgRayContribution() > mTermMaxRayContribution)1135 ++ mStat.maxRayContribNodes;1136 1137 if (data.mGeometry->GetArea() <= mTermMinArea)1138 ++ mStat.minAreaNodes;1139 1136 1140 1137 #ifdef _DEBUG
Note: See TracChangeset
for help on using the changeset viewer.