Ignore:
Timestamp:
11/23/05 18:29:41 (19 years ago)
Author:
mattausch
Message:

fixed vspkdtree rays bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r426 r428  
    3838int BspTree::sConstructionMethod = FROM_INPUT_VIEW_CELLS; 
    3939 
     40int BspTree::sFrontId = 0;  
     41int BspTree::sBackId = 0; 
     42int BspTree::sFrontAndBackId = 0; 
    4043 
    4144/****************************************************************/ 
     
    14201423} 
    14211424 
     1425inline void BspTree::GenerateUniqueIdsForPvs() 
     1426{ 
     1427        Intersectable::NewMail(); sBackId = ViewCell::sMailId; 
     1428        Intersectable::NewMail(); sFrontId = ViewCell::sMailId; 
     1429        Intersectable::NewMail(); sFrontAndBackId = ViewCell::sMailId; 
     1430} 
     1431 
    14221432float BspTree::SplitPlaneCost(const Plane3 &candidatePlane,  
    14231433                                                          const BoundedRayContainer &rays, 
     
    14451455        if (mSplitPlaneStrategy & PVS) 
    14461456        { 
    1447                 // create three unique ids for pvs heuristics 
    1448                 Intersectable::NewMail(); backId = ViewCell::sMailId; 
    1449                 Intersectable::NewMail(); frontId = ViewCell::sMailId; 
    1450                 Intersectable::NewMail(); frontAndBackId = ViewCell::sMailId; 
     1457                // create unique ids for pvs heuristics 
     1458                GenerateUniqueIdsForPvs(); 
    14511459 
    14521460                if (mPvsUseArea) // use front and back cell areas to approximate volume 
     
    14901498                if (mSplitPlaneStrategy & PVS) 
    14911499                { 
    1492                         if (!ray->intersections.empty()) 
    1493                         { 
    1494                                 // in case the ray intersects an objcrs 
    1495                                 // assure that we only count a object  
    1496                                 // once for the front and once for the back side of the plane 
    1497                                 IncPvs(*ray->intersections[0].mObject, frontPvs, backPvs,  
    1498                                            cf, frontId, backId, frontAndBackId); 
    1499                         } 
    1500  
    1501                         // the source object in the origin of the ray 
    1502                         if (ray->sourceObject.mObject) 
    1503                         { 
    1504                                 IncPvs(*ray->sourceObject.mObject, frontPvs, backPvs,  
    1505                                            cf, frontId, backId, frontAndBackId); 
    1506                         } 
    1507  
     1500                        // in case the ray intersects an object 
     1501                        // assure that we only count the object  
     1502                        // once for the front and once for the back side of the plane 
     1503                         
     1504                        // add the termination object 
     1505                        AddObjToPvs(ray->intersections[0].mObject, cf, frontPvs, backPvs); 
     1506                         
     1507                        // add the source object 
     1508                        AddObjToPvs(ray->sourceObject.mObject, cf, frontPvs, backPvs); 
     1509                         
    15081510                        if (!mPvsUseArea) // use front and back cell areas to approximate volume 
    15091511                        {        
     
    15841586} 
    15851587 
    1586 void BspTree::IncPvs(Intersectable &obj, 
    1587                                          int &frontPvs, 
    1588                                          int &backPvs, 
    1589                                          const int cf,  
    1590                                          const int frontId,  
    1591                                          const int backId,  
    1592                                          const int frontAndBackId) const 
    1593 { 
     1588void BspTree::AddObjToPvs(Intersectable *obj, 
     1589                                                  const int cf, 
     1590                                                  int &frontPvs, 
     1591                                                  int &backPvs) const 
     1592{ 
     1593        if (!obj) 
     1594                return; 
    15941595        // TODO: does this really belong to no pvs? 
    15951596        //if (cf == Ray::COINCIDENT) return; 
    15961597 
    1597         if (cf == Ray::FRONT) 
    1598         { 
    1599                 if ((obj.mMailbox != frontId) &&  
    1600                         (obj.mMailbox != frontAndBackId)) 
     1598        // object belongs to both PVS 
     1599        const bool bothSides = (cf == Ray::FRONT_BACK) ||  
     1600                                                   (cf == Ray::BACK_FRONT) || 
     1601                                                   (cf == Ray::COINCIDENT); 
     1602 
     1603        if ((cf == Ray::FRONT) || bothSides) 
     1604        { 
     1605                if ((obj->mMailbox != sFrontId) &&  
     1606                        (obj->mMailbox != sFrontAndBackId)) 
    16011607                { 
    16021608                        ++ frontPvs; 
    16031609 
    1604                         if (obj.mMailbox != backId) 
    1605                                 obj.mMailbox = frontId; 
     1610                        if (obj->mMailbox == sBackId) 
     1611                                obj->mMailbox = sFrontAndBackId;         
    16061612                        else 
    1607                                 obj.mMailbox = frontAndBackId;                                   
    1608                 } 
    1609         } 
    1610         else if (cf == Ray::BACK) 
    1611         { 
    1612                 if ((obj.mMailbox != backId) && 
    1613                         (obj.mMailbox != frontAndBackId)) 
     1613                                obj->mMailbox = sFrontId;                                                                
     1614                } 
     1615        } 
     1616         
     1617        if ((cf == Ray::BACK) || bothSides) 
     1618        { 
     1619                if ((obj->mMailbox != sBackId) && 
     1620                        (obj->mMailbox != sFrontAndBackId)) 
    16141621                { 
    16151622                        ++ backPvs; 
    16161623 
    1617                         if (obj.mMailbox != frontId) 
    1618                                 obj.mMailbox = backId; 
     1624                        if (obj->mMailbox == sFrontId) 
     1625                                obj->mMailbox = sFrontAndBackId;  
    16191626                        else 
    1620                                 obj.mMailbox = frontAndBackId;  
    1621                 } 
    1622         } 
    1623         // object belongs to both PVS 
    1624         else if ((cf == Ray::FRONT_BACK) || (cf == Ray::BACK_FRONT) ||(cf == Ray::COINCIDENT)) 
    1625         { 
    1626                 if (obj.mMailbox !=  frontAndBackId) 
    1627                 { 
    1628                         if (obj.mMailbox != frontId) 
    1629                                 ++ frontPvs; 
    1630                         if (obj.mMailbox != backId) 
    1631                                 ++ backPvs; 
    1632                  
    1633                         obj.mMailbox = frontAndBackId; 
     1627                                obj->mMailbox = sBackId;                                 
    16341628                } 
    16351629        } 
Note: See TracChangeset for help on using the changeset viewer.