Changeset 2199 for GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
- Timestamp:
- 03/07/07 16:26:58 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r2198 r2199 27 27 #define USE_VOLUMES_FOR_HEURISTICS 1 28 28 #define TEST_POWERPLANT 0 29 29 #define USE_BETTER_RENDERCOST_EST 0 30 30 31 //int BvhNode::sMailId = 10000; 31 32 //int BvhNode::sReservedMailboxes = 1; … … 172 173 } 173 174 } 175 176 174 177 175 178 /******************************************************************/ … … 673 676 // high avg ray contri, the result is influenced by undersampling 674 677 splitCandidate.SetAvgRayContribution(avgRayContri); 675 const float viewSpaceVol = 678 const float viewSpaceVol = GetViewSpaceVolume(); 676 679 677 680 const float oldVolume = EvalViewCellsVolume(leaf->mObjects) / viewSpaceVol; … … 1046 1049 Intersectable *obj = (*cit).mObject; 1047 1050 1048 const float renderCost = mViewCellsManager->EvalRenderCost(obj); 1051 #if USE_BETTER_RENDERCOST_EST 1052 const float renderCost = ViewCellsManager::EvalRenderCost(obj); 1049 1053 1050 1054 objectsLeft += renderCost; 1051 1055 objectsRight -= renderCost; 1052 1056 1057 const bool noValidSplit = ((objectsLeft <= Limits::Small) || (objectsRight <= Limits::Small)); 1058 1059 #else 1060 ++ objectsLeft; 1061 -- objectsRight; 1062 1063 const bool noValidSplit = !objectsLeft || !objectsRight; 1064 #endif 1053 1065 const AxisAlignedBox3 obox = obj->GetBox(); 1054 1066 … … 1070 1082 ar = rbox.SurfaceArea(); 1071 1083 1072 const bool noValidSplit = ((objectsLeft <= Limits::Small) || (objectsRight <= Limits::Small));1073 1084 const float sum = noValidSplit ? 1e25f : objectsLeft * al + objectsRight * ar; 1074 1085 … … 1317 1328 float volRight = totalVol; 1318 1329 1330 #if USE_BETTER_RENDERCOST_EST 1319 1331 const float nTotalObjects = EvalAbsCost(tData.mNode->mObjects); 1320 1332 float nObjectsLeft = 0; 1321 1333 float nObjectsRight = nTotalObjects; 1334 #else 1335 const int nTotalObjects = (int)EvalAbsCost(tData.mNode->mObjects); 1336 int nObjectsLeft = 0; 1337 int nObjectsRight = (int)nTotalObjects; 1338 #endif 1322 1339 1323 1340 const float viewSpaceVol = … … 1362 1379 EvalHeuristicsContribution(object, volLeft, volRight); 1363 1380 1364 const float rc = mViewCellsManager->EvalRenderCost(object); 1365 1381 #if USE_BETTER_RENDERCOST_EST 1382 1383 const float rc = ViewCellsManager::EvalRenderCost(object); 1384 1366 1385 nObjectsLeft += rc; 1367 1386 nObjectsRight -= rc; … … 1370 1389 const bool noValidSplit = ((nObjectsLeft <= Limits::Small) || 1371 1390 (nObjectsRight <= Limits::Small)); 1372 1391 #else 1392 ++ nObjectsLeft; 1393 -- nObjectsRight; 1394 1395 // split is only valid if #objects on left and right is not zero 1396 const bool noValidSplit = !nObjectsLeft || !nObjectsRight; 1397 1398 #endif 1399 1373 1400 // the heuristics 1374 1401 const float sum = noValidSplit ? … … 1378 1405 if (printStats) 1379 1406 { 1380 PrintHeuristics(nObjectsRight, sum, volLeft, volRight, viewSpaceVol, 1407 PrintHeuristics(nObjectsRight, sum, volLeft, 1408 volRight, viewSpaceVol, 1381 1409 sumStats, vollStats, volrStats); 1382 1410 } … … 1432 1460 void BvHierarchy::PrepareLocalSubdivisionCandidates(const BvhTraversalData &tData, 1433 1461 const int axis) 1434 {mSort2Timer.Entry(); 1462 { 1463 mSortTimer.Entry(); 1464 1435 1465 //-- insert object queries 1436 1466 ObjectContainer *objects = mUseGlobalSorting ? … … 1438 1468 1439 1469 CreateLocalSubdivisionCandidates(*objects, &mSubdivisionCandidates, !mUseGlobalSorting, axis); 1440 mSort2Timer.Exit(); 1470 1471 mSortTimer.Exit(); 1441 1472 } 1442 1473 … … 1466 1497 for (oit = objects.begin(); oit < oit_end; ++ oit) 1467 1498 { 1468 Intersectable *object = *oit; 1469 const AxisAlignedBox3 &box = object->GetBox(); 1470 const float midPt = (box.Min(axis) + box.Max(axis)) * 0.5f; 1471 1472 (*subdivisionCandidates)->push_back(SortableEntry(object, midPt)); 1499 (*subdivisionCandidates)->push_back(SortableEntry(*oit, (*oit)->GetBox().Center(axis))); 1473 1500 } 1474 1501 … … 1502 1529 const bool onlyUnmailed = true; 1503 1530 1504 const int numRays = CollectViewCells(tData.mNode->mObjects, 1505 viewCells, 1506 setCounter, 1507 onlyUnmailed); 1508 1509 //cout << "number of rays: " << numRays << endl; 1531 1532 CollectViewCells(tData.mNode->mObjects, 1533 viewCells, 1534 setCounter, 1535 onlyUnmailed); 1510 1536 1511 1537 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 1538 1512 1539 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 1513 1540 { … … 1520 1547 } 1521 1548 1522 // we will mail view cells switching to the back side1549 // mail view cells that go from front node to back node 1523 1550 ViewCell::NewMail(); 1524 1551 … … 1536 1563 // (also multiple times, if they are pierced by several rays) 1537 1564 ViewCellContainer viewCells; 1565 1538 1566 const bool useMailboxing = false; 1539 1540 CollectViewCells(obj, viewCells, useMailboxing, false, true); 1567 const bool setCounter = false; 1568 const bool onlyUnmailedRays = true; 1569 1570 CollectViewCells(obj, viewCells, useMailboxing, setCounter, onlyUnmailedRays); 1541 1571 1542 1572 // classify view cells and compute volume contri accordingly … … 1551 1581 // view cells can also be seen from left child node 1552 1582 ViewCell *viewCell = *vit; 1583 1553 1584 #if USE_VOLUMES_FOR_HEURISTICS 1554 1585 const float vol = viewCell->GetVolume(); … … 2248 2279 int nViewCells = 0; 2249 2280 2250 //ViewCell::NewMail();2281 ViewCell::NewMail(); 2251 2282 ObjectContainer::const_iterator oit, oit_end = objects.end(); 2252 2283
Note: See TracChangeset
for help on using the changeset viewer.