Changeset 1765


Ignore:
Timestamp:
11/18/06 23:15:55 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
12 edited

Legend:

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

    r1763 r1765  
    15421542                        } 
    15431543                } 
     1544 
    15441545#if COUNT_ORIGIN_OBJECTS 
     1546 
    15451547                if (ray->mOriginObject) 
    15461548                { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1763 r1765  
    364364public: 
    365365 
    366         /// Rays piercing this leaf. 
    367         //VssRayContainer mVssRays; 
    368366        /// objects 
    369367        ObjectContainer mObjects; 
    370         /// universal counter 
    371         int mCounter; 
    372368 
    373369protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp

    r1763 r1765  
    6161{ 
    6262        // random barycentric coordinates 
    63         float a = RandomValue(0,1); 
    64         float b = RandomValue(0,1); 
    65         float c = RandomValue(0,1); 
     63        float a = RandomValue(0.0f, 1.0f); 
     64        float b = RandomValue(0.0f, 1.0f); 
     65        float c = RandomValue(0.0f, 1.0f); 
    6666         
    6767        const float sum = a + b + c; 
     
    9595                                                                                          Vector3 &normal) 
    9696{ 
    97         int edge = Random(3); 
     97        const int edge = Random(3); 
    9898 
    99         Vector3 a = mItem.mVertices[edge]; 
    100         Vector3 b = mItem.mVertices[(edge + 1) % 3]; 
     99        const Vector3 a = mItem.mVertices[edge]; 
     100        const Vector3 b = mItem.mVertices[(edge + 1) % 3]; 
    101101 
    102102        const float factor = RandomValue(0.0f, 1.0f); 
     
    112112  IntersectableWrapper<KdNode *>(item) 
    113113{ 
    114   mBox = box; 
     114        mBox = box; 
    115115} 
    116116} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1757 r1765  
    934934} 
    935935 
    936 bool Preprocessor::GenerateRays(const int number, 
    937                                                                 const int sampleType, 
    938                                                                 SimpleRayContainer &rays) 
     936int Preprocessor::GenerateRays(const int number, 
     937                                                           const int sampleType, 
     938                                                           SimpleRayContainer &rays) 
    939939{ 
    940940        const int startSize = (int)rays.size(); 
     
    943943        if (!strategy) 
    944944        { 
    945                 return false; 
    946         } 
    947  
    948         for (int i=0; (int)rays.size() - startSize < number; ++ i)  
     945                return 0; 
     946        } 
     947 
     948        int castRays = 0; 
     949 
     950        for (int i = 0; (int)rays.size() - startSize < number; ++ i)  
    949951        { 
    950952                SimpleRay newRay; 
     
    954956#if 1 
    955957                        rays.AddRay(newRay); 
     958                        ++ castRays; 
    956959#else 
    957960                        GenerateRayBundle(rays, newRay, 16, 0); 
     961                        castRays += 16; 
    958962#endif 
    959963                }        
     
    961965 
    962966        delete strategy; 
    963     return true; 
     967    return castRays; 
    964968} 
    965969 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r1740 r1765  
    121121        bool ExportKdTree(const string filename); 
    122122 
    123         virtual bool GenerateRays(const int number, 
    124                                                           const int raysType, 
    125                                                           SimpleRayContainer &rays); 
     123        virtual int GenerateRays(const int number, 
     124                                                         const int raysType, 
     125                                                         SimpleRayContainer &rays); 
    126126 
    127127        bool GenerateRayBundle(SimpleRayContainer &rayBundle, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r1761 r1765  
    5656 
    5757 
    58 bool 
     58int 
    5959RssPreprocessor::GenerateRays( 
    6060                                                          const int number, 
     
    6363                                                          ) 
    6464{ 
    65   bool result = false; 
     65  int result = 0; 
    6666   
    6767  Debug<<"Generate rays...\n"<<flush; 
     
    7171  case SamplingStrategy::RSS_SILHOUETTE_BASED_DISTRIBUTION: 
    7272        if (mRssTree) { 
    73           GenerateImportanceRays(mRssTree, number, rays); 
    74           result = true; 
     73          result = GenerateImportanceRays(mRssTree, number, rays); 
    7574        } 
    7675        break; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.h

    r1737 r1765  
    133133 
    134134  /** Redefininition of the get sample rays method from the preprocessor */ 
    135   bool 
     135  int 
    136136  GenerateRays( 
    137137                           const int number, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r1763 r1765  
    166166 
    167167        object->GetRandomSurfacePoint(point, normal); 
     168         
    168169        direction = origin - point; 
    169  
    170         // $$ jb the pdf is yet not correct for all sampling methods! 
    171         const float c = Magnitude(direction); 
    172  
    173         if (c <= Limits::Small)  
    174                 return false; 
     170         
     171        // $$ jb the pdf is yet not correct for all sampling methods! 
     172        const float c = Magnitude(direction); 
     173         
     174        if ((c <= Limits::Small) || (DotProd(direction, normal) < 0)) 
     175        { 
     176                return false; 
     177        } 
    175178 
    176179        // $$ jb the pdf is yet not correct for all sampling methods! 
     
    178181        //cout << "p: " << point << " "; 
    179182        direction *= 1.0f / c; 
     183        // a little offset 
     184        point += direction * 0.01f; 
     185 
    180186        ray = SimpleRay(point, direction, pdf); 
    181187         
     
    220226} 
    221227 
     228 
    222229#if 0 
    223230bool ObjectsInteriorDistribution::GenerateSample(SimpleRay &ray) const 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1764 r1765  
    316316 
    317317        // create one third of each type 
    318         int stype; 
    319          
    320         const int numStrategies = 3; 
    321  
    322         stype = SamplingStrategy::OBJECT_BASED_DISTRIBUTION; 
    323         mPreprocessor->GenerateRays(samplesPerPass / numStrategies, sampleType, simpleRays); 
    324          
    325         stype = SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION; 
    326         mPreprocessor->GenerateRays(samplesPerPass / numStrategies, sampleType, simpleRays); 
    327          
    328         if (0) 
    329         { 
    330                 stype = SamplingStrategy::DIRECTION_BASED_DISTRIBUTION; 
    331                 mPreprocessor->GenerateRays(samplesPerPass / numStrategies, sampleType, simpleRays); 
    332         } 
    333  
    334         stype = SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION; 
    335         mPreprocessor->GenerateRays(samplesPerPass / numStrategies, sampleType, simpleRays); 
     318        int castRays = 0; 
     319         
     320        vector<int> strategies; 
     321          
     322        strategies.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 
     323        strategies.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 
     324        strategies.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 
     325 
     326        const int numRaysPerPass = samplesPerPass / (int)strategies.size(); 
     327 
     328        vector<int>::const_iterator iit, iit_end = strategies.end(); 
     329 
     330        for (iit = strategies.begin(); iit != iit_end; ++ iit) 
     331        { 
     332                int stype = *iit; 
     333                const int newRays =  
     334                        mPreprocessor->GenerateRays(numRaysPerPass, stype, simpleRays); 
     335         
     336                cout << "cast " << newRays << " rays of strategy " << stype << endl; 
     337                castRays += newRays; 
     338        } 
    336339 
    337340        cout << "generated " << samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     
    27082711                        if (vcValid) 
    27092712                        { 
    2710                                 m.mDiffuseColor.r = 0.5f + RandomValue(0.0f, 0.5f); 
    2711                                 m.mDiffuseColor.g = 0.5f + RandomValue(0.0f, 0.5f); 
    2712                                 m.mDiffuseColor.b = 0.5f + RandomValue(0.f, 0.5f); 
     2713                                m.mDiffuseColor.r = 0.2f + RandomValue(0.0f, 0.8f); 
     2714                                m.mDiffuseColor.g = 0.2f + RandomValue(0.0f, 0.8f); 
     2715                                m.mDiffuseColor.b = 0.2f + RandomValue(0.0f, 0.8f); 
    27132716                        } 
    27142717                        else 
     
    27532756        // special color code for invalid view cells 
    27542757        m.mDiffuseColor.r = importance; 
    2755         m.mDiffuseColor.g = 1.0f - m.mDiffuseColor.r; 
    2756         m.mDiffuseColor.b = vcValid ? 1.0f : 0.0f; 
     2758        m.mDiffuseColor.g = vcValid ? 0.0f : 1.0f; 
     2759        m.mDiffuseColor.b = 1.0f - importance; 
    27572760 
    27582761        //Debug << "importance: " << importance << endl; 
     
    54355438        Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 
    54365439 
    5437         Vector3 scale(1.0f, 0.9f, 1.0f); 
     5440        Vector3 scale(0.9f, 0.9f, 0.9f); 
    54385441        if (exporter) 
    54395442        { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1727 r1765  
    4141 
    4242// pvs penalty can be different from pvs size 
    43 inline static float EvalPvsPenalty(const int pvs,  
    44                                                                    const int lower, 
    45                                                                    const int upper) 
     43inline static float EvalPvsPenalty(const float pvs,  
     44                                                                   const float lower, 
     45                                                                   const float upper) 
    4646{ 
    4747        // clamp to minmax values 
     
    22672267                AddObjToPvs((*rit).mRay->mTerminationObject, side, pvsFront, pvsBack, pvsTotal); 
    22682268 
    2269                 if (COUNT_ORIGIN_OBJECTS)  
     2269                if (COUNT_ORIGIN_OBJECTS) 
     2270                { 
    22702271                        AddObjToPvs((*rit).mRay->mOriginObject, side, pvsFront, pvsBack, pvsTotal); 
     2272                } 
    22712273        } 
    22722274 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1764 r1765  
    4040 
    4141// pvs penalty can be different from pvs size 
    42 inline static float EvalPvsPenalty(const int pvs,  
    43                                                                    const int lower, 
    44                                                                    const int upper) 
     42inline static float EvalPvsPenalty(const float pvs,  
     43                                                                   const float lower, 
     44                                                                   const float upper) 
    4545{ 
    4646        // clamp to minmax values 
     
    734734                         
    735735                mTotalCost -= sc->GetRenderCostDecrease(); 
    736                 mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - tData.mPvs; 
     736                mTotalPvsSize += (int)(tFrontData.mPvs + tBackData.mPvs - tData.mPvs); 
    737737                mPvsEntries += sc->GetPvsEntriesIncr(); 
    738738 
     
    932932 
    933933        //-- compute pvs 
    934         frontData.mPvs = EvalPvsSize(*frontData.mRays); 
    935         backData.mPvs = EvalPvsSize(*backData.mRays); 
     934        frontData.mPvs = EvalPvsCost(*frontData.mRays); 
     935        backData.mPvs = EvalPvsCost(*backData.mRays); 
    936936                 
    937937        //-- split front and back node geometry and compute area 
     
    11201120 
    11211121 
    1122 int VspTree::PrepareHeuristics(KdLeaf *leaf) 
     1122float VspTree::PrepareHeuristics(KdLeaf *leaf) 
    11231123{        
    1124         int pvsSize = 0; 
     1124        float pvsSize = 0; 
    11251125         
    11261126        if (!leaf->Mailed()) 
     
    11601160 
    11611161 
    1162 int VspTree::PrepareHeuristics(const RayInfoContainer &rays) 
     1162float VspTree::PrepareHeuristics(const RayInfoContainer &rays) 
    11631163{        
    11641164        Intersectable::NewMail(); 
     
    11661166        BvhLeaf::NewMail(); 
    11671167 
    1168         int pvsSize = 0; 
     1168        float pvsSize = 0; 
    11691169 
    11701170        RayInfoContainer::const_iterator ri, ri_end = rays.end(); 
     
    12431243 
    12441244void VspTree::EvalHeuristics(const SortableEntry &ci, 
    1245                                                          int &pvsLeft, 
    1246                                                          int &pvsRight) const 
     1245                                                         float &pvsLeft, 
     1246                                                         float &pvsRight) const 
    12471247{ 
    12481248        VssRay *ray = ci.ray; 
     
    12511251        if (ci.type == SortableEntry::ERayMin) 
    12521252        { 
     1253                pvsLeft += EvalMinEventContribution(*ray, true); 
    12531254#if COUNT_ORIGIN_OBJECTS 
    1254                 pvsLeft += EvalMinEventContribution(*ray, true); 
    1255 #else 
    12561255                pvsLeft += EvalMinEventContribution(*ray, false); 
    12571256#endif 
     
    12591258        else // eval changes in pvs causes by max event  
    12601259        { 
     1260                pvsRight -= EvalMaxEventContribution(*ray, true); 
    12611261#if COUNT_ORIGIN_OBJECTS 
    1262                 pvsRight -= EvalMaxEventContribution(*ray, true); 
    1263 #else 
    12641262                pvsRight -= EvalMaxEventContribution(*ray, false); 
    12651263#endif 
     
    12711269                                                                           const AxisAlignedBox3 &box, 
    12721270                                                                           const int axis, 
    1273                                                                            float &position) 
    1274 { 
    1275         // get subset of rays 
    1276         RayInfoContainer randomRays; 
    1277         randomRays.reserve(mMaxTests); 
    1278  
    1279         RayInfoContainer *usedRays; 
    1280  
    1281         if (mMaxTests < (int)tData.mRays->size()) 
    1282         { 
    1283                 GetRayInfoSets(*tData.mRays, mMaxTests, randomRays); 
    1284                 usedRays = &randomRays; 
    1285         } 
    1286         else 
    1287         { 
    1288                 usedRays = tData.mRays; 
    1289         } 
    1290  
     1271                                                                           float &position, 
     1272                                                                           const RayInfoContainer &usedRays) 
     1273{ 
    12911274        const float minBox = box.Min(axis); 
    12921275        const float maxBox = box.Max(axis); 
     
    12971280        const float maxBand = minBox + mMaxBand * sizeBox; 
    12981281 
    1299         SortSubdivisionCandidates(*usedRays, axis, minBand, maxBand); 
     1282        SortSubdivisionCandidates(usedRays, axis, minBand, maxBand); 
    13001283 
    13011284        // prepare the sweep 
    13021285        // note: returns pvs size => no need t give pvs size as function parameter 
    1303         const int pvsSize = PrepareHeuristics(*usedRays); 
     1286        const float pvsCost = PrepareHeuristics(usedRays); 
    13041287 
    13051288        // go through the lists, count the number of objects left and right 
     
    13071290        // C = ct_div_ci  + (ql*rl + qr*rr)/queries 
    13081291 
    1309         int pvsl = 0; 
    1310         int pvsr = pvsSize; 
    1311  
    1312         int pvsBack = pvsl; 
    1313         int pvsFront = pvsr; 
    1314  
    1315         float sum = (float)pvsSize * sizeBox; 
     1292        float pvsl = 0; 
     1293        float pvsr = pvsCost; 
     1294 
     1295        float pvsBack = pvsl; 
     1296        float pvsFront = pvsr; 
     1297 
     1298        float sum = pvsCost * sizeBox; 
    13161299        float minSum = 1e20f; 
    13171300 
     
    13271310        BvhLeaf::NewMail(); 
    13281311 
    1329         //-- traverse through visibility events 
    1330         vector<SortableEntry>::const_iterator ci, ci_end = mLocalSubdivisionCandidates->end(); 
    1331  
    1332 #ifdef GTPGTP_DEBUG 
    1333         const float volRatio = tData.mBoundingBox.GetVolume() / (sizeBox * mBoundingBox.GetVolume()); 
     1312        const float volRatio =  
     1313                tData.mBoundingBox.GetVolume() / (sizeBox * mBoundingBox.GetVolume()); 
     1314 
     1315        //////// 
     1316        //-- iterate through visibility events 
     1317 
     1318        vector<SortableEntry>::const_iterator ci,  
     1319                ci_end = mLocalSubdivisionCandidates->end(); 
     1320 
     1321#ifdef GTP_DEBUG 
    13341322        const int leaves = mVspStats.Leaves(); 
    13351323        const bool printStats = ((axis == 0) && (leaves > 0) && (leaves < 90)); 
     
    13701358                        sum = pvsl * ((*ci).value - minBox) + pvsr * (maxBox - (*ci).value); 
    13711359                         
    1372 #ifdef GTPGTP_DEBUG 
     1360#ifdef GTP_DEBUG 
    13731361                        if (printStats) 
    13741362                        { 
     
    14041392        //-- compute cost 
    14051393 
    1406         const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); 
    1407         const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 
     1394        const float lowerPvsLimit = (float)mViewCellsManager->GetMinPvsSize(); 
     1395        const float upperPvsLimit = (float)mViewCellsManager->GetMaxPvsSize(); 
    14081396 
    14091397        const float pOverall = sizeBox; 
     
    14111399        const float pFront = maxBox - position; 
    14121400 
    1413         const float penaltyOld = EvalPvsPenalty(pvsSize, lowerPvsLimit, upperPvsLimit); 
     1401        const float penaltyOld = EvalPvsPenalty(pvsCost, lowerPvsLimit, upperPvsLimit); 
    14141402    const float penaltyFront = EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 
    14151403        const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 
     
    14231411        } 
    14241412         
    1425 #ifdef GTPGTP_DEBUG 
    1426         Debug << "\n§§§§ eval local cost §§§§" << endl 
     1413//#ifdef GTP_DEBUG 
     1414        cout << "\n((((( eval local cost )))))" << endl 
    14271415                  << "back pvs: " << penaltyBack << " front pvs: " << penaltyFront << " total pvs: " << penaltyOld << endl  
    14281416                  << "back p: " << pBack * volRatio << " front p " << pFront * volRatio << " p: " << pOverall * volRatio << endl 
    14291417                  << "old rc: " << oldRenderCost * volRatio << " new rc: " << newRenderCost * volRatio << endl 
    14301418                  << "render cost decrease: " << oldRenderCost * volRatio - newRenderCost * volRatio << endl; 
    1431 #endif 
     1419//#endif 
    14321420        return ratio; 
    14331421} 
     
    14541442                mOnlyDrivingAxis || mCirculatingAxis; 
    14551443         
     1444        // get subset of rays 
     1445        RayInfoContainer randomRays; 
     1446        randomRays.reserve(mMaxTests); 
     1447 
     1448        RayInfoContainer *usedRays; 
     1449 
     1450        if (mMaxTests < (int)tData.mRays->size()) 
     1451        { 
     1452                GetRayInfoSets(*tData.mRays, mMaxTests, randomRays); 
     1453                usedRays = &randomRays; 
     1454        } 
     1455        else 
     1456        { 
     1457                usedRays = tData.mRays; 
     1458        } 
     1459 
    14561460        if (mCirculatingAxis) 
    14571461        { 
     
    14601464 
    14611465                if (parent) 
     1466                { 
    14621467                        parentAxis = dynamic_cast<VspInterior *>(parent)->GetAxis(); 
     1468                } 
    14631469 
    14641470                sAxis = (parentAxis + 1) % 3; 
     
    14761482                        { 
    14771483                                //-- place split plane using heuristics 
     1484 
    14781485                                nCostRatio[axis] = 
    14791486                                        EvalLocalCostHeuristics(tData, 
    14801487                                                                                        box, 
    14811488                                                                                        axis, 
    1482                                                                                         nPosition[axis]);                        
     1489                                                                                        nPosition[axis], 
     1490                                                                                        *usedRays);                      
    14831491                        } 
    14841492                        else 
    14851493                        { 
    14861494                                //-- split plane position is spatial median                              
     1495                                 
    14871496                                nPosition[axis] = (box.Min()[axis] + box.Max()[axis]) * 0.5f; 
    14881497                                nCostRatio[axis] = EvalLocalSplitCost(tData, 
     
    15051514        } 
    15061515 
    1507         //////////////////////////////// 
     1516        ///////////////////////// 
    15081517        //-- assign values of best split 
    15091518 
     
    15711580 
    15721581 
    1573         //////////////////////////////////// 
     1582        /////////////////// 
    15741583        //-- evaluate render cost heuristics 
    15751584 
    1576         const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); 
    1577         const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 
    1578  
    1579         const float penaltyOld = EvalPvsPenalty((int)totalPvs, lowerPvsLimit, upperPvsLimit); 
    1580     const float penaltyFront = EvalPvsPenalty((int)pvsFront, lowerPvsLimit, upperPvsLimit); 
    1581         const float penaltyBack = EvalPvsPenalty((int)pvsBack, lowerPvsLimit, upperPvsLimit); 
     1585        const float lowerPvsLimit = (float)mViewCellsManager->GetMinPvsSize(); 
     1586        const float upperPvsLimit = (float)mViewCellsManager->GetMaxPvsSize(); 
     1587 
     1588        const float penaltyOld = EvalPvsPenalty(totalPvs, lowerPvsLimit, upperPvsLimit); 
     1589    const float penaltyFront = EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 
     1590        const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 
    15821591                         
    15831592        const float oldRenderCost = pOverall * penaltyOld; 
     
    15901599        const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol; 
    15911600 
    1592 #ifdef GTPGTP_DEBUG 
     1601#ifdef GTP_DEBUG 
    15931602        Debug << "\nvsp render cost decrease" << endl 
    15941603                  << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl  
     
    16191628        KdLeaf::NewMail(3); 
    16201629 
    1621         const int pvsSize = data.mPvs; 
     1630        const float pvsSize = data.mPvs; 
    16221631        RayInfoContainer::const_iterator rit, rit_end = data.mRays->end(); 
    16231632 
     
    18631872        if (data.mPvs > mVspStats.maxPvs) 
    18641873        { 
    1865                 mVspStats.maxPvs = data.mPvs; 
    1866         } 
    1867  
    1868         mVspStats.pvs += data.mPvs; 
     1874                mVspStats.maxPvs = (int)data.mPvs; 
     1875        } 
     1876 
     1877        mVspStats.pvs += (int)data.mPvs; 
    18691878 
    18701879        if (data.mDepth < mVspStats.minDepth) 
     
    22152224 
    22162225 
    2217 int VspTree::EvalPvsSize(const RayInfoContainer &rays) const 
    2218 { 
    2219         int pvsSize = 0; 
     2226float VspTree::EvalPvsCost(const RayInfoContainer &rays) const 
     2227{ 
     2228        float pvsCost = 0; 
    22202229         
    22212230        Intersectable::NewMail(); 
     
    22282237        { 
    22292238                VssRay *ray = (*rit).mRay; 
     2239                 
     2240                pvsCost += EvalContributionToPvs(*ray, true); 
     2241 
    22302242#if COUNT_ORIGIN_OBJECTS 
    2231                 pvsSize += EvalContributionToPvs(*ray, true); 
    2232 #else 
    2233                 pvsSize += EvalContributionToPvs(*ray, false); 
     2243                pvsCost += EvalContributionToPvs(*ray, false); 
    22342244#endif 
    22352245        } 
    22362246         
    2237         return pvsSize; 
     2247        return pvsCost; 
    22382248} 
    22392249 
     
    23072317        { 
    23082318                VssRay *ray = (*rit).mRay; 
     2319 
     2320                pvsSize += EvalPvsEntriesContribution(*ray, true); 
     2321 
    23092322#if COUNT_ORIGIN_OBJECTS 
    2310                 pvsSize += EvalPvsEntriesContribution(*ray, true); 
    2311 #else 
    23122323                pvsSize += EvalPvsEntriesContribution(*ray, false); 
    23132324#endif 
     
    28902901 
    28912902        /// collect pvs from rays 
    2892         const int pvsSize = EvalPvsSize(rays); 
     2903        const float pvsCost = EvalPvsCost(rays); 
    28932904         
    28942905        // root and bounding box were already constructed 
     
    29012912         
    29022913        // first vsp traversal data 
    2903         VspTraversalData vData(leaf, 0, &rays, pvsSize, prop, mBoundingBox); 
     2914        VspTraversalData vData(leaf, 0, &rays, pvsCost, prop, mBoundingBox); 
    29042915 
    29052916 
     
    29232934        leaf->SetSubdivisionCandidate(splitCandidate); 
    29242935 
    2925         mTotalCost = (float)pvsSize; 
     2936        mTotalCost = pvsCost; 
    29262937        mPvsEntries = EvalPvsEntriesSize(rays); 
    29272938 
     
    30573068 
    30583069 
    3059 int VspTree::PrepareHeuristics(const VssRay &ray, const bool isTermination) 
    3060 { 
    3061         int pvsSize = 0; 
     3070float VspTree::PrepareHeuristics(const VssRay &ray, const bool isTermination) 
     3071{ 
     3072        float pvsSize = 0; 
    30623073         
    30633074        Intersectable *obj; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h

    r1764 r1765  
    384384                                                 const int depth,  
    385385                                                 RayInfoContainer *rays, 
    386                                                  const int pvs, 
     386                                                 const float pvs, 
    387387                                                 const float p, 
    388388                                                 const AxisAlignedBox3 &box): 
     
    441441                AxisAlignedBox3 mBoundingBox; 
    442442                /// pvs size 
    443                 int mPvs; 
     443                float mPvs; 
    444444                /// how often this branch has missed the max-cost ratio 
    445445                int mMaxCostMisses; 
     
    817817                                                         float maxBand); 
    818818 
    819         /** Evaluate pvs size as induced by the samples. 
    820         */ 
    821         int EvalPvsSize(const RayInfoContainer &rays) const; 
     819        /** Evaluate render cost of this pvs. 
     820        */ 
     821        float EvalPvsCost(const RayInfoContainer &rays) const; 
    822822 
    823823        int EvalPvsEntriesIncr(VspSubdivisionCandidate &splitCandidate) const; 
     
    826826        */ 
    827827        int EvalPvsEntriesSize(const RayInfoContainer &rays) const; 
     828 
    828829        int EvalPvsEntriesContribution(const VssRay &ray, const bool isTermination) const; 
     830 
    829831        /** Computes best cost for axis aligned planes. 
    830832        */ 
     
    832834                                                                  const AxisAlignedBox3 &box, 
    833835                                                                  const int axis, 
    834                                                                   float &position); 
     836                                                                  float &position, 
     837                                                                  const RayInfoContainer &usedRays); 
    835838 
    836839 
     
    843846                @param rightPvs updates the right pvs 
    844847        */ 
    845         void EvalHeuristics(const SortableEntry &ve, int &pvsLeft, int &pvsRight) const; 
     848        void EvalHeuristics(const SortableEntry &ve, float &pvsLeft, float &pvsRight) const; 
    846849 
    847850        /** Evaluates contribution of min event to pvs 
     
    865868                @returns pvs size as seen by the rays. 
    866869        */ 
    867         int PrepareHeuristics(const RayInfoContainer &rays); 
     870        float PrepareHeuristics(const RayInfoContainer &rays); 
    868871         
    869872        /** Prepare a single ray for heuristics. 
    870873        */ 
    871         int PrepareHeuristics(const VssRay &ray, const bool isTermination); 
     874        float PrepareHeuristics(const VssRay &ray, const bool isTermination); 
     875 
    872876        /** Prepare a single kd leaf for heuristics. 
    873877        */ 
    874         int PrepareHeuristics(KdLeaf *leaf); 
     878        float PrepareHeuristics(KdLeaf *leaf); 
    875879 
    876880         
Note: See TracChangeset for help on using the changeset viewer.