Changeset 1912 for GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
- Timestamp:
- 12/20/06 00:26:02 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1911 r1912 381 381 const BvhTraversalData &tData = sc.mParentData; 382 382 BvhLeaf *leaf = tData.mNode; 383 383 384 AxisAlignedBox3 parentBox = leaf->GetBoundingBox(); 384 385 … … 424 425 425 426 //////////////////////////////////////// 426 //-- fill 427 //-- fill front and back traversal data with the new values 427 428 428 429 frontData.mDepth = backData.mDepth = tData.mDepth + 1; … … 442 443 AssociateObjectsWithLeaf(front); 443 444 444 #if PROBABILIY_IS_BV_VOLUME 445 // volume of bvh (= probability that this bvh can be seen) 446 frontData.mProbability = fbox.GetVolume(); 447 backData.mProbability = bbox.GetVolume(); 448 #else 445 //-- compute pvs correction to cope with undersampling 446 frontData.mPvs = CountViewCells(front->mObjects); 447 backData.mPvs = CountViewCells(back->mObjects); 448 449 frontData.mCorrectedPvs = sc.mCorrectedFrontPvs; 450 backData.mCorrectedPvs = sc.mCorrectedBackPvs; 451 449 452 // compute probability of this node being visible, 450 453 // i.e., volume of the view cells that can see this node 451 frontData.mProbability = EvalViewCellsVolume(sc.mFrontObjects); 452 backData.mProbability = EvalViewCellsVolume(sc.mBackObjects); 453 #endif 454 frontData.mRenderCost = EvalRenderCost(sc.mFrontObjects); 455 backData.mRenderCost = EvalRenderCost(sc.mBackObjects); 456 457 frontData.mCorrectedRenderCost = sc.mCorrectedFrontCost; 458 backData.mCorrectedRenderCost = sc.mCorrectedBackCost; 454 459 455 460 // how often was max cost ratio missed in this branch? 456 461 frontData.mMaxCostMisses = sc.GetMaxCostMisses(); 457 462 backData.mMaxCostMisses = sc.GetMaxCostMisses(); 458 463 459 464 // set the time stamp so the order of traversal can be reconstructed 460 465 node->SetTimeStamp(mHierarchyManager->mTimeStamp ++); … … 619 624 } 620 625 621 BvhLeaf *leaf = splitCandidate.mParentData.mNode; 622 623 if (USE_AVGRAYCONTRI) 624 { 625 // this leaf is a pvs entry in all the view cells 626 // that see one of the objects. 627 const int pvs = CountViewCells(leaf->mObjects); 628 //const int pvs = (int)leaf->mObjects.size(); 629 630 // avg contribution of a ray to a pvs 631 const float avgRayContri = 632 AvgRayContribution(pvs, splitCandidate.mParentData.mNumRays); 633 634 // high avg ray contri, the result is influenced by undersampling 635 splitCandidate.SetAvgRayContri(avgRayContri); 636 } 637 638 const float oldProp = EvalViewCellsVolume(leaf->mObjects); 626 const BvhTraversalData &tData = splitCandidate.mParentData; 627 BvhLeaf *leaf = tData.mNode; 628 629 // avg contribution of a ray to a pvs 630 const float pvs = CountViewCells(leaf->mObjects); 631 const float avgRayContri = AvgRayContribution(pvs, tData.mNumRays); 632 633 cout << "bvh avg ray contri: " << avgRayContri << endl; 634 // high avg ray contri, the result is influenced by undersampling 635 splitCandidate.SetAvgRayContribution(avgRayContri); 636 639 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 // this leaf is a pvs entry in all the view cells 643 // 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.mCorrectedFrontCost = 649 mHierarchyManager->EvalCorrectedPvs(frontCost, parentCost, avgRayContri); 650 651 cout << "bvh front cost: " << frontCost << " corrected: " << splitCandidate.mCorrectedFrontCost << endl; 652 cout <<"here104 "<< endl; 653 654 splitCandidate.mCorrectedBackCost = 655 mHierarchyManager->EvalCorrectedPvs(backCost, parentCost, avgRayContri); 656 657 cout << "back cost: " << backCost << " corrected: " << splitCandidate.mCorrectedBackCost << endl; 640 658 641 659 // compute global decrease in render cost 642 const float newRenderCost = EvalRenderCost(splitCandidate.mFrontObjects) + 643 EvalRenderCost(splitCandidate.mBackObjects); 644 645 const float renderCostDecr = oldRenderCost - newRenderCost; 660 const float newRenderCost = 661 splitCandidate.mCorrectedFrontCost + splitCandidate.mCorrectedBackCost; 662 const float renderCostDecr = parentCost - newRenderCost; 646 663 647 664 splitCandidate.SetRenderCostDecrease(renderCostDecr); 648 665 649 666 // increase in pvs entries 650 const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate );667 const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate, avgRayContri); 651 668 splitCandidate.SetPvsEntriesIncr(pvsEntriesIncr); 652 669 … … 666 683 667 684 668 int BvHierarchy::EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate) const 685 int BvHierarchy::EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate, 686 const float avgRayContri) const 669 687 { 670 688 const int oldPvsSize = CountViewCells(splitCandidate.mParentData.mNode->mObjects); 671 672 const int fPvsSize = CountViewCells(splitCandidate.mFrontObjects); 673 const int bPvsSize = CountViewCells(splitCandidate.mBackObjects); 674 675 return fPvsSize + bPvsSize - oldPvsSize; 689 const float oldPvsRatio = splitCandidate.mParentData.mPvs > 0 ? oldPvsSize / splitCandidate.mParentData.mPvs : 1; 690 691 const float parentPvs = splitCandidate.mParentData.mCorrectedPvs * oldPvsRatio; 692 693 const int frontViewCells = CountViewCells(splitCandidate.mFrontObjects); 694 const int backViewCells = CountViewCells(splitCandidate.mBackObjects); 695 696 cout <<"here105 " << splitCandidate.mParentData.mCorrectedPvs << endl; 697 cout <<"here106 " << oldPvsRatio << endl; 698 699 splitCandidate.mCorrectedFrontPvs = 700 mHierarchyManager->EvalCorrectedPvs(frontViewCells, parentPvs, avgRayContri); 701 splitCandidate.mCorrectedBackPvs = 702 mHierarchyManager->EvalCorrectedPvs(backViewCells, parentPvs, avgRayContri); 703 704 return splitCandidate.mCorrectedFrontPvs + splitCandidate.mCorrectedBackPvs - parentPvs; 676 705 } 677 706 … … 730 759 731 760 732 if (data.mProbability <= mTermMinProbability)761 /*if (data.mProbability <= mTermMinProbability) 733 762 { 734 763 ++ mBvhStats.minProbabilityNodes; 735 } 764 }*/ 736 765 737 766 //////////////////////////////////////////// … … 2167 2196 // create bvh traversal data 2168 2197 BvhTraversalData oData(bvhLeaf, 0, prop, nRays); 2169 2198 2170 2199 // create sorted object lists for the first data 2171 2200 if (mUseGlobalSorting) … … 2178 2207 //-- add first candidate for object space partition 2179 2208 2209 mTotalCost = EvalRenderCost(objects); 2210 mPvsEntries = CountViewCells(objects); 2211 2212 oData.mCorrectedPvs = oData.mPvs = mPvsEntries; 2213 oData.mCorrectedRenderCost = oData.mRenderCost = mTotalCost; 2214 cout << "here52 " << oData.mCorrectedPvs << " " << oData.mRenderCost << " " << oData.mCorrectedRenderCost << endl; 2215 2216 2180 2217 BvhSubdivisionCandidate *oSubdivisionCandidate = 2181 2218 new BvhSubdivisionCandidate(oData); 2182 2219 2183 2220 bvhLeaf->SetSubdivisionCandidate(oSubdivisionCandidate); 2184 2185 mTotalCost = EvalRenderCost(objects);2186 mPvsEntries = CountViewCells(objects);2187 2221 2188 2222 if (mApplyInitialPartition)
Note: See TracChangeset
for help on using the changeset viewer.