- Timestamp:
- 12/20/06 00:26:02 (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
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) -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1903 r1912 382 382 mNode(NULL), 383 383 mDepth(0), 384 mProbability(0.0),385 384 mMaxCostMisses(0), 386 385 mAxis(0), 387 mNumRays(0) 386 mNumRays(0), 387 mCorrectedPvs(0), 388 mPvs(0), 389 mCorrectedRenderCost(0), 390 mRenderCost(0) 388 391 { 389 392 for (int i = 0; i < 4; ++ i) … … 397 400 mNode(node), 398 401 mDepth(depth), 399 //mBoundingBox(box),400 mProbability(v),401 402 mMaxCostMisses(0), 402 403 mAxis(0), 403 mNumRays(numRays) 404 mNumRays(numRays), 405 mCorrectedPvs(0), 406 mPvs(0), 407 mCorrectedRenderCost(0), 408 mRenderCost(v) 404 409 { 405 410 for (int i = 0; i < 4; ++ i) … … 420 425 /// current depth 421 426 int mDepth; 422 /// the probability that this node is seen423 float m Probability;424 /// the bounding box of the node425 //AxisAlignedBox3 mBoundingBox;427 /// the render cost of the node 428 float mRenderCost; 429 /// the corrected render cost; 430 float mCorrectedRenderCost; 426 431 /// how often this branch has missed the max-cost ratio 427 432 int mMaxCostMisses; … … 430 435 /// number of rays 431 436 int mNumRays; 437 /// parent Pvs; 438 float mPvs; 439 /// parent pvs correction factor 440 float mCorrectedPvs; 441 432 442 /// the sorted objects for the three dimensions 433 443 ObjectContainer *mSortedObjects[4]; … … 486 496 return mPriority; 487 497 } 498 499 /////////////////////////////7 488 500 489 501 /// pointer to parent tree. … … 496 508 /// the objects on the back of the potential split 497 509 ObjectContainer mBackObjects; 510 511 float mCorrectedFrontPvs; 512 float mCorrectedBackPvs; 513 514 float mCorrectedFrontCost; 515 float mCorrectedBackCost; 498 516 }; 499 517 … … 821 839 /** Evaluates increase in pvs size. 822 840 */ 823 int EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate ) const;841 int EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate, const float avgRayContri) const; 824 842 825 843 /** Rays will be clipped to the bounding box. -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1902 r1912 2658 2658 "99999.0"); 2659 2659 2660 RegisterOption("Hierarchy.Construction.minAvgRayContri", 2661 optFloat, 2662 "hierarchy_construction_min_avg_raycontri=", 2663 "99990.0"); 2664 2660 2665 ///////////////////////////////////////////////////////////////// 2661 2666 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1911 r1912 156 156 "Hierarchy.Construction.maxAvgRayContri", mMaxAvgRayContri); 157 157 158 Environment::GetSingleton()->GetFloatValue( 159 "Hierarchy.Construction.minAvgRayContri", mMinAvgRayContri); 160 158 161 // for comparing it with byte - value 159 162 mTermMaxMemory *= (1024.0f * 1024.0f); … … 734 737 735 738 736 float HierarchyManager::EvalPvsCorrectionFactor(const float childPvs, 737 const float totalPvs, 738 const float avgRayContri) const 739 { 740 if (!childPvs || 741 // assume pvs sampled sufficiently => take child pvs 742 (avgRayContri < mMinAvgRayContri)) 743 return 1.0f; 739 float HierarchyManager::EvalCorrectedPvs(const float childPvs, 740 const float totalPvs, 741 const float avgRayContri) const 742 { 743 // assume pvs sampled sufficiently => take child pvs 744 if (avgRayContri < mMinAvgRayContri) 745 return childPvs; 744 746 745 747 // assume pvs not sampled sufficiently => take total pvs 746 748 if (avgRayContri > mMaxAvgRayContri) 747 return totalPvs / childPvs; 748 749 const float factor = 750 (mMaxAvgRayContri - avgRayContri) / 751 (mMaxAvgRayContri - mMinAvgRayContri); 752 753 const float newPvs = factor * childPvs + (1.0f - factor) * totalPvs; 754 755 return newPvs / childPvs; 749 return totalPvs; 750 751 const float alpha = (mMaxAvgRayContri - avgRayContri) / 752 (mMaxAvgRayContri - mMinAvgRayContri); 753 754 cout << "here41 **************** " << alpha << " " << childPvs << " " << totalPvs << endl; 755 756 const float beta = (1.0f - alpha) * (totalPvs + childPvs) / totalPvs; 757 758 return childPvs + beta; 756 759 } 757 760 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1911 r1912 296 296 void CreateUniqueObjectIds(); 297 297 298 float Eval PvsCorrectionFactor(const float pvsFront,299 300 298 float EvalCorrectedPvs(const float pvsFront, 299 const float totalPvs, 300 const float avgRayContri) const; 301 301 302 302 -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
r1845 r1912 206 206 Name="VCLinkerTool" 207 207 AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib Preprocessor.lib RTScene.lib RTWorld.lib QtCore4.lib qtmain.lib QtOpenGL4.lib Qt3Support4.lib QtTest4.lib QtGui4.lib QtGlRenderer.lib" 208 OutputFile="../bin/release/Preprocessor .exe"208 OutputFile="../bin/release/Preprocessor2.exe" 209 209 LinkIncremental="1" 210 210 AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\Preprocessing\lib\release;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\MultiLevelRayTracing\RTScene\Release;..\MultiLevelRayTracing\RTWorld\Release;"$(QTDIR)\lib";.\QtGlRenderer\Release" -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1911 r1912 724 724 725 725 // create new interior node and two leaf node 726 const AxisAlignedPlane splitPlane = sc->mSplitPlane;727 726 const int maxCostMisses = sc->GetMaxCostMisses(); 728 727 729 newNode = SubdivideNode(splitPlane, tData, tFrontData, tBackData); 728 newNode = SubdivideNode(*sc, 729 tFrontData, 730 tBackData); 730 731 731 732 // how often was max cost ratio missed in this branch? … … 832 833 833 834 VspLeaf *leaf = dynamic_cast<VspLeaf *>(splitCandidate.mParentData.mNode); 834 835 836 ///////////// 837 // avg ray contri 838 839 const int pvs = EvalPvsEntriesSize(*splitCandidate.mParentData.mRays); 840 841 const float avgRayContri = (float)pvs / 842 ((float)splitCandidate.mParentData.mRays->size() + Limits::Small); 843 844 splitCandidate.SetAvgRayContribution(avgRayContri); 845 cout << "vsp avg ray contri: " << avgRayContri << endl; 846 835 847 // compute global decrease in render cost 836 848 float oldRenderCost; 837 const float renderCostDecr = EvalRenderCostDecrease(splitCandidate.mSplitPlane, 838 splitCandidate.mParentData, 839 oldRenderCost); 840 849 const float renderCostDecr = EvalRenderCostDecrease(splitCandidate, oldRenderCost); 841 850 splitCandidate.SetRenderCostDecrease(renderCostDecr); 842 851 … … 854 863 { 855 864 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mMemoryConst); 856 }857 858 859 /////////////860 // avg ray contri861 862 if (USE_AVGRAYCONTRI)863 {864 const int pvs = EvalPvsEntriesSize(*splitCandidate.mParentData.mRays);865 866 const float avgRayContri = (float)pvs /867 ((float)splitCandidate.mParentData.mRays->size() + Limits::Small);868 869 splitCandidate.SetAvgRayContribution(avgRayContri);870 865 } 871 866 … … 904 899 } 905 900 906 return (int)(fPvsSize + bPvsSize - oldPvsSize); 907 } 908 909 910 VspInterior *VspTree::SubdivideNode(const AxisAlignedPlane &splitPlane, 911 VspTraversalData &tData, 901 const float oldPvsRatio = oldPvsSize / splitCandidate.mParentData.mPvs; 902 const float correctedOldPvs = splitCandidate.mParentData.mCorrectedPvs * oldPvsRatio; 903 904 cout <<"here102 "<< endl; 905 cout << "old pvs ratio: " << oldPvsRatio << endl; 906 const float correctedFrontPvs = 907 mHierarchyManager->EvalCorrectedPvs(fPvsSize, 908 correctedOldPvs, 909 splitCandidate.GetAvgRayContribution()); 910 cout <<"here103 "<< endl; 911 const float correctedBackPvs = 912 mHierarchyManager->EvalCorrectedPvs(bPvsSize, 913 correctedOldPvs, 914 splitCandidate.GetAvgRayContribution()); 915 916 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); 921 } 922 923 924 VspInterior *VspTree::SubdivideNode(const VspSubdivisionCandidate &sc, 912 925 VspTraversalData &frontData, 913 926 VspTraversalData &backData) 914 927 { 915 VspLeaf *leaf = dynamic_cast<VspLeaf *>(tData.mNode); 916 928 VspLeaf *leaf = dynamic_cast<VspLeaf *>(sc.mParentData.mNode); 929 930 const VspTraversalData &tData = sc.mParentData; 931 const AxisAlignedPlane splitPlane = sc.mSplitPlane; 932 917 933 /////////////// 918 934 //-- new traversal values … … 928 944 929 945 //-- compute pvs 930 frontData.mPvs = EvalPvsCost(*frontData.mRays); 931 backData.mPvs = EvalPvsCost(*backData.mRays); 932 946 frontData.mPvs = (float)EvalPvsEntriesSize(*frontData.mRays); 947 backData.mPvs = (float)EvalPvsEntriesSize(*backData.mRays); 948 949 //-- compute pvs correction for coping with undersampling 950 frontData.mCorrectedPvs = sc.mCorrectedFrontPvs; 951 backData.mCorrectedPvs = sc.mCorrectedBackPvs; 952 933 953 //-- split front and back node geometry and compute area 934 954 tData.mBoundingBox.Split(splitPlane.mAxis, … … 940 960 backData.mProbability = tData.mProbability - frontData.mProbability; 941 961 962 //-- compute render cost 963 frontData.mRenderCost = (float)EvalRenderCost(*frontData.mRays); 964 backData.mRenderCost = (float)EvalRenderCost(*backData.mRays); 965 966 frontData.mCorrectedRenderCost = sc.mCorrectedFrontPvs; 967 backData.mCorrectedRenderCost = sc.mCorrectedBackPvs; 942 968 943 969 //////// … … 1519 1545 1520 1546 1521 float VspTree::EvalRenderCostDecrease(const AxisAlignedPlane &candidatePlane, 1522 const VspTraversalData &tData, 1523 float &normalizedOldRenderCost, 1524 const float avgRayContri) const 1547 float VspTree::EvalRenderCostDecrease(VspSubdivisionCandidate &sc, 1548 float &normalizedOldRenderCost) const 1525 1549 { 1526 1550 float pvsFront = 0; … … 1529 1553 1530 1554 const float viewSpaceVol = mBoundingBox.GetVolume(); 1555 const VspTraversalData &tData = sc.mParentData; 1556 1557 const AxisAlignedPlane &candidatePlane = sc.mSplitPlane; 1558 const float avgRayContri = sc.GetAvgRayContribution(); 1531 1559 1532 1560 ////////////////////////////////////////////// … … 1537 1565 KdLeaf::NewMail(3); 1538 1566 1539 RayInfoContainer::const_iterator rit, rit_end = data.mRays->end();1540 1541 for (rit = data.mRays->begin(); rit != rit_end; ++ rit)1567 RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end(); 1568 1569 for (rit = tData.mRays->begin(); rit != rit_end; ++ rit) 1542 1570 { 1543 1571 RayInfo rayInf = *rit; … … 1563 1591 AxisAlignedBox3 backBox; 1564 1592 1565 data.mBoundingBox.Split(candidatePlane.mAxis,1566 candidatePlane.mPosition,1567 frontBox,1568 backBox);1569 1570 1571 float pOverall = data.mProbability;1593 tData.mBoundingBox.Split(candidatePlane.mAxis, 1594 candidatePlane.mPosition, 1595 frontBox, 1596 backBox); 1597 1598 // probability that view point lies in back / front node 1599 float pOverall = tData.mProbability; 1572 1600 float pFront = frontBox.GetVolume(); 1573 1601 float pBack = pOverall - pFront; … … 1576 1604 /////////////////// 1577 1605 //-- evaluate render cost heuristics 1578 #if 0 1579 const float penaltyOld = totalPvs; 1580 1581 const float penaltyFront = pvsFront; 1582 const float penaltyBack = pvsBack; 1583 #else 1584 const float penaltyOld = totalPvs * tData.mPvsCorrectionFactor; 1585 1586 const float frontCorr = mHierarchyManager->EvalPvsCorrectionFactor(pvsFront, penaltyOld, avgRayContri); 1587 const float backCorr = mHierarchyManager->EvalPvsCorrectionFactor(pvsBack, penaltyOld, avgRayContri); 1588 1589 const float penaltyFront = frontCorr; 1590 const float penaltyBack = pvsBack * backCorr;; 1591 #endif 1606 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; 1592 1618 1593 1619 const float oldRenderCost = pOverall * penaltyOld; 1594 const float newRenderCost = penaltyFront * pFront + penaltyBack* pBack;1620 const float newRenderCost = sc.mCorrectedFrontPvs * pFront + sc.mCorrectedBackPvs * pBack; 1595 1621 1596 1622 // we also return the old render cost … … 1612 1638 1613 1639 1614 float VspTree::EvalLocalSplitCost(const VspTraversalData & data,1640 float VspTree::EvalLocalSplitCost(const VspTraversalData &tData, 1615 1641 const AxisAlignedBox3 &box, 1616 1642 const int axis, … … 1627 1653 KdLeaf::NewMail(3); 1628 1654 1629 const float pvsSize = data.mPvs; 1630 RayInfoContainer::const_iterator rit, rit_end = data.mRays->end(); 1655 RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end(); 1631 1656 1632 1657 // this is the main ray classification loop! 1633 for(rit = data.mRays->begin(); rit != rit_end; ++ rit)1658 for(rit = tData.mRays->begin(); rit != rit_end; ++ rit) 1634 1659 { 1635 1660 VssRay *ray = (*rit).mRay; … … 1645 1670 ////////////// 1646 1671 //-- evaluate cost heuristics 1647 float pOverall = data.mProbability; 1672 1673 float pOverall = tData.mProbability; 1648 1674 1649 1675 // we use spatial mid split => simplified computation … … 1651 1677 1652 1678 const float newCost = pvsBack * pBack + pvsFront * pFront; 1653 const float oldCost = (float)pvs Size* pOverall + Limits::Small;1679 const float oldCost = (float)pvsTotal * pOverall + Limits::Small; 1654 1680 1655 1681 #ifdef GTPGTP_DEBUG … … 2921 2947 #endif 2922 2948 2949 mTotalCost = vData.mCorrectedPvs = pvsCost; 2950 mPvsEntries = EvalPvsEntriesSize(rays); 2951 2923 2952 ////////////// 2924 2953 //-- create the first split candidate … … 2927 2956 EvalSubdivisionCandidate(*splitCandidate); 2928 2957 leaf->SetSubdivisionCandidate(splitCandidate); 2929 2930 mTotalCost = pvsCost;2931 mPvsEntries = EvalPvsEntriesSize(rays);2932 2958 2933 2959 EvalSubdivisionStats(*splitCandidate); … … 3333 3359 // create new interior node and two leaf node 3334 3360 const AxisAlignedPlane splitPlane = oldInterior->GetPlane(); 3335 3336 3361 sc->mSplitPlane = splitPlane; 3337 3362 … … 3339 3364 EvalSubdivisionCandidate(*sc, false); 3340 3365 3341 newNode = SubdivideNode( splitPlane, tData, tFrontData, tBackData);3366 newNode = SubdivideNode(*sc, tFrontData, tBackData); 3342 3367 3343 3368 //oldNode->mRenderCostDecr += sc->GetRenderCostDecrease(); -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1845 r1912 372 372 373 373 VspTraversalData(): 374 mNode(NULL), 375 mDepth(0), 376 mRays(NULL), 377 mPvs(0), 378 mProbability(0.0), 379 mMaxCostMisses(0), 380 mPriority(0) 374 mNode(NULL), 375 mDepth(0), 376 mRays(NULL), 377 mPvs(0), 378 mProbability(0.0), 379 mMaxCostMisses(0), 380 mPriority(0), 381 mCorrectedPvs(0) 381 382 {} 382 383 … … 387 388 const float p, 388 389 const AxisAlignedBox3 &box): 389 mNode(node), 390 mDepth(depth), 391 mRays(rays), 392 mPvs(pvs), 393 mProbability(p), 394 mBoundingBox(box), 395 mMaxCostMisses(0), 396 mPriority(0) 390 mNode(node), 391 mDepth(depth), 392 mRays(rays), 393 mProbability(p), 394 mBoundingBox(box), 395 mMaxCostMisses(0), 396 mPriority(0), 397 mCorrectedPvs(0), 398 mPvs(pvs), 399 mRenderCost(0), 400 mCorrectedRenderCost(0) 397 401 {} 398 402 … … 400 404 RayInfoContainer *rays, 401 405 const AxisAlignedBox3 &box): 402 mNode(NULL), 403 mDepth(depth), 404 mRays(rays), 405 mPvs(0), 406 mProbability(0), 407 mMaxCostMisses(0), 408 mBoundingBox(box) 406 mNode(NULL), 407 mDepth(depth), 408 mRays(rays), 409 mProbability(0), 410 mMaxCostMisses(0), 411 mBoundingBox(box), 412 mCorrectedPvs(0), 413 mPvs(0) , 414 mRenderCost(0), 415 mCorrectedRenderCost(0) 409 416 {} 410 417 … … 425 432 // delete old view cell 426 433 delete mNode->GetViewCell(); 434 427 435 delete mNode; 428 436 mNode = NULL; … … 440 448 /// the bounding box of the node 441 449 AxisAlignedBox3 mBoundingBox; 442 /// pvs size443 float mPvs;444 450 /// how often this branch has missed the max-cost ratio 445 451 int mMaxCostMisses; 446 452 // current priority 447 453 float mPriority; 448 449 454 /// pvs size 455 float mPvs; 456 /// the correction factor for this pvs 457 float mCorrectedPvs; 458 /// pvs size 459 float mRenderCost; 460 /// the correction factor for this pvs 461 float mCorrectedRenderCost; 462 450 463 friend bool operator<(const VspTraversalData &a, const VspTraversalData &b) 451 464 { … … 460 473 public: 461 474 462 static VspTree* sVspTree;463 464 /// the current split plane465 AxisAlignedPlane mSplitPlane;466 /// parent node traversal data467 VspTraversalData mParentData;468 469 475 VspSubdivisionCandidate(const VspTraversalData &tData): mParentData(tData) 470 476 {}; … … 502 508 } 503 509 504 505 mSplitPlane(plane), mParentData(tData)510 VspSubdivisionCandidate(const AxisAlignedPlane &plane, const VspTraversalData &tData): 511 mSplitPlane(plane), mParentData(tData) 506 512 {} 507 513 … … 510 516 return mPriority; 511 517 } 518 519 //////////////////// 520 521 static VspTree* sVspTree; 522 523 /// the current split plane 524 AxisAlignedPlane mSplitPlane; 525 /// parent node traversal data 526 VspTraversalData mParentData; 527 528 float mCorrectedFrontPvs; 529 float mCorrectedBackPvs; 530 531 float mCorrectedFrontRenderCost; 532 float mCorrectedBackRenderCost; 512 533 }; 513 534 … … 729 750 /** Evaluates render cost decrease of next split. 730 751 */ 731 float EvalRenderCostDecrease(const AxisAlignedPlane &candidatePlane, 732 const VspTraversalData &data, 752 float EvalRenderCostDecrease(VspSubdivisionCandidate &splitData, 733 753 float &normalizedOldRenderCost) const; 734 754 … … 790 810 @returns the root of the subdivision 791 811 */ 792 VspInterior *SubdivideNode(const AxisAlignedPlane &splitPlane, 793 VspTraversalData &tData, 812 VspInterior *SubdivideNode(const VspSubdivisionCandidate &sc, 794 813 VspTraversalData &frontData, 795 814 VspTraversalData &backData); … … 813 832 */ 814 833 void SortSubdivisionCandidates(const RayInfoContainer &rays, 815 const int axis,816 float minBand,817 float maxBand);834 const int axis, 835 float minBand, 836 float maxBand); 818 837 819 838 /** Evaluate render cost of this pvs.
Note: See TracChangeset
for help on using the changeset viewer.