Ignore:
Timestamp:
05/03/07 23:23:31 (17 years ago)
Author:
mattausch
Message:

fixed new evaluation method

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r2347 r2350  
    693693                AssociateViewCellsWithObjects(*tData.mSampledObjects); 
    694694 
    695                 EvalSubdivisionCandidate2(*frontCandidate, true, false); 
    696                 cout << "\nfc2: " << frontCandidate->GetPriority() << endl; 
    697695                EvalSubdivisionCandidate(*frontCandidate, true, false); 
    698                 cout << "fc1: " << frontCandidate->GetPriority() << endl; 
    699696                EvalSubdivisionCandidate(*backCandidate, true, false); 
    700697 
     
    789786 
    790787 
    791 void BvHierarchy::EvalSubdivisionCandidate2(BvhSubdivisionCandidate &splitCandidate,  
     788void BvHierarchy::EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitCandidate,  
    792789                                                                                   const bool computeSplitPlane, 
    793790                                                                                   const bool preprocessViewCells) 
     
    890887        } 
    891888 
    892         //cout << "pvol: " << parentVol << " front: " << volFront << " back: " << volBack << " diff: " <<  parentVol - volFront - volBack << endl; 
    893          
    894889 
    895890        ///////////////////// 
     
    936931        const int backTri = (int)splitCandidate.mBackObjects.size(); 
    937932         
    938         if (totalTri - frontTri - backTri != 0) 
    939                 cout << "big error!!!" << endl; 
    940933 
    941934        // compute render cost decrease in the view cells which can see the object 
     
    980973                oldRenderCost += oldRc * vc->GetVolume() / viewSpaceVol; 
    981974                newRenderCost += newRc * vc->GetVolume() / viewSpaceVol; 
    982                 //cout << "old rc=" << oldRenderCost << " new rc " << newRenderCost << endl; 
    983         } 
    984  
    985  
    986         const float dummyFrontVol = EvalViewCellsVolume(splitCandidate.mSampledFrontObjects) / viewSpaceVol; 
    987         const float dummyBackVol = EvalViewCellsVolume(splitCandidate.mSampledBackObjects) / viewSpaceVol; 
    988         const float dummyParentVol = EvalViewCellsVolume(leaf->mObjects) / viewSpaceVol; 
    989  
    990         const int dummyNumFrontViewCells = CountViewCells(splitCandidate.mSampledFrontObjects); 
    991         const int dummyNumBackViewCells = CountViewCells(splitCandidate.mSampledBackObjects); 
    992         const int dummyPvs = CountViewCells(*tData.mSampledObjects); 
    993          
    994         const int dummyPvsEntriesIncr = - dummyPvs + dummyNumFrontViewCells + dummyNumBackViewCells; 
    995  
    996         const float relfrontCost = dummyFrontVol * (float)splitCandidate.mFrontObjects.size(); 
    997         const float relBackCost =  dummyBackVol * (float)splitCandidate.mBackObjects.size(); 
    998         const float relParentCost = dummyParentVol * (float)leaf->mObjects.size(); 
    999  
    1000         // compute global decrease in render cost 
    1001         const float dummyNewRenderCost = relfrontCost + relBackCost; 
    1002         const float dummyRenderCostDecr = relParentCost - dummyNewRenderCost; 
    1003  
     975        } 
    1004976 
    1005977 
     
    1011983        splitCandidate.SetRenderCostDecrease(renderCostDecr); 
    1012984         
    1013         float pseudoOldRenderCost = parentVol * (float)leaf->mObjects.size() / viewSpaceVol; 
    1014  
    1015         //cout << "cor. entries: " << dummyPvsEntriesIncr << " entries: " << frontAndBackViewCells << endl; 
    1016         cout << "\nv1: " << renderCostDecr << " " << pseudoOldRenderCost << " " << newRenderCost << endl; 
    1017         cout << "v2: " << dummyRenderCostDecr << " " << relParentCost << " " << dummyNewRenderCost << endl; 
     985        const float pseudoOldRenderCost = parentVol * (float)leaf->mObjects.size() / viewSpaceVol; 
    1018986 
    1019987        // at last computed priority based on render cost reduction / memory increase 
    1020988        const float priority = EvalPriority(splitCandidate, renderCostDecr,     pseudoOldRenderCost); 
    1021         cout << "\nfc0: " << priority << endl; 
    1022         const float priority2 = EvalPriority(splitCandidate, dummyRenderCostDecr, relParentCost); 
    1023         splitCandidate.SetPriority(priority2); 
    1024  
    1025 #if STORE_VIEWCELLS_WITH_BVH 
    1026         if (preprocessViewCells) 
    1027                 ReleaseViewCells(*splitCandidate.mParentData.mSampledObjects); 
    1028 #endif 
    1029  
    1030         mEvalTimer.Exit(); 
    1031 } 
    1032  
    1033  
    1034 void BvHierarchy::EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitCandidate,  
    1035                                                                                    const bool computeSplitPlane, 
    1036                                                                                    const bool preprocessViewCells) 
    1037 { 
    1038         mPlaneTimer.Entry(); 
    1039  
    1040 #if STORE_VIEWCELLS_WITH_BVH 
    1041         if (preprocessViewCells) // fill view cells cache 
    1042                 AssociateViewCellsWithObjects(*splitCandidate.mParentData.mSampledObjects); 
    1043 #endif 
    1044  
    1045         if (computeSplitPlane) 
    1046         { 
    1047                 splitCandidate.mFrontObjects.clear(); 
    1048                 splitCandidate.mBackObjects.clear(); 
    1049                 splitCandidate.mSampledFrontObjects.clear(); 
    1050                 splitCandidate.mSampledBackObjects.clear(); 
    1051  
    1052                 const bool sufficientSamples =  
    1053                         splitCandidate.mParentData.mNumRays > mMinRaysForVisibility; 
    1054  
    1055                 //if (!sufficientSamples) cout << splitCandidate.mParentData.mNumRays << " "; 
    1056  
    1057                 const bool useVisibiliyBasedHeuristics =  
    1058                                         !mUseSah && 
    1059                                         (mHierarchyManager->GetViewSpaceSubdivisionType() ==  
    1060                                         HierarchyManager::KD_BASED_VIEWSPACE_SUBDIV) && 
    1061                                         sufficientSamples; 
    1062  
    1063                 // compute best object partition 
    1064                 const float ratio =     SelectObjectPartition(splitCandidate.mParentData,  
    1065                                                                                                   splitCandidate.mFrontObjects,  
    1066                                                                                                   splitCandidate.mBackObjects, 
    1067                                                                                                   useVisibiliyBasedHeuristics); 
    1068          
    1069                 // cost ratio violated? 
    1070                 const bool maxCostRatioViolated = mTermMaxCostRatio < ratio; 
    1071                 const int previousMisses = splitCandidate.mParentData.mMaxCostMisses; 
    1072  
    1073                 splitCandidate.SetMaxCostMisses(maxCostRatioViolated ?  
    1074                                                                                 previousMisses + 1 : previousMisses); 
    1075  
    1076                 StoreSampledObjects(splitCandidate.mSampledFrontObjects, splitCandidate.mFrontObjects); 
    1077                 StoreSampledObjects(splitCandidate.mSampledBackObjects, splitCandidate.mBackObjects); 
    1078         } 
    1079  
    1080         mPlaneTimer.Exit(); 
    1081  
    1082         mEvalTimer.Entry(); 
    1083  
    1084         const BvhTraversalData &tData = splitCandidate.mParentData; 
    1085         BvhLeaf *leaf = tData.mNode; 
    1086  
    1087         // avg contribution of a ray to a pvs 
    1088         const float pvs = (float)CountViewCells(*tData.mSampledObjects); 
    1089         //const float avgRayContri = AvgRayContribution((int)pvs, tData.mNumRays); 
    1090         const float avgRaysPerObject = AvgRaysPerObject((int)pvs, tData.mNumRays); 
    1091  
    1092         // high avg ray contri, the result is influenced by undersampling 
    1093         splitCandidate.SetAvgRaysPerObject(avgRaysPerObject); 
    1094         const float viewSpaceVol = GetViewSpaceVolume(); 
    1095  
    1096         const float oldVolume = EvalViewCellsVolume(*tData.mSampledObjects) / viewSpaceVol; 
    1097         const float oldRatio = (tData.mVolume > 0) ? oldVolume / tData.mVolume : 1; 
    1098         const float parentVol = tData.mCorrectedVolume * oldRatio; 
    1099  
    1100         // this leaf is a pvs entry in all the view cells 
    1101         // that see one of the objects. 
    1102         splitCandidate.mVolumeFrontViewCells = EvalViewCellsVolume(splitCandidate.mSampledFrontObjects) / viewSpaceVol; 
    1103         splitCandidate.mVolumeBackViewCells = EvalViewCellsVolume(splitCandidate.mSampledBackObjects) / viewSpaceVol; 
    1104  
    1105         splitCandidate.mNumFrontViewCells = CountViewCells(splitCandidate.mSampledFrontObjects); 
    1106         splitCandidate.mNumBackViewCells = CountViewCells(splitCandidate.mSampledBackObjects); 
    1107  
    1108         splitCandidate.mCorrectedFrontVolume =  
    1109                 mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeFrontViewCells, parentVol, avgRaysPerObject); 
    1110          
    1111         splitCandidate.mCorrectedBackVolume =  
    1112                 mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeBackViewCells, parentVol, avgRaysPerObject); 
    1113  
    1114 #if 0 
    1115         const float relfrontCost = splitCandidate.mCorrectedFrontVolume * splitCandidate.mFrontObjects.size(); 
    1116         const float relBackCost =  splitCandidate.mCorrectedBackVolume * splitCandidate.mBackObjects.size(); 
    1117         const float relParentCost = parentVol * leaf->mObjects.size(); 
    1118 #else 
    1119         const float relfrontCost = splitCandidate.mVolumeFrontViewCells * splitCandidate.mFrontObjects.size(); 
    1120         const float relBackCost =  splitCandidate.mVolumeBackViewCells * splitCandidate.mBackObjects.size(); 
    1121         const float relParentCost = oldVolume * leaf->mObjects.size(); 
    1122 #endif 
    1123         // compute global decrease in render cost 
    1124         const float newRenderCost = relfrontCost + relBackCost; 
    1125         const float renderCostDecr = relParentCost - newRenderCost; 
    1126          
    1127         splitCandidate.SetRenderCostDecrease(renderCostDecr); 
    1128  
    1129         // increase in pvs entries 
    1130         const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate,  
    1131                                                                                                   avgRaysPerObject,  
    1132                                                                                                   (int)pvs,  
    1133                                                                                                   splitCandidate.mNumFrontViewCells,  
    1134                                                                                                   splitCandidate.mNumBackViewCells); 
    1135  
    1136         splitCandidate.SetPvsEntriesIncr(pvsEntriesIncr); 
    1137  
    1138 #ifdef GTP_DEBUG 
    1139         Debug << "old render cost: " << oldRenderCost << endl; 
    1140         Debug << "new render cost: " << newRenderCost << endl; 
    1141         Debug << "render cost decrease: " << renderCostDecr << endl; 
    1142 #endif 
    1143  
    1144         float priority = EvalPriority(splitCandidate,  
    1145                                                                   renderCostDecr, 
    1146                                                                   relParentCost); 
    1147  
    1148         // compute global decrease in render cost 
    1149989        splitCandidate.SetPriority(priority); 
    1150990 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r2347 r2350  
    579579                                                                  const bool preprocessViewCells); 
    580580 
    581         void EvalSubdivisionCandidate2(BvhSubdivisionCandidate &splitData, 
    582                                                                   const bool computeSplitPlane, 
    583                                                                   const bool preprocessViewCells); 
    584  
    585581        /** Returns vector of leaves. 
    586582        */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r2347 r2350  
    3131#define HACK_PERFORMANCE 1 
    3232 
    33 #define HAS_TO_BE_REDONE 0 
    3433 
    3534///////////// 
     
    849848        splitCandidate.mBackPvs = (float)sData.mBackObjects; 
    850849 
    851 #if HAS_TO_BE_REDONE 
    852850        return (int)(splitCandidate.mCorrectedFrontPvs + splitCandidate.mCorrectedBackPvs - correctedOldPvs); 
    853 #else 
    854         return sData.mFrontObjects + sData.mBackObjects - sData.mTotalObjects; 
    855 #endif 
    856851} 
    857852 
     
    16271622        sc.mBackRenderCost = sData.mBackRenderCost; 
    16281623 
    1629 #if HAS_TO_BE_REDONE // undersampling evalution does not work yet 
    1630  
    16311624        const float oldRenderCost = penaltyOld * pOverall; 
    16321625        const float newRenderCost = sc.mCorrectedFrontRenderCost * pFront +  
    16331626                                                                sc.mCorrectedBackRenderCost * pBack; 
    16341627 
    1635 #else 
    1636  
    1637         const float oldRenderCost = sData.mTotalRenderCost * pOverall; 
    1638         const float newRenderCost = sData.mFrontRenderCost * pFront + sData.mBackRenderCost * pBack; 
    1639  
    1640 #endif 
    16411628 
    16421629        // the normalized old render cost is needed for the priority 
Note: See TracChangeset for help on using the changeset viewer.