Changeset 495 for trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
- Timestamp:
- 01/04/06 10:02:28 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r492 r495 35 35 float BspMergeCandidate::sOverallCost = 0; 36 36 37 38 /// Adds object to the pvs of the front and back node39 inline void AddObject2Pvs(Intersectable *object,40 const int side,41 int &pvsBack,42 int &pvsFront)43 {44 if (!object)45 return;46 47 if (side <= 0)48 {49 if (!object->Mailed() && !object->Mailed(2))50 {51 ++ pvsBack;52 53 if (object->Mailed(1))54 object->Mail(2);55 else56 object->Mail();57 }58 }59 60 if (side >= 0)61 {62 if (!object->Mailed(1) && !object->Mailed(2))63 {64 ++ pvsFront;65 66 if (object->Mailed())67 object->Mail(2);68 else69 object->Mail(1);70 }71 }72 }73 74 75 37 /****************************************************************/ 76 38 /* class VspBspTree implementation */ … … 83 45 mViewCellsManager(NULL), 84 46 mStoreRays(false), 85 mOnlyDrivingAxis(false),86 47 mOutOfBoundsCell(NULL) 87 48 { … … 794 755 float VspBspTree::SelectAxisAlignedPlane(Plane3 &plane, 795 756 const VspBspTraversalData &tData, 796 int &bestAxis) 757 int &axis, 758 float &position, 759 int &raysBack, 760 int &raysFront, 761 int &pvsBack, 762 int &pvsFront) 797 763 { 798 764 AxisAlignedBox3 box; … … 810 776 float nPosition[3]; 811 777 float nCostRatio[3]; 812 bestAxis = -1;778 int bestAxis = -1; 813 779 814 780 const int sAxis = box.Size().DrivingAxis(); 815 781 816 for ( intaxis = 0; axis < 3; ++ axis)782 for (axis = 0; axis < 3; ++ axis) 817 783 { 818 784 if (!mOnlyDrivingAxis || axis == sAxis) … … 851 817 } 852 818 853 //-- assign best axis 819 //-- assign values 820 axis = bestAxis; 821 position = nPosition[bestAxis]; 822 823 raysBack = 0;//nRaysBack[bestAxis]; 824 raysFront = 0;//nRaysFront[bestAxis]; 825 826 pvsBack = 0;//nPvsBack[bestAxis]; 827 pvsFront = 0;//nPvsFront[bestAxis]; 828 854 829 Vector3 normal(0,0,0); normal[bestAxis] = 1; 855 830 plane = Plane3(normal, nPosition[bestAxis]); … … 1070 1045 } 1071 1046 1047 1072 1048 bool VspBspTree::SelectPlaneHeuristics(Plane3 &bestPlane, 1073 1049 BspLeaf *leaf, … … 1086 1062 for (int i = 0; i < limit; ++ i) 1087 1063 { 1088 // assure that no index is taken twice1064 //-- assure that no index is taken twice 1089 1065 const int candidateIdx = (int)RandomValue(0, (Real)(-- maxIdx)); 1090 //Debug << "current Idx: " << maxIdx << " cand idx " << candidateIdx << endl;1091 1092 1066 Polygon3 *poly = (*data.mPolygons)[candidateIdx]; 1093 1067 … … 1109 1083 //-- axis aligned splits 1110 1084 int axis; 1111 candidateCost = SelectAxisAlignedPlane(plane, data, axis); 1085 float position; 1086 int raysBack; 1087 int raysFront; 1088 int pvsFront; 1089 int pvsBack; 1090 1091 candidateCost = SelectAxisAlignedPlane(plane, 1092 data, 1093 axis, 1094 position, 1095 raysBack, 1096 raysFront, 1097 pvsFront, 1098 pvsBack); 1112 1099 1113 1100 if (candidateCost < lowestCost) … … 1116 1103 { 1117 1104 useAxisAlignedPlane = true; 1105 //if (data.mPolygons->size() > 0) 1106 // Debug << "haha" << endl; 1118 1107 //! error also computed if cost ratio is missed 1119 1108 ++ mStat.splits[axis]; … … 1142 1131 Intersectable::NewMail(); sFrontAndBackId = ViewCell::sMailId; 1143 1132 } 1133 1144 1134 1145 1135 float VspBspTree::SplitPlaneCost(const Plane3 &candidatePlane, … … 1159 1149 float pBack = 0; 1160 1150 1161 const bool pvsUseLen = false;1162 1163 1151 if (mSplitPlaneStrategy & PVS) 1164 1152 { 1165 // matt: change back!!1166 Intersectable::NewMail(3);1167 1153 // create unique ids for pvs heuristics 1168 //GenerateUniqueIdsForPvs();1154 GenerateUniqueIdsForPvs(); 1169 1155 1170 1156 if (mPvsUseArea) // use front and back cell areas to approximate volume … … 1227 1213 // assure that we only count the object 1228 1214 // once for the front and once for the back side of the plane 1229 1230 // add the termination object 1231 //AddObjToPvs(ray->mTerminationObject, cf, frontPvs, backPvs); 1232 AddObject2Pvs(ray->mTerminationObject, cf, frontPvs, backPvs); 1233 // add the source object 1234 //AddObjToPvs(ray->mOriginObject, cf, frontPvs, backPvs); 1215 AddObjToPvs(ray->mTerminationObject, cf, frontPvs, backPvs); 1216 AddObjToPvs(ray->mOriginObject, cf, frontPvs, backPvs); 1235 1217 1236 1218 // use number of rays to approximate volume 1237 1219 if (!mPvsUseArea) 1238 1220 { 1239 ++ pOverall;1221 pOverall = (float)data.mRays->size(); 1240 1222 1241 1223 if (cf >= 0) … … 1253 1235 1254 1236 if (mSplitPlaneStrategy & BALANCED_RAYS) 1255 cost += mBalancedRaysFactor * fabs(sumBalancedRays) / 1237 cost += mBalancedRaysFactor * fabs(sumBalancedRays) / raysSize; 1256 1238 1257 1239 // pvs criterium … … 2125 2107 BspNode *VspBspTree::CollapseTree(BspNode *node) 2126 2108 { 2127 2109 if (node->IsLeaf()) 2128 2110 return node; 2129 2111 … … 2156 2138 } 2157 2139 2140 return node; 2141 } 2142 2143 2144 void VspBspTree::CollapseTree() 2145 { 2146 CollapseTree(mRoot); 2158 2147 // revalidate leaves 2159 2148 RepairVcLeafLists(); 2160 2161 return node;2162 2149 } 2163 2150
Note: See TracChangeset
for help on using the changeset viewer.