Changeset 611 for trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
- Timestamp:
- 02/10/06 13:04:39 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note: See TracChangeset
for help on using the changeset viewer.