Changeset 428 for trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
- Timestamp:
- 11/23/05 18:29:41 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r426 r428 38 38 int BspTree::sConstructionMethod = FROM_INPUT_VIEW_CELLS; 39 39 40 int BspTree::sFrontId = 0; 41 int BspTree::sBackId = 0; 42 int BspTree::sFrontAndBackId = 0; 40 43 41 44 /****************************************************************/ … … 1420 1423 } 1421 1424 1425 inline void BspTree::GenerateUniqueIdsForPvs() 1426 { 1427 Intersectable::NewMail(); sBackId = ViewCell::sMailId; 1428 Intersectable::NewMail(); sFrontId = ViewCell::sMailId; 1429 Intersectable::NewMail(); sFrontAndBackId = ViewCell::sMailId; 1430 } 1431 1422 1432 float BspTree::SplitPlaneCost(const Plane3 &candidatePlane, 1423 1433 const BoundedRayContainer &rays, … … 1445 1455 if (mSplitPlaneStrategy & PVS) 1446 1456 { 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(); 1451 1459 1452 1460 if (mPvsUseArea) // use front and back cell areas to approximate volume … … 1490 1498 if (mSplitPlaneStrategy & PVS) 1491 1499 { 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 1508 1510 if (!mPvsUseArea) // use front and back cell areas to approximate volume 1509 1511 { … … 1584 1586 } 1585 1587 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 { 1588 void BspTree::AddObjToPvs(Intersectable *obj, 1589 const int cf, 1590 int &frontPvs, 1591 int &backPvs) const 1592 { 1593 if (!obj) 1594 return; 1594 1595 // TODO: does this really belong to no pvs? 1595 1596 //if (cf == Ray::COINCIDENT) return; 1596 1597 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)) 1601 1607 { 1602 1608 ++ frontPvs; 1603 1609 1604 if (obj .mMailbox != backId)1605 obj .mMailbox = frontId;1610 if (obj->mMailbox == sBackId) 1611 obj->mMailbox = sFrontAndBackId; 1606 1612 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)) 1614 1621 { 1615 1622 ++ backPvs; 1616 1623 1617 if (obj .mMailbox != frontId)1618 obj .mMailbox = backId;1624 if (obj->mMailbox == sFrontId) 1625 obj->mMailbox = sFrontAndBackId; 1619 1626 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; 1634 1628 } 1635 1629 }
Note: See TracChangeset
for help on using the changeset viewer.