Changeset 1913 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 12/20/06 12:18:41 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1912 r1913 374 374 } 375 375 376 float BvHierarchy::GetViewSpaceVolume() const 377 { 378 return mViewCellsManager->GetViewSpaceBox().GetVolume(); 379 } 380 376 381 377 382 BvhInterior *BvHierarchy::SubdivideNode(const BvhSubdivisionCandidate &sc, … … 444 449 445 450 //-- compute pvs correction to cope with undersampling 446 frontData.mPvs = CountViewCells(front->mObjects);447 backData.mPvs = CountViewCells(back->mObjects);451 frontData.mPvs = (float)CountViewCells(front->mObjects); 452 backData.mPvs = (float)CountViewCells(back->mObjects); 448 453 449 454 frontData.mCorrectedPvs = sc.mCorrectedFrontPvs; … … 452 457 // compute probability of this node being visible, 453 458 // i.e., volume of the view cells that can see this node 454 frontData.m RenderCost = EvalRenderCost(sc.mFrontObjects);455 backData.m RenderCost = EvalRenderCost(sc.mBackObjects);456 457 frontData.mCorrected RenderCost = sc.mCorrectedFrontCost;458 backData.mCorrected RenderCost = sc.mCorrectedBackCost;459 frontData.mVolume = EvalViewCellsVolume(sc.mFrontObjects) / GetViewSpaceVolume(); 460 backData.mVolume = EvalViewCellsVolume(sc.mBackObjects) / GetViewSpaceVolume(); 461 462 frontData.mCorrectedVolume = sc.mCorrectedFrontVolume; 463 backData.mCorrectedVolume = sc.mCorrectedBackVolume; 459 464 460 465 // how often was max cost ratio missed in this branch? … … 628 633 629 634 // avg contribution of a ray to a pvs 630 const float pvs = CountViewCells(leaf->mObjects);631 const float avgRayContri = AvgRayContribution( pvs, tData.mNumRays);635 const float pvs = (float)CountViewCells(leaf->mObjects); 636 const float avgRayContri = AvgRayContribution((int)pvs, tData.mNumRays); 632 637 633 638 cout << "bvh avg ray contri: " << avgRayContri << endl; … … 635 640 splitCandidate.SetAvgRayContribution(avgRayContri); 636 641 637 const float oldRenderCost = EvalRenderCost(leaf->mObjects); 638 const float oldRatio = oldRenderCost / tData.mRenderCost; 639 const float parentCost = tData.mCorrectedRenderCost * oldRatio; 640 641 cout << "old ratio: " << oldRatio << endl; 642 const float oldVolume = EvalViewCellsVolume(leaf->mObjects) / GetViewSpaceVolume(); 643 const float oldRatio = tData.mVolume > 0 ? oldVolume / tData.mVolume : 1; 644 const float parentVol = tData.mCorrectedVolume * oldRatio; 645 642 646 // this leaf is a pvs entry in all the view cells 643 647 // that see one of the objects. 644 const int frontCost = EvalRenderCost(splitCandidate.mFrontObjects);645 const int backCost = EvalRenderCost(splitCandidate.mBackObjects);646 647 cout <<"here8 ============ "<< parentCost<< endl;648 splitCandidate.mCorrectedFront Cost=649 mHierarchyManager->EvalCorrectedPvs(front Cost, parentCost, avgRayContri);650 651 cout << "bvh front cost: " << frontCost << " corrected: " << splitCandidate.mCorrectedFrontCost<< endl;648 const float frontVol = EvalViewCellsVolume(splitCandidate.mFrontObjects) / GetViewSpaceVolume(); 649 const float backVol = EvalViewCellsVolume(splitCandidate.mBackObjects) / GetViewSpaceVolume(); 650 651 cout <<"here8 "<< parentVol << " " << " old ratio: " << oldRatio << " frointvol: " << frontVol << endl; 652 splitCandidate.mCorrectedFrontVolume = 653 mHierarchyManager->EvalCorrectedPvs(frontVol, parentVol, avgRayContri); 654 655 cout << "bvh front vol: " << frontVol << " corrected: " << splitCandidate.mCorrectedFrontVolume << endl; 652 656 cout <<"here104 "<< endl; 653 657 654 splitCandidate.mCorrectedBackCost = 655 mHierarchyManager->EvalCorrectedPvs(backCost, parentCost, avgRayContri); 656 657 cout << "back cost: " << backCost << " corrected: " << splitCandidate.mCorrectedBackCost << endl; 658 splitCandidate.mCorrectedBackVolume = 659 mHierarchyManager->EvalCorrectedPvs(backVol, parentVol, avgRayContri); 660 661 cout << "back vol: " << backVol << " corrected: " << splitCandidate.mCorrectedBackVolume << endl; 662 663 const float relfrontCost = splitCandidate.mCorrectedFrontVolume * 664 EvalAbsCost(splitCandidate.mFrontObjects); 665 const float relBackCost = splitCandidate.mCorrectedFrontVolume * 666 EvalAbsCost(splitCandidate.mBackObjects); 667 const float relParentCost = parentVol * 668 EvalAbsCost(leaf->mObjects); 658 669 659 670 // compute global decrease in render cost 660 const float newRenderCost = 661 splitCandidate.mCorrectedFrontCost + splitCandidate.mCorrectedBackCost; 662 const float renderCostDecr = parentCost - newRenderCost; 671 const float newRenderCost = relfrontCost + relBackCost; 672 const float renderCostDecr = relParentCost - newRenderCost; 663 673 664 674 splitCandidate.SetRenderCostDecrease(renderCostDecr); … … 676 686 float priority = EvalPriority(splitCandidate, 677 687 renderCostDecr, 678 oldRenderCost);688 relParentCost); 679 689 680 690 // compute global decrease in render cost … … 686 696 const float avgRayContri) const 687 697 { 688 const int oldPvsSize =CountViewCells(splitCandidate.mParentData.mNode->mObjects);689 const float oldPvsRatio = splitCandidate.mParentData.mPvs > 0? oldPvsSize / splitCandidate.mParentData.mPvs : 1;698 const float oldPvsSize = (float)CountViewCells(splitCandidate.mParentData.mNode->mObjects); 699 const float oldPvsRatio = (splitCandidate.mParentData.mPvs > 0) ? oldPvsSize / splitCandidate.mParentData.mPvs : 1; 690 700 691 701 const float parentPvs = splitCandidate.mParentData.mCorrectedPvs * oldPvsRatio; … … 698 708 699 709 splitCandidate.mCorrectedFrontPvs = 700 mHierarchyManager->EvalCorrectedPvs( frontViewCells, parentPvs, avgRayContri);710 mHierarchyManager->EvalCorrectedPvs((float)frontViewCells, parentPvs, avgRayContri); 701 711 splitCandidate.mCorrectedBackPvs = 702 mHierarchyManager->EvalCorrectedPvs( backViewCells, parentPvs, avgRayContri);703 704 return splitCandidate.mCorrectedFrontPvs + splitCandidate.mCorrectedBackPvs - parentPvs;712 mHierarchyManager->EvalCorrectedPvs((float)backViewCells, parentPvs, avgRayContri); 713 714 return (int)(splitCandidate.mCorrectedFrontPvs + splitCandidate.mCorrectedBackPvs - parentPvs); 705 715 } 706 716 … … 1755 1765 1756 1766 1767 float BvHierarchy::EvalProb(const ObjectContainer &objects) const 1768 { 1769 /////////////// 1770 //-- render cost heuristics 1771 1772 const float viewSpaceVol = mViewCellsManager->GetViewSpaceBox().GetVolume(); 1773 1774 // probability that view point lies in a view cell which sees this node 1775 return EvalViewCellsVolume(objects) / viewSpaceVol; 1776 } 1777 1778 1757 1779 AxisAlignedBox3 BvHierarchy::EvalBoundingBox(const ObjectContainer &objects, 1758 1780 const AxisAlignedBox3 *parentBox) const … … 2176 2198 BvhLeaf *bvhLeaf = dynamic_cast<BvhLeaf *>(mRoot); 2177 2199 2178 // multiply termination criterium for comparison,2179 // so it can be set between zero and one and2180 // no division is necessary during traversal2181 2182 #if PROBABILIY_IS_BV_VOLUME2183 mTermMinProbability *= mBoundingBox.GetVolume();2184 // probability that bounding volume is seen2185 const float prop = GetBoundingBox().GetVolume();2186 #else2187 mTermMinProbability *= mVspTree->GetBoundingBox().GetVolume();2188 2200 // probability that volume is "seen" from the view cells 2189 const float prop = EvalViewCellsVolume(objects); 2190 #endif 2201 const float prop = EvalViewCellsVolume(objects) / GetViewSpaceVolume(); 2191 2202 2192 2203 // only rays intersecting objects in node are interesting … … 2210 2221 mPvsEntries = CountViewCells(objects); 2211 2222 2212 oData.mCorrectedPvs = oData.mPvs = mPvsEntries; 2213 oData.mCorrectedRenderCost = oData.mRenderCost = mTotalCost; 2214 cout << "here52 " << oData.mCorrectedPvs << " " << oData.mRenderCost << " " << oData.mCorrectedRenderCost << endl; 2215 2223 oData.mCorrectedPvs = oData.mPvs = (float)mPvsEntries; 2224 oData.mCorrectedVolume = oData.mVolume = prop; 2225 cout << "here52 " << oData.mCorrectedPvs << " " << oData.mVolume << " " << oData.mCorrectedVolume << endl; 2216 2226 2217 2227 BvhSubdivisionCandidate *oSubdivisionCandidate = -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1912 r1913 387 387 mCorrectedPvs(0), 388 388 mPvs(0), 389 mCorrected RenderCost(0),390 m RenderCost(0)389 mCorrectedVolume(0), 390 mVolume(0) 391 391 { 392 392 for (int i = 0; i < 4; ++ i) … … 405 405 mCorrectedPvs(0), 406 406 mPvs(0), 407 mCorrected RenderCost(0),408 m RenderCost(v)407 mCorrectedVolume(0), 408 mVolume(v) 409 409 { 410 410 for (int i = 0; i < 4; ++ i) … … 425 425 /// current depth 426 426 int mDepth; 427 /// the render costof the node428 float m RenderCost;429 /// the corrected render cost;430 float mCorrected RenderCost;427 /// the volume of the node 428 float mVolume; 429 /// the corrected volume 430 float mCorrectedVolume; 431 431 /// how often this branch has missed the max-cost ratio 432 432 int mMaxCostMisses; … … 512 512 float mCorrectedBackPvs; 513 513 514 float mCorrectedFront Cost;515 float mCorrectedBack Cost;514 float mCorrectedFrontVolume; 515 float mCorrectedBackVolume; 516 516 }; 517 517 … … 597 597 void SetViewCellsManager(ViewCellsManager *vcm); 598 598 599 float GetViewSpaceVolume() const; 599 600 /** Writes tree to output stream 600 601 */ … … 640 641 641 642 static float EvalAbsCost(const ObjectContainer &objects); 643 644 float EvalProb(const ObjectContainer &objects) const; 642 645 643 646 void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1912 r1913 743 743 // assume pvs sampled sufficiently => take child pvs 744 744 if (avgRayContri < mMinAvgRayContri) 745 { 746 cout << "here4 child" << endl; 745 747 return childPvs; 746 748 } 747 749 // assume pvs not sampled sufficiently => take total pvs 748 750 if (avgRayContri > mMaxAvgRayContri) 751 { 752 cout << "here9 parent" << endl; 749 753 return totalPvs; 754 } 750 755 751 756 const float alpha = (mMaxAvgRayContri - avgRayContri) / 752 757 (mMaxAvgRayContri - mMinAvgRayContri); 753 758 754 cout << "here41 **************** " << alpha << " " << childPvs << " " << totalPvs << endl; 755 756 const float beta = (1.0f - alpha) * (totalPvs + childPvs) / totalPvs; 757 758 return childPvs + beta; 759 const float beta = (1.0f - alpha) * (totalPvs - childPvs); 760 761 cout << "alpha " << alpha << " beta: " << beta << " child: " << childPvs << " parent: " << totalPvs << endl; 762 763 const float newPvs = childPvs + beta; 764 765 if ((newPvs < childPvs - Limits::Small) || (newPvs > totalPvs + Limits::Small)) 766 cout << "Error!! " << newPvs << endl; 767 return newPvs; 759 768 } 760 769 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1912 r1913 346 346 VspLeaf::VspLeaf(): 347 347 mViewCell(NULL), mSubdivisionCandidate(NULL) 348 //, mPvs(NULL)349 348 { 350 349 } … … 380 379 VspLeaf::VspLeaf(VspInterior *parent): 381 380 VspNode(parent), mViewCell(NULL) 382 //, mPvs(NULL)383 381 {} 384 382 … … 386 384 VspLeaf::VspLeaf(VspInterior *parent, ViewCellLeaf *viewCell): 387 385 VspNode(parent), mViewCell(viewCell) 388 //, mPvs(NULL)389 386 { 390 387 } … … 735 732 736 733 mTotalCost -= sc->GetRenderCostDecrease(); 737 mTotalPvsSize += (int)(tFrontData.mPvs + tBackData.mPvs - tData.mPvs);734 //mTotalPvsSize += (int)(tFrontData.mPvs + tBackData.mPvs - tData.mPvs); 738 735 mPvsEntries += sc->GetPvsEntriesIncr(); 739 736 … … 899 896 } 900 897 901 const float oldPvsRatio = oldPvsSize / splitCandidate.mParentData.mPvs; 898 const float oldPvsRatio = (splitCandidate.mParentData.mPvs > 0) ? 899 oldPvsSize / splitCandidate.mParentData.mPvs : 1; 902 900 const float correctedOldPvs = splitCandidate.mParentData.mCorrectedPvs * oldPvsRatio; 903 901 904 902 cout <<"here102 "<< endl; 905 903 cout << "old pvs ratio: " << oldPvsRatio << endl; 906 const float correctedFrontPvs =904 splitCandidate.mCorrectedFrontPvs = 907 905 mHierarchyManager->EvalCorrectedPvs(fPvsSize, 908 906 correctedOldPvs, 909 907 splitCandidate.GetAvgRayContribution()); 910 908 cout <<"here103 "<< endl; 911 const float correctedBackPvs =909 splitCandidate.mCorrectedBackPvs = 912 910 mHierarchyManager->EvalCorrectedPvs(bPvsSize, 913 911 correctedOldPvs, … … 915 913 916 914 917 cout << "vsp front entries " << fPvsSize << " corrected: " << correctedFrontPvs << endl;918 cout << "vsp back entries " << bPvsSize << " corrected: " << correctedBackPvs << endl;919 920 return (int)( correctedFrontPvs + correctedBackPvs - correctedOldPvs);915 cout << "vsp front entries " << fPvsSize << " corrected: " << splitCandidate.mCorrectedFrontPvs << endl; 916 cout << "vsp back entries " << bPvsSize << " corrected: " << splitCandidate.mCorrectedBackPvs << endl; 917 918 return (int)(splitCandidate.mCorrectedFrontPvs + splitCandidate.mCorrectedBackPvs - correctedOldPvs); 921 919 } 922 920 … … 961 959 962 960 //-- compute render cost 963 frontData.mRenderCost = (float)Eval RenderCost(*frontData.mRays);964 backData.mRenderCost = (float)Eval RenderCost(*backData.mRays);965 966 frontData.mCorrectedRenderCost = sc.mCorrectedFront Pvs;967 backData.mCorrectedRenderCost = sc.mCorrectedBack Pvs;961 frontData.mRenderCost = (float)EvalPvsCost(*frontData.mRays); 962 backData.mRenderCost = (float)EvalPvsCost(*backData.mRays); 963 964 frontData.mCorrectedRenderCost = sc.mCorrectedFrontRenderCost; 965 backData.mCorrectedRenderCost = sc.mCorrectedBackRenderCost; 968 966 969 967 //////// … … 1605 1603 //-- evaluate render cost heuristics 1606 1604 1607 const float oldRenderCostRatio = tData.mPvs ? (totalPvs / tData.mPvs) : 1; 1608 1609 const float penaltyOld = tData.mCorrectedPvs * oldRenderCostRatio; 1610 1611 cout <<"here107 " << penaltyOld << endl; 1612 sc.mCorrectedFrontPvs = mHierarchyManager->EvalCorrectedPvs(pvsFront, penaltyOld, avgRayContri); 1613 cout <<"here108 " << tData.mCorrectedPvs << " " << oldRenderCostRatio << endl; 1614 sc.mCorrectedBackPvs = mHierarchyManager->EvalCorrectedPvs(pvsBack, penaltyOld, avgRayContri); 1615 1616 cout << "vsp front pvs " << pvsFront << " corrected: " << sc.mCorrectedFrontPvs << endl; 1617 cout << "vsp back pvs " << pvsBack << " corrected: " << sc.mCorrectedBackPvs << endl; 1605 const float oldRenderCostRatio = (tData.mRenderCost > 0)? 1606 (totalPvs / tData.mRenderCost) : 1; 1607 1608 const float penaltyOld = tData.mCorrectedRenderCost * oldRenderCostRatio; 1609 1610 cout <<"here107 old render cost ratio " << oldRenderCostRatio << " old cost: " << penaltyOld << endl; 1611 sc.mCorrectedFrontRenderCost = mHierarchyManager->EvalCorrectedPvs(pvsFront, penaltyOld, avgRayContri); 1612 cout <<"here108 " << tData.mCorrectedRenderCost << " " << oldRenderCostRatio << endl; 1613 sc.mCorrectedBackRenderCost = mHierarchyManager->EvalCorrectedPvs(pvsBack, penaltyOld, avgRayContri); 1614 1615 cout << "vsp front pvs " << pvsFront << " corrected: " << sc.mCorrectedFrontRenderCost << endl; 1616 cout << "vsp back render cost " << pvsBack << " corrected: " << sc.mCorrectedBackRenderCost << endl; 1618 1617 1619 1618 const float oldRenderCost = pOverall * penaltyOld; 1620 const float newRenderCost = sc.mCorrectedFrontPvs * pFront + sc.mCorrectedBackPvs * pBack; 1619 const float newRenderCost = sc.mCorrectedFrontRenderCost * pFront + 1620 sc.mCorrectedFrontRenderCost * pBack; 1621 1621 1622 1622 // we also return the old render cost … … 2934 2934 VspTraversalData vData(leaf, 0, &rays, pvsCost, prop, mBoundingBox); 2935 2935 2936 2937 2936 #if WORK_WITH_VIEWCELL_PVS 2938 2937 // add first view cell to all the objects view cell pvs … … 2947 2946 #endif 2948 2947 2949 mTotalCost = vData.mCorrected Pvs= pvsCost;2950 mPvsEntries = EvalPvsEntriesSize(rays);2948 mTotalCost = vData.mCorrectedRenderCost = vData.mRenderCost = pvsCost; 2949 mPvsEntries = vData.mCorrectedPvs = vData.mPvs = EvalPvsEntriesSize(rays); 2951 2950 2952 2951 ////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1912 r1913 531 531 float mCorrectedFrontRenderCost; 532 532 float mCorrectedBackRenderCost; 533 float mCorrectedFrontVolume; 534 float mCorrectedBackVolume; 533 535 }; 534 536
Note: See TracChangeset
for help on using the changeset viewer.