Changeset 335 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 10/18/05 02:06:28 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r332 r335 113 113 #splitPlaneStrategy 130 114 114 115 splitPlaneStrategy 66115 splitPlaneStrategy 130 116 116 117 maxCandidates 130117 maxCandidates 50 118 118 119 119 Termination { 120 120 # autopartition 121 121 maxRays -1 122 maxPolygons 4122 maxPolygons 20 123 123 maxDepth 100 124 124 125 125 #axis aligned split 126 maxPolysForAxisAligned 100126 maxPolysForAxisAligned 200 127 127 maxCostRatio 0.9 128 128 ct_div_ci 0.5 -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r333 r335 26 26 27 27 void 28 SamplingPreprocessor::SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction) 28 SamplingPreprocessor::SetupRay(Ray &ray, 29 const Vector3 &point, 30 const Vector3 &direction, 31 const int type) 29 32 { 30 33 ray.intersections.clear(); … … 34 37 35 38 // cout<<point<<" "<<direction<<endl; 36 ray.Init(point, direction, Ray::LOCAL_RAY);39 ray.Init(point, direction, type); 37 40 } 38 41 … … 259 262 Vector3 target = t*poly.mVertices[edge] + (1.0f-t)*poly.mVertices[(edge + 1)% 260 263 poly.mVertices.size()]; 261 SetupRay(ray, point, target - point );264 SetupRay(ray, point, target - point, Ray::LOCAL_RAY); 262 265 if (!mesh->CastRay(ray, mi)) { 263 266 // the rays which intersect the mesh have been discarded since they are not tangent … … 395 398 396 399 // construct a ray 397 SetupRay(ray, point, direction );400 SetupRay(ray, point, direction, Ray::LOCAL_RAY); 398 401 399 402 sampleContributions = CastRay(object, ray); -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h
r333 r335 34 34 35 35 void 36 SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction); 36 SetupRay(Ray &ray, 37 const Vector3 &point, 38 const Vector3 &direction, 39 const int type); 37 40 38 41 KdNode * -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r332 r335 1059 1059 1060 1060 // evaluate current candidate 1061 float candidateCost = SplitPlaneCost( polys, candidatePlane, rays);1061 float candidateCost = SplitPlaneCost(candidatePlane, polys, rays); 1062 1062 1063 1063 if (candidateCost < lowestCost) … … 1085 1085 } 1086 1086 1087 float BspTree::SplitPlaneCost(PolygonContainer &polys, 1088 const Plane3 &candidatePlane, 1089 const RayContainer &rays) 1087 float BspTree::SplitPlaneCost(const Plane3 &candidatePlane, 1088 const PolygonContainer &polys) const 1090 1089 { 1091 1090 float val = 0; 1092 1093 if (sSplitPlaneStrategy & VERTICAL_AXIS)1094 {1095 Vector3 tinyAxis(0,0,0); tinyAxis[mBox.Size().TinyAxis()] = 1.0f;1096 // we put a penalty on the dot product between the "tiny" vertical axis1097 // and the split plane axis1098 val += sVerticalSplitsFactor *1099 fabs(DotProd(candidatePlane.mNormal, tinyAxis));1100 }1101 1102 if (!((sSplitPlaneStrategy & BALANCED_POLYS) ||1103 (sSplitPlaneStrategy & LEAST_SPLITS) ||1104 (sSplitPlaneStrategy & LARGEST_POLY_AREA) ||1105 (sSplitPlaneStrategy & BALANCED_VIEW_CELLS) ||1106 (sSplitPlaneStrategy & BLOCKED_RAYS)))1107 {1108 return val;1109 }1110 1111 // -- strategies where the effect of the split plane is tested1112 // on all input polygons1113 1091 1114 1092 float sumBalancedPolys = 0; … … 1119 1097 float totalBlockedRays = 0; 1120 1098 //float totalArea = 0; 1121 1122 // container for balanced view cells criterium 1123 ObjectContainer frontViewCells; 1124 ObjectContainer backViewCells; 1125 1099 int totalViewCells = 0; 1100 1101 ViewCell::NewMail(); 1102 1126 1103 PolygonContainer::const_iterator it, it_end = polys.end(); 1127 1104 … … 1159 1136 MeshInstance *viewCell = (*it)->mParent; 1160 1137 1161 if (classification == Plane3::FRONT_SIDE) 1162 frontViewCells.push_back(viewCell); 1163 else if (viewCell && (classification == Plane3::BACK_SIDE)) 1164 backViewCells.push_back(viewCell); 1138 if (!viewCell->Mailed()) 1139 { 1140 viewCell->Mail(); 1141 1142 if (classification == Plane3::FRONT_SIDE) 1143 sumBalancedViewCells += 1.0f; 1144 else if (viewCell && (classification == Plane3::BACK_SIDE)) 1145 sumBalancedViewCells -= 1.0f; 1146 ++ totalViewCells; 1147 } 1165 1148 } 1166 1149 } … … 1179 1162 1180 1163 if (sSplitPlaneStrategy & BLOCKED_RAYS) 1181 if (totalBlockedRays >0)1164 if (totalBlockedRays != 0) 1182 1165 val += sBlockedRaysFactor * sumBlockedRays / totalBlockedRays; 1183 1166 1184 1167 if (sSplitPlaneStrategy & BALANCED_VIEW_CELLS) 1185 { 1186 // count number of unique view cells 1187 sort(frontViewCells.begin(), frontViewCells.end()); 1188 sort(backViewCells.begin(), backViewCells.end()); 1189 1190 ObjectContainer::const_iterator frontIt, frontIt_end = frontViewCells.end(); 1191 1192 Intersectable *vc = NULL; 1193 // increase counter for view cells in front of plane 1194 for (frontIt = frontViewCells.begin(); frontIt != frontIt_end; ++frontIt) 1195 { 1196 if (*frontIt != vc) 1197 { 1198 vc = *frontIt; 1199 sumBalancedViewCells += 1.0f; 1200 } 1201 } 1202 1203 ObjectContainer::const_iterator backIt, backIt_end = backViewCells.end(); 1204 vc = NULL; 1205 // decrease counter for view cells on back side of plane 1206 for (backIt = backViewCells.begin(); backIt != backIt_end; ++backIt) 1207 { 1208 if (*backIt != vc) 1209 { 1210 vc = *backIt; 1211 sumBalancedViewCells -= 1.0f; 1212 } 1213 } 1214 1215 val += sBalancedViewCellsFactor * fabs(sumBalancedViewCells) / 1216 (float)(frontViewCells.size() + backViewCells.size()); 1217 } 1168 if (totalViewCells != 0) 1169 val += sBalancedViewCellsFactor * fabs(sumBalancedViewCells) / 1170 (float)totalViewCells; 1171 1172 return val; 1173 } 1174 1175 float BspTree::SplitPlaneCost(const Plane3 &candidatePlane, 1176 const RayContainer &rays) const 1177 { 1178 float val = 0; 1218 1179 1219 1180 float sumBalancedRays = 0; … … 1232 1193 } 1233 1194 } 1195 1234 1196 if (sSplitPlaneStrategy & LEAST_RAY_SPLITS) 1235 1197 if (!rays.empty()) … … 1239 1201 if (!rays.empty()) 1240 1202 val += sBalancedRaysFactor * fabs(sumBalancedRays) / (float)rays.size(); 1203 1204 return val; 1205 } 1206 1207 float BspTree::SplitPlaneCost(const Plane3 &candidatePlane, 1208 const PolygonContainer &polys, 1209 const RayContainer &rays) const 1210 { 1211 float val = 0; 1212 1213 if (sSplitPlaneStrategy & VERTICAL_AXIS) 1214 { 1215 Vector3 tinyAxis(0,0,0); tinyAxis[mBox.Size().TinyAxis()] = 1.0f; 1216 // we put a penalty on the dot product between the "tiny" vertical axis 1217 // and the split plane axis 1218 val += sVerticalSplitsFactor * 1219 fabs(DotProd(candidatePlane.mNormal, tinyAxis)); 1220 } 1221 1222 if ((sSplitPlaneStrategy & BALANCED_POLYS) || 1223 (sSplitPlaneStrategy & LEAST_SPLITS) || 1224 (sSplitPlaneStrategy & LARGEST_POLY_AREA) || 1225 (sSplitPlaneStrategy & BALANCED_VIEW_CELLS) || 1226 (sSplitPlaneStrategy & BLOCKED_RAYS)) 1227 { 1228 val += SplitPlaneCost(candidatePlane, polys); 1229 } 1230 1231 if ((sSplitPlaneStrategy & BALANCED_RAYS) || 1232 (sSplitPlaneStrategy & LEAST_RAY_SPLITS)) 1233 { 1234 val += SplitPlaneCost(candidatePlane, rays); 1235 } 1241 1236 1242 1237 // return linear combination of the sums … … 1370 1365 } 1371 1366 1372 //#ifdef _DEBUG1367 #ifdef _DEBUG 1373 1368 Debug << "BSP stats: " 1374 1369 << "Depth: " << data.mDepth << " (max: " << sTermMaxDepth << "), " 1375 1370 << "#polygons: " << (int)data.mPolygons->size() << " (max: " << sTermMaxPolygons << "), " 1376 1371 << "#rays: " << (int)data.mRays->size() << " (max: " << sTermMaxRays << ")" << endl; 1377 //#endif1372 #endif 1378 1373 } 1379 1374 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r332 r335 403 403 @param polys the polygon list on which the split decition is based 404 404 @param rays ray container on which selection may be based 405 Returns the split plane 405 @note the polygons can be reordered in the process 406 @returns the split plane 406 407 */ 407 408 Plane3 SelectPlane(BspLeaf *leaf, … … 410 411 411 412 /** Evaluates the contribution of the candidate split plane. 412 @note the polygons can be reordered in the process. 413 414 @param canditatePlane the candidate split plane 415 @param polys the polygons the split can be based on 416 @param rays the rays the split can be based on 413 417 @returns the cost of the candidate split plane 414 418 */ 415 float SplitPlaneCost(PolygonContainer &polys, 416 const Plane3 &candidatePlane, 417 const RayContainer &rays); 419 float SplitPlaneCost(const Plane3 &candidatePlane, 420 const PolygonContainer &polys, 421 const RayContainer &rays) const; 422 423 /** Strategies where the effect of the split plane is tested 424 on all input rays. 425 @returns the cost of the candidate split plane 426 */ 427 float SplitPlaneCost(const Plane3 &candidatePlane, 428 const PolygonContainer &polys) const; 429 430 /** Strategies where the effect of the split plane is tested 431 on all input polygons. 432 @returns the cost of the candidate split plane 433 */ 434 float SplitPlaneCost(const Plane3 &candidatePlane, 435 const RayContainer &polys) const; 418 436 419 437 /** Filters next view cell down the tree and inserts it into the appropriate leaves -
trunk/VUT/GtpVisibilityPreprocessor/src/default.env
r333 r335 9 9 # filename vienna.x3d 10 10 # filename ../data/vienna/vienna-simple.x3d 11 #filename ../data/vienna/vienna-buildings.x3d11 filename ../data/vienna/vienna-buildings.x3d 12 12 # filename ../data/vienna/viewcells-25-sel.x3d 13 filename ../data/atlanta/atlanta2.x3d13 # filename ../data/atlanta/atlanta2.x3d 14 14 # filename ../data/soda/soda.dat 15 15 # filename ../data/soda/soda5.dat … … 30 30 sahUseFaces true 31 31 Termination { 32 minCost 132 minCost 2 33 33 maxDepth 18 34 maxCostRatio 0.9 534 maxCostRatio 0.9 35 35 ct_div_ci 0.5 36 36 } … … 43 43 MeshKdTree { 44 44 Termination { 45 minCost 146 maxDepth 1 247 maxCostRatio 0.9 545 minCost 4 46 maxDepth 18 47 maxCostRatio 0.9 48 48 ct_div_ci 0.5 49 49 } … … 56 56 57 57 Sampling { 58 totalSamples 100 58 totalSamples 1000000 59 59 samplesPerPass 20 60 60 } 61 61 62 62 ViewCells { 63 hierarchyType bspTree 63 #hierarchy kdTree 64 hierarchy bspTree 65 # hierarchy sceneDependent 66 64 67 height 5.0 65 68 maxViewCells 0 66 #hierarchyType kdTree 67 #hierarchyType sceneDependent 69 68 70 # filename ../data/atlanta/atlanta_viewcells_large.x3d 69 #filename ../data/vienna/viewcells-25-sel.x3d70 filename ../data/vienna/viewcells-25.x3d71 filename ../data/vienna/viewcells-25-sel.x3d 72 # filename ../data/vienna/viewcells-25.x3d 71 73 # filename ../data/vienna/viewcells-large-sel.x3d 72 74 } 73 75 74 76 BspTree { 75 # constructionMethod fromRays 76 # constructionMethod fromViewCells 77 constructionMethod fromSceneGeometry 77 Construction { 78 # input fromRays 79 # input fromViewCells 80 input fromSceneGeometry 81 samples 200000 82 sideTolerance 0.002 83 } 84 78 85 79 86 # random polygon = 1 … … 85 92 # vertical axis = 64 86 93 # blocked rays = 128 87 94 # least ray splits = 256 95 # balanced rays = 512 96 88 97 # least splits + balanced polygons 89 98 #splitPlaneStrategy 12 … … 101 110 #splitPlaneStrategy 72 102 111 112 # axis aligned + blocked rays 113 #splitPlaneStrategy 130 114 103 115 splitPlaneStrategy 66 104 116 … … 106 118 107 119 Termination { 108 maxPolysForAxisAligned 100 120 # autopartition 121 maxRays -1 109 122 maxPolygons 20 110 123 maxDepth 100 124 125 #axis aligned split 126 maxPolysForAxisAligned 100 127 maxCostRatio 0.9 128 ct_div_ci 0.5 111 129 } 130 131 #axis aligned split 132 splitBorder 0.01 133 112 134 # if split polys are stored for visualization 113 135 storeSplitPolys false -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r333 r335 96 96 97 97 98 if ( 0) {98 if (1) { 99 99 p->ComputeVisibility(); 100 100 p->ExportPreprocessedData("scene.vis");
Note: See TracChangeset
for help on using the changeset viewer.