Changeset 1744 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 11/13/06 21:25:40 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1737 r1744 294 294 //mMemoryConst = (float)(sizeof(VspLeaf) + sizeof(VspViewCell)); 295 295 //mMemoryConst = (float)sizeof(BvhLeaf); 296 mMemoryConst = (float)sizeof(ObjectContainer); 297 cout << "bvh memcost: " << mMemoryConst << endl; 296 mMemoryConst = (float)sizeof(ObjectContainer); 297 298 /*cout << "bvh memcost: " << mMemoryConst << endl; 298 299 cout << "triangle: " << sizeof(TriangleIntersectable) << endl; 299 300 cout << "triangle: " << sizeof(Intersectable) << endl; … … 301 302 cout << "triangle: " << sizeof(float) << endl; 302 303 cout << "triangle: " << sizeof(int) << endl; 303 304 */ 304 305 mUseBboxAreaForSah = true; 305 306 … … 327 328 Debug << "minimal rays for visibility: " << mMinRaysForVisibility << endl; 328 329 Debug << "bvh mem const: " << mMemoryConst << endl; 329 330 cout << "here10 " << mRenderCostDecreaseWeight << endl; 330 331 Debug << endl; 331 332 } … … 509 510 EvaluateLeafStats(tData); 510 511 511 const bool mStoreRays = true;512 if (mStoreRays)513 {514 BvhLeaf *leaf = dynamic_cast<BvhLeaf *>(currentNode);515 // CollectRays(leaf->mObjects, leaf->mVssRays);516 }517 518 //////////////////////////////////////519 520 512 // this leaf is no candidate for splitting anymore 521 513 // => detach subdivision candidate … … 598 590 { 599 591 priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 600 if (mHierarchyManager->mConsiderMemory 2)592 if (mHierarchyManager->mConsiderMemory) 601 593 { 602 594 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mMemoryConst); … … 605 597 else 606 598 { 607 if (!mHierarchyManager->mConsiderMemory 2)599 if (!mHierarchyManager->mConsiderMemory) 608 600 { 609 601 priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; … … 619 611 } 620 612 613 //splitCandidate.SetOldCost(oldRenderCost); 621 614 // compute global decrease in render cost 622 615 splitCandidate.SetPriority(priority); … … 1356 1349 1357 1350 VssRayContainer rays; 1358 rays.reserve(tData.mNumRays); 1351 // maximal 2 objects share the same ray 1352 rays.reserve(tData.mNumRays * 2); 1359 1353 CollectRays(tData.mNode->mObjects, rays); 1360 1354 1361 const float prop = (float)mMaxTests / ( float)tData.mNumRays;1355 const float prop = (float)mMaxTests / ((float)tData.mNumRays + Limits::Small); 1362 1356 1363 1357 VssRay::NewMail(); 1364 1358 1359 //cout << "here7 " << tData.mNumRays << " " << rays.size() << endl; 1360 //cout << "here5 prop: " << prop << " " << mMaxTests << " " << tData.mNumRays << endl; 1365 1361 // only use a subset of the rays 1366 1362 VssRayContainer::const_iterator rit, rit_end = rays.end(); 1367 1363 1364 int nRays = 0; 1365 1368 1366 for (rit = rays.begin(); rit != rit_end; ++ rit) 1369 1367 { 1370 if ((mMaxTests >= tData.mNumRays) || (Random(1.0f) < prop))1368 if ((mMaxTests >= (int)rays.size()) || (Random(1.0f) < prop)) 1371 1369 { 1372 1370 (*rit)->Mail(); 1373 } 1374 } 1375 1371 ++ nRays; 1372 } 1373 } 1374 1375 //cout << "here99 " << nRays << " obj " << tData.mNode->mObjects.size() << endl; 1376 1376 // collect and mark the view cells as belonging to front pvs 1377 1377 ViewCellContainer viewCells; 1378 1378 CollectViewCells(tData.mNode->mObjects, viewCells, true, true); 1379 1379 1380 1380 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 1381 1381 for (vit = viewCells.begin(); vit != vit_end; ++ vit) … … 1488 1488 if (useVisibilityBasedHeuristics) 1489 1489 { 1490 //cout << "v rays: " << tData.mNumRays << " " << endl;1491 1490 /////////// 1492 1491 //-- heuristics using objects weighted by view cells volume … … 1498 1497 } 1499 1498 else 1500 { //cout << "e rays: " << tData.mNumRays << " ";1499 { 1501 1500 ////////////////// 1502 1501 //-- view cells not constructed yet => use surface area heuristic … … 1710 1709 1711 1710 1712 voidBvHierarchy::CollectViewCells(const ObjectContainer &objects,1713 1714 1715 1711 int BvHierarchy::CollectViewCells(const ObjectContainer &objects, 1712 ViewCellContainer &viewCells, 1713 const bool setCounter, 1714 const bool onlyMailedRays) const 1716 1715 { 1717 1716 ViewCell::NewMail(); 1718 1717 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1719 1718 1719 int numRays = 0; 1720 1720 // loop through all object and collect view cell pvs of this node 1721 1721 for (oit = objects.begin(); oit != oit_end; ++ oit) 1722 1722 { 1723 1723 // always use only mailed objects 1724 CollectViewCells(*oit, viewCells, true, setCounter, onlyMailedRays); 1725 } 1726 } 1727 1728 1729 void BvHierarchy::CollectViewCells(Intersectable *obj, 1730 ViewCellContainer &viewCells, 1731 const bool useMailBoxing, 1732 const bool setCounter, 1733 const bool onlyMailedRays) const 1724 numRays += CollectViewCells(*oit, viewCells, true, setCounter, onlyMailedRays); 1725 } 1726 //cout << "here4 " << numRays << " boj: " << objects.size() << " " << onlyMailedRays << endl; 1727 1728 return numRays; 1729 } 1730 1731 1732 int BvHierarchy::CollectViewCells(Intersectable *obj, 1733 ViewCellContainer &viewCells, 1734 const bool useMailBoxing, 1735 const bool setCounter, 1736 const bool onlyMailedRays) const 1734 1737 { 1735 1738 VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 1739 1740 int numRays = 0; 1736 1741 1737 1742 for (rit = obj->GetOrCreateRays()->begin(); rit < rit_end; ++ rit) … … 1742 1747 continue; 1743 1748 1744 ray->Mail(); 1749 //ray->Mail(); 1750 ++ numRays; 1745 1751 1746 1752 ViewCellContainer tmpViewCells; … … 1774 1780 } 1775 1781 } 1782 1783 return numRays; 1776 1784 } 1777 1785 … … 1833 1841 ViewCellContainer viewCells; 1834 1842 ViewCell::NewMail(); 1835 CollectViewCells(node->mObjects, viewCells, true, false); 1836 1843 int numRays = CollectViewCells(node->mObjects, viewCells, true, false); 1844 1845 //cout << "here6 " << numRays << endl; 1837 1846 if (0) cout << "collected " << (int)viewCells.size() << " dirty candidates" << endl; 1838 1847 … … 2015 2024 2016 2025 ViewCellContainer viewCells; 2017 // here we have to account for all view cells that can 2026 2027 // we have to account for all view cells that can 2018 2028 // be seen from the objects 2019 CollectViewCells(objects, viewCells, false, false);2029 int numRays = CollectViewCells(objects, viewCells, false, false); 2020 2030 2021 2031 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1732 r1744 781 781 /** Collect view cells which see this bvh leaf. 782 782 */ 783 voidCollectViewCells(const ObjectContainer &objects,784 785 786 const bool onlyMailedRays) const;783 int CollectViewCells(const ObjectContainer &objects, 784 ViewCellContainer &viewCells, 785 const bool setCounter, 786 const bool onlyUnmailedRays) const; 787 787 788 788 /** Counts the view cells of this object. note: only … … 797 797 /** Collects view cells which see an object. 798 798 */ 799 voidCollectViewCells(Intersectable *object,800 801 802 803 const bool onlyMailedRays) const;799 int CollectViewCells(Intersectable *object, 800 ViewCellContainer &viewCells, 801 const bool useMailBoxing, 802 const bool setCounter, 803 const bool onlyUnmailedRays) const; 804 804 805 805 /** Evaluates increase in pvs size. -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1727 r1744 2542 2542 optBool, 2543 2543 "hierarchy_construction_consider_memory=", 2544 "false"); 2545 2546 RegisterOption("Hierarchy.Construction.considerMemory2", 2547 optBool, 2548 "hierarchy_construction_consider_memory2=", 2549 "false"); 2544 "true"); 2550 2545 2551 2546 RegisterOption("Hierarchy.Construction.repairQueue", -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1743 r1744 91 91 << "#FullMem\n" << mFullMemory << endl 92 92 << "#RenderCostDecrease\n" << mRenderCostDecrease << endl 93 << "#Priority\n" << mPriority << endl 93 94 << "#FpsPerMb\n" << FpsPerMb() << endl 94 95 << endl; … … 142 143 Environment::GetSingleton()->GetBoolValue( 143 144 "Hierarchy.Construction.considerMemory", mConsiderMemory); 144 145 Environment::GetSingleton()->GetBoolValue(146 "Hierarchy.Construction.considerMemory2", mConsiderMemory2);147 145 148 146 Environment::GetSingleton()->GetFloatValue( … … 166 164 Debug << "maximal allowed memory: " << mTermMaxMemory << endl; 167 165 Debug << "consider memory: " << mConsiderMemory << endl; 168 Debug << "consider memory2: " << mConsiderMemory << endl;169 166 Debug << "min steps of same kind: " << mMinStepsOfSameType << endl; 170 167 Debug << "max steps of same kind: " << mMaxStepsOfSameType << endl; … … 266 263 { 267 264 SubdivisionCandidate *splitCandidate = splitQueue.Top(); 268 269 if (splitCandidate->IsDirty())270 splitCandidate->EvalCandidate();271 272 265 splitQueue.Pop(); 273 266 … … 287 280 288 281 HierarchySubdivisionStats stats; 282 289 283 stats.mNumSplits = mHierarchyStats.Leaves(); 290 284 stats.mTotalRenderCost = mHierarchyStats.mTotalCost; … … 295 289 stats.mViewSpaceSplits = mVspTree->mVspStats.Leaves(); 296 290 stats.mObjectSpaceSplits = GetObjectSpaceSubdivisionLeaves(); 297 291 stats.mRenderCostDecrease = mHierarchyStats.mRenderCostDecrease; 292 stats.mPriority = mPriority; 293 298 294 stats.Print(mSubdivisionStats); 299 295 } … … 740 736 const bool success = sc->Apply(splitQueue, terminationCriteriaMet); 741 737 738 if (sc->IsDirty()) 739 cout << "*******************************error!" << endl; 740 742 741 if (!success) // split was not taken 743 742 { 743 cout << "x"; 744 744 return false; 745 745 } 746 746 747 //cout << "priority: " << sc->GetPriority() << " rc decr: " << sc->GetRenderCostDecrease() << " | "; 747 748 /////////////// 748 749 //-- split was successful => update stats and queue … … 750 751 // cost ratio of cost decrease / totalCost 751 752 const float costRatio = sc->GetRenderCostDecrease() / mHierarchyStats.mTotalCost; 752 // Debug<< "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl;753 //cout << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 753 754 754 755 if (costRatio < mTermMinGlobalCostRatio) … … 772 773 mHierarchyStats.mMemory += (float)ObjectPvs::GetEntrySizeByte() * pvsEntriesIncr; 773 774 mHierarchyStats.mRenderCostDecrease = sc->GetRenderCostDecrease(); 775 776 mPriority = sc->GetPriority(); 774 777 775 778 static float memoryCount = 0; … … 1391 1394 { 1392 1395 SubdivisionCandidate *candidate = NextSubdivisionCandidate(splitQueue); 1393 // reevaluate local split plane and priority 1396 1397 // reevaluate local split plane and priority 1394 1398 candidate->EvalCandidate(recomputeSplitPlane); 1395 1399 cout << "."; … … 1924 1928 subStats.mViewSpaceSplits = 0; 1925 1929 subStats.mObjectSpaceSplits = 0; 1926 1930 subStats.mRenderCostDecrease = 0; 1927 1931 subStats.Print(stats); 1928 1932 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1743 r1744 128 128 int mObjectSpaceSplits; 129 129 130 float mPriority; 130 131 131 132 float VspOspRatio() const { return (float)mViewSpaceSplits / (float)mObjectSpaceSplits; } … … 145 146 mViewSpaceSplits = 0; 146 147 mObjectSpaceSplits = 0; 148 mPriority = 0; 147 149 } 148 150 … … 287 289 inline bool ConsiderMemory() const { return mConsiderMemory; } 288 290 //inline float GetMemoryConst() const { return mMemoryConst; } 289 290 291 291 292 void EvaluateSubdivision(const VssRayContainer &sampleRays, … … 625 626 bool mConsiderMemory; 626 627 627 bool mConsiderMemory2;628 629 628 int mMaxRepairs; 630 629 … … 633 632 friend OspTree; 634 633 friend BvHierarchy; 634 635 float mPriority; 636 635 637 friend ViewCellsParseHandlers; 636 638 -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1742 r1744 121 121 122 122 123 /*template<typename T, typename S>124 class PvsIterator125 {126 Next(PvsEntry<T, S>)127 private:128 typename vector<PvsEntry<T, S> >::iterator mItCurrent;129 typename vector<PvsEntry<T, S> >::iterator mItEnd;130 };*/131 132 133 123 template<typename T, typename S> 134 124 class PvsIterator … … 147 137 } 148 138 149 PvsEntry<T, S>Next()139 const PvsEntry<T, S> &Next() 150 140 { 151 141 return *(mItCurrent ++); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1743 r1744 42 42 // HACK 43 43 const static bool SAMPLE_AFTER_SUBDIVISION = true; 44 const static bool CLAMP_TO_BOX = false;45 //const static bool CLAMP_TO_BOX = true;44 //const static bool CLAMP_TO_BOX = false; 45 const static bool CLAMP_TO_BOX = true; 46 46 47 47 … … 119 119 120 120 121 ObjectPvs pvs1, pvs2, mergedPvs;121 /*ObjectPvs pvs1, pvs2, mergedPvs; 122 122 123 123 pvs1.AddSample((Intersectable *)1, 1); … … 172 172 cout << (int)entry.mObject << " " << entry.mData.mSumPdf << " x "; 173 173 } 174 174 */ 175 175 // sampling type for view cells construction samples 176 176 if (strcmp(buf, "object") == 0) -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1738 r1744 462 462 Environment::GetSingleton()->GetIntValue("VspTree.maxTests", mMaxTests); 463 463 464 Environment::GetSingleton()-> 465 GetFloatValue("VspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 464 Environment::GetSingleton()->GetFloatValue("VspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 466 465 467 466 // if only the driving axis is used for axis aligned split … … 505 504 506 505 Debug << "vsp mem const: " << mMemoryConst << endl; 507 506 cout << "here11 " << mRenderCostDecreaseWeight << endl; 508 507 Debug << endl; 509 508 } … … 852 851 { 853 852 priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 854 if (mHierarchyManager->mConsiderMemory 2)853 if (mHierarchyManager->mConsiderMemory) 855 854 { 856 855 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mMemoryConst); … … 859 858 else 860 859 { 861 if (!mHierarchyManager->mConsiderMemory 2)860 if (!mHierarchyManager->mConsiderMemory) 862 861 { 863 862 priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost;
Note: See TracChangeset
for help on using the changeset viewer.