- Timestamp:
- 11/03/05 18:49:59 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj
r373 r375 255 255 </File> 256 256 <File 257 RelativePath="..\src\Statistics.h"> 258 </File> 259 <File 257 260 RelativePath="..\src\Triangle3.cpp"> 258 261 </File> … … 286 289 <File 287 290 RelativePath="..\src\VisibilityVector3.h"> 291 </File> 292 <File 293 RelativePath="..\src\VssPreprocessor.cpp"> 294 </File> 295 <File 296 RelativePath="..\src\VssPreprocessor.h"> 297 </File> 298 <File 299 RelativePath="..\src\VssRay.cpp"> 300 </File> 301 <File 302 RelativePath="..\src\VssRay.h"> 303 </File> 304 <File 305 RelativePath="..\src\VssTree.cpp"> 306 </File> 307 <File 308 RelativePath="..\src\VssTree.h"> 288 309 </File> 289 310 <File -
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r371 r375 68 68 maxViewCells 0 69 69 70 minPvsDif 100 70 minPvsDif 1000 71 71 # maxPvsSize 200 72 72 -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
r372 r375 414 414 } 415 415 416 int Polygon3:: CountIntersectables(const PolygonContainer &polys)416 int Polygon3::ParentObjectsSize(const PolygonContainer &polys) 417 417 { 418 418 int count = 0; -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.h
r372 r375 122 122 /** Counts the number of different intersectables associated with the polygons. 123 123 */ 124 static int CountIntersectables(const PolygonContainer &polys);124 static int ParentObjectsSize(const PolygonContainer &polys); 125 125 }; 126 126 -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r374 r375 514 514 << "k #SampleContributions=" << passSampleContributions << " (" 515 515 << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS=" 516 << pvsSize /(float)objects.size() << endl516 << pvsSize /(float)objects.size() << endl 517 517 << "avg ray contrib=" << avgRayContrib << endl 518 518 << "reverse samples [%]" << reverseSamples/(float)passSamples*100.0f << endl; … … 531 531 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 532 532 533 //-- post processing of bsp view cells 533 534 if (mBspTree) 534 535 { 536 int vcSize = 0; 537 int pvsSize = 0; 538 539 BspViewCellsStatistics stat; 540 541 Debug << "overall scene size: " << objects.size() << endl; 542 mBspTree->EvaluateViewCellsStats(stat); 543 544 Debug << "original view cell partition:\n" << stat << endl; 545 535 546 cout << "starting post processing using " << mSampleRays.size() << " samples ... "; 536 537 Debug << "original pvs size: " << mBspTree->CountViewCellPvs() << endl; 538 539 // merge or subdivide view cells 547 540 548 long startTime = GetTime(); 541 549 int merged = PostprocessViewCells(mSampleRays); … … 545 553 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 546 554 555 cout << "evaluating render time heuristics ... "; 556 547 557 //-- recount pvs 548 Debug << "merged pvs size: " << mBspTree->CountViewCellPvs() << endl;549 550 551 cout << "evaluating render time heuristics ... "; 558 mBspTree->EvaluateViewCellsStats(stat); 559 560 Debug << "after post processing:\n" << stat << endl; 561 552 562 Real rt = SimulateRendering(); 553 563 cout << "finished" << endl; … … 591 601 592 602 // export the bsp splits 603 cout << "exporting splits ... "; 593 604 if (exportSplits) 594 605 ExportSplits(objects); 595 606 cout << "finished" << endl; 607 596 608 ExportBspPvs(objects); 597 609 } … … 686 698 { 687 699 int merged = 0; 700 688 701 RayContainer::const_iterator rit, rit_end = rays.end(); 689 702 vector<Ray::BspIntersection>::const_iterator iit; … … 708 721 { 709 722 mBspTree->MergeViewCells(leaf, previousLeaf); 723 710 724 ++ merged; 711 725 } … … 723 737 if (exporter) 724 738 { 725 cout << "exporting splits ... ";726 727 739 Material m; 728 740 m.mDiffuseColor = RgbColor(1, 0, 0); … … 769 781 770 782 delete exporter; 771 772 cout << "finished" << endl;773 783 } 774 784 } … … 787 797 const int raysOut = min((int)mSampleRays.size(), 20000); 788 798 789 // check whether we can add the current ray to the output rays 790 for (int k = 0; k < raysOut; ++ k) 799 ViewCell::NewMail(); 800 801 for (int i = 0; i < bspLeaves.size(); ++ i) 791 802 { 792 Ray *ray = mSampleRays[k];793 794 for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j)795 { 796 BspLeaf *leaf = ray->bspIntersections[j].mLeaf;797 798 for (int i = 0; i < (int)bspLeaves.size(); ++ i)803 cout << "creating output for view cell " << i << " ... "; 804 // check whether we can add the current ray to the output rays 805 for (int k = 0; k < raysOut; ++ k) 806 { 807 Ray *ray = mSampleRays[k]; 808 809 for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 799 810 { 811 BspLeaf *leaf = ray->bspIntersections[j].mLeaf; 812 800 813 if (bspLeaves[i]->GetViewCell() == leaf->GetViewCell()) 801 814 { … … 804 817 } 805 818 } 806 } 807 808 ViewCell::NewMail(); 809 810 for (int i = 0; i < bspLeaves.size(); ++ i) 811 { 819 812 820 Intersectable::NewMail(); 813 821 … … 883 891 } 884 892 DEL_PTR(exporter); 893 cout << "finished" << endl; 885 894 } 886 895 887 896 if (1) // export view cells and leaves 888 897 { 898 cout << "exporting view cells and leaves ... "; 889 899 Exporter *exporter = Exporter::GetExporter("viewCells.x3d"); 890 900 if (exporter) … … 901 911 delete exporter; 902 912 } 913 cout << "finished" << endl; 903 914 } 904 915 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r374 r375 343 343 } 344 344 345 void BspViewCellsStatistics::Print(ostream &app) const 346 { 347 app << "===== BspViewCells statistics ===============\n"; 348 349 app << setprecision(4); 350 351 app << "#N_PMAXPVS ( largest PVS )\n" << maxPvs << endl; 352 353 app << "#N_PMINPVS ( smallest PVS )\n" << minPvs << endl; 354 355 app << "#N_PAVGPVS ( average PVS )\n" << AvgPvs() << endl; 356 357 app << "#N_PEMPTYPVS ( view cells with PVS smaller 2 )\n" << emptyPvs << endl; 358 359 app << "#N_VIEWCELLS ( number of view cells)\n" << viewCells << endl; 360 361 app << "#N_AVGBSPLEAVES (average number of BSP leaves per view cell )\n" << AvgBspLeaves() << endl; 362 363 app << "#N_MAXBSPLEAVES ( maximal number of BSP leaves per view cell )\n" << maxBspLeaves << endl; 364 365 app << "===== END OF BspViewCells statistics ==========\n"; 366 } 367 345 368 void BspTreeStatistics::Print(ostream &app) const 346 369 { … … 368 391 app << "#N_INPUT_POLYGONS (number of input polygons )\n" << polys << endl; 369 392 370 app << "#N_PVS: " << pvs << endl;393 //app << "#N_PVS: " << pvs << endl; 371 394 372 395 app << "#N_ROUTPUT_INPUT_POLYGONS ( ratio polygons after subdivision / input polygons )\n" << … … 375 398 app << "===== END OF BspTree statistics ==========\n"; 376 399 } 400 377 401 378 402 BspTree::~BspTree() … … 1044 1068 ((int)rays.size() > sTermMaxRaysForAxisAligned) && 1045 1069 ((sTermMaxObjectsForAxisAligned < 0) || 1046 (Polygon3:: CountIntersectables(polys) > sTermMaxObjectsForAxisAligned)))1070 (Polygon3::ParentObjectsSize(polys) > sTermMaxObjectsForAxisAligned))) 1047 1071 { 1048 1072 Plane3 plane; … … 1529 1553 if (data.mDepth >= sTermMaxDepth) 1530 1554 ++ mStat.maxDepthNodes; 1555 1531 1556 // store maximal and minimal depth 1532 1557 if (data.mDepth > mStat.maxDepth) 1533 1558 mStat.maxDepth = data.mDepth; 1559 1534 1560 if (data.mDepth < mStat.minDepth) 1535 1561 mStat.minDepth = data.mDepth; … … 1537 1563 // accumulate depth to compute average 1538 1564 mStat.accumDepth += data.mDepth; 1539 1540 if (leaf->mViewCell != mRootCell)1541 {1542 ++ mStat.viewCells;1543 mStat.pvs += leaf->mViewCell->GetPvs().GetSize();1544 }1545 1565 1546 1566 #ifdef _DEBUG … … 1695 1715 } 1696 1716 1697 int BspTree::CountViewCellPvs() const 1698 { 1699 int count = 0; 1717 void BspTree::EvaluateViewCellsStats(BspViewCellsStatistics &stat) const 1718 { 1719 stat.Reset(); 1720 1700 1721 stack<BspNode *> nodeStack; 1701 1722 nodeStack.push(mRoot); … … 1713 1734 if (node->IsLeaf()) 1714 1735 { 1715 ViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->mViewCell; 1736 ++ stat.bspLeaves; 1737 1738 BspViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->mViewCell; 1716 1739 1717 1740 if (!viewCell->Mailed()) 1718 1741 { 1719 1742 viewCell->Mail(); 1720 count += viewCell->GetPvs().GetSize(); 1743 1744 ++ stat.viewCells; 1745 int pvsSize = viewCell->GetPvs().GetSize(); 1746 1747 stat.pvs += pvsSize; 1748 1749 if (pvsSize < 2) 1750 ++ stat.emptyPvs; 1751 1752 if (pvsSize > stat.maxPvs) 1753 stat.maxPvs = pvsSize; 1754 1755 if (pvsSize < stat.minPvs) 1756 stat.minPvs = pvsSize; 1757 1758 if ((int)viewCell->mBspLeaves.size() > stat.maxBspLeaves) 1759 stat.maxBspLeaves = (int)viewCell->mBspLeaves.size(); 1721 1760 } 1722 1761 } … … 1729 1768 } 1730 1769 } 1731 return count;1732 1770 } 1733 1771 … … 2308 2346 Ray *ray = (*rit)->mRay; 2309 2347 2310 for (iit = ray->bspIntersections.begin(); iit != ray->bspIntersections.end(); ++ iit) 2348 for (iit = ray->bspIntersections.begin(); 2349 iit != ray->bspIntersections.end(); ++ iit) 2311 2350 { 2312 2351 BspViewCell *vc = (*iit).mLeaf->mViewCell; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r373 r375 68 68 // number of initial polygons 69 69 int polys; 70 /// number of view cells different to the view cell representing unbounded space.71 int viewCells;72 /// size of the VPS73 int pvs;74 70 /// samples contributing to pvs 75 71 int contributingSamples; 76 72 /// sample contributions to pvs 77 73 int sampleContributions; 74 /// largest pvs 75 int largestPvs; 78 76 79 77 // Constructor … … 97 95 polys = 0; 98 96 accumDepth = 0; 99 viewCells = 0; 100 pvs = 0; 97 101 98 contributingSamples = 0; 102 99 sampleContributions = 0; … … 107 104 108 105 friend ostream &operator<<(ostream &s, const BspTreeStatistics &stat) { 106 stat.Print(s); 107 return s; 108 } 109 110 }; 111 112 class BspViewCellsStatistics 113 { 114 public: 115 116 /// number of view cells 117 int viewCells; 118 119 /// size of the PVS 120 int pvs; 121 122 /// largest PVS of all view cells 123 int maxPvs; 124 125 /// smallest PVS of all view cells 126 int minPvs; 127 128 /// view cells with empty PVS 129 int emptyPvs; 130 131 /// number of bsp leaves covering the view space 132 int bspLeaves; 133 134 /// largest number of leaves covered by one view cell 135 int maxBspLeaves; 136 137 138 // Constructor 139 BspViewCellsStatistics() 140 { 141 Reset(); 142 } 143 144 double AvgBspLeaves() const {return (double)bspLeaves / (double)viewCells;}; 145 double AvgPvs() const {return (double)pvs / (double)viewCells;}; 146 147 148 void Reset() 149 { 150 viewCells = 0; 151 pvs = 0; 152 maxPvs = 0; 153 minPvs = 999999; 154 emptyPvs = 0; 155 bspLeaves = 0; 156 maxBspLeaves = 0; 157 } 158 159 void 160 Print(ostream &app) const; 161 162 friend ostream &operator<<(ostream &s, const BspViewCellsStatistics &stat) { 109 163 stat.Print(s); 110 164 return s; … … 422 476 bool MergeViewCells(BspLeaf *front, BspLeaf *back) const; 423 477 424 /** Traverses tree and counts PVS size of all view cells425 */ 426 int CountViewCellPvs() const;478 /** Traverses tree and counts all view cells as well as their PVS size. 479 */ 480 void EvaluateViewCellsStats(BspViewCellsStatistics &stat) const; 427 481 428 482 protected: … … 667 721 BspNode *mRoot; 668 722 669 /// Pointer to the root cell of the viewspace670 // ViewCell *mRootCell;671 723 672 724 BspTreeStatistics mStat;
Note: See TracChangeset
for help on using the changeset viewer.