Changeset 611 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 02/10/06 13:04:39 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r607 r611 1912 1912 optBool, 1913 1913 "vsp_bsp_usePolygonSplitIfAvailable=", 1914 " true");1914 "false"); 1915 1915 1916 1916 RegisterOption("VspBspTree.Termination.AxisAligned.minRays", -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r610 r611 262 262 263 263 environment->GetFloatValue("BspTree.Construction.epsilon", mEpsilon); 264 264 265 mSubdivisionStats.open("subdivisionStats.log"); 266 265 267 Debug << "BSP max depth: " << mTermMaxDepth << endl; 266 268 Debug << "BSP min PVS: " << mTermMinPvs << endl; … … 841 843 geom); 842 844 845 mTotalCost = tData.mPvs * tData.mProbability / mBox.GetVolume(); 846 mTotalPvsSize = tData.mPvs; 847 848 mSubdivisionStats 849 << "#ViewCells\n1\n" << endl 850 << "#RenderCostDecrease\n0\n" << endl 851 << "#TotalRenderCost\n" << mTotalCost << endl 852 << "#AvgRenderCost\n" << mTotalPvsSize << endl; 853 843 854 tStack.push(tData); 844 855 856 // used for intermediate time measurements and progress 857 long interTime = GetTime(); 858 int nleaves = 500; 859 845 860 mStat.Start(); 846 cout << "Contructing bsp tree ... 861 cout << "Contructing bsp tree ...\n"; 847 862 long startTime = GetTime(); 848 863 while (!tStack.empty()) … … 858 873 Debug << "BSP tree construction time spent at root: " 859 874 << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 875 876 if (mStat.Leaves() >= nleaves) 877 { 878 nleaves += 500; 879 880 cout << "leaves=" << mStat.Leaves() << endl; 881 Debug << "needed " 882 << TimeDiff(interTime, GetTime())*1e-3 883 << " secs to create 500 leaves" << endl; 884 interTime = GetTime(); 885 } 860 886 } 861 887 … … 937 963 new BoundedRayContainer(), 0, 0, new BspNodeGeometry()); 938 964 965 int pvsData = tData.mPvs; 966 float cData = (float)tData.mPvs * tData.mProbability; 967 939 968 // create new interior node and two leaf nodes 940 969 BspInterior *interior = 941 970 SubdivideNode(tData, tFrontData, tBackData, coincident); 942 971 972 973 if (1) 974 { 975 float cFront = (float)tFrontData.mPvs * tFrontData.mProbability; 976 float cBack = (float)tBackData.mPvs * tBackData.mProbability; 977 978 float costDecr = 979 (cFront + cBack - cData) / mBox.GetVolume(); 980 981 982 mTotalCost += costDecr; 983 mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - pvsData; 984 985 mSubdivisionStats 986 << "#ViewCells\n" << mStat.Leaves() << endl 987 << "#RenderCostDecrease\n" << -costDecr << endl 988 << "#TotalRenderCost\n" << mTotalCost << endl 989 << "#AvgRenderCost\n" << mTotalPvsSize / mStat.Leaves() << endl; 990 } 943 991 944 992 // extract view cells from coincident polygons according to plane normal … … 1006 1054 BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 1007 1055 1008 long startTime; 1009 if (0) 1010 { 1011 Debug << "*********************" << endl; 1012 startTime = GetTime(); 1013 } 1056 1014 1057 1015 1058 // select subdivision plane … … 1017 1060 new BspInterior(SelectPlane(leaf, tData)); 1018 1061 1019 if (0) 1020 { 1021 Debug << "time used for split plane selection: " 1022 << TimeDiff(startTime, GetTime()) * 1e-3 << "s" << endl; 1023 } 1062 1024 1063 #ifdef _DEBUG 1025 1064 Debug << interior << endl; … … 1027 1066 1028 1067 1029 if (0)1030 {1031 Debug << "number of rays: " << (int)tData.mRays->size() << endl;1032 Debug << "number of polys: " << (int)tData.mPolygons->size() << endl;1033 1034 startTime = GetTime();1035 }1036 1037 1068 // subdivide rays into front and back rays 1038 1069 SplitRays(interior->mPlane, *tData.mRays, *frontData.mRays, *backData.mRays); 1039 1070 1040 if (0) 1041 { 1042 Debug << "time used for rays splitting: " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 1043 startTime = GetTime(); 1044 } 1071 1045 1072 1046 1073 // subdivide polygons with plane … … 1051 1078 coincident); 1052 1079 1053 if (0) 1054 { 1055 Debug << "time used for polygon splitting: " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 1056 } 1080 1057 1081 1058 1082 // compute pvs … … 1070 1094 1071 1095 1072 frontData.mProbability = frontData.mGeometry->GetVolume(); 1073 backData.mProbability = backData.mGeometry->GetVolume(); 1074 } 1075 1076 // compute accumulated ray length 1077 //frontData.mAccRayLength = AccumulatedRayLength(*frontData.mRays); 1078 //backData.mAccRayLength = AccumulatedRayLength(*backData.mRays); 1096 if (mUseAreaForPvs) 1097 { 1098 frontData.mProbability = frontData.mGeometry->GetArea(); 1099 backData.mProbability = backData.mGeometry->GetArea(); 1100 } 1101 else 1102 { 1103 frontData.mProbability = frontData.mGeometry->GetVolume(); 1104 backData.mProbability = tData.mProbability - frontData.mProbability; 1105 } 1106 } 1079 1107 1080 1108 //-- create front and back leaf … … 1582 1610 inline void BspTree::GenerateUniqueIdsForPvs() 1583 1611 { 1584 Intersectable::NewMail(); sBackId = ViewCell::sMailId;1585 Intersectable::NewMail(); sFrontId = ViewCell::sMailId;1586 Intersectable::NewMail(); sFrontAndBackId = ViewCell::sMailId;1612 ViewCell::NewMail(); sBackId = ViewCell::sMailId; 1613 ViewCell::NewMail(); sFrontId = ViewCell::sMailId; 1614 ViewCell::NewMail(); sFrontAndBackId = ViewCell::sMailId; 1587 1615 } 1588 1616 … … 1895 1923 return 0; 1896 1924 1897 Intersectable::NewMail();1925 ViewCell::NewMail(); 1898 1926 1899 1927 Vector3 entp = ray.Extrap(mint); -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r610 r611 9 9 #include "VssRay.h" 10 10 #include "ViewCell.h" 11 12 11 13 12 14 class ViewCell; … … 430 432 #endif 431 433 #if 1 434 return (float) (-mDepth); // for regular grid 435 #endif 436 #if 0 432 437 return mProbability; 433 438 #endif … … 958 963 959 964 int mTimeStamp; 965 966 float mTotalCost; 967 int mTotalPvsSize; 968 969 //int mSplits; 970 ofstream mSubdivisionStats; 960 971 961 972 private: -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r610 r611 426 426 prop, 427 427 geom); 428 428 #if OCTREE_HACK 429 tData.mAxis = 0; 430 #endif 429 431 // first node is kd node, i.e. an axis aligned box 430 432 if (1) … … 528 530 VspBspTraversalData tFrontData; 529 531 VspBspTraversalData tBackData; 530 532 #if OCTREE_HACK 533 //Debug << "new axis:" << (tData.mAxis + 1) % 3 << endl; 534 535 tFrontData.mAxis = (tData.mAxis + 1) % 3; 536 tBackData.mAxis = (tData.mAxis + 1) % 3; 537 #endif 531 538 // create new interior node and two leaf nodes 532 539 // or return leaf as it is (if maxCostRatio missed) … … 537 544 if (1) 538 545 { 539 float cFront = tFrontData.mPvs * tFrontData.mProbability;540 float cBack = tBackData.mPvs * tBackData.mProbability;541 float cData = tData.mPvs * tData.mProbability;;546 float cFront = (float)tFrontData.mPvs * tFrontData.mProbability; 547 float cBack = (float)tBackData.mPvs * tBackData.mProbability; 548 float cData = (float)tData.mPvs * tData.mProbability;; 542 549 543 550 float costDecr = 544 551 (cFront + cBack - cData) / mBox.GetVolume(); 545 546 int pvsFront = tFrontData.mPvs * tFrontData.mProbability;547 int pvsBack = tBackData.mPvs * tBackData.mProbability;548 int pvsData = tData.mPvs * tData.mProbability;;549 552 550 553 mTotalCost += costDecr; … … 979 982 box.Include((*ri).ExtrapTermination()); 980 983 } 981 984 #if OCTREE_HACK 985 //Debug << "choosing axis:" << tData.mAxis << endl; 986 const int sAxis = tData.mAxis; 987 #else 982 988 const int sAxis = mUseRandomAxis ? Random(3) : box.Size().DrivingAxis(); 983 989 #endif 984 990 for (axis = 0; axis < 3; ++ axis) 985 991 { … … 1130 1136 1131 1137 // cost ratio miss 1132 if ( !mUsePolygonSplitIfAvailable ||data.mPolygons->empty())1138 if (mUsePolygonSplitIfAvailable && !data.mPolygons->empty()) 1133 1139 { 1134 1140 frontData.mIsKdNode = backData.mIsKdNode = false; … … 1183 1189 // cost ratio miss 1184 1190 if (lowestCost > mTermMaxCostRatio) 1191 { 1185 1192 return false; 1193 } 1186 1194 1187 1195 return true; … … 1629 1637 if (data.mDepth >= mTermMaxDepth) 1630 1638 ++ mBspStats.maxDepthNodes; 1639 1631 1640 // accumulate rays to compute rays / leaf 1632 1641 mBspStats.accumRays += (int)data.mRays->size(); -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r610 r611 28 28 struct BspRay; 29 29 30 30 #define OCTREE_HACK 0 31 31 /** 32 32 This is a view space partitioning specialised BSPtree. … … 64 64 /// if this node is a kd-node (i.e., boundaries are axis aligned 65 65 bool mIsKdNode; 66 #if OCTREE_HACK // OCTREE HACK 67 int mAxis; 68 #endif 66 69 /// bounding box of current view space. 67 70 ///AxisAlignedBox3 mBbox; … … 124 127 float GetCost() const 125 128 { 126 #if 1129 #if 0 127 130 return mPvs * mProbability; 128 131 #endif 129 #if 0132 #if 1 130 133 return (float) (-mDepth); // for regular grid 131 134 #endif … … 708 711 int mTotalPvsSize; 709 712 710 int mSplits;713 //int mSplits; 711 714 712 715 ofstream mSubdivsionStats;
Note: See TracChangeset
for help on using the changeset viewer.