Changeset 1302 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 08/30/06 21:54:49 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1298 r1302 29 29 int BvhNode::sReservedMailboxes = 1; 30 30 31 32 31 BvHierarchy *BvHierarchy::BvhSubdivisionCandidate::sBvHierarchy = NULL; 33 34 32 35 33 … … 85 83 86 84 BvhLeaf::BvhLeaf(const AxisAlignedBox3 &bbox): 87 BvhNode(bbox) 85 BvhNode(bbox), mSubdivisionCandidate(NULL) 88 86 { 89 87 } … … 430 428 431 429 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 432 const float oldRenderCost = 433 splitCandidate.mParentData.mProbability * (float)leaf->mObjects.size() / viewSpaceVol; 430 const float oldProp = EvalViewCellsVolume(leaf->mObjects); 431 const float oldProp2 = splitCandidate.mParentData.mProbability; //Debug << "here8 " << (oldProp - oldProp2) / viewSpaceVol << " " << oldProp / viewSpaceVol << " " << oldProp2 / viewSpaceVol << endl; 432 433 const float oldRenderCost = oldProp * (float)leaf->mObjects.size() / viewSpaceVol; 434 434 435 435 // compute global decrease in render cost 436 436 float newRenderCost = EvalRenderCost(splitCandidate.mParentData, 437 splitCandidate.mFrontObjects, 437 splitCandidate.mFrontObjects, 438 438 splitCandidate.mBackObjects); 439 439 … … 445 445 splitCandidate.SetRenderCostDecrease(renderCostDecr); 446 446 447 #if 0447 #if 1 448 448 const float priority = (float)-splitCandidate.mParentData.mDepth; 449 449 #else … … 452 452 const float factor = mRenderCostDecreaseWeight; 453 453 const float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 454 455 454 #endif 456 455 … … 476 475 return (0 477 476 || (mBvhStats.Leaves() >= mTermMaxLeaves) 478 || (mGlobalCostMisses >= mTermGlobalCostMissTolerance)477 //|| (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 479 478 //|| mOutOfMemory 480 479 ); … … 574 573 } 575 574 576 const float oldRenderCost = tData.mProbability * (float)tData.mNode->mObjects.size(); 577 const float newRenderCost = 578 EvalRenderCost(tData, objectsFront, objectsBack); 575 const float oldProp = EvalViewCellsVolume(tData.mNode->mObjects); 576 //const float oldProp2 = tData.mProbability; Debug << "here65 " << oldProp - oldProp2 << endl; 577 578 const float oldRenderCost = oldProp * (float)tData.mNode->mObjects.size(); 579 const float newRenderCost = EvalRenderCost(tData, objectsFront, objectsBack); 579 580 580 581 const float ratio = newRenderCost / oldRenderCost; … … 960 961 961 962 //-- pvs rendering heuristics 962 const float newRenderCost = nObjectsFront * pFront + 963 nObjectsBack * pBack; 964 963 const float newRenderCost = nObjectsFront * pFront + nObjectsBack * pBack; 964 /* 965 965 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 966 /*Debug << "\nbvh render cost\n"966 Debug << "\nbvh render cost\n" 967 967 << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol << endl 968 968 << "new rc: " << newRenderCost / viewSpaceVol << endl;*/ 969 970 969 971 970 return newRenderCost; … … 1100 1099 1101 1100 Debug << "collecting " << (int)viewCells.size() << " dirty candidates" << endl; 1101 1102 1102 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 1103 1103 { … … 1105 1105 VspLeaf *leaf = vc->mLeaf; 1106 1106 SubdivisionCandidate *candidate = leaf->GetSubdivisionCandidate(); 1107 Debug << "here100 candidate: " << candidate << " type: " << candidate->Type() << endl; 1107 1108 1108 1109 dirtyList.push_back(leaf->GetSubdivisionCandidate()); … … 1301 1302 1302 1303 // compute bounding box from objects 1303 // we assume that root was already created1304 // note: we assume that root was already created 1304 1305 mBoundingBox = mRoot->GetBoundingBox(); 1305 1306 BvhLeaf *bvhleaf = dynamic_cast<BvhLeaf *>(mRoot); … … 1311 1312 AssociateObjectsWithRays(sampleRays); 1312 1313 1313 1314 1314 // probabilty is voume of all "seen" view cells 1315 1315 #if 1 … … 1326 1326 new BvhSubdivisionCandidate(oData); 1327 1327 1328 //UpdateViewCellsPvs(kdleaf, rays);1329 1330 1328 EvalSubdivisionCandidate(*oSubdivisionCandidate); 1329 bvhleaf->SetSubdivisionCandidate(oSubdivisionCandidate); 1331 1330 1332 1331 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1297 r1302 35 35 class VspTree; 36 36 class ViewCellsContainer; 37 class BvhSubdivisionCandidate;37 //class BvhSubdivisionCandidate; 38 38 39 39 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1298 r1302 232 232 || (mHierarchyStats.Leaves() >= mTermMaxLeaves) 233 233 //|| (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 234 //|| candidate->GlobalTerminationCriteriaMet()234 || candidate->GlobalTerminationCriteriaMet() 235 235 ); 236 236 } … … 269 269 *objectSpaceRays); 270 270 271 272 271 cout << "Constructing view space / object space tree ... \n"; 273 272 const long startTime = GetTime(); 274 273 275 274 const bool repairQueue = true; 275 //const bool repairQueue = false; 276 276 277 // process object space candidates 277 278 RunConstruction(repairQueue); 278 279 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 279 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 280 280 281 281 mVspTree->mVspStats.Stop(); … … 424 424 if (repair) RepairQueue(); 425 425 426 cout<< "candidate: " << mCurrentCandidate->Type() << ", priority: "427 << mCurrentCandidate->GetPriority() << endl;428 } 429 426 Debug << "candidate: " << mCurrentCandidate->Type() << ", priority: " 427 << mCurrentCandidate->GetPriority() << endl; 428 } 429 430 430 DEL_PTR(mCurrentCandidate); 431 431 } … … 457 457 458 458 mBvHierarchy->CollectDirtyCandidates(sc, dirtyList); 459 460 sc->mParentData.mNode->SetSubdivisionCandidate(NULL); // HACK 459 461 break; 460 462 } … … 471 473 472 474 mVspTree->CollectDirtyCandidates(sc, dirtyList); 475 476 sc->mParentData.mNode->SetSubdivisionCandidate(NULL); // HACK 473 477 } 474 478 475 479 476 480 void HierarchyManager::CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList) 477 { 481 { 478 482 // we have either a object space or view space split 479 483 if (mCurrentCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) 480 484 { 485 Debug << "collecting candidates after view space split" << endl; 481 486 CollectViewSpaceDirtyList(dirtyList); 482 487 } 483 488 else // object space split 484 { 489 { Debug << "collecting candidates after object space split" << endl; 485 490 CollectObjectSpaceDirtyList(dirtyList); 486 491 } … … 509 514 // collect list of "dirty" candidates 510 515 vector<SubdivisionCandidate *> dirtyList; 516 Debug << "collecting dirty candidates" << endl; 511 517 CollectDirtyCandidates(dirtyList); 512 518 513 519 //-- reevaluate the dirty list 514 520 vector<SubdivisionCandidate *>::const_iterator sit, sit_end = dirtyList.end(); 521 522 Debug << "collected " << (int)dirtyList.size() << " candidates" << endl; 515 523 516 524 for (sit = dirtyList.begin(); sit != sit_end; ++ sit) 517 525 { 518 526 SubdivisionCandidate* sc = *sit; 519 // erase from queue 520 mTQueue.Erase(sc); 521 // reevaluate 522 sc->EvalPriority(); 523 // reinsert 524 mTQueue.Push(sc); 527 float rcd = sc->GetRenderCostDecrease(); 528 Debug << "here6 " << rcd << endl; 529 Debug << "here84 " << endl; 530 Debug << "here7 " << sc << endl; 531 Debug << "here90 " << sc->GetPosition() << endl; 532 Debug << "here91 " << sc->Type() << endl; 533 //Debug << "here1191" << sc->Type() << endl; 534 //Debug << "sc: " << sc << " " << sc->GetPosition() << " " << sc->Type() << endl; 535 536 Debug << "here11" << endl; 537 mTQueue.Erase(sc); // erase from queue 538 Debug << "here2" << endl; 539 540 sc->EvalPriority(); // reevaluate 541 542 /* cout << "render cost decrease diff " << rcd - sc->GetRenderCostDecrease() 543 << " old: " << rcd << " new " << sc->GetRenderCostDecrease() 544 << " type " << sc->Type() << endl;*/ 545 546 mTQueue.Push(sc); // reinsert 525 547 } 526 548 } -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
r1299 r1302 521 521 // use a small box outside of the scene 522 522 box.Scale(Vector3(0.1f,0.5f,0.5f)); 523 box.Translate(Vector3(Magnitude(mKdTree->GetBox().Size())*0.5 , 0, 0));523 box.Translate(Vector3(Magnitude(mKdTree->GetBox().Size())*0.5f, 0, 0)); 524 524 } else { 525 525 float s = box.Size(0); … … 692 692 GenerateRays(mRssSamplesPerPass*ratios[0], RSS_BASED_DISTRIBUTION, rays); 693 693 694 rays.NormalizePdf(( int)rays.size());694 rays.NormalizePdf((float)rays.size()); 695 695 696 696 CastRays(rays, tmpVssRays); … … 702 702 #endif 703 703 times[0] = TimeDiff(t1, GetTime()); 704 nrays[0] = rays.size();704 nrays[0] = (int)rays.size(); 705 705 706 706 mStats<<"#RssRelContrib"<<endl<<contributions[0]/nrays[0]<<endl; … … 713 713 GenerateRays(mRssSamplesPerPass*ratios[1], SPATIAL_BOX_BASED_DISTRIBUTION, rays); 714 714 CastRays(rays, tmpVssRays); 715 castRays += rays.size();715 castRays += (int)rays.size(); 716 716 #if ADD_RAYS_IN_PLACE 717 717 contributions[1] = mViewCellsManager->ComputeSampleContributions(tmpVssRays, true, false); … … 720 720 #endif 721 721 times[1] = TimeDiff(t1, GetTime()); 722 nrays[1] = rays.size();722 nrays[1] = (int)rays.size(); 723 723 724 724 mStats<<"#SpatialRelContrib"<<endl<<contributions[1]/nrays[1]<<endl; … … 735 735 GenerateRays(mRssSamplesPerPass*ratios[2], DIRECTION_BASED_DISTRIBUTION, rays); 736 736 CastRays(rays, tmpVssRays); 737 castRays += rays.size();737 castRays += (int)rays.size(); 738 738 #if ADD_RAYS_IN_PLACE 739 739 contributions[2] = mViewCellsManager->ComputeSampleContributions(tmpVssRays, true, false); … … 742 742 #endif 743 743 times[2] = TimeDiff(t1, GetTime()); 744 nrays[2] = rays.size();744 nrays[2] = (int)rays.size(); 745 745 746 746 mStats<<"#DirectionalRelContrib"<<endl<<contributions[2]/nrays[2]<<endl; … … 790 790 CastRays(rays, vssRays); 791 791 cout<<"done."<<endl; 792 castRays += rays.size();792 castRays += (int)rays.size(); 793 793 if (mUseViewcells) { 794 794 /// compute view cell contribution of rays -
GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h
r1297 r1302 25 25 26 26 SubdivisionCandidate(): mRenderCostDecrease(0) {}; 27 28 /*SubdivisionCandidate(const AxisAlignedPlane &plane):29 mSplitPlane(plane), mRenderCostDecrease(0)30 {}*/31 27 32 28 virtual void EvalPriority() = 0; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1293 r1302 5703 5703 } 5704 5704 5705 Debug << "\n here295" << rc / mHierarchyManager->GetVspTree()->GetBoundingBox().GetVolume() << endl;5705 Debug << "\nrendercost hack: " << rc / mHierarchyManager->GetVspTree()->GetBoundingBox().GetVolume() << endl; 5706 5706 mViewCellsTree->ExportStats(fileName); 5707 5707 cout << "finished" << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1291 r1302 529 529 geom); 530 530 531 // evaluate the priority of this traversal data 531 532 EvalPriority(tData); 532 533 533 534 534 // first node is kd node, i.e. an axis aligned box … … 750 750 { 751 751 return 752 (mOutOfMemory 752 (0 753 || mOutOfMemory 753 754 || (mBspStats.Leaves() >= mMaxViewCells) 754 755 || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) … … 2316 2317 2317 2318 #ifdef _DEBUG 2318 Debug << axis << " " << pvsSize << " " << pvsBack << " " << pvsFront << endl;2319 Debug << pFront << " " << pBack << " " << pOverall << endl;2319 Debug << "axis: " << axis << " " << pvsSize << " " << pvsBack << " " << pvsFront << endl; 2320 Debug << "p: " << pFront << " " << pBack << " " << pOverall << endl; 2320 2321 #endif 2321 2322 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1297 r1302 23 23 24 24 25 25 26 namespace GtpVisibilityPreprocessor { 26 27 … … 32 33 33 34 VspTree *VspTree::VspSubdivisionCandidate::sVspTree = NULL; 34 35 int VspNode::sMailId = 1; 35 36 36 37 // variable for debugging volume contribution for heuristics 37 38 static float debugVol; 38 39 39 int VspNode::sMailId = 1;40 40 41 41 // pvs penalty can be different from pvs size … … 53 53 return (float)upper; 54 54 } 55 56 55 return (float)pvs; 57 56 } … … 299 298 300 299 301 VspLeaf::VspLeaf(): mViewCell(NULL), mPvs(NULL) 300 VspLeaf::VspLeaf(): mViewCell(NULL), mPvs(NULL), mSubdivisionCandidate(NULL) 302 301 { 303 302 } … … 554 553 // || mOutOfMemory 555 554 || (mVspStats.Leaves() >= mMaxViewCells) 556 || (mGlobalCostMisses >= mTermGlobalCostMissTolerance)555 //|| (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 557 556 ); 558 557 … … 630 629 VspSubdivisionCandidate *sc = 631 630 dynamic_cast<VspSubdivisionCandidate *>(splitCandidate); 631 632 632 VspTraversalData &tData = sc->mParentData; 633 634 633 VspNode *newNode = tData.mNode; 635 634 … … 735 734 736 735 // max cost threshold violated? 737 splitCandidate.mMaxCostMisses = 738 maxCostRatioViolated ? 736 splitCandidate.mMaxCostMisses = maxCostRatioViolated ? 739 737 splitCandidate.mParentData.mMaxCostMisses + 1: 740 738 splitCandidate.mParentData.mMaxCostMisses; … … 749 747 splitCandidate.SetRenderCostDecrease(renderCostDecr); 750 748 751 #if 0749 #if 1 752 750 const float priority = (float)-splitCandidate.mParentData.mDepth; 753 #else 754 751 #else 755 752 // take render cost of node into account 756 753 // otherwise danger of being stuck in a local minimum!! … … 785 782 786 783 //-- compute pvs 784 787 785 frontData.mPvs = EvalPvsSize(*frontData.mRays); 788 786 backData.mPvs = EvalPvsSize(*backData.mRays); … … 815 813 816 814 VspInterior *interior = new VspInterior(splitPlane); 817 818 #ifdef _DEBUG819 Debug << interior << endl;820 #endif+821 815 822 816 … … 1196 1190 float minSum = 1e20f; 1197 1191 1198 1199 1192 // if no good split can be found, take mid split 1200 1193 position = minBox + 0.5f * sizeBox; … … 1209 1202 1210 1203 //-- traverse through visibility events 1211 1212 1204 vector<SortableEntry>::const_iterator ci, ci_end = mLocalSubdivisionCandidates->end(); 1213 1205 … … 1373 1365 Intersectable::NewMail(3); 1374 1366 KdLeaf::NewMail(3); 1375 //for (int i=0;i<25;++i) BvhLeaf::NewMail();1376 1367 BvhLeaf::NewMail(3); 1377 1368 … … 1392 1383 // evaluate contribution of ray endpoint to front and back pvs 1393 1384 // with respect to the classification 1394 //Debug << "mail1: " << BvhLeaf::sMailId << endl;1395 1385 UpdateContributionsToPvs(*ray, true, cf, pvsFront, pvsBack, totalPvs); 1396 //Debug << "mail2: " << BvhLeaf::sMailId << endl;1397 1386 UpdateContributionsToPvs(*ray, false, cf, pvsFront, pvsBack, totalPvs); 1398 //Debug << "mail3: " << BvhLeaf::sMailId << endl; 1399 } 1400 1387 } 1401 1388 1402 1389 AxisAlignedBox3 frontBox; … … 1412 1399 1413 1400 //-- pvs rendering heuristics 1401 1414 1402 const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); 1415 1403 const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 1416 1404 1417 //-- only render cost heuristics or combined with standard deviation 1418 1405 // only render cost heuristics or combined with standard deviation 1419 1406 const float penaltyOld = EvalPvsPenalty((int)totalPvs, lowerPvsLimit, upperPvsLimit); 1420 1407 const float penaltyFront = EvalPvsPenalty((int)pvsFront, lowerPvsLimit, upperPvsLimit); … … 1484 1471 1485 1472 #ifdef _DEBUG 1486 Debug << axis << " " << pvsSize << " " << pvsBack << " " << pvsFront << endl;1487 Debug << pFront << " " << pBack << " " << pOverall << endl;1473 Debug << "axis: " << axis << " " << pvsSize << " " << pvsBack << " " << pvsFront << endl; 1474 Debug << "p: " << pFront << " " << pBack << " " << pOverall << endl; 1488 1475 #endif 1489 1476 … … 2662 2649 VspSubdivisionCandidate *splitCandidate = new VspSubdivisionCandidate(vData); 2663 2650 EvalSubdivisionCandidate(*splitCandidate); 2651 leaf->SetSubdivisionCandidate(splitCandidate); 2664 2652 2665 2653 mTotalCost = (float)pvsSize; … … 2674 2662 vector<SubdivisionCandidate *> &dirtyList) const 2675 2663 { 2664 2676 2665 Intersectable *obj; 2677 2666 Vector3 pt; … … 2679 2668 2680 2669 ray.GetSampleData(isTermination, pt, &obj, &node); 2681 2670 2682 2671 if (!obj) return; 2683 2672 … … 2693 2682 dirtyList.push_back(leaf->mSubdivisionCandidate); 2694 2683 } 2695 2696 2684 break; 2697 2685 } 2698 2686 case HierarchyManager::BV_BASED_OBJ_SUBDIV: 2699 2687 { 2688 BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 2689 2690 if (!leaf->Mailed()) 2691 { 2692 leaf->Mail(); 2693 dirtyList.push_back(leaf->GetSubdivisionCandidate()); 2694 Debug << "here120 candidate: " << leaf->GetSubdivisionCandidate() << " type: " << leaf->GetSubdivisionCandidate()->Type() << endl; 2695 } 2696 break; 2700 2697 } 2701 2698 break; … … 2714 2711 KdLeaf::NewMail(); 2715 2712 BvhLeaf::NewMail(); 2716 2713 2717 2714 RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end(); 2718 2715 … … 2721 2718 { 2722 2719 VssRay *ray = (*rit).mRay; 2723 2720 2724 2721 CollectDirtyCandidate(*ray, true, dirtyList); 2725 2722 CollectDirtyCandidate(*ray, false, dirtyList); -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1297 r1302 36 36 class VspTree; 37 37 class KdTreeStatistics; 38 class SubdivisionCandidate;39 class VspSubdivisionCandidate;38 //class SubdivisionCandidate; 39 //class VspSubdivisionCandidate; 40 40 41 41 /** View space partition statistics. … … 482 482 }; 483 483 484 //typedef std::priority_queue<VspTraversalData> VspOspTraversalQueue;485 486 484 /** Default constructor creating an empty tree. 487 485 */ 488 486 VspTree(); 489 490 487 /** Default destructor. 491 488 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.cpp
r1297 r1302 801 801 // C = ct_div_ci + (ql*rl + qr*rr)/queries 802 802 803 int rl=0, rr = leaf->rays.size();804 int pl=0, pr = leaf->GetPvsSize();803 int rl=0, rr = (int)leaf->rays.size(); 804 int pl=0, pr = (int)leaf->GetPvsSize(); 805 805 float sizeBox = maxBox - minBox; 806 806 807 float minBand = minBox + 0.1 *(maxBox - minBox);808 float maxBand = minBox + 0.9 *(maxBox - minBox);807 float minBand = minBox + 0.1f*(maxBox - minBox); 808 float maxBand = minBox + 0.9f*(maxBox - minBox); 809 809 810 810 float minRatio = 1e20f; … … 901 901 splitCandidates->clear(); 902 902 903 int requestedSize = 2*( node->rays.size());903 int requestedSize = 2*((int)node->rays.size()); 904 904 // creates a sorted split candidates array 905 905 if (splitCandidates->capacity() > 500000 && … … 1304 1304 1305 1305 if (removeAllScheduledRays) { 1306 int tail = leaf->rays.size()-1;1306 int tail = (int)leaf->rays.size()-1; 1307 1307 1308 1308 for (int i=0; i < (int)(leaf->rays.size()); i++) { … … 1664 1664 VssTreeLeaf *leaf = (VssTreeLeaf *)node; 1665 1665 float c = leaf->GetImportance(); 1666 int num = (c*ratioPerLeaf + 0.5f);1666 int num = int(c*ratioPerLeaf + 0.5f); 1667 1667 // cout<<num<<" "; 1668 1668 … … 1683 1683 } 1684 1684 1685 return rays.size();1685 return (int)rays.size(); 1686 1686 } 1687 1687 … … 1975 1975 } 1976 1976 } 1977 return rays.size();1977 return (int)rays.size(); 1978 1978 } 1979 1979 … … 2009 2009 } 2010 2010 2011 return rays.size();2012 } 2013 2014 } 2011 return (int)rays.size(); 2012 } 2013 2014 }
Note: See TracChangeset
for help on using the changeset viewer.