Changeset 1294 for GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
- Timestamp:
- 08/29/06 17:34:19 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1293 r1294 213 213 Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.minGlobalCostRatio", 214 214 mTermMinGlobalCostRatio); 215 Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 215 Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.globalCostMissTolerance", 216 mTermGlobalCostMissTolerance); 216 217 217 218 //-- factors for bsp tree split plane heuristics … … 285 286 // add the new nodes to the tree 286 287 BvhInterior *node = new BvhInterior(tData.mBoundingBox, leaf->GetParent()); 287 //cout << "bbox: " << tData.mBoundingBox << endl; 288 288 289 289 290 290 //-- the front and back traversal data is filled with the new values … … 292 292 frontData.mDepth = backData.mDepth = tData.mDepth + 1; 293 293 294 frontData.mBoundingBox = ComputeBoundingBox(frontObjects, & (tData.mBoundingBox));295 backData.mBoundingBox = ComputeBoundingBox(backObjects, & (tData.mBoundingBox));294 frontData.mBoundingBox = ComputeBoundingBox(frontObjects, &tData.mBoundingBox); 295 backData.mBoundingBox = ComputeBoundingBox(backObjects, &tData.mBoundingBox); 296 296 297 297 ///////////// … … 354 354 if (!LocalTerminationCriteriaMet(tData) && !globalCriteriaMet) 355 355 { 356 //-- continue subdivision 357 356 358 BvhTraversalData tFrontData; 357 359 BvhTraversalData tBackData; 358 359 //-- continue subdivision 360 360 361 361 // create new interior node and two leaf node 362 362 newNode = SubdivideNode(sc->mFrontObjects, … … 392 392 393 393 // delete old leaf node 394 DEL_PTR(tData.mNode);394 //DEL_PTR(tData.mNode); 395 395 } 396 396 … … 409 409 CollectRays(leaf->mObjects, leaf->mVssRays); 410 410 } 411 } 412 413 tData.Clear(); // cleanup 411 412 // detach node so it won't get deleted 413 tData.mNode = NULL; 414 } 414 415 415 416 return newNode; … … 447 448 const float renderCostDecr = oldRenderCost - newRenderCost; 448 449 449 //Debug << "render cost decr: " << renderCostDecr << endl;450 Debug << "\nbvh render cost decr: " << renderCostDecr << endl; 450 451 splitCandidate.SetRenderCostDecrease(renderCostDecr); 451 452 452 #if 0453 const float priority = (float)- data.mDepth;453 #if 1 454 const float priority = (float)-splitCandidate.mParentData.mDepth; 454 455 #else 455 456 // take render cost of node into account … … 469 470 // matt: TODO 470 471 return ( 0 471 || (data.mNode->mObjects.size() < mTermMinObjects)472 || (data.mProbability <= mTermMinProbability)473 || (data.mDepth >= mTermMaxDepth)472 //|| ((int)data.mNode->mObjects.size() < mTermMinObjects) 473 //|| (data.mProbability <= mTermMinProbability) 474 //|| (data.mDepth >= mTermMaxDepth) 474 475 ); 475 476 } … … 536 537 AxisAlignedBox3 box = obj->GetBox(); 537 538 538 const float objMid = (box.Max(axis) + box.Min(axis)) * 0.5 ;539 const float objMid = (box.Max(axis) + box.Min(axis)) * 0.5f; 539 540 540 541 // object mailed => belongs to back objects … … 936 937 937 938 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 938 Debug << "\n***** eval render cost *********\n"939 /*Debug << "\nbvh render cost\n" 939 940 << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol << endl 940 << "new rc: " << newRenderCost / viewSpaceVol << endl; 941 << "new rc: " << newRenderCost / viewSpaceVol << endl;*/ 941 942 942 943 … … 1319 1320 } 1320 1321 1322 void BvHierarchy::CreateRoot(const ObjectContainer &objects) 1323 { 1324 //-- create new root 1325 AxisAlignedBox3 box = ComputeBoundingBox(objects); 1326 BvhLeaf *bvhleaf = new BvhLeaf(box, NULL, (int)objects.size()); 1327 bvhleaf->mObjects = objects; 1328 1329 mRoot = bvhleaf; 1330 1331 // associate root with current objects 1332 AssociateObjectsWithLeaf(bvhleaf); 1333 } 1334 1321 1335 1322 1336 SubdivisionCandidate *BvHierarchy::PrepareConstruction(const VssRayContainer &sampleRays, 1323 const ObjectContainer &objects 1324 //,AxisAlignedBox3 *forcedObjectSpace 1325 ) 1337 const ObjectContainer &objects) 1326 1338 { 1327 1339 // note matt: we assume that we have objects sorted by their id … … 1332 1344 1333 1345 // compute bounding box from objects 1334 mBoundingBox = ComputeBoundingBox(objects); 1346 // we assume that root was already created 1347 mBoundingBox = mRoot->GetBoundingBox(); 1348 BvhLeaf *bvhleaf = dynamic_cast<BvhLeaf *>(mRoot); 1335 1349 1336 1350 mTermMinProbability *= mBoundingBox.GetVolume(); 1337 1351 mGlobalCostMisses = 0; 1338 1352 1339 //-- create new root1340 1341 BvhLeaf *bvhleaf = new BvhLeaf(mBoundingBox, NULL, (int)objects.size());1342 bvhleaf->mObjects = objects;1343 mRoot = bvhleaf;1344 1345 1353 // only rays intersecting objects in node are interesting 1346 1354 AssociateObjectsWithRays(sampleRays); 1347 // associate root with current objects 1348 AssociateObjectsWithLeaf(bvhleaf); 1349 1350 //-- add first candidate for object space partition 1351 1355 1356 1352 1357 // probabilty is voume of all "seen" view cells 1353 1358 #if 1 1354 const float prop = EvalViewCellsVolume( bvhleaf->mObjects);1359 const float prop = EvalViewCellsVolume(objects); 1355 1360 #else 1356 1361 const float prop = GetBoundingBox().GetVolume(); … … 1360 1365 BvhTraversalData oData(bvhleaf, 0, mBoundingBox, prop); 1361 1366 1362 //-- first split candidate1367 //-- add first candidate for object space partition 1363 1368 BvhSubdivisionCandidate *oSubdivisionCandidate = 1364 1369 new BvhSubdivisionCandidate(oData);
Note: See TracChangeset
for help on using the changeset viewer.