Changeset 1667 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/23/06 20:24:14 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/vsposp_typical.sh
r1666 r1667 12 12 13 13 #SCENE=vsposp_typical 14 #SCENE=soda5_vsposp15 SCENE=soda_vsposp14 SCENE=soda5_vsposp 15 #SCENE=soda_vsposp 16 16 #SCENE=vienna_vsposp 17 17 #SCENE=arena_vsposp … … 64 64 echo "$SCENE $METHOD" 65 65 66 #$PROGRAM $ENVIRONMENT \66 $PROGRAM $ENVIRONMENT \ 67 67 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 68 68 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 71 71 -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 72 72 -hierarchy_construction_type=2 \ 73 -hierarchy_construction_consider_memory= true \73 -hierarchy_construction_consider_memory=false \ 74 74 -hierarchy_construction_multilevel=false \ 75 -hierarchy_term_memory_const=0.9 \ 75 76 -hierarchy_construction_recompute_split_on_repair=true 76 77 … … 102 103 echo "$SCENE $METHOD" 103 104 104 $PROGRAM $ENVIRONMENT \105 #$PROGRAM $ENVIRONMENT \ 105 106 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 106 107 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 138 139 echo ********" $SCENE $METHOD ************" 139 140 140 $PROGRAM $ENVIRONMENT \141 # $PROGRAM $ENVIRONMENT \ 141 142 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 142 143 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 161 162 echo ********" $SCENE $METHOD ************" 162 163 163 $PROGRAM $ENVIRONMENT \164 #$PROGRAM $ENVIRONMENT \ 164 165 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 165 166 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 184 185 echo "$SCENE $METHOD" 185 186 186 $PROGRAM $ENVIRONMENT \187 #$PROGRAM $ENVIRONMENT \ 187 188 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 188 189 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ -
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 -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1666 r1667 13 13 #include "AxisAlignedBox3.h" 14 14 #include "IntersectableWrapper.h" 15 15 #include "HierarchyManager.h" 16 16 17 17 … … 408 408 int Type() const { return OBJECT_SPACE; } 409 409 410 void Eval Priority(bool computeSplitplane = true)410 void EvalCandidate(bool computeSplitplane = true) 411 411 { 412 if (computeSplitplane) 413 { 414 sBvHierarchy->EvalSubdivisionCandidate(*this); 415 } 416 else 417 { 418 mPvsEntriesIncr = sBvHierarchy->EvalPvsEntriesIncr(*this); 419 mPriority = sBvHierarchy->EvalPriority(*this); 420 } 412 sBvHierarchy->EvalSubdivisionCandidate(*this, computeSplitplane); 421 413 } 422 414 423 415 bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) 424 416 { 425 BvhNode *n = 426 sBvHierarchy->Subdivide(splitQueue, this, terminationCriteriaMet); 417 BvhNode *n = sBvHierarchy->Subdivide(splitQueue, this, terminationCriteriaMet); 418 427 419 // local or global termination criteria failed 428 420 return !n->IsLeaf(); … … 440 432 } 441 433 442 BvhSubdivisionCandidate( 443 const ObjectContainer &frontObjects, 444 const ObjectContainer &backObjects, 445 const BvhTraversalData &tData): 434 BvhSubdivisionCandidate(const ObjectContainer &frontObjects, 435 const ObjectContainer &backObjects, 436 const BvhTraversalData &tData): 446 437 mFrontObjects(frontObjects), mBackObjects(backObjects), mParentData(tData) 447 438 {} 439 440 float GetPriority() const 441 { 442 HierarchyManager *hm = sBvHierarchy->mHierarchyManager; 443 if (hm->ConsiderMemory()) 444 { 445 const float rc = hm->GetHierarchyStats().mTotalCost - mRenderCostDecrease; 446 const float mc = hm->GetHierarchyStats().mMemory + 447 (float)mPvsEntriesIncr * ObjectPvs::GetEntrySizeByte(); 448 //cout << "x"; 449 return - (rc * mc) / float(1024 * 1024); 450 } 451 else 452 { 453 return mPriority; 454 } 455 } 456 448 457 449 458 /// pointer to parent tree. … … 494 503 /** Evaluates candidate for splitting. 495 504 */ 496 void EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitData );505 void EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitData, bool computeSplitPlane = true); 497 506 498 507 /** Returns list of leaves with pvs smaller than … … 726 735 @returns priority 727 736 */ 728 float EvalPriority(const BvhSubdivisionCandidate &splitCandidate) const;737 //float EvalPriority(const BvhSubdivisionCandidate &splitCandidate) const; 729 738 730 739 //////////////////////////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/FlexibleHeap.h
r1313 r1667 24 24 25 25 inline void SetPriority(const float k) { mPriority = k; } 26 inline float GetPriority() const { return mPriority; }27 26 //inline float GetPriority() const { return mPriority; } 27 virtual float GetPriority() const = 0; 28 28 protected: 29 29 … … 54 54 unsigned int Size() const { return (unsigned int)mBuffer.size(); } 55 55 bool Empty() const {return mBuffer.empty(); } 56 T Item(const unsigned int i) 56 T Item(const unsigned int i) { return mBuffer[i]; } 57 57 const T Item(const unsigned int i) const { return mBuffer[i]; } 58 58 T Pop(); -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1666 r1667 358 358 // hack: assume that object space can be seen from view space 359 359 mHierarchyStats.mTotalCost = (float)objects.size(); 360 // only one entry for start 360 361 mHierarchyStats.mPvsEntries = 1; 361 362 const int entrySize = sizeof(PvsData) + sizeof(Intersectable *); 363 mHierarchyStats.mMemory = entrySize / (1024.0f * 1024.0f); 362 mHierarchyStats.mMemory = (float)ObjectPvs::GetEntrySizeByte(); 364 363 365 364 EvalSubdivisionStats(); … … 396 395 // for first round, use sah splits. Once view space partition 397 396 // has started, use render cost heuristics instead 398 const int ospSteps = 399 RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, minSteps); 397 const int ospSteps = RunConstruction(objectSpaceQueue, dirtyVspList, NULL, minSteps); 400 398 401 399 cout << "\n" << ospSteps << " object space partition steps taken" << endl; 402 400 403 401 // create view space 404 SubdivisionCandidate *vsc = 405 PrepareViewSpaceSubdivision(sampleRays, objects); 402 SubdivisionCandidate *vsc = PrepareViewSpaceSubdivision(sampleRays, objects); 406 403 407 404 viewSpaceQueue.Push(vsc); … … 414 411 // account so we can compare to view space splits 415 412 ResetQueue(objectSpaceQueue, false); 416 417 //minSteps = 1;418 413 419 414 // This method subdivides view space / object space … … 425 420 while (!(viewSpaceQueue.Empty() && objectSpaceQueue.Empty())) 426 421 { 427 float vspPriority; 422 // decide upon next split type 423 const float vspPriority = viewSpaceQueue.Top() ? viewSpaceQueue.Top()->GetPriority() : -1e20; 424 const float ospPriority = viewSpaceQueue.Top() ? objectSpaceQueue.Top()->GetPriority() : -1e20; 428 425 429 // decide upon next split type430 if (!viewSpaceQueue.Empty())431 {432 vspPriority = viewSpaceQueue.Top()->GetPriority();433 434 // rather take this into account directly when computing priority435 if (0 && mConsiderMemory)436 vspPriority /= ((float)viewSpaceQueue.Top()->GetPvsEntriesIncr() + Limits::Small);437 }438 else439 {440 vspPriority = 0;441 }442 443 float ospPriority;444 445 if (!objectSpaceQueue.Empty())446 {447 ospPriority = objectSpaceQueue.Top()->GetPriority();448 449 // rather take this into account directly when computing priority450 if (0 && mConsiderMemory)451 ospPriority /= ((float)objectSpaceQueue.Top()->GetPvsEntriesIncr() + Limits::Small);452 }453 else454 {455 ospPriority = 0;456 }457 458 426 cout << "new decicion, vsp: " << vspPriority << ", osp: " << ospPriority << endl; 459 427 … … 471 439 // has started, use render cost heuristics instead 472 440 const int ospSteps = 473 RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, minSteps);441 RunConstruction(objectSpaceQueue, dirtyVspList, viewSpaceQueue.Top(), minSteps); 474 442 475 443 cout << "\n" << ospSteps << " object space partition steps taken" << endl; … … 493 461 // process view space candidates 494 462 const int vspSteps = 495 RunConstruction(viewSpaceQueue, dirtyOspList, renderCostDecr, minSteps);463 RunConstruction(viewSpaceQueue, dirtyOspList, objectSpaceQueue.Top(), minSteps); 496 464 497 465 cout << "\n" << vspSteps << " view space partition steps taken" << endl; … … 526 494 mHierarchyStats.mNodes = 2; 527 495 mHierarchyStats.mPvsEntries = 1; 528 mHierarchyStats.mMemory = sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f);496 mHierarchyStats.mMemory = (float)ObjectPvs::GetEntrySizeByte(); 529 497 mHierarchyStats.mTotalCost = (float)objects.size(); 530 498 … … 570 538 571 539 // begin subdivision 572 RunConstruction(mRepairQueue, 573 sampleRays, 574 objects, 575 forcedViewSpace); 540 RunConstruction(mRepairQueue, sampleRays, objects, forcedViewSpace); 576 541 577 542 cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; … … 734 699 //cout << "pvs entries: " << pvsEntriesIncr << " " << mHierarchyStats.pvsEntries << endl; 735 700 736 const int sizeOfEntry = sizeof(PvsData) + sizeof(Intersectable *);737 701 // memory size in byte 738 mHierarchyStats.mMemory += float(pvsEntriesIncr * sizeOfEntry);702 mHierarchyStats.mMemory += (float)ObjectPvs::GetEntrySizeByte(); 739 703 mHierarchyStats.mRenderCostDecrease = sc->GetRenderCostDecrease(); 740 704 … … 744 708 { 745 709 memoryCount += 100000; 746 cout << "\nstorage cost: " << mHierarchyStats.mMemory / (1024.0f * 1024.0f) << ", steps: " << mHierarchyStats.Leaves() << endl;710 cout << "\nstorage cost: " << mHierarchyStats.mMemory / float(1024 * 1024) << " MB, steps: " << mHierarchyStats.Leaves() << endl; 747 711 } 748 712 … … 930 894 int HierarchyManager::RunConstruction(SplitQueue &splitQueue, 931 895 SubdivisionCandidateContainer &dirtyCandidates, 932 const float minRenderCostDecr,896 SubdivisionCandidate *oldCandidate, 933 897 const int minSteps) 934 898 { … … 939 903 while (!splitQueue.Empty()) 940 904 { 905 const float threshold = oldCandidate ? oldCandidate->GetPriority() : 1e20; 941 906 SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue); 942 907 //cout << "here2 " << sc->GetPriority() << " " << threshold << endl; 908 943 909 // minimum slope reached 944 if ((sc->GetRenderCostDecrease() < minRenderCostDecr) && 945 !(steps < minSteps)) 946 { 947 //cout << "breaking on " << sc->GetRenderCostDecrease() << " smaller than " << minRenderCostDecr << endl; 910 if ((sc->GetPriority() < threshold) && !(steps < minSteps)) 911 { 912 cout << "**************** breaking on " << sc->GetPriority() << " smaller than " << threshold << endl; 948 913 break; 949 914 } 915 950 916 //////// 951 917 //-- subdivide leaf node of either type … … 993 959 mHierarchyStats.mPvsEntries = mBvHierarchy->CountViewCells(objects); 994 960 995 mHierarchyStats.mMemory = mHierarchyStats.mPvsEntries *996 sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f);961 mHierarchyStats.mMemory = 962 (float)mHierarchyStats.mPvsEntries * ObjectPvs::GetEntrySizeByte(); 997 963 998 964 mHierarchyStats.mRenderCostDecrease = 0; … … 1038 1004 mHierarchyStats.mRenderCostDecrease = 0; 1039 1005 1040 mHierarchyStats.mMemory = mHierarchyStats.mPvsEntries * 1041 sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 1006 mHierarchyStats.mMemory = (float)mHierarchyStats.mPvsEntries * ObjectPvs::GetEntrySizeByte(); 1042 1007 1043 1008 // evaluate new stats before first subdivsiion … … 1309 1274 const float rcd = sc->GetRenderCostDecrease(); 1310 1275 1311 splitQueue.Erase(sc); // erase from queue 1312 sc->EvalPriority(recomputeSplitPlaneOnRepair); // reevaluate 1313 1276 // erase from queue 1277 splitQueue.Erase(sc); 1278 // reevaluate candidate 1279 sc->EvalCandidate(recomputeSplitPlaneOnRepair); 1280 // reinsert 1281 splitQueue.Push(sc); 1282 1283 cout << "."; 1284 1314 1285 #ifdef _DEBUG 1315 1286 Debug << "candidate " << sc << " reevaluated\n" … … 1317 1288 << " old: " << rcd << " new " << sc->GetRenderCostDecrease() << endl; 1318 1289 #endif 1319 splitQueue.Push(sc); // reinsert1320 cout << ".";1321 1290 } 1322 1291 … … 1339 1308 SubdivisionCandidate *candidate = NextSubdivisionCandidate(splitQueue); 1340 1309 // reevaluate local split plane and priority 1341 candidate->Eval Priority(recomputeSplitPlane);1310 candidate->EvalCandidate(recomputeSplitPlane); 1342 1311 cout << "."; 1343 1312 mCandidateBuffer.push_back(candidate); -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1666 r1667 41 41 class BvHierarchy; 42 42 class Exporter; 43 class ViewCellsParseHandlers; 44 43 45 44 46 #define COUNT_ORIGIN_OBJECTS 1 … … 130 132 class HierarchyManager 131 133 { 132 friend VspTree;133 friend OspTree;134 friend BvHierarchy;135 friend ViewCellsParseHandlers;136 137 134 public: 138 135 /** Constructor with the view space partition tree and … … 233 230 } 234 231 232 HierarchyStatistics &GetHierarchyStats() { return mHierarchyStats; }; 233 234 inline bool ConsiderMemory() const { return mConsiderMemory; } 235 235 236 protected: 236 237 … … 254 255 float GetObjectSpaceMemUsage() const; 255 256 257 256 258 ////////////////////////////// 257 259 // the main loop 258 //////////////////////259 260 260 261 /** This is for interleaved construction / sequential construction. … … 270 271 int RunConstruction(SplitQueue &splitQueue, 271 272 SubdivisionCandidateContainer &chosenCandidates, 272 const float minRenderCostDecr, 273 //const float minRenderCostDecr, 274 SubdivisionCandidate *oldCandidate, 273 275 const int minSteps); 274 276 … … 344 346 bool StartViewSpaceSubdivision() const; 345 347 348 346 349 //////////////////////////// 347 350 // Helper function for preparation of subdivision 348 ///////349 351 350 352 /** Prepare bv hierarchy for subdivision … … 493 495 float mTermMaxMemory; 494 496 497 495 498 //////////////////// 496 499 500 /// number of minimal steps of the same type 497 501 int mMinStepsOfSameType; 498 502 … … 532 536 533 537 float mMemoryConst; 538 539 540 friend VspTree; 541 friend OspTree; 542 friend BvHierarchy; 543 friend ViewCellsParseHandlers; 544 534 545 }; 535 546 -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h
r1633 r1667 13 13 #include "IntersectableWrapper.h" 14 14 #include "KdTree.h" 15 #include "HierarchyManager.h" 16 15 17 16 18 … … 250 252 int Type() const { return OBJECT_SPACE; } 251 253 252 void EvalPriority(bool computeSplitplane = true) 253 { 254 if (computeSplitplane) 255 sOspTree->EvalSubdivisionCandidate(*this); 256 // else TODO 254 void EvalCandidate(bool computeSplitplane = true) 255 { 256 //if (computeSplitplane) TODO 257 sOspTree->EvalSubdivisionCandidate(*this); 257 258 } 258 259 … … 274 275 { 275 276 sOspTree->CollectDirtyCandidates(this, dirtyList, onlyUnmailed); 277 } 278 279 float GetPriority() const 280 { 281 HierarchyManager *hm = sOspTree->mHierarchyManager; 282 if (hm->ConsiderMemory()) 283 { 284 const float rc = hm->GetHierarchyStats().mTotalCost - mRenderCostDecrease; 285 const float mc = hm->GetHierarchyStats().mMemory + 286 (float)mPvsEntriesIncr * ObjectPvs::GetEntrySizeByte(); 287 288 return - (rc * mc); 289 } 290 else 291 { 292 return mPriority; 293 } 276 294 } 277 295 … … 698 716 699 717 void AddSubdivisionStats(const int viewCells, 700 const float renderCostDecr,701 const float totalRenderCost);718 const float renderCostDecr, 719 const float totalRenderCost); 702 720 703 721 void EvalViewCellsForHeuristics(const VssRay &ray, 704 float &volLeft,705 float &volRight);722 float &volLeft, 723 float &volRight); 706 724 707 725 float EvalViewCellsVolume(KdLeaf *leaf, const RayInfoContainer &rays) const; 708 726 709 int RemoveParentViewCellsPvs(KdLeaf *leaf, 710 const RayInfoContainer &rays 711 ) const; 727 int RemoveParentViewCellsPvs(KdLeaf *leaf, const RayInfoContainer &rays) const; 712 728 713 729 int UpdateViewCellsPvs(KdLeaf *leaf, const RayInfoContainer &rays) const; 714 int CheckViewCellsPvs(KdLeaf *leaf, 715 const RayInfoContainer &rays) const; 716 bool AddViewCellToObjectPvs( 717 Intersectable *obj, 718 ViewCell *vc, 719 float &contribution, 720 bool onlyUnmailed) const; 721 722 int ClassifyRays( 723 const RayInfoContainer &rays, 724 KdLeaf *leaf, 725 const AxisAlignedPlane &plane, 726 RayInfoContainer &frontRays, 727 RayInfoContainer &backRays) const; 728 729 void CollectTouchedViewCells( 730 const RayInfoContainer &rays, 731 ViewCellContainer &touchedViewCells) const; 732 733 void AddObjectContribution( 734 KdLeaf *leaf, 735 Intersectable * obj, 736 ViewCellContainer &touchedViewCells, 737 float &renderCost); 738 739 void SubtractObjectContribution( 740 KdLeaf *leaf, 741 Intersectable * obj, 742 ViewCellContainer &touchedViewCells, 743 float &renderCost); 744 745 SubdivisionCandidate *PrepareConstruction( 746 const VssRayContainer &sampleRays, 747 const ObjectContainer &objects, 748 RayInfoContainer &rays); 730 731 int CheckViewCellsPvs(KdLeaf *leaf, const RayInfoContainer &rays) const; 732 733 bool AddViewCellToObjectPvs(Intersectable *obj, 734 ViewCell *vc, 735 float &contribution, 736 bool onlyUnmailed) const; 737 738 int ClassifyRays(const RayInfoContainer &rays, 739 KdLeaf *leaf, 740 const AxisAlignedPlane &plane, 741 RayInfoContainer &frontRays, 742 RayInfoContainer &backRays) const; 743 744 void CollectTouchedViewCells(const RayInfoContainer &rays, 745 ViewCellContainer &touchedViewCells) const; 746 747 void AddObjectContribution(KdLeaf *leaf, 748 Intersectable * obj, 749 ViewCellContainer &touchedViewCells, 750 float &renderCost); 751 752 void SubtractObjectContribution(KdLeaf *leaf, 753 Intersectable * obj, 754 ViewCellContainer &touchedViewCells, 755 float &renderCost); 756 757 SubdivisionCandidate *PrepareConstruction(const VssRayContainer &sampleRays, 758 const ObjectContainer &objects, 759 RayInfoContainer &rays); 749 760 750 761 -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1586 r1667 177 177 */ 178 178 void Clear(); 179 180 static int GetEntrySizeByte(); 181 static float GetEntrySize(); 179 182 180 183 /** Compute continuous PVS difference */ … … 189 192 190 193 return pvsReduction + pvsEnlargement; 191 } 192 193 194 } 194 195 195 196 /// Map of PVS entries … … 493 494 494 495 496 template <typename T, typename S> 497 float Pvs<T, S>::GetEntrySize() 498 { 499 return (float)sizeof(T) + sizeof(S) / float(1024 * 1024); 500 } 501 502 503 template <typename T, typename S> 504 int Pvs<T, S>::GetEntrySizeByte() 505 { 506 return sizeof(T) + sizeof(S); 507 } 508 509 510 /////////////////////////////////////// 511 495 512 /** Class instantiating the Pvs template for kd tree nodes. 496 513 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h
r1633 r1667 25 25 26 26 virtual ~SubdivisionCandidate() {}; 27 virtual void EvalPriority(bool computeSplitplane = true) = 0; 27 /** Evaluate this subdivision candidate. 28 */ 29 virtual void EvalCandidate(bool computeSplitplane = true) = 0; 30 /** Returns type of this subdivision candidate. 31 */ 28 32 virtual int Type() const = 0; 33 /** Evaluate this candidate and put results into queue for further traversal. 34 */ 29 35 virtual bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) = 0; 36 /** Returns true of the global termination criteria of this split were met, 37 false otherwise. 38 */ 30 39 virtual bool GlobalTerminationCriteriaMet() const = 0; 31 40 /** Collects #of subdivision candidates that were affected by the 41 application of this one. 42 */ 32 43 virtual void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList, 33 44 const bool onlyUnmailed) = 0; … … 56 67 mSplitAxis = splitAxis; 57 68 } 69 58 70 inline void SetMaxCostMisses(const int misses) 59 71 { 60 72 mMaxCostMisses = misses; 61 73 } 74 62 75 inline void SetPvsEntriesIncr(const int pvsEntriesIncr) 63 76 { … … 69 82 return mSplitAxis; 70 83 } 84 71 85 inline int GetMaxCostMisses() const 72 86 { 73 87 return mMaxCostMisses; 74 88 } 89 75 90 inline int GetPvsEntriesIncr() const 76 91 { 77 92 return mPvsEntriesIncr; 78 93 } 94 79 95 80 96 ////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1666 r1667 1548 1548 stats.open(mergeStats.c_str()); 1549 1549 1550 const float entrySize = sizeof(PvsData) + sizeof(Intersectable *); 1551 const float memoryCost = (float)entriesInPvs * entrySize / (1024.0f * 1024.0f); 1550 const float memoryCost = (float)entriesInPvs * ObjectPvs::GetEntrySize(); 1552 1551 1553 1552 ///////////// … … 1621 1620 avgRenderCost = (float)totalPvs / (float)numViewCells; 1622 1621 1623 const float entrySize = sizeof(PvsData) + sizeof(Intersectable *); 1624 const float memoryCost = (float)entriesInPvs * entrySize / (1024.0f * 1024.0f); 1622 const float memoryCost = (float)entriesInPvs * ObjectPvs::GetEntrySize(); 1625 1623 1626 1624 UpdateStats(stats, … … 2065 2063 float ViewCellsTree::GetMemoryCost(ViewCell *vc) const 2066 2064 { 2067 const float entrySize = 2068 sizeof(PvsData) + sizeof(Intersectable *); 2069 2070 return (float)CountStoredPvsEntries(vc) * entrySize; 2065 return (float)CountStoredPvsEntries(vc) * ObjectPvs::GetEntrySize(); 2071 2066 } 2072 2067 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r1653 r1667 35 35 /// number of view cells 36 36 int viewCells; 37 38 37 /// size of the PVS 39 38 int pvsSize; 40 41 39 /// largest PVS of all view cells 42 40 int maxPvs; 43 44 41 /// smallest PVS of all view cells 45 42 int minPvs; 46 47 43 /// view cells with empty PVS 48 44 int emptyPvs; 49 50 45 /// number of leaves covering the view space 51 46 int leaves; 52 53 47 /// largest number of leaves covered by one view cell 54 48 int maxLeaves; 55 49 /// number of invalid view cells 56 50 int invalid; 57 51 … … 89 83 90 84 /** 91 View cell with an optional mesh representation 85 A view cell. View cells are regions in space. The visibility informations, 86 i.e., the primitives seen by the view cell are stored in a PVs. 87 A view cell can be represented in many different ways, e.g., 88 a mesh representation. 92 89 */ 93 94 95 90 class ViewCell: public MeshInstance 96 91 { -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1666 r1667 26 26 27 27 28 // should not count origin object for sampling because it disturbs heuristics29 #define SAMPLE_ORIGIN_OBJECTS 1 28 // warning: Should not count origin object for sampling because it disturbs heuristics 29 #define SAMPLE_ORIGIN_OBJECTS 1 // matt temp 30 30 31 31 // $$JB HACK … … 5442 5442 5443 5443 5444 void VspOspViewCellsManager::Finalize(ViewCell *viewCell, 5445 const bool createMesh) 5444 void VspOspViewCellsManager::Finalize(ViewCell *viewCell, const bool createMesh) 5446 5445 { 5447 5446 float area = 0; … … 5651 5650 totalRenderCost = avgRenderCost = expectedCost = (float)rootPvs; 5652 5651 5653 const float entrySize = sizeof(PvsData) + sizeof(Intersectable *); 5654 const float memoryCost = (float)entriesInPvs * entrySize / (1024.0f * 1024.0f); 5652 const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize(); 5655 5653 5656 5654 ///////////// … … 5728 5726 avgRenderCost = (float)totalPvs / (float)numViewCells; 5729 5727 5730 const float entrySize = sizeof(PvsData) + sizeof(Intersectable *);5731 const float memoryCost = (float)entriesInPvs * entrySize / (1024.0f * 1024.0f);5728 const float memoryCost = (float)entriesInPvs * 5729 (float)ObjectPvs::GetEntrySize(); 5732 5730 5733 5731 mViewCellsTree->UpdateStats(stats, -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1633 r1667 161 161 { 162 162 // for a spatial subdivision, it is not necessary to store 163 // the objects with the leaves, they can be classified 164 // geometrically 165 mHierarchyManager->mOspTree->InsertObjects( 166 mHierarchyManager->mOspTree->mRoot, *mObjects); 163 // the objects with the leaves, they can be classified geometrically 164 mHierarchyManager->mOspTree-> 165 InsertObjects(mHierarchyManager->mOspTree->mRoot, *mObjects); 167 166 } 168 167 } … … 1173 1172 void ViewCellsParseHandlers::StartOspLeaf(AttributeList& attributes) 1174 1173 { 1175 KdLeaf * leaf = 1176 new KdLeaf(dynamic_cast<KdInterior *>(mCurrentOspNode), NULL); 1177 1178 if (mCurrentOspNode) // replace front or (if not NULL) back child1179 {1174 KdLeaf * leaf = new KdLeaf(dynamic_cast<KdInterior *>(mCurrentOspNode), NULL); 1175 1176 if (mCurrentOspNode) 1177 { 1178 // replace front or (if not NULL) back child 1180 1179 dynamic_cast<KdInterior *>(mCurrentOspNode)->ReplaceChildLink(NULL, leaf); 1181 1180 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r1632 r1667 154 154 typedef std::priority_queue<VspBspTraversalData> VspBspTraversalQueue; 155 155 156 // note: should be inherited from subdivision candidate 156 157 class VspBspSubdivisionCandidate 157 158 { … … 172 173 return mPriority; 173 174 #else 174 return (float) (-mDepth); // for kd tree175 return (float) (-mDepth); // for standard breath-first traversal 175 176 #endif 176 177 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1666 r1667 786 786 787 787 788 void VspTree::EvalSubdivisionCandidate(VspSubdivisionCandidate &splitCandidate) 789 { 790 float frontProb; 791 float backProb; 788 void VspTree::EvalSubdivisionCandidate(VspSubdivisionCandidate &splitCandidate, bool computeSplitPlane) 789 { 790 if (computeSplitPlane) 791 { 792 float frontProb; 793 float backProb; 794 795 // compute locally best split plane 796 const float ratio = SelectSplitPlane(splitCandidate.mParentData, 797 splitCandidate.mSplitPlane, 798 frontProb, 799 backProb); 800 801 const bool maxCostRatioViolated = mTermMaxCostRatio < ratio; 802 803 const int maxCostMisses = splitCandidate.mParentData.mMaxCostMisses; 804 // max cost threshold violated? 805 splitCandidate.SetMaxCostMisses(maxCostRatioViolated ? maxCostMisses + 1: maxCostMisses); 806 } 792 807 793 808 VspLeaf *leaf = dynamic_cast<VspLeaf *>(splitCandidate.mParentData.mNode); 794 809 795 // compute locally best split plane796 const float ratio = SelectSplitPlane(splitCandidate.mParentData,797 splitCandidate.mSplitPlane,798 frontProb,799 backProb);800 801 const bool maxCostRatioViolated = mTermMaxCostRatio < ratio;802 803 // max cost threshold violated?804 splitCandidate.SetMaxCostMisses(maxCostRatioViolated ?805 splitCandidate.mParentData.mMaxCostMisses + 1:806 splitCandidate.mParentData.mMaxCostMisses);807 808 810 // compute global decrease in render cost 809 811 float oldRenderCost; … … 821 823 // otherwise danger of being stuck in a local minimum!! 822 824 const float factor = mRenderCostDecreaseWeight; 823 824 825 float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 825 826 826 if (mHierarchyManager->mConsiderMemory) 827 { 828 //cout << "here4 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 829 //const float priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr(); 827 if (1)//0 && mHierarchyManager->mConsiderMemory) 828 { 830 829 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst); 831 830 } … … 835 834 836 835 837 float VspTree::EvalPriority(const VspSubdivisionCandidate &splitCandidate) const836 /*float VspTree::EvalPriority(const VspSubdivisionCandidate &splitCandidate) const 838 837 { 839 838 // compute global decrease in render cost … … 857 856 858 857 return priority; 859 } 858 }*/ 860 859 861 860 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1664 r1667 11 11 #include "gzstream.h" 12 12 #include "SubdivisionCandidate.h" 13 #include "HierarchyManager.h" 13 14 14 15 … … 457 458 int Type() const { return VIEW_SPACE; } 458 459 459 void Eval Priority(bool computeSplitplane = true)460 void EvalCandidate(bool computeSplitplane = true) 460 461 { 461 if (computeSplitplane) 462 sVspTree->EvalSubdivisionCandidate(*this); 463 else 464 { 465 mPvsEntriesIncr = sVspTree->EvalPvsEntriesIncr(*this); 466 mPriority = sVspTree->EvalPriority(*this); 467 } 462 sVspTree->EvalSubdivisionCandidate(*this, computeSplitplane); 468 463 } 469 464 … … 490 485 mSplitPlane(plane), mParentData(tData) 491 486 {} 487 488 float GetPriority() const 489 { 490 HierarchyManager *hm = sVspTree->mHierarchyManager; 491 if (hm->ConsiderMemory()) 492 { 493 const float rc = hm->GetHierarchyStats().mTotalCost - mRenderCostDecrease; 494 const float mc = hm->GetHierarchyStats().mMemory + 495 (float)mPvsEntriesIncr * ObjectPvs::GetEntrySizeByte(); 496 497 return - (rc * mc) / float(1024 * 1024); 498 } 499 else 500 { 501 return mPriority; 502 } 503 } 492 504 }; 493 505 … … 702 714 /** Evaluates candidate for splitting. 703 715 */ 704 void EvalSubdivisionCandidate(VspSubdivisionCandidate &splitData); 716 void EvalSubdivisionCandidate(VspSubdivisionCandidate &splitData, 717 bool computeSplitPlane = true); 705 718 706 719 /** Evaluates render cost decrease of next split. … … 854 867 @returns priority 855 868 */ 856 float EvalPriority(const VspSubdivisionCandidate &splitCandidate) const;869 //float EvalPriority(const VspSubdivisionCandidate &splitCandidate) const; 857 870 858 871 /////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.