Changeset 1624 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 10/16/06 07:58:19 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1614 r1624 932 932 const float viewSpaceVol = mViewCellsManager->GetViewSpaceBox().GetVolume(); 933 933 934 SortableEntryContainer::const_iterator backObjectsStart = mSubdivisionCandidates->begin(); 934 SortableEntryContainer::const_iterator backObjectsStart = 935 mSubdivisionCandidates->begin(); 935 936 936 937 ///////////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1614 r1624 109 109 "Hierarchy.Construction.levels", mNumMultiLevels); 110 110 111 char subdivisionStatsLog[100]; 112 Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats", subdivisionStatsLog); 113 mSubdivisionStats.open(subdivisionStatsLog); 114 115 mMinRenderCostDecrease = -1; 116 111 117 Debug << "******** Hierachy Manager Parameters ***********" << endl; 112 118 Debug << "max leaves: " << mTermMaxLeaves << endl; … … 117 123 Debug << "repair queue: " << mRepairQueue << endl; 118 124 Debug << "number of multilevels: " << mNumMultiLevels << endl; 125 Debug << "min render cost " << mMinRenderCostDecrease << endl; 119 126 Debug << endl; 120 127 } … … 198 205 199 206 200 void HierarchyManager::EvalSubdivisionStats( const float renderCostDecr)207 void HierarchyManager::EvalSubdivisionStats() 201 208 { 202 209 //cout << "pvs entries " << mHierarchyStats.pvsEntries << endl; 203 210 AddSubdivisionStats(mHierarchyStats.Leaves(), 204 renderCostDecr,205 m TotalCost,206 mHierarchyStats. pvsEntries211 mHierarchyStats.mRenderCostDecrease, 212 mHierarchyStats.mTotalCost, 213 mHierarchyStats.mPvsEntries 207 214 ); 208 215 } … … 229 236 || (mHierarchyStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 230 237 || (candidate->GlobalTerminationCriteriaMet()) 238 || (mHierarchyStats.mRenderCostDecrease < mMinRenderCostDecrease) 231 239 ); 232 240 … … 254 262 else 255 263 { 264 ConstructInterleaved(sampleRays, objects, forcedViewSpace); 265 } 266 } 267 268 269 void HierarchyManager::ConstructInterleaved2(const VssRayContainer &sampleRays, 270 const ObjectContainer &objects, 271 AxisAlignedBox3 *forcedViewSpace) 272 { 273 mHierarchyStats.Reset(); 274 mHierarchyStats.Start(); 275 mHierarchyStats.mNodes = 2; 276 277 mHierarchyStats.mTotalCost = (float)objects.size(); 278 Debug << "setting total cost to " << mHierarchyStats.mTotalCost << endl; 279 280 const long startTime = GetTime(); 281 cout << "Constructing view space / object space tree ... \n"; 282 283 // compute view space bounding box 284 mVspTree->ComputeBoundingBox(sampleRays, forcedViewSpace); 285 286 // use sah for evaluating osp tree construction 287 // in the first iteration of the subdivision 288 289 mSavedViewSpaceSubdivisionType = mViewSpaceSubdivisionType; 290 mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 291 292 mSavedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 293 //mObjectSpaceSubdivisionType = NO_OBJ_SUBDIV; 294 295 const int limit = mNumMultiLevels; 296 int i = 0; 297 298 // This method subdivides view space / object space 299 // in order to converge to some optimal cost for this partition 300 // start with object space partiton 301 // then optimizate view space partition for the current osp 302 // and vice versa until iteration depth is reached. 303 while (1) 304 { 256 305 char subdivisionStatsLog[100]; 257 Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats", 258 subdivisionStatsLog); 306 sprintf(subdivisionStatsLog, "tests/i3d/subdivision-%04d.log", i); 259 307 mSubdivisionStats.open(subdivisionStatsLog); 260 308 261 ConstructInterleaved(sampleRays, objects, forcedViewSpace); 262 } 263 } 309 float oldRenderCost = mHierarchyStats.mRenderCostDecrease; 310 const bool isObjectSpace = true; 311 312 // subdivide object space first 313 ResetObjectSpaceSubdivision(sampleRays, objects); 314 315 // process object space candidates using 316 // render queue for objects 317 RunConstruction(false, isObjectSpace, oldRenderCost); 318 319 oldRenderCost = mHierarchyStats.mRenderCostDecrease; 320 321 // object space subdivision constructed 322 mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 323 324 cout << "iteration " << i << " of " << limit << " finished" << endl; 325 326 mSubdivisionStats.close(); 327 328 sprintf(subdivisionStatsLog, "tests/i3d/subdivision-%04d.log", i); 329 mSubdivisionStats.open(subdivisionStatsLog); 330 331 ///////////////// 332 // subdivide view space with respect to the objects 333 334 ResetViewSpaceSubdivision(sampleRays, objects); 335 336 // process view space candidates 337 RunConstruction(false, !isObjectSpace, oldRenderCost); 338 339 // view space subdivision constructed 340 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 341 342 cout << "iteration " << i << " of " << limit << " finished" << endl; 343 344 mSubdivisionStats.close(); 345 346 if ((i ++) >= limit) 347 break; 348 } 349 350 cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 351 352 /*#if _DEBUG 353 cout << "view space: " << GetViewSpaceBox() << endl; 354 cout << "object space: " << GetObjectSpaceBox() << endl; 355 #endif*/ 356 357 mHierarchyStats.Stop(); 358 mVspTree->mVspStats.Stop(); 359 FinishObjectSpaceSubdivision(objects); 360 } 361 264 362 265 363 … … 270 368 mHierarchyStats.Reset(); 271 369 mHierarchyStats.Start(); 272 mHierarchyStats.nodes = 2; // two nodes for view space and object space 273 274 mTotalCost = (float)objects.size(); 275 EvalSubdivisionStats(0); 276 Debug << "setting total cost to " << mTotalCost << endl; 370 mHierarchyStats.mNodes = 2; // two nodes for view space and object space 371 372 mHierarchyStats.mTotalCost = (float)objects.size(); 373 mHierarchyStats.mRenderCostDecrease = 0; 374 375 EvalSubdivisionStats(); 376 Debug << "setting total cost to " << mHierarchyStats.mTotalCost << endl; 277 377 278 378 const long startTime = GetTime(); … … 290 390 mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 291 391 292 // start with view space subdivison : prepare vsp tree for traversal392 // start with view space subdivison immediately? 293 393 if (StartViewSpaceSubdivision()) 294 394 { 395 // prepare vsp tree for traversal 295 396 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 296 397 PrepareViewSpaceSubdivision(sampleRays, objects); … … 304 405 } 305 406 306 // process object space candidates407 // begin subdivision 307 408 RunConstruction(mRepairQueue, sampleRays, objects, forcedViewSpace); 308 409 … … 329 430 mVspTree->PrepareConstruction(sampleRays, *viewSpaceRays); 330 431 331 m TotalCost = mVspTree->mTotalCost;332 cout << "\nreseting cost for vsp, new total cost: " << m TotalCost << endl;432 mHierarchyStats.mTotalCost = mVspTree->mTotalCost; 433 cout << "\nreseting cost for vsp, new total cost: " << mHierarchyStats.mTotalCost << endl; 333 434 334 435 mTQueue.Push(vsc); … … 363 464 mBvHierarchy->PrepareConstruction(sampleRays, objects); 364 465 365 m TotalCost = mBvHierarchy->mTotalCost;366 Debug << "\nreseting cost, new total cost: " << m TotalCost << endl;466 mHierarchyStats.mTotalCost = mBvHierarchy->mTotalCost; 467 Debug << "\nreseting cost, new total cost: " << mHierarchyStats.mTotalCost << endl; 367 468 368 469 mTQueue.Push(sc); … … 386 487 mOspTree->PrepareConstruction(sampleRays, objects, *objectSpaceRays); 387 488 388 m TotalCost = mOspTree->mTotalCost;389 Debug << "\nreseting cost, new total cost: " << m TotalCost << endl;489 mHierarchyStats.mTotalCost = mOspTree->mTotalCost; 490 Debug << "\nreseting cost, new total cost: " << mHierarchyStats.mTotalCost << endl; 390 491 391 492 mTQueue.Push(osc); … … 393 494 394 495 395 bool HierarchyManager::ApplySubdivisionCandidate(SubdivisionCandidate *sc, const bool repairQueue) 496 bool HierarchyManager::ApplySubdivisionCandidate(SubdivisionCandidate *sc, 497 const bool repairQueue) 396 498 { 397 499 // test if global termination criteria were met before this split 398 const bool globalTerminationCriteriaMet = GlobalTerminationCriteriaMet(sc);500 const bool terminationCriteriaMet = GlobalTerminationCriteriaMet(sc); 399 501 const bool vspSplit = (sc->Type() == SubdivisionCandidate::VIEW_SPACE); 400 502 … … 405 507 case SubdivisionCandidate::VIEW_SPACE: 406 508 { 407 VspNode *n = mVspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 408 success = !n->IsLeaf(); // local or global termination criteria failed? 509 VspNode *n = mVspTree->Subdivide(mTQueue, sc, terminationCriteriaMet); 510 // check if termination criteria failed 511 success = !n->IsLeaf(); 409 512 } 410 513 break; … … 413 516 if (mObjectSpaceSubdivisionType == KD_BASED_OBJ_SUBDIV) 414 517 { 415 KdNode *n = mOspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet);518 KdNode *n = mOspTree->Subdivide(mTQueue, sc, terminationCriteriaMet); 416 519 // local or global termination criteria failed 417 520 success = !n->IsLeaf(); … … 419 522 else if (mObjectSpaceSubdivisionType == BV_BASED_OBJ_SUBDIV) 420 523 { 421 BvhNode *n = mBvHierarchy->Subdivide(mTQueue, sc, globalTerminationCriteriaMet);524 BvhNode *n = mBvHierarchy->Subdivide(mTQueue, sc, terminationCriteriaMet); 422 525 // local or global termination criteria failed 423 526 success = !n->IsLeaf(); … … 435 538 436 539 /////////////// 437 //-- split was successful => 438 //-- update stats and render queue 540 //-- split was successful => update stats and queue 439 541 440 542 // cost ratio of cost decrease / totalCost 441 const float costRatio = mCurrentCandidate->GetRenderCostDecrease() /mTotalCost;543 const float costRatio = sc->GetRenderCostDecrease() / mHierarchyStats.mTotalCost; 442 544 //Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 443 545 … … 447 549 } 448 550 449 m TotalCost -= mCurrentCandidate->GetRenderCostDecrease();551 mHierarchyStats.mTotalCost -= sc->GetRenderCostDecrease(); 450 552 451 553 cout << sc->Type() << " "; 452 554 453 555 // update stats 454 mHierarchyStats. nodes += 2;556 mHierarchyStats.mNodes += 2; 455 557 456 558 const int pvsEntries = sc->GetPvsEntriesIncr(); 457 mHierarchyStats. pvsEntries += pvsEntries;559 mHierarchyStats.mPvsEntries += pvsEntries; 458 560 459 561 //cout << "pvs entries: " << pvsEntries << " " << mHierarchyStats.pvsEntries << endl; 460 mHierarchyStats.memory += 0; // TODO 461 562 mHierarchyStats.mMemory += 0; // TODO 563 mHierarchyStats.mRenderCostDecrease = sc->GetRenderCostDecrease(); 564 462 565 // subdivision successful 463 EvalSubdivisionStats( sc->GetRenderCostDecrease());566 EvalSubdivisionStats(); 464 567 465 // reevaluate candidates affected by the split for view space splits,466 // this would be object space splits and other way round467 568 if (repairQueue) 468 { 469 RepairQueue(); 569 { 570 // reevaluate candidates affected by the split for view space splits, 571 // this would be object space splits and other way round 572 573 RepairQueue(sc); 470 574 } 471 575 … … 541 645 while (!FinishedConstruction()) 542 646 { 543 mCurrentCandidate= NextSubdivisionCandidate();647 SubdivisionCandidate *sc = NextSubdivisionCandidate(); 544 648 545 649 /////////////////// 546 650 //-- subdivide leaf node 547 651 548 ApplySubdivisionCandidate( mCurrentCandidate, repairQueue);652 ApplySubdivisionCandidate(sc, repairQueue); 549 653 550 654 // we use objects for evaluating vsp tree construction until … … 580 684 } 581 685 582 DEL_PTR(mCurrentCandidate); 583 } 584 } 585 686 DEL_PTR(sc); 687 } 688 } 586 689 587 690 588 691 void HierarchyManager::RunConstruction(const bool repairQueue) 589 692 { 590 int i = 0;693 //int i = 0; 591 694 // main loop 592 695 while (!FinishedConstruction()) 593 696 { 594 mCurrentCandidate= NextSubdivisionCandidate();697 SubdivisionCandidate *sc = NextSubdivisionCandidate(); 595 698 596 /////// 597 //-- subdivide leaf node 598 599 ApplySubdivisionCandidate(mCurrentCandidate, repairQueue); 600 DEL_PTR(mCurrentCandidate); 699 //////// 700 //-- subdivide leaf node of either type 701 ApplySubdivisionCandidate(sc, repairQueue); 702 703 DEL_PTR(sc); 704 } 705 } 706 707 708 void HierarchyManager::RunConstruction(const bool isObjectSpace, 709 const float oldRenderCostDecr) 710 { 711 //int i = 0; 712 // main loop 713 while (!FinishedConstruction()) 714 { 715 SubdivisionCandidate *sc = NextSubdivisionCandidate(); 716 717 //////// 718 //-- subdivide leaf node of either type 719 ApplySubdivisionCandidate(sc, repairQueue); 720 721 DEL_PTR(sc); 601 722 } 602 723 } … … 605 726 void HierarchyManager::ResetObjectSpaceSubdivision(const VssRayContainer &sampleRays, 606 727 const ObjectContainer &objects) 728 //const bool startFromScratch) 607 729 { 608 #if 0609 DEL_PTR(mBvHierarchy);610 mBvHierarchy = new BvHierarchy();611 mBvHierarchy->mHierarchyManager = this;612 613 PrepareObjectSpaceSubdivision(sampleRays, objects);614 return;615 #else616 617 730 // no object space subdivision yet 618 731 if (!ObjectSpaceSubdivisionConstructed()) … … 629 742 Debug << "old bv hierarchy:\n " << mBvHierarchy->mBvhStats << endl; 630 743 631 SubdivisionCandidate *firstCandidate = 632 mBvHierarchy->Reset(sampleRays, objects); 633 634 mTQueue.Push(firstCandidate); 635 mTotalCost = mBvHierarchy->mTotalCost; 636 637 mHierarchyStats.nodes = 2; 638 mHierarchyStats.pvsEntries = 0; 639 EvalSubdivisionStats(0); 744 //if (startFromScratch) 745 //{ 746 SubdivisionCandidate *firstCandidate = 747 mBvHierarchy->Reset(sampleRays, objects); 748 749 mTQueue.Push(firstCandidate); 750 mHierarchyStats.mTotalCost = mBvHierarchy->mTotalCost; 751 752 mHierarchyStats.mNodes = 2; 753 mHierarchyStats.mPvsEntries = 0; 754 mHierarchyStats.mRenderCostDecrease = 0; 755 756 EvalSubdivisionStats(); 757 /*} 758 else 759 { 760 }*/ 640 761 } 641 762 break; … … 647 768 break; 648 769 } 649 #endif650 770 } 651 771 … … 656 776 ViewCellsManager *vc = mVspTree->mViewCellsManager; 657 777 778 // HACK: rather not destroy vsp tree 658 779 DEL_PTR(mVspTree); 659 780 mVspTree = new VspTree(); … … 663 784 PrepareViewSpaceSubdivision(sampleRays, objects); 664 785 665 mHierarchyStats.nodes = 2; 666 mHierarchyStats.pvsEntries = 0; 667 EvalSubdivisionStats(0); 668 786 mHierarchyStats.mNodes = 2; 787 mHierarchyStats.mPvsEntries = 0; 788 mHierarchyStats.mRenderCostDecrease = 0; 789 790 EvalSubdivisionStats(); 669 791 } 670 792 … … 676 798 mHierarchyStats.Reset(); 677 799 mHierarchyStats.Start(); 678 mHierarchyStats. nodes = 2;679 680 m TotalCost = (float)objects.size();681 Debug << "setting total cost to " << m TotalCost << endl;800 mHierarchyStats.mNodes = 2; 801 802 mHierarchyStats.mTotalCost = (float)objects.size(); 803 Debug << "setting total cost to " << mHierarchyStats.mTotalCost << endl; 682 804 683 805 const long startTime = GetTime(); … … 699 821 int i = 0; 700 822 701 // render cost optimization 823 // This method subdivides view space / object space 824 // in order to converge to some optimal cost for this partition 702 825 // start with object space partiton 703 826 // then optimizate view space partition for the current osp … … 709 832 mSubdivisionStats.open(subdivisionStatsLog); 710 833 711 // fsubdivide object space first 834 // subdivide object space first 835 712 836 ResetObjectSpaceSubdivision(sampleRays, objects); 837 713 838 // process object space candidates 714 839 RunConstruction(false); … … 730 855 731 856 ResetViewSpaceSubdivision(sampleRays, objects); 857 732 858 // process view space candidates 733 859 RunConstruction(false); 860 734 861 // view space subdivision constructed 735 862 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; … … 782 909 783 910 784 void HierarchyManager::CollectObjectSpaceDirtyList(SubdivisionCandidateContainer &dirtyList) 911 void HierarchyManager::CollectObjectSpaceDirtyList(SubdivisionCandidate *sc, 912 SubdivisionCandidateContainer &dirtyList) 785 913 { 786 914 switch (mObjectSpaceSubdivisionType) … … 788 916 case KD_BASED_OBJ_SUBDIV: 789 917 { 790 OspTree::OspSubdivisionCandidate * sc =791 dynamic_cast<OspTree::OspSubdivisionCandidate *>( mCurrentCandidate);792 793 mOspTree->CollectDirtyCandidates( sc, dirtyList);918 OspTree::OspSubdivisionCandidate *ospSc = 919 dynamic_cast<OspTree::OspSubdivisionCandidate *>(sc); 920 921 mOspTree->CollectDirtyCandidates(ospSc, dirtyList); 794 922 break; 795 923 } 796 924 case BV_BASED_OBJ_SUBDIV: 797 925 { 798 BvHierarchy::BvhSubdivisionCandidate * sc =799 dynamic_cast<BvHierarchy::BvhSubdivisionCandidate *>( mCurrentCandidate);800 801 mBvHierarchy->CollectDirtyCandidates( sc, dirtyList);926 BvHierarchy::BvhSubdivisionCandidate *bvhSc = 927 dynamic_cast<BvHierarchy::BvhSubdivisionCandidate *>(sc); 928 929 mBvHierarchy->CollectDirtyCandidates(bvhSc, dirtyList); 802 930 break; 803 931 } … … 808 936 809 937 810 void HierarchyManager::CollectViewSpaceDirtyList(SubdivisionCandidateContainer &dirtyList) 811 { 812 VspTree::VspSubdivisionCandidate *sc = 813 dynamic_cast<VspTree::VspSubdivisionCandidate *>(mCurrentCandidate); 814 815 mVspTree->CollectDirtyCandidates(sc, dirtyList); 816 } 817 818 819 void HierarchyManager::CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList) 938 void HierarchyManager::CollectViewSpaceDirtyList(SubdivisionCandidate *sc, 939 SubdivisionCandidateContainer &dirtyList) 940 { 941 VspTree::VspSubdivisionCandidate *vspSc = 942 dynamic_cast<VspTree::VspSubdivisionCandidate *>(sc); 943 944 mVspTree->CollectDirtyCandidates(vspSc, dirtyList); 945 } 946 947 948 void HierarchyManager::CollectDirtyCandidates(SubdivisionCandidate *sc, 949 SubdivisionCandidateContainer &dirtyList) 820 950 { 821 951 // we have either a object space or view space split 822 if ( mCurrentCandidate->Type() == SubdivisionCandidate::VIEW_SPACE)823 { 824 CollectViewSpaceDirtyList( dirtyList);952 if (sc->Type() == SubdivisionCandidate::VIEW_SPACE) 953 { 954 CollectViewSpaceDirtyList(sc, dirtyList); 825 955 } 826 956 else // object space split 827 957 { 828 CollectObjectSpaceDirtyList( dirtyList);829 } 830 } 831 832 833 void HierarchyManager::RepairQueue( )958 CollectObjectSpaceDirtyList(sc, dirtyList); 959 } 960 } 961 962 963 void HierarchyManager::RepairQueue(SubdivisionCandidate *sc) 834 964 { 835 965 // for each update of the view space partition: … … 853 983 854 984 vector<SubdivisionCandidate *> dirtyList; 855 CollectDirtyCandidates( dirtyList);985 CollectDirtyCandidates(sc, dirtyList); 856 986 if (0) cout << "repairing " << (int)dirtyList.size() << " candidates ... "; 857 987 988 858 989 ///////////////////////////////// 859 990 //-- reevaluate the dirty list … … 880 1011 long endTime = GetTime(); 881 1012 Real timeDiff = TimeDiff(startTime, endTime); 882 mHierarchyStats. repairTime += timeDiff;1013 mHierarchyStats.mRepairTime += timeDiff; 883 1014 884 1015 if (1) cout << "repaired in " << timeDiff * 1e-3f << " secs" << endl; … … 1057 1188 app << "#N_CTIME ( Construction time [s] )\n" << Time() << " \n"; 1058 1189 1059 app << "#N_RTIME ( Repair time [s] )\n" << repairTime * 1e-3f << " \n";1060 1061 app << "#N_NODES ( Number of nodes )\n" << nodes << "\n";1190 app << "#N_RTIME ( Repair time [s] )\n" << mRepairTime * 1e-3f << " \n"; 1191 1192 app << "#N_NODES ( Number of nodes )\n" << mNodes << "\n"; 1062 1193 1063 1194 app << "#N_INTERIORS ( Number of interior nodes )\n" << Interior() << "\n"; … … 1065 1196 app << "#N_LEAVES ( Number of leaves )\n" << Leaves() << "\n"; 1066 1197 1067 app << "#N_PMAXDEPTH ( Maximal reached depth )\n" << m axDepth << endl;1198 app << "#N_PMAXDEPTH ( Maximal reached depth )\n" << mMaxDepth << endl; 1068 1199 1069 1200 app << "#N_GLOBALCOSTMISSES ( Global cost misses )\n" << mGlobalCostMisses << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1614 r1624 50 50 public: 51 51 /// total number of entries in the pvs 52 int pvsEntries;52 int mPvsEntries; 53 53 /// storage cost 54 int m emory;54 int mMemory; 55 55 /// total number of nodes 56 int nodes;56 int mNodes; 57 57 /// maximal reached depth 58 int m axDepth;58 int mMaxDepth; 59 59 /// accumulated depth 60 int accumDepth;60 int mAccumDepth; 61 61 /// time spent for queue repair 62 float repairTime; 62 float mRepairTime; 63 63 64 // global cost ratio violations 64 65 int mGlobalCostMisses; 66 /// total cost of subdivision 67 float mTotalCost; 68 /// render cost decrease of subdivision 69 float mRenderCostDecrease; 65 70 66 71 // Constructor … … 70 75 } 71 76 72 int Nodes() const {return nodes;}73 int Interior() const { return nodes / 2; }74 int Leaves() const { return ( nodes / 2) + 1; }77 int Nodes() const {return mNodes;} 78 int Interior() const { return mNodes / 2; } 79 int Leaves() const { return (mNodes / 2) + 1; } 75 80 76 81 // TODO: computation wrong 77 double AvgDepth() const { return accumDepth / (double)Leaves();}82 double AvgDepth() const { return mAccumDepth / (double)Leaves();} 78 83 79 84 void Reset() 80 85 { 81 86 mGlobalCostMisses = 0; 82 nodes = 0; 83 maxDepth = 0; 84 accumDepth = 0; 85 repairTime = 0; 86 memory = 0; 87 pvsEntries = 0; 87 mTotalCost = 0; 88 mRenderCostDecrease = 0; 89 90 mNodes = 0; 91 mMaxDepth = 0; 92 mAccumDepth = 0; 93 mRepairTime = 0; 94 mMemory = 0; 95 mPvsEntries = 0; 88 96 } 89 97 … … 201 209 */ 202 210 //AxisAlignedBox3 GetViewSpaceBox() const; 211 203 212 /** Returns object space bounding box. 204 213 */ … … 257 266 /** Repairs the dirty entries of the candidate queue. 258 267 */ 259 void RepairQueue(); 260 261 /** Collect the list of dirty candidates after the current subdivision candidate 262 split. 263 */ 264 void CollectDirtyCandidates(vector<SubdivisionCandidate *> &dirtyList); 268 void RepairQueue(SubdivisionCandidate *sc); 269 270 /** Collect the list of dirty candidates after the current 271 subdivision candidate split. 272 */ 273 void CollectDirtyCandidates( 274 SubdivisionCandidate *sc, 275 vector<SubdivisionCandidate *> &dirtyList); 265 276 266 277 /** Evaluate subdivision stats for log. 267 278 */ 268 void EvalSubdivisionStats( const float renderCostDecr);279 void EvalSubdivisionStats(); 269 280 270 281 void AddSubdivisionStats( … … 274 285 const int totalPvsEntries); 275 286 276 void CollectObjectSpaceDirtyList(); 277 void CollectViewSpaceDirtyList(); 278 279 bool AddSampleToPvs(Intersectable *obj, 280 const float pdf, 281 float &contribution) const; 282 283 void CollectViewSpaceDirtyList(SubdivisionCandidateContainer &dirtyList); 284 void CollectObjectSpaceDirtyList(SubdivisionCandidateContainer &dirtyList); 287 bool AddSampleToPvs( 288 Intersectable *obj, 289 const float pdf, 290 float &contribution) const; 291 292 void CollectViewSpaceDirtyList( 293 SubdivisionCandidate *sc, 294 SubdivisionCandidateContainer &dirtyList); 295 296 void CollectObjectSpaceDirtyList( 297 SubdivisionCandidate *sc, 298 SubdivisionCandidateContainer &dirtyList); 285 299 286 void ExportOspTree(Exporter *exporter, const ObjectContainer &objects) const; 300 void ExportOspTree( 301 Exporter *exporter, 302 const ObjectContainer &objects) const; 287 303 288 304 void ParseEnvironment(); … … 313 329 314 330 void ConstructInterleaved( 331 const VssRayContainer &sampleRays, 332 const ObjectContainer &objects, 333 AxisAlignedBox3 *forcedViewSpace); 334 335 void ConstructInterleaved2( 315 336 const VssRayContainer &sampleRays, 316 337 const ObjectContainer &objects, … … 359 380 int mSavedViewSpaceSubdivisionType; 360 381 /// the current subdivision candidate 361 SubdivisionCandidate *mCurrentCandidate;382 //SubdivisionCandidate *mCurrentCandidate; 362 383 363 384 … … 389 410 390 411 /// keeps track of cost during subdivision 391 float mTotalCost;412 //float mTotalCost; 392 413 /// statistics about the hierarchy 393 414 HierarchyStatistics mHierarchyStats; … … 396 417 int mMinDepthForViewSpaceSubdivion; 397 418 419 int mMinRenderCostDecrease; 420 398 421 ofstream mSubdivisionStats; 399 422
Note: See TracChangeset
for help on using the changeset viewer.