Changeset 1449
- Timestamp:
- 09/21/06 19:14:24 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1444 r1449 525 525 (0 526 526 || (mBvhStats.Leaves() >= mTermMaxLeaves) 527 || (m GlobalCostMisses >= mTermGlobalCostMissTolerance)527 || (mBvhStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 528 528 //|| mOutOfMemory 529 529 ); … … 532 532 { 533 533 Debug << "bvh global termination criteria met:" << endl; 534 Debug << "cost misses: " << m GlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl;534 Debug << "cost misses: " << mBvhStats.mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 535 535 Debug << "leaves: " << mBvhStats.Leaves() << " " << mTermMaxLeaves << endl; 536 536 } … … 1623 1623 void BvHierarchy::CreateRoot(const ObjectContainer &objects) 1624 1624 { 1625 /////// 1625 1626 //-- create new root 1627 1626 1628 AxisAlignedBox3 box = EvalBoundingBox(objects); 1627 1629 BvhLeaf *bvhleaf = new BvhLeaf(box, NULL, (int)objects.size()); … … 1661 1663 1662 1664 mBvhStats.nodes = 1; 1663 mGlobalCostMisses = 0;1665 1664 1666 1665 1667 // store pointer to this tree … … 1699 1701 1700 1702 1701 /////////////////// /////////////////////////////////1703 /////////////////// 1702 1704 //-- add first candidate for object space partition 1703 1705 … … 1847 1849 maxRayContriNodes * 100 / (double)Leaves() << endl; 1848 1850 1851 app << "#N_PGLOBALCOSTMISSES ( Global cost misses )\n" << mGlobalCostMisses << endl; 1852 1849 1853 app << "========== END OF BvHierarchy statistics ==========\n"; 1850 1854 } -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1408 r1449 88 88 rayRefs = 0; 89 89 maxRayContriNodes = 0; 90 mGlobalCostMisses = 0; 90 91 } 91 92 … … 109 110 /// nodes termination because of max cost ratio; 110 111 int maxCostNodes; 111 112 /////////////////////////// 112 // global cost ratio violations 113 int mGlobalCostMisses; 114 115 ////////////////// 113 116 // nodes with minimum objects 114 117 int minObjectsNodes; … … 799 802 800 803 801 //////////////////// ////////////804 //////////////////// 802 805 //-- local termination criteria 803 806 … … 816 819 817 820 818 //////////////////// ////////////////821 //////////////////// 819 822 //-- global termination criteria 820 823 821 824 float mTermMinGlobalCostRatio; 822 825 int mTermGlobalCostMissTolerance; 823 int mGlobalCostMisses;826 824 827 825 828 /// maximal number of view cells -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1444 r1449 2464 2464 "-1"); 2465 2465 2466 RegisterOption("Hierarchy.Construction.useMultiLevelConstruction", 2467 optBool, 2468 "hierarchy_construction_use_multilevel_construction=", 2469 "false"); 2470 2466 2471 ////////////////////////////////////////////////////////////////////////////////// 2467 2472 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1444 r1449 106 106 "Hierarchy.Construction.repairQueue", mRepairQueue); 107 107 108 Environment::GetSingleton()->GetBoolValue( 109 "Hierarchy.Construction.useMultiLevelConstruction", mUseMultiLevelConstruction); 110 111 mUseMultiLevelConstruction; 108 112 Debug << "******** Hierachy Manager Parameters ***********" << endl; 109 113 Debug << "max leaves: " << mTermMaxLeaves << endl; … … 113 117 Debug << "min depth for object space subdivision: " << mMinDepthForObjectSpaceSubdivion << endl; 114 118 Debug << "repair queue: " << mRepairQueue << endl; 119 Debug << endl; 115 120 } 116 121 … … 234 239 (0 235 240 || (mHierarchyStats.Leaves() >= mTermMaxLeaves) 236 || (m GlobalCostMisses >= mTermGlobalCostMissTolerance)237 || (candidate->GlobalTerminationCriteriaMet())241 || (mHierarchyStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 242 || (candidate->GlobalTerminationCriteriaMet()) 238 243 ); 239 244 … … 242 247 Debug << "hierarchy global termination criteria met:" << endl; 243 248 Debug << "leaves: " << mHierarchyStats.Leaves() << " " << mTermMaxLeaves << endl; 244 Debug << "cost misses: " << m GlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl;249 Debug << "cost misses: " << mHierarchyStats.mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 245 250 } 246 251 return terminationCriteriaMet; … … 252 257 AxisAlignedBox3 *forcedViewSpace) 253 258 { 259 if (mUseMultiLevelConstruction) 260 { 261 ConstructMultiLevel(sampleRays, objects, forcedViewSpace); 262 } 263 else 264 { 265 ConstructInterleaved(sampleRays, objects, forcedViewSpace); 266 } 267 } 268 269 270 void HierarchyManager::ConstructInterleaved(const VssRayContainer &sampleRays, 271 const ObjectContainer &objects, 272 AxisAlignedBox3 *forcedViewSpace) 273 { 254 274 mHierarchyStats.Reset(); 255 275 mHierarchyStats.Start(); 256 276 mHierarchyStats.nodes = 2; // two nodes for view space and object space 277 257 278 mTotalCost = (float)objects.size(); 258 279 Debug << "setting total cost to " << mTotalCost << endl; … … 287 308 288 309 // process object space candidates 289 RunConstruction( sampleRays, objects, forcedViewSpace);310 RunConstruction(mRepairQueue, sampleRays, objects, forcedViewSpace); 290 311 291 312 cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; … … 342 363 343 364 cout << "preparing bv hierarchy construction ... " << endl; 344 mBvHierarchy->CreateRoot(objects);365 mBvHierarchy->CreateRoot(objects); 345 366 346 367 // compute first candidate … … 390 411 if (costRatio < mTermMinGlobalCostRatio) 391 412 { 392 ++ m GlobalCostMisses;413 ++ mHierarchyStats.mGlobalCostMisses; 393 414 } 394 415 … … 484 505 485 506 486 void HierarchyManager::RunConstruction(const VssRayContainer &sampleRays, 507 void HierarchyManager::RunConstruction(const bool repairQueue, 508 const VssRayContainer &sampleRays, 487 509 const ObjectContainer &objects, 488 510 AxisAlignedBox3 *forcedViewSpace) 489 511 { 490 mHierarchyStats.nodes = 0;491 mGlobalCostMisses = 0;492 493 512 int i = 0; 494 513 while (!FinishedConstruction()) … … 511 530 // reevaluate candidates affected by the split for view space splits, 512 531 // this would be object space splits and other way round 513 if ( mRepairQueue) RepairQueue();532 if (repairQueue) RepairQueue(); 514 533 } 515 534 … … 548 567 DEL_PTR(mCurrentCandidate); 549 568 } 569 } 570 571 572 573 void HierarchyManager::RunConstruction(const bool repairQueue) 574 { 575 int i = 0; 576 while (!FinishedConstruction()) 577 { 578 mCurrentCandidate = NextSubdivisionCandidate(); 579 580 /////////////////// 581 //-- subdivide leaf node 582 583 if (ApplySubdivisionCandidate(mCurrentCandidate)) 584 { 585 cout << mCurrentCandidate->Type() << " "; 586 if (0) cout << "subdividing candidate " << ++ i << " of type " 587 << mCurrentCandidate->Type() << endl; 588 mHierarchyStats.nodes += 2; 589 590 // subdivision successful 591 EvalSubdivisionStats(*mCurrentCandidate); 592 593 // reevaluate candidates affected by the split for view space splits, 594 // this would be object space splits and other way round 595 if (repairQueue) RepairQueue(); 596 } 597 598 DEL_PTR(mCurrentCandidate); 599 } 600 } 601 602 603 void HierarchyManager::ResetObjectSpaceSubdivision(const ObjectContainer &objects) 604 { 605 Debug << "old bv hierarchy: " << mBvHierarchy->mBvhStats << endl; 606 mHierarchyStats.nodes -= mBvHierarchy->mBvhStats.nodes; 607 mHierarchyStats.mGlobalCostMisses = 0; // hack: reset global cost misses 608 DEL_PTR(mBvHierarchy); 609 mBvHierarchy = new BvHierarchy(); 610 mBvHierarchy->mHierarchyManager = this; 611 } 612 613 614 void HierarchyManager::ConstructMultiLevel(const VssRayContainer &sampleRays, 615 const ObjectContainer &objects, 616 AxisAlignedBox3 *forcedViewSpace) 617 { 618 mHierarchyStats.Reset(); 619 mHierarchyStats.Start(); 620 621 mHierarchyStats.nodes = 2; 622 623 624 mTotalCost = (float)objects.size(); 625 Debug << "setting total cost to " << mTotalCost << endl; 626 627 const long startTime = GetTime(); 628 cout << "Constructing view space / object space tree ... \n"; 629 630 // compute view space bounding box 631 mVspTree->ComputeBoundingBox(sampleRays, forcedViewSpace); 632 633 // use sah for evaluating object space construction for the first run 634 mSavedViewSpaceSubdivisionType = mViewSpaceSubdivisionType; 635 mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 636 637 // start with object space subdivision 638 PrepareObjectSpaceSubdivision(sampleRays, objects); 639 640 // process object space candidates 641 RunConstruction(false); 642 643 ///////////////// 644 // now do view space subdivison on the sah bvh nodes 645 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 646 PrepareViewSpaceSubdivision(sampleRays, objects); 647 648 // process view space candidates 649 RunConstruction(false); 650 651 // again run object space subdivision on the view cells 652 ResetObjectSpaceSubdivision(objects); 653 PrepareObjectSpaceSubdivision(sampleRays, objects); 654 655 // process object space candidates 656 RunConstruction(false); 657 658 cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 659 660 #if _DEBUG 661 cout << "view space: " << GetViewSpaceBox() << endl; 662 cout << "object space: " << GetObjectSpaceBox() << endl; 663 #endif 664 665 mHierarchyStats.Stop(); 666 mVspTree->mVspStats.Stop(); 667 FinishObjectSpaceSubdivision(objects); 550 668 } 551 669 … … 863 981 864 982 app << "#N_PMAXDEPTH ( Maximal reached depth )\n" << maxDepth << endl; 983 984 app << "#N_GLOBALCOSTMISSES ( Global cost misses )\n" << mGlobalCostMisses << endl; 865 985 866 986 app << "========== END OF Hierarchy statistics ==========\n"; -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1421 r1449 72 72 /// accumulated depth 73 73 int accumDepth; 74 74 /// time spent for queue repair 75 75 float repairTime; 76 // global cost ratio violations 77 int mGlobalCostMisses; 76 78 77 79 // Constructor … … 88 90 double AvgDepth() const { return accumDepth / (double)Leaves();} 89 91 90 void Reset() 91 { 92 void Reset() 93 { 94 mGlobalCostMisses = 0; 92 95 nodes = 0; 93 96 maxDepth = 0; … … 247 250 248 251 void RunConstruction( 252 const bool repairQueue, 249 253 const VssRayContainer &sampleRays, 250 254 const ObjectContainer &objects, 251 255 AxisAlignedBox3 *forcedViewSpace); 252 256 257 void RunConstruction(const bool repairQueue); 258 253 259 bool ApplySubdivisionCandidate(SubdivisionCandidate *sc); 254 260 … … 306 312 int GetObjectSpaceSubdivisionDepth() const; 307 313 314 void ConstructInterleaved( 315 const VssRayContainer &sampleRays, 316 const ObjectContainer &objects, 317 AxisAlignedBox3 *forcedViewSpace); 318 319 void ConstructMultiLevel( 320 const VssRayContainer &sampleRays, 321 const ObjectContainer &objects, 322 AxisAlignedBox3 *forcedViewSpace); 323 324 void ResetObjectSpaceSubdivision(const ObjectContainer &objects); 325 308 326 protected: 309 327 … … 329 347 SubdivisionCandidate *mCurrentCandidate; 330 348 349 //////// 331 350 //-- global criteria 332 351 float mTermMinGlobalCostRatio; 333 352 int mTermGlobalCostMissTolerance; 334 int mGlobalCostMisses; 335 353 336 354 /// keeps track of cost during subdivision 337 355 float mTotalCost; … … 348 366 349 367 bool mStartWithObjectSpace; 368 369 bool mUseMultiLevelConstruction; 350 370 }; 351 371 -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r1420 r1449 735 735 } 736 736 737 738 737 739 /********************************************************/ 738 740 /* MeshInstance implementation */ -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h
r1379 r1449 79 79 /// accumulated number of rays refs 80 80 int accumRays; 81 /// potentially visible objects from this leaf81 /// overall potentially visible objects 82 82 int pvs; 83 84 83 // accumulated depth (used to compute average) 85 84 int accumDepth; 85 // global cost ratio violations 86 int mGlobalCostMisses; 87 86 88 87 89 // Constructor … … 111 113 maxDepthNodes = 0; 112 114 minPvsNodes = 0; 113 114 115 minProbabilityNodes = 0; 115 116 maxCostNodes = 0; 116 117 117 contributingSamples = 0; 118 118 sampleContributions = 0; 119 120 119 maxPvs = 0; 121 120 invalidLeaves = 0; 122 121 objectRefs = 0; 123 124 122 maxObjectRefs = 0; 123 mGlobalCostMisses = 0; 125 124 } 126 125 -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
r1415 r1449 690 690 t1 = GetTime(); 691 691 692 GenerateRays( mRssSamplesPerPass*ratios[0], RSS_BASED_DISTRIBUTION, rays);692 GenerateRays(int(mRssSamplesPerPass*ratios[0]), RSS_BASED_DISTRIBUTION, rays); 693 693 694 694 rays.NormalizePdf((float)rays.size()); … … 711 711 if (ratios[1]!=0.0f) { 712 712 t1 = GetTime(); 713 GenerateRays( mRssSamplesPerPass*ratios[1], SPATIAL_BOX_BASED_DISTRIBUTION, rays);713 GenerateRays(int(mRssSamplesPerPass*ratios[1]), SPATIAL_BOX_BASED_DISTRIBUTION, rays); 714 714 CastRays(rays, tmpVssRays); 715 715 castRays += (int)rays.size(); … … 733 733 if (ratios[2]!=0.0f) { 734 734 t1 = GetTime(); 735 GenerateRays( mRssSamplesPerPass*ratios[2], DIRECTION_BASED_DISTRIBUTION, rays);735 GenerateRays(int(mRssSamplesPerPass*ratios[2]), DIRECTION_BASED_DISTRIBUTION, rays); 736 736 CastRays(rays, tmpVssRays); 737 737 castRays += (int)rays.size(); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h
r1291 r1449 207 207 int accumRays; 208 208 int pvs; 209 // global cost ratio violations 210 int mGlobalCostMisses; 209 211 210 212 // Constructor … … 227 229 for (int i = 0; i < 3; ++ i) 228 230 splits[i] = 0; 229 231 232 mGlobalCostMisses = 0; 230 233 maxDepth = 0; 231 234 minDepth = 99999; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1444 r1449 4924 4924 if (0 && mExportViewCells) 4925 4925 { 4926 cout << "here5" << endl;4927 4926 char filename[100]; 4928 4927 Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename); -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1418 r1449 474 474 mBspStats.nodes = 1; 475 475 mBspStats.polys = (int)polys.size(); 476 m GlobalCostMisses = 0;476 mBspStats.mGlobalCostMisses = 0; 477 477 478 478 … … 676 676 //Debug << "cost ratio: " << costRatio << endl; 677 677 if (costRatio < mTermMinGlobalCostRatio) 678 ++ mGlobalCostMisses; 679 678 { 679 ++ mBspStats.mGlobalCostMisses; 680 } 681 680 682 if (0 && !mOutOfMemory) 681 683 { 682 684 float mem = GetMemUsage(); 683 684 685 if (mem > mMaxMemory) 685 686 { … … 693 694 694 695 if (r == mRoot) 696 { 695 697 Debug << "VSP BSP tree construction time spent at root: " 696 698 << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 699 } 697 700 698 701 if (mBspStats.Leaves() >= nLeaves) … … 753 756 || mOutOfMemory 754 757 || (mBspStats.Leaves() >= mMaxViewCells) 755 || (m GlobalCostMisses >= mTermGlobalCostMissTolerance)758 || (mBspStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 756 759 ); 757 760 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r1288 r1449 774 774 float mAxisAlignedSplitBorder; 775 775 776 776 /////////// 777 777 //-- global terminatino criteria 778 779 778 float mTermMinGlobalCostRatio; 780 779 int mTermGlobalCostMissTolerance; 781 int mGlobalCostMisses; 782 780 783 781 /// maximal number of view cells 784 782 int mMaxViewCells; … … 795 793 796 794 797 795 ////////// 798 796 //-- axis aligned split criteria 799 797 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1444 r1449 127 127 app << "#N_INVALIDLEAVES (number of invalid leaves )\n" << invalidLeaves << endl; 128 128 129 app << "#N_RAYS (number of rays / leaf)\n" << AvgRays() << endl; 130 129 app << "#AVGRAYS (number of rays / leaf)\n" << AvgRays() << endl; 130 131 app << "#N_GLOBALCOSTMISSES ( Global cost misses )\n" << mGlobalCostMisses << endl; 131 132 132 133 app << "========== END OF VspTree statistics ==========\n"; … … 561 562 // || mOutOfMemory 562 563 || (mVspStats.Leaves() >= mMaxViewCells) 563 || (m GlobalCostMisses >= mTermGlobalCostMissTolerance)564 || (mVspStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 564 565 ); 565 566 … … 567 568 { 568 569 Debug << "vsp global termination criteria met:" << endl; 569 Debug << "cost misses: " << m GlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl;570 Debug << "cost misses: " << mVspStats.mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 570 571 Debug << "leaves: " << mVspStats.Leaves() << " " << mMaxViewCells << endl; 571 572 } … … 2677 2678 // initialise termination criteria 2678 2679 mTermMinProbability *= mBoundingBox.GetVolume(); 2679 mGlobalCostMisses = 0;2680 2681 2680 // get clipped rays 2682 2681 PreprocessRays(sampleRays, rays); 2683 2682 2683 /// collect pvs from rays 2684 2684 const int pvsSize = EvalPvsSize(rays); 2685 2685 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1379 r1449 82 82 /// accumulated number of rays refs 83 83 int accumRays; 84 /// overall pvs size 84 85 int pvs; 85 86 // accumulated depth (used to compute average) 86 87 int accumDepth; 88 // global cost ratio violations 89 int mGlobalCostMisses; 87 90 88 91 // Constructor … … 124 127 accumRays = 0; 125 128 maxObjectRefs = 0; 129 mGlobalCostMisses = 0; 126 130 } 127 131 … … 1002 1006 float mTermMinGlobalCostRatio; 1003 1007 int mTermGlobalCostMissTolerance; 1004 int mGlobalCostMisses;1008 1005 1009 1006 1010 /// maximal number of view cells
Note: See TracChangeset
for help on using the changeset viewer.