- Timestamp:
- 11/02/05 02:50:57 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r366 r367 56 56 57 57 Sampling { 58 totalSamples 2000000058 totalSamples 300000 59 59 samplesPerPass 3 60 60 } … … 82 82 # input fromViewCells 83 83 # input fromSceneGeometry 84 samples 10000 084 samples 10000 85 85 sideTolerance 0.005 86 86 } … … 97 97 # least ray splits = 256 98 98 # balanced rays = 512 99 # pvs = 1024 99 100 100 101 # least splits + balanced polygons … … 119 120 #splitPlaneStrategy 130 120 121 121 splitPlaneStrategy 1 30122 splitPlaneStrategy 1024 122 123 123 124 maxCandidates 80 … … 125 126 Termination { 126 127 # autopartition 127 maxRays 80128 maxPolygons 0128 maxRays 200 129 maxPolygons 5 129 130 maxDepth 100 130 131 131 132 # axis aligned splits 132 133 AxisAligned { 133 maxPolys 500 134 maxRays 300135 maxObjects 20 134 maxPolys 5000 135 maxRays 5000 136 maxObjects 2000 136 137 maxCostRatio 0.9 137 138 ct_div_ci 0.5 … … 142 143 splitBorder 0.01 143 144 } 145 146 PostProcessing { 147 samples 100000 148 } 144 149 145 150 # if split polys are stored for visualization -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r362 r367 1180 1180 "100000"); 1181 1181 1182 RegisterOption("BspTree.PostProcessing.samples", 1183 optInt, 1184 "-bsp_postprocessing_samples=", 1185 "200000"); 1186 1182 1187 RegisterOption("BspTree.Construction.sideTolerance", 1183 1188 optFloat, -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
r362 r367 351 351 Polygon3 &back_piece) const 352 352 { 353 if (mPiercingRays.empty()) 354 return; 355 353 356 RayContainer::const_iterator it, 354 357 it_end = mPiercingRays.end(); -
trunk/VUT/GtpVisibilityPreprocessor/src/Ray.cpp
r366 r367 195 195 196 196 197 void Ray::Insert(const BspIntersection &bspi)198 {199 vector<BspIntersection>::iterator it;200 201 while (it !=202 }203 204 197 ostream & 205 198 operator<<(ostream &s, const PassingRaySet &set) -
trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h
r366 r367 55 55 56 56 }; 57 58 struct BspIntersection 59 { 60 float mT; 61 BspLeaf *leaf; 62 BspIntersection(float t, BspLeaf *l): mT(t), leaf(l) 63 {} 64 65 bool operator<(const BspIntersection &b) const 66 { 67 return mT < b.mT; 68 } 69 }; 57 70 58 71 59 // I should have some abstract cell data type !!! here … … 75 63 76 64 vector<Intersection> intersections; 77 vector<Bsp Intersection> bspIntersections;65 vector<BspLeaf *> bspLeaves; 78 66 vector<KdLeaf *> kdLeaves; 79 67 vector<MeshInstance *> meshes; … … 210 198 int ClassifyPlane(const Plane3 &plane, const float minT, const float maxT) const; 211 199 212 void Insert(const BspIntersection &bspi);213 214 200 private: 215 201 Vector3 loc, dir; // Describes ray origin and vector -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r366 r367 14 14 environment->GetIntValue("Sampling.totalSamples", mTotalSamples); 15 15 environment->GetIntValue("BspTree.Construction.samples", mBspConstructionSamples); 16 16 environment->GetIntValue("BspTree.PostProcessing.samples", mPostProcessSamples); 17 17 mKdPvsDepth = 100; 18 18 mStats.open("stats.log"); … … 121 121 for (j=1; j < ((int)ray.bspLeaves.size() - 1); ++ j) 122 122 { 123 BspLeaf *leaf = ray.bsp Intersections.leaf;123 BspLeaf *leaf = ray.bspLeaves[j]; 124 124 125 125 if (leaf->GetViewCell() != &mUnbounded) … … 380 380 381 381 int reverseSamples = 0; 382 bool collectSamplesForBsp = 383 (ViewCell::sHierarchy == ViewCell::BSP) && 384 (BspTree::sConstructionMethod == BspTree::FROM_RAYS) && 385 (totalSamples < mBspConstructionSamples); 382 386 383 387 384 //cout << "totalSamples: " << totalSamples << endl; … … 457 454 if (ViewCell::sHierarchy == ViewCell::BSP) 458 455 { 459 ProcessBspViewCells(collectSamplesForBsp, 460 ray, 456 ProcessBspViewCells(ray, 461 457 object, 462 458 faceIndex, … … 523 519 if (mBspTree) 524 520 { 525 cout << "starting post processing ... ";521 cout << "starting post processing using " << mSampleRays.size() << " samples ... "; 526 522 527 523 Debug << "original pvs size: " << mBspTree->CountViewCellPvs() << endl; … … 620 616 } 621 617 622 bool SamplingPreprocessor::ProcessBspViewCells(bool collectSamplesForBsp, 623 Ray &ray, 618 bool SamplingPreprocessor::ProcessBspViewCells(Ray &ray, 624 619 Intersectable *object, 625 620 int faceIndex, … … 628 623 { 629 624 // save rays for bsp tree construction 630 if (collectSamplesForBsp) 625 if ((BspTree::sConstructionMethod == BspTree::FROM_RAYS) && 626 (mSampleRays.size() < mBspConstructionSamples)) 631 627 { 632 628 // also add origin to sample in order to extract it as input polygons … … 639 635 } 640 636 641 // construct BSP tree using the samples 642 if (!mBspTree) 637 if (!mBspTree) // construct BSP tree using the samples 643 638 { 639 cout << "building bsp tree from " << mSampleRays.size() << " samples " << endl; 644 640 BuildBspTree(); 645 641 642 // add contributions of saved samples to PVS 646 643 contributingSamples += mBspTree->GetStat().contributingSamples; 647 644 sampleContributions += mBspTree->GetStat().sampleContributions; 648 645 649 646 BspTreeStatistics(Debug); 647 650 648 if (0) Export("vc_bsptree.x3d", false, false, true); 649 650 // throw away samples because BSP leaves not stored in order 651 // Need ordered rays for post processing => collect new rays 652 CLEAR_CONTAINER(mSampleRays); 653 } 654 655 if ((int)mSampleRays.size() < mPostProcessSamples) 656 { 657 mSampleRays.push_back(new Ray(ray)); 651 658 } 652 659 … … 676 683 { 677 684 BspLeaf *leaf = *lit; 685 678 686 if (mBspTree->ShouldMerge(leaf, previousLeaf)) 679 687 { -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h
r362 r367 25 25 RayContainer mSampleRays; 26 26 int mBspConstructionSamples; 27 27 int mPostProcessSamples; 28 28 29 29 SamplingPreprocessor(); … … 65 65 66 66 /** Processes the BSP based view cells during a pass. 67 @param collectSamplesForBps if still in sample collection phase67 68 68 @param ray the current ray 69 69 @param object the currently processed object … … 75 75 76 76 */ 77 bool ProcessBspViewCells(bool collectSamplesForBsp, 78 Ray &ray, 77 bool ProcessBspViewCells(Ray &ray, 79 78 Intersectable *object, 80 79 int faceIndex, -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r366 r367 41 41 float BspTree::sLeastRaySplitsFactor = 1.0f; 42 42 float BspTree::sBalancedRaysFactor = 1.0f; 43 float BspTree::sPvsFactor = 1.0f; 43 44 44 45 bool BspTree::sStoreSplitPolys = false; … … 194 195 195 196 // classify polygon 196 const int c lassification= poly->ClassifyPlane(mPlane);197 const int cf = poly->ClassifyPlane(mPlane); 197 198 198 199 Polygon3 *front_piece = NULL; … … 201 202 VertexContainer splitVertices; 202 203 203 switch (c lassification)204 switch (cf) 204 205 { 205 206 case Polygon3::COINCIDENT: … … 224 225 ++ splits; // increase number of splits 225 226 226 //-- inherit rays from parent polygon 227 //-- inherit rays from parent polygon for blocked ray criterium 227 228 poly->InheritRays(*front_piece, *back_piece); 228 229 //Debug << "p: " << poly->mPiercingRays.size() << " f: " << front_piece->mPiercingRays.size() << " b: " << back_piece->mPiercingRays.size() << endl; … … 291 292 void BspLeaf::GenerateViewCell(const BoundedRayContainer &rays, 292 293 int &sampleContributions, 293 int &contributingSamples, 294 const bool storeRays) 294 int &contributingSamples) 295 295 { 296 296 sampleContributions = 0; … … 321 321 } 322 322 323 ray->bspIntersections.push_back(BspIntersection(this, (*it)->mMinT); 324 325 if (storeRays) 326 mViewCell->mPiercingRays.push_back(ray); 323 ray->bspLeaves.push_back(this); 327 324 } 328 325 } … … 628 625 if (it != facePolyMap.end()) 629 626 { 630 (*it).second->mPiercingRays.push_back(ray); 627 //store rays if needed for heuristics 628 if (sSplitPlaneStrategy & BLOCKED_RAYS) 629 (*it).second->mPiercingRays.push_back(ray); 631 630 } 632 631 else 633 { 632 { //store rays if needed for heuristics 634 633 Polygon3 *poly = new Polygon3(face, obj->GetMesh()); 635 634 poly->mParent = obj; 636 635 polys->push_back(poly); 637 poly->mPiercingRays.push_back(ray); 636 637 if (sSplitPlaneStrategy & BLOCKED_RAYS) 638 poly->mPiercingRays.push_back(ray); 638 639 639 640 facePolyMap[face] = poly; … … 642 643 } 643 644 645 facePolyMap.clear(); 646 647 // compue bounding box 644 648 Polygon3::IncludeInBox(*polys, mBox); 645 649 … … 848 852 849 853 // subdivide polygons with plane 850 mStat.splits += 851 interior->SplitPolygons(polys, frontPolys, backPolys, 852 coincident, sStoreSplitPolys); 854 mStat.splits += interior->SplitPolygons(polys, 855 frontPolys, 856 backPolys, 857 coincident, 858 sStoreSplitPolys); 853 859 854 860 BspInterior *parent = leaf->GetParent(); … … 1247 1253 float sumRaySplits = 0; 1248 1254 float pvsSize = 0; 1249 1255 float totalSize = 0; 1256 1257 // need three unique ids for small pvs criterium 1250 1258 Intersectable::NewMail(); 1259 const int backId = ViewCell::sMailId; 1260 Intersectable::NewMail(); 1261 const int frontId = ViewCell::sMailId; 1262 Intersectable::NewMail(); 1263 const int frontAndBackId = ViewCell::sMailId; 1264 //Debug << "f " << frontId << " b " << backId << " fb " << frontAndBackId << endl; 1251 1265 1252 1266 BoundedRayContainer::const_iterator rit, rit_end = rays.end(); … … 1258 1272 const float maxT = (*rit)->mMaxT; 1259 1273 1260 const int c lassification=1274 const int cf = 1261 1275 ray->ClassifyPlane(candidatePlane, minT, maxT); 1262 1276 1263 1277 if (sSplitPlaneStrategy & LEAST_RAY_SPLITS) 1264 1278 { 1265 sumBalancedRays += sBalancedRaysTable[c lassification];1279 sumBalancedRays += sBalancedRaysTable[cf]; 1266 1280 } 1267 1281 1268 1282 if (sSplitPlaneStrategy & BALANCED_RAYS) 1269 1283 { 1270 sumRaySplits += sLeastRaySplitsTable[c lassification];1284 sumRaySplits += sLeastRaySplitsTable[cf]; 1271 1285 } 1272 1286 … … 1276 1290 it_end = ray->intersections.end(); 1277 1291 1278 for (it = ray->intersections.begin(); it != it_end; ++ it)1292 if (!ray->intersections.empty()) 1279 1293 { 1280 if (!(*it).mObject->Mailed()) 1281 { 1282 (*it).mObject->Mail(); 1283 } 1294 1295 // assure that we only count a object 1296 // once for the front and once for the back side of the plane 1297 pvsSize += PvsValue(*ray->intersections[0].mObject, 1298 cf, 1299 frontId, 1300 backId, 1301 frontAndBackId); 1302 1303 // always add 2 for each object (= maximal large PVS) 1304 //if (inc > 0.01) totalSize += 2.0; 1284 1305 } 1306 //todo emerging obj 1285 1307 } 1286 1308 } … … 1294 1316 val += sBalancedRaysFactor * fabs(sumBalancedRays) / (float)rays.size(); 1295 1317 1318 if (sSplitPlaneStrategy & PVS) 1319 if (!rays.empty()) // HACK (should be maximal possible pvs) 1320 val += sPvsFactor * pvsSize / (float)rays.size(); 1321 1322 //Debug << "pvs: " << pvsSize << " val " << val << endl; 1296 1323 return val; 1324 } 1325 1326 1327 float BspTree::PvsValue(Intersectable &obj, 1328 const int cf, 1329 const int frontId, 1330 const int backId, 1331 const int frontAndBackId) const 1332 { 1333 float pvsVal = 0; 1334 1335 if (cf == Ray::COINCIDENT) 1336 return pvsVal; 1337 1338 if (cf == Ray::FRONT) 1339 { 1340 if ((obj.mMailbox != frontId) && 1341 (obj.mMailbox != frontAndBackId)) 1342 pvsVal = 1.0; 1343 1344 if (obj.mMailbox != backId) 1345 obj.mMailbox = frontId; 1346 else 1347 obj.mMailbox = frontAndBackId; 1348 } 1349 else if (cf == Ray::BACK) 1350 { 1351 if ((obj.mMailbox != backId) && 1352 (obj.mMailbox != frontAndBackId)) 1353 { 1354 pvsVal = 1.0; 1355 1356 if (obj.mMailbox != frontId) 1357 obj.mMailbox = backId; 1358 else 1359 obj.mMailbox = frontAndBackId; 1360 } 1361 } 1362 else if ((cf == Ray::FRONT_BACK) || (cf == Ray::BACK_FRONT)) 1363 { 1364 if ((obj.mMailbox == backId) || (obj.mMailbox == frontId)) 1365 pvsVal = 1.0; 1366 else if (obj.mMailbox != frontAndBackId) 1367 pvsVal = 2.0; 1368 1369 obj.mMailbox = frontAndBackId; 1370 } 1371 1372 return pvsVal; 1297 1373 } 1298 1374 … … 1324 1400 // the following criteria loop over all rays to find the cost value 1325 1401 if ((sSplitPlaneStrategy & BALANCED_RAYS) || 1326 (sSplitPlaneStrategy & LEAST_RAY_SPLITS)) 1402 (sSplitPlaneStrategy & LEAST_RAY_SPLITS) || 1403 (sSplitPlaneStrategy & PVS)) 1327 1404 { 1328 1405 val += SplitPlaneCost(candidatePlane, rays); … … 1403 1480 if (sSplitPlaneStrategy & BLOCKED_RAYS) 1404 1481 Debug << "blocked rays "; 1405 1482 if (sSplitPlaneStrategy & PVS) 1483 Debug << "pvs"; 1406 1484 Debug << endl; 1407 1485 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r366 r367 194 194 @param coincident returns the polygons coincident to the split plane 195 195 @param storePolys if the polygons should be stored in the node 196 196 197 @returns the number of splits 197 198 */ … … 250 251 @param sampleContributions the number contributions of the sampels 251 252 @param contributingSampels the number of contributing rays 252 @param storeRays if ray set should be stored in view cell253 253 254 */ 254 255 void GenerateViewCell(const BoundedRayContainer &rays, 255 256 int &sampleContributions, 256 int &contributingSamples, 257 const bool storeRays = false); 257 int &contributingSamples); 258 258 259 259 protected: … … 657 657 658 658 int CountPvs(const BoundedRayContainer &rays) const; 659 660 float PvsValue(Intersectable &obj, 661 const int cf, 662 const int frontId, 663 const int backId, 664 const int frontAndBackId) const; 665 659 666 /// Pointer to the root of the tree 660 667 BspNode *mRoot; … … 729 736 static float sLeastRaySplitsFactor; 730 737 static float sBalancedRaysFactor; 738 static float sPvsFactor; 731 739 732 740 /// if polygons should be stored in the tree
Note: See TracChangeset
for help on using the changeset viewer.