Changeset 1705 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/31/06 21:15:07 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1703 r1705 307 307 Debug << "max memory: " << mMaxMemory << endl; 308 308 Debug << "use cost heuristics: " << mUseCostHeuristics << endl; 309 Debug << "use sah (surface area heuristics: " << mUseSah << endl; 309 310 Debug << "subdivision stats log: " << subdivisionStatsLog << endl; 310 311 Debug << "split borders: " << mSplitBorder << endl; … … 572 573 HierarchyManager::NO_VIEWSPACE_SUBDIV) 573 574 { 574 //////////////// 575 //-- surface area heuristics 576 577 const AxisAlignedBox3 box = EvalBoundingBox(leaf->mObjects); 578 const float area = box.SurfaceArea(); 579 const float viewSpaceArea = mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 580 581 priority = (float)leaf->mObjects.size() * area / viewSpaceArea; 575 priority = EvalSahCost(leaf); 582 576 } 583 577 else … … 612 606 inline bool BvHierarchy::LocalTerminationCriteriaMet(const BvhTraversalData &data) const 613 607 { 614 return ( 0 615 || ((int)data.mNode->mObjects.size() <= mTermMinObjects) 608 const bool terminationCriteriaMet = 609 (0 610 || ((int)data.mNode->mObjects.size() <= 1)//mTermMinObjects) 616 611 //|| (data.mProbability <= mTermMinProbability) 617 || (data.mNumRays <= mTermMinRays)612 //|| (data.mNumRays <= mTermMinRays) 618 613 ); 614 615 #ifdef _DEBUG 616 if (terminationCriteriaMet) 617 { 618 cout << "bvh local termination criteria met:" << endl; 619 cout << "objects: " << data.mNode->mObjects.size() << " " << mTermMinObjects << endl; 620 } 621 #endif 622 return terminationCriteriaMet; 619 623 } 620 624 … … 722 726 } 723 727 724 #if 0728 #ifdef _DEBUG 725 729 cout << "depth: " << data.mDepth << " objects: " << (int)leaf->mObjects.size() 726 730 << " rays: " << data.mNumRays << " rays / objects " … … 764 768 765 769 const float oldRenderCost = EvalRenderCost(tData.mNode->mObjects); 766 const float newRenderCost = 767 EvalRenderCost(objectsFront) * EvalRenderCost(objectsBack); 770 const float newRenderCost = EvalRenderCost(objectsFront) * EvalRenderCost(objectsBack); 768 771 769 772 const float ratio = newRenderCost / oldRenderCost; … … 801 804 } 802 805 803 float heur = 0; 804 805 if (tData.mNode->GetBoundingBox().Size().DrivingAxis() == axis) 806 { 807 heur = -1; 808 } 809 810 return heur; 806 #if 1 807 const float cost = (tData.mNode->GetBoundingBox().Size().DrivingAxis() == axis) ? -1.0f : 0.0f; 808 #else 809 const float oldRenderCost = EvalRenderCost(tData.mNode->mObjects); 810 const float newRenderCost = EvalRenderCost(objectsFront) * EvalRenderCost(objectsBack); 811 812 const float cost = newRenderCost / oldRenderCost; 813 #endif 814 815 return cost; 811 816 } 812 817 #endif … … 918 923 } 919 924 920 const float sum = objectsLeft * al + objectsRight * ar; 925 const bool noValidSplit = ((objectsLeft <= Limits::Small) || (objectsRight <= Limits::Small)); 926 927 const float sum = noValidSplit ? 1e25 : objectsLeft * al + objectsRight * ar; 921 928 922 929 /*cout << "pos=" << (*cit).mPos << "\t q=(" << objectsLeft << "," << objectsRight <<")\t r=(" … … 925 932 cout << "cost= " << sum << endl; 926 933 */ 934 927 935 if (sum < minSum) 928 { 936 { //cout <<" sum: " << sum; 929 937 minSum = sum; 930 938 areaLeft = al; … … 935 943 } 936 944 } 937 938 945 939 946 //////////////////////////////////////////// … … 952 959 953 960 #ifdef _DEBUG 961 // if (objectsBack.empty() ||objectsFront.empty()) 954 962 cout << "\n\nobjects=(" << (int)objectsBack.size() << "," << (int)objectsFront.size() << " of " 955 963 << (int)tData.mNode->mObjects.size() << ")\t area=(" 956 << areaLeft << ", " << areaRight<< ")" << endl957 << "cost= " << minSum<< endl;964 << areaLeft << ", " << areaRight << ", " << boxArea << ")" << endl 965 << "cost= " << newCost << " oldCost=" << totalRenderCost / boxArea << endl; 958 966 #endif 959 967 … … 1069 1077 nObjectsRight -= rc; 1070 1078 1079 const bool noValidSplit = ((nObjectsLeft <= Limits::Small) || (nObjectsRight <= Limits::Small)); 1080 1071 1081 // the heuristics 1072 const float sum = volLeft * (float)nObjectsLeft +1073 1082 const float sum = noValidSplit ? 1083 1e25 : volLeft * (float)nObjectsLeft + volRight * (float)nObjectsRight; 1074 1084 1075 1085 #ifdef _DEBUG … … 1442 1452 1443 1453 1454 float BvHierarchy::EvalSahCost(BvhLeaf *leaf) 1455 { 1456 //////////////// 1457 //-- surface area heuristics 1458 if (leaf->mObjects.empty()) 1459 return 0.0f; 1460 1461 const AxisAlignedBox3 box = GetBoundingBox(leaf); 1462 const float area = box.SurfaceArea(); 1463 const float viewSpaceArea = mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 1464 1465 return EvalAbsCost(leaf->mObjects) * area / viewSpaceArea; 1466 } 1467 1468 1444 1469 float BvHierarchy::EvalRenderCost(const ObjectContainer &objects) const 1445 1470 { -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1703 r1705 70 70 splits = 0; 71 71 maxDepth = 0; 72 72 73 minDepth = 99999; 73 74 accumDepth = 0; … … 75 76 minProbabilityNodes = 0; 76 77 maxCostNodes = 0; 77 78 78 /////////////////// 79 79 minObjectsNodes = 0; … … 421 421 void EvalCandidate(bool computeSplitplane = true) 422 422 { 423 423 mDirty = false; 424 424 sBvHierarchy->EvalSubdivisionCandidate(*this, computeSplitplane); 425 425 } … … 452 452 float GetPriority() const 453 453 { 454 HierarchyManager *hm = sBvHierarchy->mHierarchyManager; 455 456 if (hm->ConsiderMemory()) 457 { 458 const float rc = mRenderCostDecrease / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 459 //const float mc = mMemoryIncr / / hm->GetHierarchyStats().mMemory; 460 //const float rc = mPriority / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 461 const float mc = (float)mPvsEntriesIncr / (float)hm->GetHierarchyStats().mPvsEntries; 462 463 //cout << "\np: " << mPriority << " i: " << hm->mInitialRenderCost << " t: " << hm->GetHierarchyStats().mTotalCost << endl; 464 //cout << "osp rc: " << rc << " mc: " << mc << endl; 465 466 return hm->GetMemoryConst() * rc - (1.0f - hm->GetMemoryConst()) * mc; 467 } 468 else 469 { 470 return mPriority; 471 } 454 return mPriority; 472 455 } 473 456 … … 755 738 float PrepareHeuristics(const BvhTraversalData &tData, const int axis); 756 739 740 /** Evaluates cost for a leaf given the surface area heuristics. 741 */ 742 float EvalSahCost(BvhLeaf *leaf); 757 743 758 744 //////////////////////////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1701 r1705 144 144 mTermMaxMemory *= (1024.0f * 1024.0f); 145 145 146 Debug << "******** Hiera chy Manager Options ***********" << endl;146 Debug << "******** Hierarchy Manager Options ***********" << endl; 147 147 Debug << "max leaves: " << mTermMaxLeaves << endl; 148 148 Debug << "min global cost ratio: " << mTermMinGlobalCostRatio << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1703 r1705 40 40 // HACK 41 41 const static bool SAMPLE_AFTER_SUBDIVISION = true; 42 const static bool CLAMP_TO_BOX = false; 42 //const static bool CLAMP_TO_BOX = false; 43 const static bool CLAMP_TO_BOX = true; 44 43 45 44 46 int ViewCellsManager::sRenderCostEvaluationType = 0; … … 511 513 if (mEvaluateViewCells) 512 514 { 515 cout << "here42 ***********" << endl; 513 516 EvalViewCellPartition(); 514 517 } 515 518 519 // write view cells to disc 520 if (1 && mExportViewCells) 521 { 522 char filename[100]; 523 Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename); 524 ExportViewCells(filename, mExportPvs, mPreprocessor->mObjects); 525 } 526 516 527 ///////////////// 517 528 //-- Finally, we do some visualization … … 2893 2904 // compute final meshes and volume / area 2894 2905 if (1) FinalizeViewCells(true); 2895 2896 // write view cells to disc2897 if (1 && mExportViewCells)2898 {2899 char filename[100];2900 Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename);2901 ExportViewCells(filename, mExportPvs, objects);2902 }2903 2906 2904 2907 return 0; … … 4153 4156 if (1) FinalizeViewCells(true); 4154 4157 4155 // write view cells to disc4156 if (1 && mExportViewCells)4157 {4158 char filename[100];4159 Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename);4160 ExportViewCells(filename, mExportPvs, objects);4161 }4162 4163 4158 return 0; 4164 4159 } … … 5020 5015 5021 5016 if (1) FinalizeViewCells(true); 5022 5023 // write out view cells (this moved to preprocessor)5024 if (mExportViewCells)5025 {5026 char filename[100];5027 Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename);5028 ExportViewCells(filename, mExportPvs, objects);5029 }5030 5017 5031 5018 return 0; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1667 r1705 789 789 790 790 //viewCell = GetOrCreateViewCell(id, isLeaf); 791 792 793 794 795 796 797 798 799 791 792 if (isLeaf) 793 { 794 viewCell = new ViewCellLeaf(); 795 } 796 else 797 { 798 viewCell = new ViewCellInterior(); 799 } 800 800 801 801 for (int i = 0; i < len; ++ i) -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1696 r1705 509 509 float GetPriority() const 510 510 { 511 HierarchyManager *hm = sVspTree->mHierarchyManager; 512 513 if (hm->ConsiderMemory()) 514 { 515 const float rc = mRenderCostDecrease / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 516 //const float mc = mMemoryIncr / / hm->GetHierarchyStats().mMemory; 517 //const float rc = mPriority / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 518 const float mc = (float)mPvsEntriesIncr / (float)hm->GetHierarchyStats().mPvsEntries; 519 520 //cout << "\np: " << mPriority << " i: " << hm->mInitialRenderCost << " t: " << hm->GetHierarchyStats().mTotalCost << endl; 521 //cout << "vsp rc: " << rc << " mc: " << mc << endl; 522 523 return hm->GetMemoryConst() * rc - (1.0f - hm->GetMemoryConst()) * mc; 524 } 525 else 526 { 527 return mPriority; 528 } 511 return mPriority; 529 512 } 530 513 }; -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r1577 r1705 392 392 } 393 393 394 395 394 mSceneGraph->CollectObjects(&mObjects); 396 395
Note: See TracChangeset
for help on using the changeset viewer.