Changeset 1667 for GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
- Timestamp:
- 10/23/06 20:24:14 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1666 r1667 411 411 const bool globalCriteriaMet) 412 412 { 413 BvhSubdivisionCandidate *sc = 414 dynamic_cast<BvhSubdivisionCandidate *>(splitCandidate); 413 BvhSubdivisionCandidate *sc = dynamic_cast<BvhSubdivisionCandidate *>(splitCandidate); 415 414 BvhTraversalData &tData = sc->mParentData; 416 415 … … 439 438 //-- push the new split candidates on the queue 440 439 441 BvhSubdivisionCandidate *frontCandidate = 442 new BvhSubdivisionCandidate(tFrontData); 443 BvhSubdivisionCandidate *backCandidate = 444 new BvhSubdivisionCandidate(tBackData); 440 BvhSubdivisionCandidate *frontCandidate = new BvhSubdivisionCandidate(tFrontData); 441 BvhSubdivisionCandidate *backCandidate = new BvhSubdivisionCandidate(tBackData); 445 442 446 443 EvalSubdivisionCandidate(*frontCandidate); … … 485 482 486 483 487 void BvHierarchy::EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitCandidate) 488 { 489 // compute best object partition 490 const float ratio = SelectObjectPartition( 491 splitCandidate.mParentData, 492 splitCandidate.mFrontObjects, 493 splitCandidate.mBackObjects); 494 484 void BvHierarchy::EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitCandidate, 485 bool computeSplitPlane) 486 { 487 if (computeSplitPlane) 488 { 489 // compute best object partition 490 const float ratio = SelectObjectPartition(splitCandidate.mParentData, 491 splitCandidate.mFrontObjects, 492 splitCandidate.mBackObjects); 493 494 // cost ratio violated? 495 const bool maxCostRatioViolated = mTermMaxCostRatio < ratio; 496 497 const int previousMisses = splitCandidate.mParentData.mMaxCostMisses; 498 499 splitCandidate.SetMaxCostMisses(maxCostRatioViolated ? 500 previousMisses + 1 : previousMisses); 501 502 } 503 495 504 BvhLeaf *leaf = splitCandidate.mParentData.mNode; 496 497 // cost ratio violated?498 const bool maxCostRatioViolated = mTermMaxCostRatio < ratio;499 500 const int previousMisses = splitCandidate.mParentData.mMaxCostMisses;501 502 splitCandidate.SetMaxCostMisses(maxCostRatioViolated ?503 previousMisses + 1 : previousMisses);504 505 505 506 const float oldProp = EvalViewCellsVolume(leaf->mObjects); … … 507 508 508 509 // compute global decrease in render cost 509 const float newRenderCost = 510 EvalRenderCost(splitCandidate.mFrontObjects) + 511 EvalRenderCost(splitCandidate.mBackObjects); 510 const float newRenderCost = EvalRenderCost(splitCandidate.mFrontObjects) + 511 EvalRenderCost(splitCandidate.mBackObjects); 512 512 513 513 const float renderCostDecr = oldRenderCost - newRenderCost; … … 527 527 float priority; 528 528 529 // surface area heuristics is used when there is no view space subdivision available. 530 // In order to have some prioritized traversal, use this formula instead 529 531 if (mHierarchyManager->GetViewSpaceSubdivisionType() == 530 532 HierarchyManager::NO_VIEWSPACE_SUBDIV) … … 541 543 else 542 544 { 545 // take render cost of node into account 546 // otherwise danger of being stuck in a local minimum! 543 547 const float factor = mRenderCostDecreaseWeight; 544 545 548 priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 546 549 547 // take render cost of node into account 548 // otherwise danger of being stuck in a local minimum!! 549 if (mHierarchyManager->mConsiderMemory) 550 { 551 //cout << "here7 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 552 //priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr();// / mBvhStats.Leaves(); 550 if (1)//0 && mHierarchyManager->mConsiderMemory) 551 { 553 552 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst); 554 553 } … … 557 556 // compute global decrease in render cost 558 557 splitCandidate.SetPriority(priority); 559 }560 561 562 float BvHierarchy::EvalPriority(const BvhSubdivisionCandidate &splitCandidate) const563 {564 BvhLeaf *leaf = splitCandidate.mParentData.mNode;565 566 const float oldRenderCost = EvalRenderCost(leaf->mObjects);567 568 // compute global decrease in render cost569 const float newRenderCost = EvalRenderCost(splitCandidate.mFrontObjects) +570 EvalRenderCost(splitCandidate.mBackObjects);571 572 const float renderCostDecr = oldRenderCost - newRenderCost;573 574 #ifdef _DEBUG575 Debug << "old render cost: " << oldRenderCost << endl;576 Debug << "new render cost: " << newRenderCost << endl;577 Debug << "render cost decrease: " << renderCostDecr << endl;578 #endif579 580 // take render cost of node into account581 // otherwise danger of being stuck in a local minimum!!582 const float factor = mRenderCostDecreaseWeight;583 584 float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost;585 586 // $$ matt temp587 if (mHierarchyManager->mConsiderMemory)588 {589 //cout << "here5 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl;590 //const float priority = factor * renderCostDecr - (1.0f - factor) * (float)splitCandidate.GetPvsEntriesIncr();591 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst);592 }593 594 return priority;595 558 } 596 559
Note: See TracChangeset
for help on using the changeset viewer.