Changeset 1305 for GTP/trunk/Lib/Vis
- Timestamp:
- 08/31/06 16:47:41 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1303 r1305 380 380 tFrontData.mNode->SetSubdivisionCandidate(frontCandidate); 381 381 tBackData.mNode->SetSubdivisionCandidate(backCandidate); 382 Debug << "here125 candidate: " << tFrontData.mNode->GetSubdivisionCandidate() << " type: " << tFrontData.mNode->GetSubdivisionCandidate()->Type() << endl; 383 Debug << "here129 candidate: " << tBackData.mNode->GetSubdivisionCandidate() << " type: " << tBackData.mNode->GetSubdivisionCandidate()->Type() << endl; 382 383 Debug << "leaf: " << tFrontData.mNode << " setting f candidate: " << tFrontData.mNode->GetSubdivisionCandidate() << " type: " << tFrontData.mNode->GetSubdivisionCandidate()->Type() << endl; 384 Debug << "leaf: " << tBackData.mNode << " setting b candidate: " << tBackData.mNode->GetSubdivisionCandidate() << " type: " << tBackData.mNode->GetSubdivisionCandidate()->Type() << endl; 385 384 386 tQueue.Push(frontCandidate); 385 387 tQueue.Push(backCandidate); … … 389 391 } 390 392 391 392 393 //-- terminate traversal 394 393 395 if (newNode->IsLeaf()) 394 396 { 395 397 //-- store additional info 398 396 399 EvaluateLeafStats(tData); 397 400 … … 402 405 CollectRays(leaf->mObjects, leaf->mVssRays); 403 406 } 404 407 408 // detach subdivision candidate: this leaf is no candidate for 409 // splitting anymore 410 tData.mNode->SetSubdivisionCandidate(NULL); 405 411 // detach node so it won't get deleted 406 412 tData.mNode = NULL; … … 430 436 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 431 437 const float oldProp = EvalViewCellsVolume(leaf->mObjects); 432 const float oldProp2 = splitCandidate.mParentData.mProbability; //Debug << "here8 " << (oldProp - oldProp2) / viewSpaceVol << " " << oldProp / viewSpaceVol << " " << oldProp2 / viewSpaceVol << endl;438 //const float oldProp2 = splitCandidate.mParentData.mProbability; Debug << "here8 " << (oldProp - oldProp2) / viewSpaceVol << " " << oldProp / viewSpaceVol << " " << oldProp2 / viewSpaceVol << endl; 433 439 434 440 const float oldRenderCost = oldProp * (float)leaf->mObjects.size() / viewSpaceVol; … … 440 446 441 447 newRenderCost /= viewSpaceVol; 442 443 448 const float renderCostDecr = oldRenderCost - newRenderCost; 444 449 … … 1071 1076 vc->Mail(); 1072 1077 if (setCounter) 1078 { 1073 1079 vc->mCounter = 0; 1080 } 1074 1081 } 1075 1076 1082 viewCells.push_back(vc); 1077 1083 } … … 1106 1112 VspLeaf *leaf = vc->mLeaf; 1107 1113 SubdivisionCandidate *candidate = leaf->GetSubdivisionCandidate(); 1108 Debug << "here100 candidate: " << candidate << " type: " << candidate->Type() << endl;1109 1114 1110 dirtyList.push_back(leaf->GetSubdivisionCandidate()); 1115 if (candidate) // is this leaf still a split candidate? 1116 { 1117 dirtyList.push_back(candidate); 1118 } 1111 1119 } 1112 1120 } -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1302 r1305 356 356 {}; 357 357 358 ~BvhSubdivisionCandidate() { mParentData.Clear(); } 358 ~BvhSubdivisionCandidate() 359 { 360 mParentData.Clear(); 361 } 359 362 360 363 int Type() const { return OBJECT_SPACE; } … … 377 380 {} 378 381 379 382 /// pointer to parent tree. 380 383 static BvHierarchy *sBvHierarchy; 381 382 384 /// parent data 383 385 BvhTraversalData mParentData; 386 /// the objects on the front of the potential split 384 387 ObjectContainer mFrontObjects; 388 /// the objects on the back of the potential split 385 389 ObjectContainer mBackObjects; 386 390 }; -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1303 r1305 311 311 312 312 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 313 314 313 mBvHierarchy->mBvhStats.Stop(); 315 314 } … … 399 398 while (!FinishedConstruction()) 400 399 { 401 mCurrentCandidate = NextSubdivisionCandidate(); 402 400 mCurrentCandidate = NextSubdivisionCandidate(); 403 401 mTotalCost -= mCurrentCandidate->GetRenderCostDecrease(); 404 402 … … 408 406 //Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 409 407 if (costRatio < mTermMinGlobalCostRatio) 408 { 410 409 ++ mGlobalCostMisses; 410 } 411 411 412 412 //-- subdivide leaf node 413 414 413 if (ApplySubdivisionCandidate(mCurrentCandidate)) 415 414 { … … 419 418 EvalSubdivisionStats(*mCurrentCandidate); 420 419 421 // reevaluate candidates affected by the split 422 // for view space splits, this would be object space splits 423 // and other way round 420 // reevaluate candidates affected by the split for view space splits, 421 // this would be object space splits and other way round 424 422 if (repair) RepairQueue(); 425 426 Debug << "candidate: " << mCurrentCandidate->Type() << ", priority: "427 << mCurrentCandidate->GetPriority() << endl;428 423 } 429 424 430 Debug << "here66 " << mCurrentCandidate << endl;431 425 DEL_PTR(mCurrentCandidate); 432 426 } … … 458 452 459 453 mBvHierarchy->CollectDirtyCandidates(sc, dirtyList); 460 461 sc->mParentData.mNode->SetSubdivisionCandidate(NULL); // HACK462 454 break; 463 455 } … … 474 466 475 467 mVspTree->CollectDirtyCandidates(sc, dirtyList); 476 477 sc->mParentData.mNode->SetSubdivisionCandidate(NULL); // HACK478 468 } 479 469 … … 484 474 if (mCurrentCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) 485 475 { 486 Debug << "collecting candidates after view space split" << endl;487 476 CollectViewSpaceDirtyList(dirtyList); 488 477 } 489 478 else // object space split 490 { Debug << "collecting candidates after object space split" << endl;479 { 491 480 CollectObjectSpaceDirtyList(dirtyList); 492 481 } … … 515 504 // collect list of "dirty" candidates 516 505 vector<SubdivisionCandidate *> dirtyList; 517 Debug << "collecting dirty candidates" << endl;518 506 CollectDirtyCandidates(dirtyList); 519 507 Debug << "collected " << (int)dirtyList.size() << " candidates for reevaluation" << endl; 508 520 509 //-- reevaluate the dirty list 521 522 510 vector<SubdivisionCandidate *>::const_iterator sit, sit_end = dirtyList.end(); 523 511 524 Debug << "collected " << (int)dirtyList.size() << " candidates" << endl;525 526 512 for (sit = dirtyList.begin(); sit != sit_end; ++ sit) 527 513 { 528 514 SubdivisionCandidate* sc = *sit; 529 float rcd = sc->GetRenderCostDecrease(); 530 Debug << "here6 " << rcd << endl; 531 Debug << "here84 " << endl; 532 Debug << "here7 " << sc << endl; 533 Debug << "here90 " << sc->GetPosition() << endl; 534 Debug << "here91 " << sc->Type() << endl; 535 //Debug << "here1191" << sc->Type() << endl; 536 //Debug << "sc: " << sc << " " << sc->GetPosition() << " " << sc->Type() << endl; 515 const float rcd = sc->GetRenderCostDecrease(); 537 516 538 Debug << "here11" << endl;539 517 mTQueue.Erase(sc); // erase from queue 540 Debug << "here2" << endl;541 542 518 sc->EvalPriority(); // reevaluate 543 519 544 /* cout << "render cost decrease diff " << rcd - sc->GetRenderCostDecrease() 545 << " old: " << rcd << " new " << sc->GetRenderCostDecrease() 546 << " type " << sc->Type() << endl;*/ 547 520 /* 521 Debug << "candidate " << sc << " reevaluated\n" 522 << "render cost decrease diff " << rcd - sc->GetRenderCostDecrease() 523 << " old: " << rcd << " new " << sc->GetRenderCostDecrease() << endl;*/ 524 if (0) 525 { 526 const float rcDiff = rcd - sc->GetRenderCostDecrease(); 527 mTotalCost += rcDiff; 528 } 548 529 mTQueue.Push(sc); // reinsert 549 530 } … … 560 541 mOspTree->Export(stream); 561 542 stream << endl << "</ObjectSpaceHierarchy>" << endl; 562 break; 563 543 break; 564 544 case BV_BASED_OBJ_SUBDIV: 565 545 stream << "<ObjectSpaceHierarchy type=\"bvh\">" << endl; … … 584 564 // potentially visible objects 585 565 return vc->AddPvsSample(obj, pdf, contribution); 586 587 566 case KD_BASED_OBJ_SUBDIV: 588 567 { … … 681 660 mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 682 661 683 // add to queue662 // add to subdivision candidate to split candidate queue 684 663 mTQueue.Push(vsc); 685 664 … … 708 687 ///////////////////////////////////////////////////////////// 709 688 710 711 689 switch (mObjectSpaceSubdivisonType) 712 690 { -
GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h
r1302 r1305 26 26 SubdivisionCandidate(): mRenderCostDecrease(0) {}; 27 27 28 virtual ~SubdivisionCandidate() {}; 28 29 virtual void EvalPriority() = 0; 29 30 virtual int Type() const = 0; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1303 r1305 709 709 // finally evaluate statistics for this leaf 710 710 EvaluateLeafStats(tData); 711 711 // detach subdivision candidate: this leaf is no candidate for 712 // splitting anymore 713 tData.mNode->SetSubdivisionCandidate(NULL); 712 714 // detach node so it won't get deleted 713 715 tData.mNode = NULL; … … 2691 2693 { 2692 2694 leaf->Mail(); 2693 dirtyList.push_back(leaf->GetSubdivisionCandidate());Debug << "here87700" << endl;2694 Debug << "here166 candidate: " << leaf->GetSubdivisionCandidate() << endl;2695 Debug << "here120 candidate: " << leaf->GetSubdivisionCandidate() << " type: " << leaf->GetSubdivisionCandidate()->Type() << endl;2696 Debug << "here877" << endl;2695 if (leaf->GetSubdivisionCandidate()) // a candidate still attached to this node 2696 { 2697 dirtyList.push_back(leaf->GetSubdivisionCandidate()); 2698 } 2697 2699 } 2698 2700 break; 2699 2701 } 2700 break;2701 2702 default: 2702 2703 break; … … 2794 2795 obj->Mail(); 2795 2796 obj->mCounter = 0; 2796 2797 2797 ++ pvsSize; 2798 2798 } 2799 2800 2799 ++ obj->mCounter; 2801 2800 break; … … 2815 2814 leaf->Mail(); 2816 2815 leaf->mCounter = 0; 2817 2818 2816 pvsSize += (int)leaf->mObjects.size(); 2819 2817 } 2820 2821 2818 ++ leaf->mCounter; 2822 2819 break; … … 2864 2861 { 2865 2862 BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 2866 2867 2863 if (!leaf->Mailed()) 2868 2864 { … … 2928 2924 ray.GetSampleData(isTermination, pt, &obj, &node); 2929 2925 2930 if (!obj) 2931 return 0; 2926 if (!obj) return 0; 2932 2927 2933 2928 int pvs = 0; … … 2977 2972 leaf->Mail(); 2978 2973 2979 int pvs = 0; 2980 pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 2974 int pvs = (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 2981 2975 2982 2976 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); … … 2985 2979 { 2986 2980 Intersectable *obj = *oit; 2987 2988 2981 if (!obj->Mailed()) 2989 2982 { … … 2996 2989 } 2997 2990 2998 } 2991 2992 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1302 r1305 447 447 {}; 448 448 449 ~VspSubdivisionCandidate() { mParentData.Clear(); } 449 ~VspSubdivisionCandidate() 450 { 451 mParentData.Clear(); 452 } 450 453 451 454 int Type() const { return VIEW_SPACE; } … … 474 477 VspNode *mNode; 475 478 Vector3 mExitPoint; 476 477 479 float mMaxT; 478 480 … … 588 590 */ 589 591 int CastBeam(Beam &beam); 590 591 592 592 593 /** Checks if tree validity-flags are right … … 778 779 const int axis, 779 780 float &position); 780 781 781 782 782
Note: See TracChangeset
for help on using the changeset viewer.