Changeset 1576 for GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
- Timestamp:
- 10/05/06 18:51:15 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1571 r1576 369 369 370 370 // how often was max cost ratio missed in this branch? 371 frontData.mMaxCostMisses = sc. mMaxCostMisses;372 backData.mMaxCostMisses = sc. mMaxCostMisses;371 frontData.mMaxCostMisses = sc.GetMaxCostMisses(); 372 backData.mMaxCostMisses = sc.GetMaxCostMisses(); 373 373 374 374 // assign the objects in sorted order … … 475 475 const bool maxCostRatioViolated = mTermMaxCostRatio < ratio; 476 476 477 splitCandidate. mMaxCostMisses =maxCostRatioViolated ?477 splitCandidate.SetMaxCostMisses(maxCostRatioViolated ? 478 478 splitCandidate.mParentData.mMaxCostMisses + 1 : 479 splitCandidate.mParentData.mMaxCostMisses ;479 splitCandidate.mParentData.mMaxCostMisses); 480 480 481 481 const float oldProp = EvalViewCellsVolume(leaf->mObjects); … … 488 488 489 489 const float renderCostDecr = oldRenderCost - newRenderCost; 490 const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate); 490 491 491 492 #ifdef _DEBUG … … 494 495 Debug << "render cost decrease: " << renderCostDecr << endl; 495 496 #endif 497 496 498 splitCandidate.SetRenderCostDecrease(renderCostDecr); 499 splitCandidate.SetPvsEntriesIncr(EvalPvsEntriesIncr(splitCandidate)); 497 500 498 501 #if 1 … … 510 513 511 514 515 int BvHierarchy::EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate) const 516 { 517 const int oldPvsSize = CountViewCells(splitCandidate.mParentData.mNode->mObjects); 518 519 const int fPvsSize = CountViewCells(splitCandidate.mFrontObjects); 520 const int bPvsSize = CountViewCells(splitCandidate.mBackObjects); 521 522 return fPvsSize + bPvsSize - oldPvsSize; 523 } 524 525 512 526 inline bool BvHierarchy::LocalTerminationCriteriaMet(const BvhTraversalData &data) const 513 527 { … … 515 529 return ( 0 516 530 || ((int)data.mNode->mObjects.size() <= mTermMinObjects) 517 || (data.mProbability <= mTermMinProbability) 518 || (data.mDepth >= mTermMaxDepth) 519 || (data.mNumRays <= mTermMinRays) 531 //|| (data.mProbability <= mTermMinProbability) 532 //|| (data.mNumRays <= mTermMinRays) 520 533 ); 521 534 } … … 1063 1076 return vol; 1064 1077 } 1078 1065 1079 /////////////////////////////////////////////////////////// 1066 1080 … … 1289 1303 return 0.0f; 1290 1304 1291 //////////////// ////1305 //////////////// 1292 1306 //-- surface area heuristics 1293 1307 … … 1298 1312 } 1299 1313 else 1300 { /////////////// /////1314 { /////////////// 1301 1315 //-- render cost heuristics 1302 1316 1303 1317 const float viewSpaceVol = mViewCellsManager->GetViewSpaceBox().GetVolume(); 1318 1304 1319 // probability that view point lies in a view cell which sees this node 1305 1320 const float p = EvalViewCellsVolume(objects) / viewSpaceVol; … … 1404 1419 for (vit = tmpViewCells.begin(); vit != vit_end; ++ vit) 1405 1420 { 1406 VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit); 1421 //VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit); 1422 ViewCell *vc = *vit; 1407 1423 1408 1424 // store view cells … … 1426 1442 } 1427 1443 } 1444 } 1445 1446 1447 int BvHierarchy::CountViewCells(Intersectable *obj) const 1448 { 1449 int result = 0; 1450 1451 VssRayContainer::const_iterator rit, rit_end = obj->mVssRays.end(); 1452 1453 for (rit = obj->mVssRays.begin(); rit < rit_end; ++ rit) 1454 { 1455 VssRay *ray = (*rit); 1456 ViewCellContainer tmpViewCells; 1457 1458 mHierarchyManager->mVspTree->GetViewCells(*ray, tmpViewCells); 1459 1460 ViewCellContainer::const_iterator vit, vit_end = tmpViewCells.end(); 1461 for (vit = tmpViewCells.begin(); vit != vit_end; ++ vit) 1462 { 1463 ViewCell *vc = *vit; 1464 1465 // store view cells 1466 if (!vc->Mailed()) 1467 { 1468 vc->Mail(); 1469 ++ result; 1470 } 1471 } 1472 } 1473 1474 return result; 1475 } 1476 1477 1478 int BvHierarchy::CountViewCells(const ObjectContainer &objects) const 1479 { 1480 // no view cells yet 1481 if (mHierarchyManager->GetViewSpaceSubdivisionType() == 1482 HierarchyManager::NO_VIEWSPACE_SUBDIV) 1483 return 1; 1484 1485 int nViewCells = 0; 1486 1487 ViewCell::NewMail(); 1488 1489 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1490 1491 // loop through all object and collect view cell pvs of this node 1492 for (oit = objects.begin(); oit != oit_end; ++ oit) 1493 { 1494 nViewCells += CountViewCells(*oit); 1495 } 1496 1497 return nViewCells; 1428 1498 } 1429 1499
Note: See TracChangeset
for help on using the changeset viewer.