Changeset 1291


Ignore:
Timestamp:
08/28/06 18:42:33 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
13 edited

Legend:

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

    r827 r1291  
    1313using namespace std; 
    1414 
     15 
     16 
    1517/** This is a small function which takes two log files and computes the 
    1618        difference in percent of the weighted render cost. 
    1719*/ 
    18  
    19  
    2020struct RenderStats  
    2121{ 
     
    105105 
    106106        statsOut << "#ViewCells\n" << index + 1 << endl 
    107                          //<< "#TotalRenderCostGain\n" << 100.0f - costRatio * 100.0f << endl 
    108                          //<< "#AvgRenderCostGain\n" << 100.0f - avgCostRatio * 100.0f << endl << endl; 
    109107                         << "#TotalRenderCostRatio\n" << costRatio << endl 
    110108                         << "#AvgRenderCostRatio\n" << avgCostRatio << endl << endl; 
     
    149147                float val; 
    150148 
    151                 // soecial cases 
     149                // special cases 
    152150                if (j == 0) 
    153151                { 
     
    178176                } 
    179177 
    180                 // lower bound 
    181                 //int j = max (0, i - 1); 
    182                 //cout << "i: " << i << " j: " << j << endl; 
    183178                float ratio = (i && val) ? (float)i / val : 1; 
    184179 
    185                 //cout << "ratio: " << ratio << endl; 
    186180                outstream << "#Pass\n" << i << endl; 
    187181                outstream << "#RenderCost\n" << renderCost << endl; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1288 r1291  
    2525 
    2626static float debugVol = 0; 
     27 
    2728int BvhNode::sMailId = 2147483647; 
     29int BvhNode::sReservedMailboxes = 1; 
     30 
     31 
    2832BvHierarchy *BvHierarchy::BvhSubdivisionCandidate::sBvHierarchy = NULL; 
     33 
    2934 
    3035 
     
    530535                Intersectable *obj = *oit; 
    531536                AxisAlignedBox3 box = obj->GetBox(); 
     537 
    532538                const float objMid = (box.Max(axis) + box.Min(axis)) * 0.5; 
     539 
    533540                // object mailed => belongs to back objects 
    534541                if (objMid < midPoint)  
     
    599606                const int nObjectsRight = nTotalObjects - nObjectsLeft; 
    600607 
    601                 // view cells that see both child nodes 
    602                 //const float volLeftAndRight = totalVol - volLeft - volRight; 
    603  
    604608                // the heuristics 
    605609            const float sum = volLeft * (float)nObjectsLeft +  
    606610                                                  volRight * (float)nObjectsRight; 
    607                 //                                volLeftAndRight * (float)nTotalObjects; 
    608611 
    609612                if (sum < newRenderCost) 
     
    811814                { 
    812815                        if (mUseCostHeuristics) 
    813                         { 
     816                        {cout << "a"; 
    814817                                //-- partition objects using heuristics 
    815818                                nCostRatio[axis] = 
     
    821824                        } 
    822825                        else 
    823                         { 
     826                        {cout << "b"; 
    824827                                nCostRatio[axis] = 
    825828                                        EvalLocalObjectPartition( 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1288 r1291  
    159159 
    160160 
     161        ///////////////////////////////////// 
    161162        //-- mailing options 
    162  
     163         
     164        static void NewMail(const int reserve = 1) { 
     165                sMailId += sReservedMailboxes; 
     166                sReservedMailboxes = reserve; 
     167        } 
     168         
    163169        void Mail() { mMailbox = sMailId; } 
    164         static void NewMail() { ++ sMailId; } 
    165170        bool Mailed() const { return mMailbox == sMailId; } 
     171 
     172        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } 
     173        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; } 
     174 
     175        int IncMail() { return ++ mMailbox - sMailId; } 
    166176 
    167177        static int sMailId; 
    168178        int mMailbox; 
     179        static int sReservedMailboxes; 
    169180 
    170181        /////////////////////////////////// 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1288 r1291  
    279279                const float costRatio = splitCandidate->GetRenderCostDecrease() / mTotalCost; 
    280280 
    281                 Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 
     281                //Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 
    282282                if (costRatio < mTermMinGlobalCostRatio) 
    283283                        ++ mGlobalCostMisses; 
     
    685685} 
    686686 
    687 } 
     687 
     688 
     689} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp

    r1288 r1291  
    12641264 
    12651265 
    1266 #if 0 
    1267  
    12681266float OspTree::EvalRenderCostDecrease(const AxisAlignedPlane &candidatePlane, 
    12691267                                                                          const OspTraversalData &tData, 
     
    12741272 
    12751273        // probability that view point lies in back / front node 
    1276         float pOverall = 0;//data.mProbability; // todo matt§: value ok? 
    1277         float pFront = 0; 
    1278         float pBack = 0; 
    1279         float pFrontAndBack = 0; 
    1280  
    1281         const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 
    1282  
    1283         Intersectable::NewMail(3); 
    1284          
    1285         KdLeaf *leaf = tData.mNode; 
    1286         const int totalPvs = (int)leaf->mObjects.size(); 
    1287          
    1288         RayInfoContainer frontRays, backRays; 
    1289         ClassifyRays(*tData.mRays, leaf, candidatePlane, frontRays, backRays); 
    1290  
    1291         ViewCellContainer touchedViewCells; 
    1292          
    1293         // sum up volume seen from the objects of left and right children 
    1294         // => the volume is the weight for the render cost equation 
    1295         ViewCell::NewMail(3); 
    1296  
    1297         RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end(); 
    1298  
    1299         for (rit = tData.mRays->begin(); rit < rit_end; ++ rit) 
    1300         { 
    1301                 VssRay *ray = (*rit).mRay; 
    1302  
    1303                 // add volume to volumes of left and / or right children 
    1304                 // if one of the ray end points is inside 
    1305                 const int classification = ClassifyRay(ray, leaf, candidatePlane); 
    1306  
    1307                 ViewCellContainer viewCells; 
    1308                 mVspTree->GetViewCells(*ray, viewCells); 
    1309                          
    1310                 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    1311  
    1312                 // traverse through view cells and classify them according 
    1313                 // to them being seen from to back / front / front and back node 
    1314                 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    1315                 { 
    1316                         ViewCell *vc = *vit; 
    1317  
    1318                         // if not previously mailed 
    1319                         if (!vc->Mailed() && !vc->Mailed(1) && !vc->Mailed(2)) 
    1320                         { 
    1321                                 touchedViewCells.push_back(vc); 
    1322                         } 
    1323  
    1324                         // classify / mail the view cell 
    1325                         MailViewCell(vc, classification);        
    1326                 } 
    1327         } 
    1328  
    1329         // evaluate view cells volume contribution  
    1330         // with respect to the mail box classification 
    1331         ViewCellContainer::const_iterator vit, vit_end = touchedViewCells.end(); 
    1332  
    1333         for (vit = touchedViewCells.begin(); vit != vit_end; ++ vit) 
    1334         { 
    1335                 AddViewCellVolumeContri(*vit, pFront, pBack, pFrontAndBack); 
    1336         } 
    1337  
    1338         ////////////////////////////////////////////// 
    1339         // 
    1340         // evaluate contribution of objects which are part of other kd nodes 
    1341         // which are seen by the same view cell 
    1342         // These contributions cannot be reduced by splitting, because 
    1343         // the object would still be part of the pvs 
    1344  
    1345         float additionalFrontRenderCost = 0; 
    1346         float additionalBackRenderCost = 0; 
    1347          
    1348         MailablePvsData::NewMail(); 
    1349  
    1350         for (rit = tData.mRays->begin(); rit != tData.mRays->end(); ++ rit) 
    1351         { 
    1352                 VssRay *ray = (*rit).mRay; 
    1353  
    1354                 ViewCellContainer viewCells; 
    1355                 mVspTree->GetViewCells(*ray, viewCells); 
    1356  
    1357                 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    1358  
    1359                 // traverse through view cells 
    1360                 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    1361                 { 
    1362                         ViewCell *viewCell = *vit; 
    1363  
    1364                         // for a view cell: 
    1365                         // if object is also in the kd pvs entries from other kd leaves, 
    1366                         // render cost cannot be reduced for this view cell 
    1367                         // => the render cost was falsly reduced, add them again 
    1368  
    1369                         if (ray->mTerminationObject) 
    1370                         {        
    1371                                 Intersectable *obj = ray->mTerminationObject; 
    1372                                  
    1373                                 const bool renderCostWrong =  
    1374                                         ViewCellHasMultipleReferences(obj, viewCell, true); 
    1375                          
    1376                                 // if there is already an entry of this object in the view cell pvs  
    1377                                 if (renderCostWrong) 
    1378                                 { 
    1379                                         // view cell was counted only for front or back => correct tjos 
    1380                                         if (viewCell->Mailed(1) && obj->Mailed()) 
    1381                                         { 
    1382                                                 additionalFrontRenderCost += viewCell->GetVolume(); 
    1383                                         } 
    1384                                         else if (viewCell->Mailed() && obj->Mailed(1)) 
    1385                                         { 
    1386                                                 additionalBackRenderCost += viewCell->GetVolume(); 
    1387                                         } 
    1388                                 } 
    1389                         } 
    1390          
    1391                         if (ray->mOriginObject) 
    1392                         { 
    1393                                 Intersectable *obj = ray->mOriginObject; 
    1394  
    1395                                 const bool renderCostWrong =  
    1396                                         ViewCellHasMultipleReferences(obj, viewCell, true); 
    1397                                 // if there is already an entry of this object in the view cell pvs  
    1398                                 if (renderCostWrong) 
    1399                                 { 
    1400                                         if (viewCell->Mailed(1) && obj->Mailed()) 
    1401                                         { 
    1402                                                 additionalFrontRenderCost += viewCell->GetVolume(); 
    1403                                         } 
    1404                                         else if (viewCell->Mailed() && obj->Mailed(1)) 
    1405                                         { 
    1406                                                 additionalBackRenderCost += viewCell->GetVolume(); 
    1407                                         } 
    1408                                 } 
    1409                         } 
    1410                 } 
    1411         } 
    1412  
    1413         ///////////////////////////// 
    1414  
    1415  
    1416         // these are non-overlapping sets 
    1417         pOverall = pFront + pBack + pFrontAndBack; 
    1418  
    1419  
    1420         //-- pvs rendering heuristics 
    1421  
    1422         const float oldRenderCost = pOverall * totalPvs; 
    1423          
    1424         // sum up the terms:  
    1425         // the view cells seeing 
    1426         // a) the left node are weighted by the #left node objects 
    1427         // b) the right node are weighted by the #right node objects 
    1428         // c) both nodes are weighted by the #parent node objects 
    1429         const float newRenderCost = pvsFront * pFront + pvsBack * pBack + totalPvs * pFrontAndBack 
    1430                 + additionalFrontRenderCost + additionalBackRenderCost; 
    1431  
    1432         // normalize volume with view space volume 
    1433         const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol; 
    1434  
    1435         Debug << "\n(((( eval render cost decrease ))))" << endl 
    1436                   << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl  
    1437                   << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol  
    1438                   << " front and back p " << pFrontAndBack / viewSpaceVol << " p: " << tData.mProbability / viewSpaceVol << endl 
    1439                   << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl 
    1440                   << "render cost decrease: " << renderCostDecrease << endl 
    1441                   << "additional front " << additionalFrontRenderCost / viewSpaceVol  
    1442                   << " additional back " << additionalBackRenderCost  / viewSpaceVol << endl; 
    1443  
    1444         if (oldRenderCost < newRenderCost * 0.99) 
    1445                 Debug <<"error!!"<<endl; 
    1446  
    1447         //if ((((pOverall - tData.mProbability) / viewSpaceVol) > 0.00001)) 
    1448         //      Debug << "ERROR!!"<<endl; 
    1449  
    1450         normalizedOldRenderCost = oldRenderCost / viewSpaceVol; 
    1451  
    1452                  
    1453         return renderCostDecrease; 
    1454 } 
    1455  
    1456 #else 
    1457  
    1458 float OspTree::EvalRenderCostDecrease(const AxisAlignedPlane &candidatePlane, 
    1459                                                                           const OspTraversalData &tData, 
    1460                                                                           float &normalizedOldRenderCost) const 
    1461 { 
    1462         float pvsFront = 0; 
    1463         float pvsBack = 0; 
    1464  
    1465         // probability that view point lies in back / front node 
    1466         float pOverall = 0;//data.mProbability; // todo matt§: value ok? 
     1274        float pOverall = 0; 
    14671275        float pFront = 0; 
    14681276        float pBack = 0; 
     
    15041312        } 
    15051313 
    1506          
    15071314        ViewCellContainer touchedViewCells; 
    15081315 
     
    16031410 
    16041411        ///////////////////////////// 
    1605  
    1606  
    1607         // these are non-overlapping sets 
    1608         pOverall = pFront + pBack + pFrontAndBack; 
    1609  
    1610  
    16111412        //-- pvs rendering heuristics 
    16121413 
    1613         const float oldRenderCost = rc;//pOverall * totalPvs; 
     1414        const float oldRenderCost = rc; 
    16141415         
    16151416        // sum up the terms:  
     
    16181419        // b) the right node are weighted by the #right node objects 
    16191420        // c) both nodes are weighted by the #parent node objects 
    1620         const float newRenderCost = newRc//pvsFront * pFront + pvsBack * pBack + totalPvs * pFrontAndBack 
    1621 ;//             + additionalFrontRenderCost + additionalBackRenderCost; 
     1421        const float newRenderCost = newRc; 
     1422 
    16221423 
    16231424        // normalize volume with view space volume 
    16241425        const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol; 
    16251426 
    1626         Debug << "\n(((( eval render cost decrease ))))" << endl 
    1627                   << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl  
    1628                   << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol  
    1629                   << " front and back p " << pFrontAndBack / viewSpaceVol << " p: " << tData.mProbability / viewSpaceVol << endl 
     1427        Debug << "\nrender cost decrease: " << endl 
    16301428                  << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl 
    16311429                  << "render cost decrease: " << renderCostDecrease << endl; 
    1632                   //<< "additional front " << additionalFrontRenderCost / viewSpaceVol  
    1633                   //<< " additional back " << additionalBackRenderCost  / viewSpaceVol << endl; 
    1634  
    1635         if (oldRenderCost < newRenderCost * 0.99) 
    1636                 Debug <<"error!!"<<endl; 
    1637  
    1638         //if ((((pOverall - tData.mProbability) / viewSpaceVol) > 0.00001)) 
    1639         //      Debug << "ERROR!!"<<endl; 
    16401430 
    16411431        normalizedOldRenderCost = oldRenderCost / viewSpaceVol; 
     
    16441434        return renderCostDecrease; 
    16451435} 
    1646 #endif 
    16471436 
    16481437 
     
    22342023        MailablePvsData::NewMail(); 
    22352024         
    2236         /*RayInfoContainer::const_iterator rit, rit_end = rays.end(); 
    2237  
    2238         for (rit = rays.begin(); rit < rit_end; ++ rit) 
    2239         { 
    2240                 VssRay *ray = (*rit).mRay; 
    2241  
    2242                 ViewCellContainer viewCells; 
    2243                 mVspTree->GetViewCells(*ray, viewCells); 
    2244  
    2245                 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    2246  
    2247                 // traverse through view cells and classify them according 
    2248                 // to them being seen from to back / front / front and back node 
    2249                 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    2250                 { 
    2251                         ViewCell *vc = *vit; 
    2252  
    2253                         Intersectable *obj = ray->mTerminationObject; 
    2254                         if (obj) 
    2255                         { 
    2256                                 float contri; 
    2257                                 AddViewCellToObjectPvs(obj, vc, contri, true); 
    2258                         } 
    2259  
    2260                         obj = ray->mOriginObject; 
    2261                         if (obj) 
    2262                         { 
    2263                                 float contri; 
    2264                                 AddViewCellToObjectPvs(obj, vc, contri, true); 
    2265                         } 
    2266                 } 
    2267         }*/ 
    2268          
    22692025        ViewCellContainer touchedViewCells; 
    22702026        CollectTouchedViewCells(rays, touchedViewCells); 
     
    22972053{ 
    22982054        MailablePvsData::NewMail(); 
    2299  
    2300         /*RayInfoContainer::const_iterator rit, rit_end = rays.end(); 
    2301         for (rit = rays.begin(); rit < rit_end; ++ rit) 
    2302         { 
    2303                 VssRay *ray = (*rit).mRay; 
    2304  
    2305                 // test if intersection point with one of the objects is inside this node 
    2306                 ViewCellContainer viewCells; 
    2307                 mVspTree->GetViewCells(*ray, viewCells); 
    2308  
    2309                 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    2310  
    2311                 // traverse through view cells and classify them according 
    2312                 // to them being seen from to back / front / front and back node 
    2313                 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    2314                 { 
    2315                         ViewCell *vc = *vit; 
    2316                         Intersectable *obj = ray->mTerminationObject; 
    2317  
    2318                         if (obj) 
    2319                         { 
    2320                                 MailablePvsData *vdata = obj->mViewCellPvs.Find(vc); 
    2321  
    2322                                 if (vdata && !vdata->Mailed()) 
    2323                                 { 
    2324                                         vdata->Mail(); 
    2325                                         obj->mViewCellPvs.RemoveSample(vc, 1); 
    2326                                 } 
    2327                         } 
    2328  
    2329                         obj = ray->mOriginObject; 
    2330  
    2331                         if (obj) 
    2332                         { 
    2333                                 MailablePvsData *vdata = obj->mViewCellPvs.Find(vc); 
    2334  
    2335                                 if (vdata && !vdata->Mailed()) 
    2336                                 { 
    2337                                         vdata->Mail(); 
    2338                                         obj->mViewCellPvs.RemoveSample(vc, 1); 
    2339                                 } 
    2340                         } 
    2341                 } 
    2342         }*/ 
    23432055 
    23442056        ViewCellContainer touchedViewCells; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1288 r1291  
    4141        int n = 200; 
    4242 
    43         if (0){ 
    44         // form grid of boxes 
    45         for (int i = 0; i < n; ++ i) 
    46         { 
    47                 for (int j = 0; j < n; ++ j) 
     43        if (0) 
     44        { 
     45                // form grid of boxes 
     46                for (int i = 0; i < n; ++ i) 
    4847                { 
    49                         const Vector3 scale2((float)j * 0.8f / n + 0.1f,  0.05f, (float)i * 0.8f  / (float)n + 0.1f); 
    50                  
    51                         const Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
    52                  
    53                         const Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 
    54                         AxisAlignedBox3 box(pt2, pt2 + boxSize); 
     48                        for (int j = 0; j < n; ++ j) 
     49                        { 
     50                                const Vector3 scale2((float)j * 0.8f / n + 0.1f,  0.05f, (float)i * 0.8f  / (float)n + 0.1f); 
     51 
     52                                const Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
     53 
     54                                const Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 
     55                                AxisAlignedBox3 box(pt2, pt2 + boxSize); 
     56                                Mesh *mesh = CreateMeshFromBox(box); 
     57 
     58                                mesh->Preprocess(); 
     59 
     60                                MeshInstance *mi = new MeshInstance(mesh); 
     61                                scene->mRoot->mGeometry.push_back(mi); 
     62                        } 
     63                } 
     64 
     65                for (int i = 0; i < n; ++ i) 
     66                { 
     67                        for (int j = 0; j < n; ++ j) 
     68                        { 
     69                                const Vector3 scale2(0.15f, (float)j * 0.8f / n + 0.1f, (float)i * 0.8f  / (float)n + 0.1f); 
     70 
     71                                Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
     72 
     73                                Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 
     74                                AxisAlignedBox3 box(pt2, pt2 + boxSize); 
     75                                Mesh *mesh = CreateMeshFromBox(box); 
     76 
     77                                mesh->Preprocess(); 
     78 
     79                                MeshInstance *mi = new MeshInstance(mesh); 
     80                                scene->mRoot->mGeometry.push_back(mi); 
     81                        } 
     82                } 
     83 
     84                for (int i = 0; i < n; ++ i) 
     85                { 
     86                        const Vector3 scale2(2, 0.2f, (float)i * 0.8f  / (float)n + 0.1f); 
     87 
     88                        Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
     89 
     90                        //Vector3 boxSize = sceneBox.Size() * Vector3(0.0025, 0.01, 0.0025); 
     91                        Vector3 boxSize = sceneBox.Size() * Vector3(0.005f, 0.02f, 0.005f); 
     92 
     93                        AxisAlignedBox3 box(pt2 + 0.1f, pt2 + boxSize); 
    5594                        Mesh *mesh = CreateMeshFromBox(box); 
    5695 
    5796                        mesh->Preprocess(); 
    58                  
     97 
    5998                        MeshInstance *mi = new MeshInstance(mesh); 
    6099                        scene->mRoot->mGeometry.push_back(mi); 
    61100                } 
    62         } 
    63  
    64         for (int i = 0; i < n; ++ i) 
    65         { 
    66                 for (int j = 0; j < n; ++ j) 
    67                 { 
    68                         const Vector3 scale2(0.15f, (float)j * 0.8f / n + 0.1f, (float)i * 0.8f  / (float)n + 0.1f); 
    69                  
    70                         Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
    71                  
    72                         Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 
    73                         AxisAlignedBox3 box(pt2, pt2 + boxSize); 
    74                         Mesh *mesh = CreateMeshFromBox(box); 
    75  
    76                         mesh->Preprocess(); 
    77                  
    78                         MeshInstance *mi = new MeshInstance(mesh); 
    79                         scene->mRoot->mGeometry.push_back(mi); 
    80                 } 
    81         } 
    82  
    83         for (int i = 0; i < n; ++ i) 
    84         { 
    85                 const Vector3 scale2(2, 0.2f, (float)i * 0.8f  / (float)n + 0.1f); 
    86                  
    87                 Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
    88                  
    89                 //Vector3 boxSize = sceneBox.Size() * Vector3(0.0025, 0.01, 0.0025); 
    90                 Vector3 boxSize = sceneBox.Size() * Vector3(0.005f, 0.02f, 0.005f); 
    91  
    92                 AxisAlignedBox3 box(pt2 + 0.1f, pt2 + boxSize); 
    93                 Mesh *mesh = CreateMeshFromBox(box); 
    94  
    95                 mesh->Preprocess(); 
    96                  
    97                 MeshInstance *mi = new MeshInstance(mesh); 
    98                 scene->mRoot->mGeometry.push_back(mi); 
    99         } 
    100          
    101         scene->mRoot->UpdateBox(); 
    102         } 
    103                  
     101 
     102                scene->mRoot->UpdateBox(); 
     103        } 
     104 
    104105        if (1) 
    105106        { 
     
    111112                Plane3 cuttingPlane(Vector3(1, 0, 0), pt); 
    112113                Mesh *planeMesh = new Mesh(); 
    113                  
     114 
    114115                Polygon3 *poly = sceneBox.CrossSection(cuttingPlane); 
    115116                IncludePolyInMesh(*poly, *planeMesh); 
    116                  
     117 
    117118                planeMesh->Preprocess(); 
    118                  
     119 
    119120                MeshInstance *planeMi = new MeshInstance(planeMesh); 
    120121                scene->mRoot->mGeometry.push_back(planeMi); 
     
    145146        Environment::GetSingleton()->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 
    146147        Environment::GetSingleton()->GetBoolValue("Preprocessor.exportVisibility", mExportVisibility ); 
    147 //#if GTP_INTERNAL // choose other ray cast method 
    148148        Environment::GetSingleton()->GetIntValue("Preprocessor.rayCastMethod", mRayCastMethod); 
    149 //#endif 
     149 
    150150        char buffer[256]; 
    151151        Environment::GetSingleton()->GetStringValue("Preprocessor.visibilityFile",  buffer); 
     
    163163Preprocessor::~Preprocessor() 
    164164{ 
    165   cout << "cleaning up" << endl; 
    166  
    167   cout << "Deleting view cells manager ... \n"; 
    168   DEL_PTR(mViewCellsManager); 
    169   cout << "done.\n"; 
    170  
    171   cout << "Deleting bsp tree ... \n"; 
    172   DEL_PTR(mBspTree); 
    173   cout << "done.\n"; 
    174  
    175   cout << "Deleting kd tree...\n"; 
    176   DEL_PTR(mKdTree); 
    177   cout << "done.\n"; 
    178   
    179   cout << "Deleting vsp tree...\n"; 
    180   DEL_PTR(mVspTree); 
    181   cout << "done.\n"; 
    182  
    183   cout << "Deleting hierarchy manager...\n"; 
    184   DEL_PTR(mHierarchyManager); 
    185   cout << "done.\n"; 
    186  
    187   cout << "Deleting vspbsp tree...\n"; 
    188   DEL_PTR(mVspBspTree); 
    189   cout << "done.\n"; 
    190  
    191    cout << "Deleting scene graph...\n"; 
    192   DEL_PTR(mSceneGraph); 
    193   cout << "done.\n"; 
    194  
    195   DEL_PTR(mRenderSimulator); 
    196   DEL_PTR(renderer); 
     165        cout << "cleaning up" << endl; 
     166 
     167        cout << "Deleting view cells manager ... \n"; 
     168        DEL_PTR(mViewCellsManager); 
     169        cout << "done.\n"; 
     170 
     171        cout << "Deleting bsp tree ... \n"; 
     172        DEL_PTR(mBspTree); 
     173        cout << "done.\n"; 
     174 
     175        cout << "Deleting kd tree...\n"; 
     176        DEL_PTR(mKdTree); 
     177        cout << "done.\n"; 
     178 
     179        cout << "Deleting vsp tree...\n"; 
     180        DEL_PTR(mVspTree); 
     181        cout << "done.\n"; 
     182 
     183        cout << "Deleting hierarchy manager...\n"; 
     184        DEL_PTR(mHierarchyManager); 
     185        cout << "done.\n"; 
     186 
     187        cout << "Deleting vspbsp tree...\n"; 
     188        DEL_PTR(mVspBspTree); 
     189        cout << "done.\n"; 
     190 
     191        cout << "Deleting scene graph...\n"; 
     192        DEL_PTR(mSceneGraph); 
     193        cout << "done.\n"; 
     194 
     195        DEL_PTR(mRenderSimulator); 
     196        DEL_PTR(renderer); 
    197197} 
    198198 
     
    461461        if (strcmp(name, "osp") == 0) 
    462462        { 
     463                Debug << "hierarchy manager: osp" << endl; 
    463464                // HACK for testing if per kd evaluation works!! 
    464465                const bool ishack = true; 
     
    470471        else if (strcmp(name, "bvh") == 0) 
    471472        { 
     473                Debug << "hierarchy manager: bvh" << endl; 
    472474                hierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::BV_BASED_OBJ_SUBDIV); 
     475        } 
     476        else // only view space partition 
     477        { 
     478                Debug << "hierarchy manager: obj" << endl; 
     479                hierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::NO_OBJ_SUBDIV); 
    473480        } 
    474481 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp

    r1284 r1291  
    8686        if (node->IsLeaf())      
    8787        { 
    88                 if (!node->Mailed()) 
    89                 { 
    90                         node->Mail(); 
    91                         return (int)(((BvhLeaf *)node)->mObjects.size()); 
    92                 } 
    93                 else 
    94                 { 
     88                // objects already accounted for 
     89                if (node->Mailed()) 
    9590                        return 0; 
    96                 } 
     91 
     92                node->Mail(); 
     93 
     94                return (int)(((BvhLeaf *)node)->mObjects.size()); 
    9795        }                         
    9896 
     
    156154                                        KdIntersectable *kdObj = dynamic_cast<KdIntersectable *>(obj); 
    157155                                        pvs += CountNewObjectsInKdNode(kdObj);   
     156                                        cout << "z"; 
    158157                                        break; 
    159158                                } 
    160159                        case Intersectable::BVH_INTERSECTABLE: 
    161160                                { 
     161                                        cout << "x"; 
    162162                                        BvhIntersectable *bvhObj = dynamic_cast<BvhIntersectable *>(obj); 
    163163                                        pvs += CountNewObjectsInBvhNode(bvhObj); 
    164164                                        break; 
    165165                                } 
    166                         default: 
     166                        default:cout << "y"; 
    167167                                ++ pvs; 
    168168                                break; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r1233 r1291  
    20612061        float mint = 0.0f, maxt = 1.0f; 
    20622062 
    2063         Intersectable::NewMail(); 
    2064         ViewCell::NewMail(); 
     2063        //ViewCell::NewMail(); 
    20652064 
    20662065        Vector3 entp = origin; 
     
    21312130                                viewcells.push_back(leaf->mViewCell); 
    21322131                                leaf->mViewCell->Mail(); 
    2133                                 hits++; 
     2132                                ++ hits; 
    21342133                        } 
    21352134                 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h

    r1278 r1291  
    618618        int     _CastRay(Ray &ray); 
    619619 
    620  
    621620        int     CastLineSegment(const Vector3 &origin, 
    622621                                                const Vector3 &termination, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1287 r1291  
    17881788        Vector3 termination = hray.Extrap(tmax); 
    17891789 
     1790        ViewCell::NewMail(); 
     1791 
    17901792        // traverse the view space subdivision 
    17911793        CastLineSegment(origin, termination, viewcells); 
     
    18071809                        // if ray not outside of view space 
    18081810                        float contribution; 
    1809                         if (ray.mTerminationObject) { 
    1810                           if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 
    1811                                                                                                                    ray.mPdf, 
    1812                                                                                                                    contribution)) 
    1813                           { 
    1814                                 ++ ray.mPvsContribution; 
    1815                                   ray.mRelativePvsContribution += contribution; 
    1816                           } 
     1811 
     1812                        if (ray.mTerminationObject)  
     1813                        { 
     1814                                cout << "f"; 
     1815                                if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 
     1816                                        ray.mPdf, 
     1817                                        contribution)) 
     1818                                { 
     1819                                        ++ ray.mPvsContribution; 
     1820                                        ray.mRelativePvsContribution += contribution; 
     1821                                } 
    18171822                        } 
     1823                         
     1824#if SAMPLE_ORIGIN_OBJECTS 
     1825 
    18181826                        // for directional sampling it is important to count only contributions 
    18191827                        // made in one direction!!! 
    18201828                        // the other contributions of this sample will be counted for the oposite ray! 
    1821 #if SAMPLE_ORIGIN_OBJECTS 
     1829 
    18221830                        if (ray.mOriginObject &&  
    18231831                                viewcell->GetPvs().GetSampleContribution(ray.mOriginObject, 
     
    34863494 
    34873495 
    3488  
    34893496/**************************************************************************/ 
    34903497/*                   VspBspViewCellsManager implementation                */ 
     
    55065513        Vector3 termination = hray.Extrap(tmax); 
    55075514 
     5515        ViewCell::NewMail(); 
     5516 
    55085517        // traverse the view space subdivision 
    55095518        CastLineSegment(origin, termination, viewcells); 
    55105519 
    55115520        if (storeViewCells) 
    5512         {       // copy viewcells memory efficiently 
     5521        {        
     5522                // copy viewcells memory efficiently 
    55135523                ray.mViewCells.reserve(viewcells.size()); 
    55145524                ray.mViewCells = viewcells; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1288 r1291  
    34103410        float mint = 0.0f, maxt = 1.0f; 
    34113411 
    3412         Intersectable::NewMail(); 
    3413         ViewCell::NewMail(); 
     3412        //ViewCell::NewMail(); 
    34143413 
    34153414        Vector3 entp = origin; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1290 r1291  
    730730         
    731731        // compute locally best split plane 
    732         const float ratio = SelectSplitPlane( 
    733                 splitCandidate.mParentData,  
    734                 splitCandidate.mSplitPlane,  
    735                 frontProb,  
    736                 backProb); 
     732        const float ratio = SelectSplitPlane(splitCandidate.mParentData,  
     733                                                                                 splitCandidate.mSplitPlane,  
     734                                                                                 frontProb,  
     735                                                                                 backProb); 
    737736 
    738737        const bool success = ratio < mTermMaxCostRatio; 
    739738 
     739        // max cost threshold violated? 
     740        splitCandidate.mMaxCostMisses =  
     741                success ? splitCandidate.mParentData.mMaxCostMisses : splitCandidate.mParentData.mMaxCostMisses + 1; 
     742         
    740743        float oldRenderCost; 
    741744 
     
    758761         
    759762        splitCandidate.SetPriority(priority); 
    760  
    761         // max cost threshold violated? 
    762         splitCandidate.mMaxCostMisses =  
    763                 success ? splitCandidate.mParentData.mMaxCostMisses : splitCandidate.mParentData.mMaxCostMisses + 1; 
    764         //Debug << "p: " << tData.mNode << " depth: " << tData.mDepth << endl; 
    765763} 
    766764 
     
    907905        } 
    908906} 
    909  
    910  
    911907 
    912908 
     
    992988        mLocalSubdivisionCandidates->reserve(requestedSize); 
    993989 
    994  
    995990        float pos; 
    996  
    997991        RayInfoContainer::const_iterator rit, rit_end = rays.end(); 
    998992 
     
    10171011 
    10181012 
    1019 int VspTree::GetPvsContribution(Intersectable *object) const 
    1020 { 
    1021     int pvsContri = 0; 
    1022  
    1023         KdPvsMap::const_iterator kit, kit_end = object->mKdPvs.mEntries.end(); 
    1024  
    1025         Intersectable::NewMail(); 
    1026  
    1027         // Search kd leaves this object is attached to 
    1028         for (kit = object->mKdPvs.mEntries.begin(); kit != kit_end; ++ kit) 
    1029         { 
    1030                 KdNode *l = (*kit).first; 
    1031  
    1032                 // new object found during sweep  
    1033                 // => increase pvs contribution of this kd node 
    1034                 if (!l->Mailed()) 
    1035                 { 
    1036                         l->Mail(); 
    1037                         ++ pvsContri; 
    1038                 } 
    1039         } 
    1040  
    1041         return pvsContri; 
    1042 } 
    1043  
    1044  
    1045 int VspTree::PrepareHeuristics(const VssRay &ray, const bool isTermination) 
    1046 { 
    1047         int pvsSize = 0; 
    1048          
    1049         Intersectable *obj; 
    1050         Vector3 pt; 
    1051         KdNode *node; 
    1052  
    1053         ray.GetSampleData(isTermination, pt, &obj, &node); 
    1054  
    1055         if (!obj) 
    1056                 return 0; 
    1057  
    1058         switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 
    1059         { 
    1060         case HierarchyManager::NO_OBJ_SUBDIV: 
    1061                 { 
    1062                         if (!obj->Mailed()) 
    1063                         { 
    1064                                 obj->Mail(); 
    1065                                 obj->mCounter = 1; 
    1066  
    1067                                 ++ pvsSize; 
    1068                         } 
    1069                         else 
    1070                         { 
    1071                                 ++ obj->mCounter; 
    1072                         } 
    1073                         break; 
    1074                 } 
    1075         case HierarchyManager::KD_BASED_OBJ_SUBDIV: 
    1076                 { 
    1077                         KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 
    1078                         pvsSize += PrepareHeuristics(leaf);      
    1079                         break; 
    1080                 } 
    1081         case HierarchyManager::BV_BASED_OBJ_SUBDIV: 
    1082                 { 
    1083                         BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
    1084  
    1085                         if (!leaf->Mailed()) 
    1086                         { 
    1087                                 leaf->Mail(); 
    1088                                 leaf->mCounter = 1; 
    1089  
    1090                                 pvsSize += (int)leaf->mObjects.size(); 
    1091                         } 
    1092                         else 
    1093                         { 
    1094                                 ++ leaf->mCounter; 
    1095                         } 
    1096                         break; 
    1097                 } 
    1098         default: 
    1099                 break; 
    1100         } 
    1101  
    1102         return pvsSize; 
    1103 } 
    1104  
    1105  
    11061013int VspTree::PrepareHeuristics(KdLeaf *leaf) 
    11071014{        
     
    11121019                leaf->Mail(); 
    11131020                leaf->mCounter = 1; 
    1114  
    11151021                // add objects without the objects which are in several kd leaves 
    11161022                pvsSize += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 
    1117                 //Debug << "adding " << (int)leaf->mObjects.size() << " " << leaf->mMultipleObjects.size() << endl; 
    11181023        } 
    11191024        else 
     
    11231028 
    11241029        //-- the objects belonging to several leaves must be handled seperately 
    1125  
    11261030        ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 
    11271031 
     
    11511055        Intersectable::NewMail(); 
    11521056        KdNode::NewMail(); 
     1057        BvhNode::NewMail(); 
    11531058 
    11541059        int pvsSize = 0; 
     
    12261131 
    12271132 
    1228 int VspTree::EvalMinEventContribution(const VssRay &ray,  
    1229                                                                           const bool isTermination) const 
    1230 { 
    1231         Intersectable *obj; 
    1232         Vector3 pt; 
    1233         KdNode *node; 
    1234  
    1235         ray.GetSampleData(isTermination, pt, &obj, &node); 
    1236  
    1237         if (!obj) return 0; 
    1238  
    1239         int pvs = 0; 
    1240  
    1241         switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 
    1242         { 
    1243         case HierarchyManager::NO_OBJ_SUBDIV: 
    1244                 { 
    1245                         if (!obj->Mailed()) 
    1246                         { 
    1247                                 obj->Mail(); 
    1248                                 ++ pvs; 
    1249                         } 
    1250  
    1251                         break; 
    1252                 } 
    1253         case HierarchyManager::KD_BASED_OBJ_SUBDIV: 
    1254                 { 
    1255                         KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 
    1256                         // add contributions of the kd nodes 
    1257                         pvs += EvalMinEventContribution(leaf); 
    1258                                          
    1259                         break; 
    1260                 } 
    1261         case HierarchyManager::BV_BASED_OBJ_SUBDIV: 
    1262                 { 
    1263                         BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
    1264  
    1265                         if (!leaf->Mailed()) 
    1266                         { 
    1267                                 leaf->Mail(); 
    1268                                 pvs += (int)leaf->mObjects.size(); 
    1269                         } 
    1270                         break; 
    1271                 } 
    1272         default: 
    1273                 break; 
    1274         } 
    1275         return pvs; 
    1276 } 
    1277  
    1278  
    1279 int VspTree::EvalMaxEventContribution(const VssRay &ray,  
    1280                                                                           const bool isTermination) const 
    1281 { 
    1282         Intersectable *obj; 
    1283         Vector3 pt; 
    1284         KdNode *node; 
    1285  
    1286         ray.GetSampleData(isTermination, pt, &obj, &node); 
    1287  
    1288         if (!obj) return 0; 
    1289  
    1290         int pvs = 0; 
    1291  
    1292         switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 
    1293         { 
    1294         case HierarchyManager::NO_OBJ_SUBDIV: 
    1295                 { 
    1296                         if (-- obj->mCounter == 0) 
    1297                                 ++ pvs; 
    1298                         break; 
    1299                 } 
    1300         case HierarchyManager::KD_BASED_OBJ_SUBDIV: 
    1301                 { 
    1302                         KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 
    1303  
    1304                         // add contributions of the kd nodes 
    1305                         pvs += EvalMaxEventContribution(leaf); 
    1306                         break; 
    1307                 } 
    1308         case HierarchyManager::BV_BASED_OBJ_SUBDIV: 
    1309                 { 
    1310                         BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
    1311  
    1312                         if (-- leaf->mCounter == 0) 
    1313                                 pvs += (int)leaf->mObjects.size(); 
    1314                         break; 
    1315                 } 
    1316         default: 
    1317                 break; 
    1318         } 
    1319  
    1320         return pvs; 
    1321 } 
    1322  
    1323  
    1324 void VspTree::EvalHeuristicsContribution(const SortableEntry &ci, 
    1325                                                                                  int &pvsLeft, 
    1326                                                                                  int &pvsRight) const 
     1133void VspTree::EvalHeuristics(const SortableEntry &ci, 
     1134                                                         int &pvsLeft, 
     1135                                                         int &pvsRight) const 
    13271136{ 
    13281137        VssRay *ray = ci.ray; 
    13291138 
     1139        // eval changes in pvs causes by min event  
    13301140        if (ci.type == SortableEntry::ERayMin) 
    13311141        { 
     
    13331143                pvsLeft += EvalMinEventContribution(*ray, false); 
    13341144        } 
    1335         else 
     1145        else // eval changes in pvs causes by max event  
    13361146        { 
    13371147                pvsRight -= EvalMaxEventContribution(*ray, true); 
     
    13581168        } 
    13591169 
    1360         int pvsSize = tData.mPvs; 
    1361  
    13621170        const float minBox = box.Min(axis); 
    13631171        const float maxBox = box.Max(axis); 
     
    13711179 
    13721180        // prepare the sweep 
    1373         // (note: returns pvs size, so there would be no need  
    1374         // to give pvs size as argument) 
    1375         pvsSize = PrepareHeuristics(usedRays); 
     1181        // note: returns pvs size => no need t give pvs size as function parameter 
     1182        const int pvsSize = PrepareHeuristics(usedRays); 
    13761183 
    13771184        // go through the lists, count the number of objects left and right 
     
    13981205        Intersectable::NewMail(); 
    13991206        KdLeaf::NewMail(); 
    1400  
     1207        BvhLeaf::NewMail(); 
    14011208 
    14021209        //-- traverse through visibility events 
     
    14061213        for (ci = mLocalSubdivisionCandidates->begin(); ci != ci_end; ++ ci) 
    14071214        { 
    1408                 EvalHeuristicsContribution(*ci, pvsl, pvsr); 
     1215                // compute changes to front and back pvs 
     1216                EvalHeuristics(*ci, pvsl, pvsr); 
    14091217 
    14101218                // Note: sufficient to compare size of bounding boxes of front and back side? 
    14111219                if (((*ci).value >= minBand) && ((*ci).value <= maxBand)) 
    14121220                { 
    1413  
    14141221                        float currentPos; 
    14151222                         
     
    14211228 
    14221229                        sum = pvsl * ((*ci).value - minBox) + pvsr * (maxBox - (*ci).value); 
    1423                         //Debug  << "pos=" << (*ci).value << "\t newpos=" << currentPos << "\t pvs=(" <<  pvsl << "," << pvsr << ")" << "\t cost= " << sum << endl; 
     1230                         
    14241231 
    14251232                        if (sum < minSum) 
     
    14601267        const float volRatio = tData.mBoundingBox.GetVolume() / (sizeBox * mBoundingBox.GetVolume()); 
    14611268 
    1462 /*       
    1463 //if (axis != 1) 
    1464         //Debug << "axis=" << axis << " costRatio=" << ratio << " pos=" << position << " t=" << (position - minBox) / (maxBox - minBox) 
    1465         //      <<"\t pb=(" << pvsBack << ")\t pf=(" << pvsFront << ")" << endl; 
    1466  
    1467 Debug << "\n§§§§ eval local cost §§§§" << endl 
     1269        Debug << "\n§§§§ eval local cost §§§§" << endl 
    14681270                  << "back pvs: " << penaltyBack << " front pvs: " << penaltyFront << " total pvs: " << penaltyOld << endl  
    14691271                  << "back p: " << pBack * volRatio << " front p " << pFront * volRatio << " p: " << pOverall * volRatio << endl 
    14701272                  << "old rc: " << oldRenderCost * volRatio << " new rc: " << newRenderCost * volRatio << endl 
    14711273                  << "render cost decrease: " << oldRenderCost * volRatio - newRenderCost * volRatio << endl; 
    1472 */ 
     1274 
    14731275        return ratio; 
    14741276} 
     
    14941296    const bool useSpecialAxis =  
    14951297                mOnlyDrivingAxis || mCirculatingAxis; 
    1496         //Debug << "data: " << tData.mBoundingBox << " pvs " << tData.mPvs << endl; 
     1298         
    14971299        if (mCirculatingAxis) 
    14981300        { 
     
    15461348        } 
    15471349 
    1548  
    15491350        //-- assign values of best split 
    1550          
    15511351        plane.mAxis = bestAxis; 
    15521352        plane.mPosition = nPosition[bestAxis]; // split plane position 
     
    15551355        pBack = nProbBack[bestAxis]; 
    15561356 
    1557         //Debug << "val: " << nCostRatio[bestAxis] << " axis: " << bestAxis << endl; 
    15581357        return nCostRatio[bestAxis]; 
    15591358} 
     
    15781377        Intersectable::NewMail(3); 
    15791378        KdLeaf::NewMail(3); 
     1379        BvhLeaf::NewMail(3); 
    15801380 
    15811381        RayInfoContainer::const_iterator rit, rit_end = data.mRays->end(); 
     
    15881388                VssRay *ray = rayInf.mRay; 
    15891389 
     1390                // classify ray 
    15901391                const int cf =  
    15911392                        rayInf.ComputeRayIntersection(candidatePlane.mAxis,  
    15921393                                                                                  candidatePlane.mPosition, t); 
    15931394 
    1594                 switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 
    1595                 { 
    1596                 case HierarchyManager::NO_OBJ_SUBDIV: 
    1597                 { 
    1598                         // find front and back pvs for origing and termination object 
    1599                         UpdateObjPvsContri(ray->mTerminationObject, cf, pvsFront, pvsBack, totalPvs); 
    1600                         UpdateObjPvsContri(ray->mOriginObject, cf, pvsFront, pvsBack, totalPvs); 
    1601  
    1602                         break; 
    1603                 } 
    1604                 case HierarchyManager::KD_BASED_OBJ_SUBDIV: 
    1605                 { 
    1606                         break; 
    1607                 } 
    1608                 case HierarchyManager::BV_BASED_OBJ_SUBDIV: 
    1609                 { 
    1610                         BvhLeaf *tLeaf = mHierarchyManager->mBvHierarchy->GetLeaf(ray->mTerminationObject); 
    1611                         BvhLeaf *oLeaf = mHierarchyManager->mBvHierarchy->GetLeaf(ray->mOriginObject); 
    1612  
    1613                         UpdateBvhLeafPvsContri(tLeaf, cf, pvsFront, pvsBack, totalPvs); 
    1614                         UpdateBvhLeafPvsContri(oLeaf, cf, pvsFront, pvsBack, totalPvs); 
    1615                          
    1616                         break; 
    1617                 } 
    1618         default: 
    1619                 break; 
    1620         } 
    1621  
    1622 /* 
    1623                 if (!mUseKdPvsForHeuristics) 
    1624                 { 
    1625                          
    1626                 } 
    1627                 else 
    1628                 { 
    1629                         if (ray->mTerminationObject) 
    1630                         { 
    1631                                 KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode); 
    1632                                 UpdateKdLeafPvsContri(leaf, cf, pvsFront, pvsBack, totalPvs); 
    1633                         } 
    1634  
    1635                         if (ray->mOriginObject) 
    1636                         { 
    1637                                 KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 
    1638                                 UpdateKdLeafPvsContri(leaf, cf, pvsFront, pvsBack, totalPvs); 
    1639                         } 
    1640                 } 
    1641 */ 
     1395                // evaluate contribution of ray endpoint to front and back pvs 
     1396                // with respect to the classification 
     1397                UpdateContributionsToPvs(*ray, true, cf, pvsFront, pvsBack, totalPvs); 
     1398                UpdateContributionsToPvs(*ray, false, cf, pvsFront, pvsBack, totalPvs); 
    16421399        } 
    16431400 
     
    16491406 
    16501407        pFront = frontBox.GetVolume(); 
    1651         pBack = pOverall - pFront; 
    1652                  
     1408        pBack = pOverall - pFront;       
    16531409 
    16541410        //-- pvs rendering heuristics 
     1411 
    16551412        const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); 
    16561413        const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 
    16571414 
    16581415        //-- only render cost heuristics or combined with standard deviation 
     1416 
    16591417        const float penaltyOld = EvalPvsPenalty((int)totalPvs, lowerPvsLimit, upperPvsLimit); 
    16601418    const float penaltyFront = EvalPvsPenalty((int)pvsFront, lowerPvsLimit, upperPvsLimit); 
     
    16671425 
    16681426        const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol; 
    1669         /* 
     1427         
    16701428        Debug << "\n==== eval render cost decrease ===" << endl 
    16711429                  << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl  
     
    16731431                  << "old rc: " << normalizedOldRenderCost << " new rc: " << newRenderCost / viewSpaceVol << endl 
    16741432                  << "render cost decrease: " << renderCostDecrease << endl; 
    1675 */ 
     1433 
    16761434        return renderCostDecrease; 
    16771435} 
     1436 
    16781437 
    16791438 
     
    16991458        for(rit = data.mRays->begin(); rit != rit_end; ++ rit) 
    17001459        { 
     1460                VssRay *ray = (*rit).mRay; 
     1461 
    17011462                // determine the side of this ray with respect to the plane 
    17021463                float t; 
    17031464                const int side = (*rit).ComputeRayIntersection(axis, position, t); 
    17041465         
    1705                 UpdateObjPvsContri((*rit).mRay->mTerminationObject, side, pvsFront, pvsBack, pvsTotal); 
    1706                 UpdateObjPvsContri((*rit).mRay->mOriginObject, side, pvsFront, pvsBack, pvsTotal); 
    1707         } 
     1466                UpdateContributionsToPvs(*ray, true, side, pvsFront, pvsBack, pvsTotal); 
     1467                UpdateContributionsToPvs(*ray, false, side, pvsFront, pvsBack, pvsTotal); 
     1468        } 
     1469 
    17081470 
    17091471        //-- evaluate cost heuristics 
    17101472 
    1711         float pOverall; 
    1712          
    1713         pOverall = data.mProbability; 
     1473        float pOverall = data.mProbability; 
    17141474 
    17151475        // we use spatial mid split => simplified computation 
     
    17281488 
    17291489 
    1730 void VspTree::UpdateObjPvsContri(Intersectable *obj, 
    1731                                                                 const int cf, 
    1732                                                                 float &frontPvs, 
    1733                                                                 float &backPvs, 
    1734                                                                 float &totalPvs) const 
     1490void VspTree::UpdateContributionsToPvs(Intersectable *obj, 
     1491                                                                          const int cf, 
     1492                                                                          float &frontPvs, 
     1493                                                                          float &backPvs, 
     1494                                                                          float &totalPvs) const 
    17351495{ 
    17361496        if (!obj) return; 
     
    17791539 
    17801540 
    1781 void VspTree::UpdateBvhLeafPvsContri(BvhLeaf *leaf, 
    1782                                                                          const int cf, 
    1783                                                                          float &frontPvs, 
    1784                                                                          float &backPvs, 
    1785                                                                          float &totalPvs) const 
     1541void VspTree::UpdateContributionsToPvs(BvhLeaf *leaf, 
     1542                                                                           const int cf, 
     1543                                                                           float &frontPvs, 
     1544                                                                           float &backPvs, 
     1545                                                                           float &totalPvs) const 
    17861546{ 
    17871547        if (!leaf) return; 
    1788 /* 
     1548 
    17891549        const int renderCost = (int)leaf->mObjects.size(); 
    17901550 
     
    18251585                                leaf->Mail(1); 
    18261586                } 
    1827         }*/ 
    1828 } 
    1829  
    1830  
    1831  
    1832 void VspTree::UpdateKdLeafPvsContri(KdLeaf *leaf, 
    1833                                                                         const int cf, 
    1834                                                                         float &frontPvs, 
    1835                                                                         float &backPvs, 
    1836                                                                         float &totalPvs) const 
     1587        } 
     1588} 
     1589 
     1590 
     1591 
     1592void VspTree::UpdateContributionsToPvs(KdLeaf *leaf, 
     1593                                                                           const int cf, 
     1594                                                                           float &frontPvs, 
     1595                                                                           float &backPvs, 
     1596                                                                           float &totalPvs) const 
    18371597{ 
    18381598        if (!leaf) return; 
     
    18471607        } 
    18481608 
    1849         // compute contribution of yet unclassified objects 
     1609        // recursivly update contributions of yet unclassified objects 
    18501610        ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 
    18511611 
    18521612        for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 
    18531613        {        
    1854                 UpdateObjPvsContri(*oit, cf, frontPvs, backPvs, totalPvs); 
     1614                UpdateContributionsToPvs(*oit, cf, frontPvs, backPvs, totalPvs); 
    18551615    }    
    18561616         
     
    22962056 
    22972057 
    2298 void VspTree::CollectPvs(const RayInfoContainer &rays,  
    2299                                                  ObjectContainer &objects) const 
    2300 { 
    2301         RayInfoContainer::const_iterator rit, rit_end = rays.end(); 
    2302  
    2303         Intersectable::NewMail(); 
    2304  
    2305         for (rit = rays.begin(); rit != rays.end(); ++ rit) 
    2306         { 
    2307                 VssRay *ray = (*rit).mRay; 
    2308  
    2309                 Intersectable *object; 
    2310                 object = ray->mOriginObject; 
    2311  
    2312         if (object) 
    2313                 { 
    2314                         if (!object->Mailed()) 
    2315                         { 
    2316                                 object->Mail(); 
    2317                                 objects.push_back(object); 
    2318                         } 
    2319                 } 
    2320  
    2321                 object = ray->mTerminationObject; 
    2322  
    2323                 if (object) 
    2324                 { 
    2325                         if (!object->Mailed()) 
    2326                         { 
    2327                                 object->Mail(); 
    2328                                 objects.push_back(object); 
    2329                         } 
    2330                 } 
    2331         } 
    2332 } 
    2333  
    2334  
    2335 int VspTree::EvalPvsContribution(const VssRay &ray, const bool isTermination) const 
    2336 {        
    2337         Intersectable *obj;  
    2338         Vector3 pt; 
    2339         KdNode *node; 
    2340  
    2341         ray.GetSampleData(isTermination, pt, &obj, &node); 
    2342  
    2343         if (!obj) return 0; 
    2344  
    2345         int pvs = 0; 
    2346  
    2347         switch(mHierarchyManager->GetObjectSpaceSubdivisonType()) 
    2348         { 
    2349         case HierarchyManager::NO_OBJ_SUBDIV: 
    2350                 { 
    2351                         if (!obj->Mailed()) 
    2352                         { 
    2353                                 obj->Mail(); 
    2354                                 ++ pvs; 
    2355                         } 
    2356  
    2357                         break; 
    2358                 } 
    2359         case HierarchyManager::KD_BASED_OBJ_SUBDIV: 
    2360                 { 
    2361                         KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 
    2362  
    2363                         if (!leaf->Mailed()) 
    2364                         { 
    2365                                 leaf->Mail(); 
    2366                                 pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 
    2367                                  
    2368                                 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 
    2369                                 for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 
    2370                                 { 
    2371                                         Intersectable *obj = *oit; 
    2372  
    2373                                         if (!obj->Mailed()) 
    2374                                         { 
    2375                                                 obj->Mail(); 
    2376                                                 ++ pvs; 
    2377                                         } 
    2378                                 } 
    2379                         } 
    2380  
    2381                         break; 
    2382                 } 
    2383         case HierarchyManager::BV_BASED_OBJ_SUBDIV: 
    2384                 { 
    2385                         BvhLeaf *bvhleaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
    2386  
    2387                         if (!bvhleaf->Mailed()) 
    2388                         { 
    2389                                 bvhleaf->Mail(); 
    2390                                 pvs += (int)bvhleaf->mObjects.size(); 
    2391                         } 
    2392  
    2393                         break; 
    2394                 } 
    2395         default: 
    2396                 break; 
    2397         } 
    2398  
    2399         return pvs; 
    2400 } 
    2401  
    2402  
    24032058int VspTree::EvalPvsSize(const RayInfoContainer &rays) const 
    24042059{ 
     
    24142069        { 
    24152070                VssRay *ray = (*rit).mRay; 
    2416                 pvsSize += EvalPvsContribution(*ray, true); 
    2417                 pvsSize += EvalPvsContribution(*ray, false); 
     2071 
     2072                pvsSize += EvalContributionToPvs(*ray, true); 
     2073                pvsSize += EvalContributionToPvs(*ray, false); 
    24182074        } 
    24192075         
     
    24302086int VspTree::CastLineSegment(const Vector3 &origin, 
    24312087                                                         const Vector3 &termination, 
    2432                              ViewCellContainer &viewcells) 
     2088                             ViewCellContainer &viewcells, 
     2089                                                         const bool useMailboxing) 
    24332090{ 
    24342091        int hits = 0; 
     
    24382095 
    24392096        stack<LineTraversalData> tStack; 
    2440  
    2441         //Intersectable::NewMail(); 
    2442         //ViewCell::NewMail(); 
    24432097 
    24442098        Vector3 entp = origin; 
     
    25032157                        ViewCell *vc = leaf->GetViewCell(); 
    25042158 
    2505                         // don't have to mail because each view cell belongs to exactly one leaf 
    2506                         //if (!vc->Mailed()) 
    2507                         //{ 
    2508                         //      vc->Mail(); 
     2159                        // don't have to mail if each view cell belongs to exactly one leaf 
     2160                        if (!useMailboxing || !vc->Mailed()) 
     2161                        { 
     2162                                if (useMailboxing) 
     2163                                        vc->Mail(); 
     2164 
    25092165                                viewcells.push_back(vc); 
    25102166                                ++ hits; 
    2511                         //} 
     2167                        } 
    25122168#if 0 
    25132169                        leaf->mRays.push_back(RayInfo(new VssRay(origin, termination, NULL, NULL, 0))); 
     
    29322588void VspTree::GetViewCells(const VssRay &ray, ViewCellContainer &viewCells) 
    29332589{ 
    2934 #if 1  
    2935         // use view cells manager to compute view cells 
    2936         VssRay vcRay(ray); 
    2937  
    2938         mViewCellsManager->ComputeSampleContribution(vcRay, false, true); 
    2939         viewCells = vcRay.mViewCells; 
    2940 #else 
    29412590        static Ray hray; 
    29422591        hray.Init(ray); 
     
    29502599        const Vector3 termination = hray.Extrap(tmax); 
    29512600 
    2952         // if no precomputation of view cells 
    2953         CastLineSegment(origin, termination, viewCells); 
    2954 #endif 
     2601        // view cells were not precomputed 
     2602        // don't mail because we need mailboxing for something else 
     2603        CastLineSegment(origin, termination, viewCells, false); 
    29552604} 
    29562605 
     
    30522701} 
    30532702 
    3054 } 
     2703 
     2704int VspTree::EvalMaxEventContribution(const VssRay &ray,  
     2705                                                                          const bool isTermination) const 
     2706{ 
     2707        Intersectable *obj; 
     2708        Vector3 pt; 
     2709        KdNode *node; 
     2710 
     2711        ray.GetSampleData(isTermination, pt, &obj, &node); 
     2712 
     2713        if (!obj)  
     2714                return 0; 
     2715 
     2716        int pvs = 0; 
     2717 
     2718        switch ( mHierarchyManager->GetObjectSpaceSubdivisonType()) 
     2719        { 
     2720        case HierarchyManager::NO_OBJ_SUBDIV: 
     2721                { 
     2722                        if (-- obj->mCounter == 0) 
     2723                                ++ pvs; 
     2724                        break; 
     2725                } 
     2726        case HierarchyManager::KD_BASED_OBJ_SUBDIV: 
     2727                { 
     2728                        KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 
     2729 
     2730                        // add contributions of the kd nodes 
     2731                        pvs += EvalMaxEventContribution(leaf); 
     2732                        break; 
     2733                } 
     2734        case HierarchyManager::BV_BASED_OBJ_SUBDIV: 
     2735                { 
     2736                        BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
     2737 
     2738                        if (-- leaf->mCounter == 0) 
     2739                                pvs += (int)leaf->mObjects.size(); 
     2740                        break; 
     2741                } 
     2742        default: 
     2743                break; 
     2744        } 
     2745 
     2746        return pvs; 
     2747} 
     2748 
     2749 
     2750int VspTree::PrepareHeuristics(const VssRay &ray, const bool isTermination) 
     2751{ 
     2752        int pvsSize = 0; 
     2753         
     2754        Intersectable *obj; 
     2755        Vector3 pt; 
     2756        KdNode *node; 
     2757 
     2758        ray.GetSampleData(isTermination, pt, &obj, &node); 
     2759 
     2760        if (!obj) 
     2761                return 0; 
     2762 
     2763        switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 
     2764        { 
     2765        case HierarchyManager::NO_OBJ_SUBDIV: 
     2766                { 
     2767                        if (!obj->Mailed()) 
     2768                        { 
     2769                                obj->Mail(); 
     2770                                obj->mCounter = 0; 
     2771 
     2772                                ++ pvsSize; 
     2773                        } 
     2774 
     2775                        ++ obj->mCounter;        
     2776                        break; 
     2777                } 
     2778        case HierarchyManager::KD_BASED_OBJ_SUBDIV: 
     2779                { 
     2780                        KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 
     2781                        pvsSize += PrepareHeuristics(leaf);      
     2782                        break; 
     2783                } 
     2784        case HierarchyManager::BV_BASED_OBJ_SUBDIV: 
     2785                { 
     2786                        BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
     2787 
     2788                        if (!leaf->Mailed()) 
     2789                        { 
     2790                                leaf->Mail(); 
     2791                                leaf->mCounter = 0; 
     2792 
     2793                                pvsSize += (int)leaf->mObjects.size(); 
     2794                        } 
     2795 
     2796                        ++ leaf->mCounter;       
     2797                        break; 
     2798                } 
     2799        default: 
     2800                break; 
     2801        } 
     2802 
     2803        return pvsSize; 
     2804} 
     2805 
     2806 
     2807int VspTree::EvalMinEventContribution(const VssRay &ray,  
     2808                                                                          const bool isTermination) const 
     2809{ 
     2810        Intersectable *obj; 
     2811        Vector3 pt; 
     2812        KdNode *node; 
     2813 
     2814        ray.GetSampleData(isTermination, pt, &obj, &node); 
     2815 
     2816        if (!obj) return 0; 
     2817 
     2818        int pvs = 0; 
     2819 
     2820        switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 
     2821        { 
     2822        case HierarchyManager::NO_OBJ_SUBDIV: 
     2823                { 
     2824                        if (!obj->Mailed()) 
     2825                        { 
     2826                                obj->Mail(); 
     2827                                ++ pvs; 
     2828                        } 
     2829                        break; 
     2830                } 
     2831        case HierarchyManager::KD_BASED_OBJ_SUBDIV: 
     2832                { 
     2833                        KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 
     2834                        // add contributions of the kd nodes 
     2835                        pvs += EvalMinEventContribution(leaf);                           
     2836                        break; 
     2837                } 
     2838        case HierarchyManager::BV_BASED_OBJ_SUBDIV: 
     2839                { 
     2840                        BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
     2841 
     2842                        if (!leaf->Mailed()) 
     2843                        { 
     2844                                leaf->Mail(); 
     2845                                pvs += (int)leaf->mObjects.size(); 
     2846                        } 
     2847                        break; 
     2848                } 
     2849        default: 
     2850                break; 
     2851        } 
     2852 
     2853        return pvs; 
     2854} 
     2855 
     2856 
     2857void VspTree::UpdateContributionsToPvs(const VssRay &ray, 
     2858                                                                           const bool isTermination, 
     2859                                                                           const int cf, 
     2860                                                                           float &frontPvs, 
     2861                                                                           float &backPvs, 
     2862                                                                           float &totalPvs) const 
     2863{ 
     2864        Intersectable *obj; 
     2865        Vector3 pt; 
     2866        KdNode *node; 
     2867 
     2868        ray.GetSampleData(isTermination, pt, &obj, &node); 
     2869 
     2870        if (!obj) return; 
     2871 
     2872        switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 
     2873        { 
     2874                case HierarchyManager::NO_OBJ_SUBDIV: 
     2875                { 
     2876                        // find front and back pvs for origing and termination object 
     2877                        UpdateContributionsToPvs(obj, cf, frontPvs, backPvs, totalPvs); 
     2878                        break; 
     2879                } 
     2880                case HierarchyManager::KD_BASED_OBJ_SUBDIV: 
     2881                { 
     2882                        KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 
     2883                        UpdateContributionsToPvs(leaf, cf, frontPvs, backPvs, totalPvs); 
     2884                        break; 
     2885                } 
     2886                case HierarchyManager::BV_BASED_OBJ_SUBDIV: 
     2887                { 
     2888                        BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
     2889                        UpdateContributionsToPvs(leaf, cf, frontPvs, backPvs, totalPvs); 
     2890                        break; 
     2891                } 
     2892        } 
     2893} 
     2894 
     2895 
     2896int VspTree::EvalContributionToPvs(const VssRay &ray,  
     2897                                                                   const bool isTermination) const 
     2898{        
     2899        Intersectable *obj;  
     2900        Vector3 pt; 
     2901        KdNode *node; 
     2902 
     2903        ray.GetSampleData(isTermination, pt, &obj, &node); 
     2904 
     2905        if (!obj)  
     2906                return 0; 
     2907 
     2908        int pvs = 0; 
     2909 
     2910        switch(mHierarchyManager->GetObjectSpaceSubdivisonType()) 
     2911        { 
     2912        case HierarchyManager::NO_OBJ_SUBDIV: 
     2913                { 
     2914                        if (!obj->Mailed()) 
     2915                        { 
     2916                                obj->Mail(); 
     2917                                ++ pvs; 
     2918                        } 
     2919                        break; 
     2920                } 
     2921        case HierarchyManager::KD_BASED_OBJ_SUBDIV: 
     2922                { 
     2923                        KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 
     2924 
     2925                        pvs += EvalContributionToPvs(leaf); 
     2926                        break; 
     2927                } 
     2928        case HierarchyManager::BV_BASED_OBJ_SUBDIV: 
     2929                { 
     2930                        BvhLeaf *bvhleaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
     2931 
     2932                        if (!bvhleaf->Mailed()) 
     2933                        { 
     2934                                bvhleaf->Mail(); 
     2935                                pvs += (int)bvhleaf->mObjects.size(); 
     2936                        } 
     2937                        break; 
     2938                } 
     2939        default: 
     2940                break; 
     2941        } 
     2942 
     2943        return pvs; 
     2944} 
     2945 
     2946 
     2947int VspTree::EvalContributionToPvs(KdLeaf *leaf) const 
     2948{ 
     2949        if (leaf->Mailed()) // leaf already mailed 
     2950                return 0; 
     2951 
     2952        leaf->Mail(); 
     2953 
     2954        int pvs = 0; 
     2955        pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 
     2956 
     2957        ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 
     2958 
     2959        for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 
     2960        { 
     2961                Intersectable *obj = *oit; 
     2962 
     2963                if (!obj->Mailed()) 
     2964                { 
     2965                        obj->Mail(); 
     2966                        ++ pvs; 
     2967                } 
     2968        } 
     2969 
     2970        return pvs; 
     2971} 
     2972 
     2973} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h

    r1289 r1291  
    548548    int CastLineSegment(const Vector3 &origin, 
    549549                                                const Vector3 &termination, 
    550                                                 ViewCellContainer &viewcells); 
     550                                                ViewCellContainer &viewcells, 
     551                                                const bool useMailboxing = true); 
    551552 
    552553                 
     
    618619        void GetViewCells(const VssRay &ray, ViewCellContainer &viewCells); 
    619620 
    620  
     621        /** Returns view cells tree. 
     622        */ 
    621623        ViewCellsTree *GetViewCellsTree() const { return mViewCellsTree; } 
    622624 
     625        /** Sets the view cells tree. 
     626        */ 
    623627        void SetViewCellsTree(ViewCellsTree *vt) { mViewCellsTree = vt; } 
    624628 
     
    763767        int EvalPvsSize(const RayInfoContainer &rays) const; 
    764768 
    765         /** Computes pvs increase with respect to the previous pvs for heuristics. 
    766         */ 
    767         int GetPvsIncr(Intersectable *object, const KdPvsMap &activeNodes); 
    768  
    769         /** Returns absolute pvs contribution of this object. 
    770         */ 
    771         int GetPvsContribution(Intersectable *object) const; 
    772  
    773769        /** Computes best cost for axis aligned planes. 
    774770        */ 
     
    778774                                                                  float &position); 
    779775 
     776 
     777 
     778        ////////////////////////////////////////// 
     779        // Helper function for computing heuristics 
     780 
    780781        /** Evaluates the contribution to left and right pvs at a visibility event ve. 
    781782                @param ve the visibility event 
     
    783784                @param rightPvs updates the right pvs 
    784785        */ 
    785         void EvalHeuristicsContribution( 
    786                 const SortableEntry &ve,  
    787                 int &pvsLeft,  
    788                 int &pvsRight) const; 
    789  
    790         /** Evaluates contribution of the ray to the left and right pvs. 
     786        void EvalHeuristics(const SortableEntry &ve, int &pvsLeft, int &pvsRight) const; 
     787 
     788        /** Evaluates contribution of min event to pvs 
    791789        */ 
    792790        int EvalMinEventContribution( 
    793791                const VssRay &ray, const bool isTermination) const; 
    794792 
     793        /** Evaluates contribution of max event to pvs 
     794        */ 
    795795        int EvalMaxEventContribution( 
    796796                const VssRay &ray, const bool isTermination) const; 
    797797 
     798        /** Evaluates contribution of kd leaf when encountering a min event 
     799        */ 
    798800        int EvalMinEventContribution(KdLeaf *leaf) const; 
     801        /**  Evaluates contribution of kd leaf when encountering a max event 
     802        */ 
    799803        int EvalMaxEventContribution(KdLeaf *leaf) const; 
    800804 
    801805        /** Prepares objects for the heuristics. 
    802                 @returns pvs size of the ray container 
     806                @returns pvs size as seen by the rays. 
    803807        */ 
    804808        int PrepareHeuristics(const RayInfoContainer &rays); 
     809         
     810        /** Prepare a single ray for heuristics. 
     811        */ 
    805812        int PrepareHeuristics(const VssRay &ray, const bool isTermination); 
     813        /** Prepare a single kd leaf for heuristics. 
     814        */ 
    806815        int PrepareHeuristics(KdLeaf *leaf); 
     816 
     817        ///////////////////////////////////////////////////////////////////////////// 
     818 
    807819 
    808820        /** Subdivides the rays into front and back rays according to the split plane. 
     
    831843         
    832844        */ 
    833         void UpdateObjPvsContri( 
     845        void UpdateContributionsToPvs( 
     846                const VssRay &ray, 
     847                const bool isTermination, 
     848                const int cf, 
     849                float &frontPvs, 
     850                float &backPvs, 
     851                float &totalPvs) const; 
     852 
     853        /** Evaluates the contribution for objects. 
     854        */ 
     855        void UpdateContributionsToPvs( 
    834856                Intersectable *obj,  
    835857                const int cf,  
     
    838860                float &totalPvs) const; 
    839861 
    840         void UpdateBvhLeafPvsContri( 
     862        /** Evaluates the contribution for bounding volume leaves. 
     863        */ 
     864        void UpdateContributionsToPvs( 
    841865                BvhLeaf *leaf, 
    842866                const int cf, 
     
    845869                float &totalPvs) const; 
    846870 
    847          
    848         /** See UpdateObjPvsContri.  
    849         */ 
    850         void UpdateKdLeafPvsContri(KdLeaf *leaf, 
     871        /** Evaluates the contribution for kd leaves. 
     872        */ 
     873        void UpdateContributionsToPvs( 
     874                KdLeaf *leaf, 
    851875                const int cf, 
    852876                float &frontPvs, 
     
    854878                float &totalPvs) const; 
    855879 
    856         /** Collects pvs from rays. 
    857         */ 
    858         void CollectPvs(const RayInfoContainer &rays, 
    859                                         ObjectContainer &objects) const; 
    860  
    861880        /** Returns true if tree can be terminated. 
    862881        */ 
     
    916935                RayInfoContainer &rays); 
    917936 
    918         /** Add pvs contribution of this ray. 
    919         */ 
    920         int EvalPvsContribution(const VssRay &ray, const bool isTermination) const; 
     937        /** Evaluates pvs contribution of this ray. 
     938        */ 
     939        int EvalContributionToPvs(const VssRay &ray, const bool isTermination) const; 
     940 
     941        /** Evaluates pvs contribution of a kd node. 
     942        */ 
     943        int EvalContributionToPvs(KdLeaf *leaf) const; 
     944 
    921945 
    922946protected: 
Note: See TracChangeset for help on using the changeset viewer.