Changeset 1664 for GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
- Timestamp:
- 10/23/06 01:36:17 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1663 r1664 25 25 #define PROBABILIY_IS_BV_VOLUME 1 26 26 #define USE_FIXEDPOINT_T 0 27 28 27 #define USE_VOLUMES_FOR_HEURISTICS 1 29 30 #define CONSIDER_MEMORY 131 28 32 29 int BvhNode::sMailId = 10000; //2147483647; … … 429 426 430 427 // create new interior node and two leaf node 431 currentNode = SubdivideNode( 432 *sc, 433 tFrontData, 434 tBackData); 428 currentNode = SubdivideNode(*sc, tFrontData, tBackData); 435 429 436 430 // decrease the weighted average cost of the subdivisoin … … 457 451 tBackData.mNode->SetSubdivisionCandidate(backCandidate); 458 452 453 //cout << "f: " << frontCandidate->GetPriority() << " b: " << backCandidate->GetPriority() << endl; 459 454 tQueue.Push(frontCandidate); 460 455 tQueue.Push(backCandidate); … … 466 461 if (currentNode->IsLeaf()) 467 462 { 468 ///////////////////// /////////////////463 ///////////////////// 469 464 //-- store additional info 470 465 EvaluateLeafStats(tData); … … 530 525 #endif 531 526 532 #if 1533 527 float priority; 534 528 535 529 if (mHierarchyManager->GetViewSpaceSubdivisionType() == 536 530 HierarchyManager::NO_VIEWSPACE_SUBDIV) … … 551 545 // take render cost of node into account 552 546 // otherwise danger of being stuck in a local minimum!! 553 #if CONSIDER_MEMORY 554 const float priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr(); 555 #else 556 const float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 557 #endif 558 } 559 560 #else 561 const float priority = (float)-splitCandidate.mParentData.mDepth; 562 #endif 547 if (mHierarchyManager->mConsiderMemory) 548 { 549 //cout << "here7 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 550 //priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr();// / mBvhStats.Leaves(); 551 priority = renderCostDecr / ((float)splitCandidate.GetPvsEntriesIncr() + 1.0f); 552 } 553 else 554 { 555 priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 556 } 557 } 558 559 // compute global decrease in render cost 560 splitCandidate.SetPriority(priority); 561 } 562 563 564 float BvHierarchy::EvalPriority(const BvhSubdivisionCandidate &splitCandidate) const 565 { 566 BvhLeaf *leaf = splitCandidate.mParentData.mNode; 567 568 const float oldRenderCost = EvalRenderCost(leaf->mObjects); 563 569 564 570 // compute global decrease in render cost 565 splitCandidate.SetPriority(priority); 566 } 567 568 569 float BvHierarchy::EvalPriority(const BvhSubdivisionCandidate &splitCandidate) const 570 { 571 BvhLeaf *leaf = splitCandidate.mParentData.mNode; 572 573 const float oldRenderCost = EvalRenderCost(leaf->mObjects); 574 575 // compute global decrease in render cost 576 const float newRenderCost = 577 EvalRenderCost(splitCandidate.mFrontObjects) + 578 EvalRenderCost(splitCandidate.mBackObjects); 571 const float newRenderCost = EvalRenderCost(splitCandidate.mFrontObjects) + 572 EvalRenderCost(splitCandidate.mBackObjects); 579 573 580 574 const float renderCostDecr = oldRenderCost - newRenderCost; … … 586 580 #endif 587 581 588 #if 1589 582 // take render cost of node into account 590 583 // otherwise danger of being stuck in a local minimum!! 591 584 const float factor = mRenderCostDecreaseWeight; 585 586 float priority; 587 592 588 // $$ matt temp 593 #if CONSIDER_MEMORY 594 const float priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr(); 595 #else 596 const float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 597 #endif 598 #else 599 const float priority = (float)-splitCandidate.mParentData.mDepth; 600 #endif 589 if (mHierarchyManager->mConsiderMemory) 590 { 591 //cout << "here5 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 592 //const float priority = factor * renderCostDecr - (1.0f - factor) * (float)splitCandidate.GetPvsEntriesIncr(); 593 priority = renderCostDecr / ((float)splitCandidate.GetPvsEntriesIncr() + 1.0f); 594 } 595 else 596 { 597 priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 598 } 601 599 602 600 return priority; … … 620 618 || ((int)data.mNode->mObjects.size() <= mTermMinObjects) 621 619 //|| (data.mProbability <= mTermMinProbability) 622 //|| (data.mNumRays <= mTermMinRays)620 || (data.mNumRays <= mTermMinRays) 623 621 ); 624 622 } … … 952 950 cout << "\n\nobjects=(" << (int)objectsBack.size() << "," << (int)objectsFront.size() << " of " 953 951 << (int)tData.mNode->mObjects.size() << ")\t area=(" 954 << areaLeft << "," << areaRight << ")" << endl ;955 cout<< "cost= " << minSum << endl;952 << areaLeft << "," << areaRight << ")" << endl 953 << "cost= " << minSum << endl; 956 954 #endif 955 957 956 return ratio; 958 957 }
Note: See TracChangeset
for help on using the changeset viewer.