Changeset 1580 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/06/06 21:37:00 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1577 r1580 174 174 ReadEnvironment(); 175 175 mSubdivisionCandidates = new SortableEntryContainer; 176 for (int i = 0; i < 3; ++ i) 177 mSortedObjects[i] = NULL; 176 178 } 177 179 … … 189 191 DEL_PTR(mSubdivisionCandidates); 190 192 193 for (int i = 0; i < 3; ++ i) 194 { 195 DEL_PTR(mSortedObjects[i]); 196 } 191 197 mSubdivisionStats.close(); 192 198 } … … 1004 1010 { 1005 1011 //-- insert object queries 1006 ObjectContainer *objects = mUseGlobalSorting ? tData.mSortedObjects[axis] : &tData.mNode->mObjects; 1012 ObjectContainer *objects = 1013 mUseGlobalSorting ? tData.mSortedObjects[axis] : &tData.mNode->mObjects; 1007 1014 1008 1015 CreateLocalSubdivisionCandidates(*objects, &mSubdivisionCandidates, !mUseGlobalSorting, axis); … … 1042 1049 1043 1050 if (sort) 1044 { 1051 { // no presorted candidate list 1045 1052 stable_sort((*subdivisionCandidates)->begin(), (*subdivisionCandidates)->end()); 1046 1053 } … … 1154 1161 } 1155 1162 1156 //////////////////////////////////// ////////1163 //////////////////////////////////// 1157 1164 //-- evaluate split cost for all three axis 1158 1165 … … 1179 1186 else 1180 1187 { 1181 //-- use surface area heuristic because view cells not constructed yet 1188 ////////////////// 1189 //-- view cells not constructed yet => use surface area heuristic 1182 1190 nCostRatio[axis] = 1183 1191 EvalSah( … … 1210 1218 } 1211 1219 1212 /////////////////////////////////////1220 //////////////// 1213 1221 //-- assign values 1214 1222 … … 1242 1250 } 1243 1251 1244 if ( 1&& ray->mOriginObject)1252 if (COUNT_ORIGIN_OBJECTS && ray->mOriginObject) 1245 1253 { 1246 1254 ray->mOriginObject->mVssRays.push_back(ray); … … 1298 1306 1299 1307 float BvHierarchy::EvalRenderCost(const ObjectContainer &objects) const 1300 { 1301 if (mHierarchyManager->GetViewSpaceSubdivisionType() == HierarchyManager::NO_VIEWSPACE_SUBDIV) 1302 { 1308 { 1309 if (mHierarchyManager->GetViewSpaceSubdivisionType() == 1310 HierarchyManager::NO_VIEWSPACE_SUBDIV) 1311 { 1312 //////////////// 1313 //-- surface area heuristics 1314 1303 1315 if (objects.empty()) 1304 1316 return 0.0f; 1305 1317 1306 ////////////////1307 //-- surface area heuristics1308 1309 1318 const AxisAlignedBox3 box = EvalBoundingBox(objects); 1310 1319 const float area = box.SurfaceArea(); 1311 1312 return (float)objects.size() * area / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 1320 const float viewSpaceArea = mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 1321 1322 return (float)objects.size() * area / viewSpaceArea; 1313 1323 } 1314 1324 else … … 1771 1781 if (mUseGlobalSorting) 1772 1782 { 1773 CreateInitialSortedObjectList(oData);1783 AssignInitialSortedObjectList(oData); 1774 1784 } 1775 1785 … … 1793 1803 1794 1804 1795 void BvHierarchy::CreateInitialSortedObjectList(BvhTraversalData &tData) 1796 { 1797 SortableEntryContainer *sortedObjects = new SortableEntryContainer(); 1798 1805 void BvHierarchy::AssignInitialSortedObjectList(BvhTraversalData &tData) 1806 { 1799 1807 // we sort the objects as a preprocess so they don't have 1800 1808 // to be sorted for each split 1801 1809 for (int i = 0; i < 3; ++ i) 1802 1810 { 1803 CreateLocalSubdivisionCandidates(tData.mNode->mObjects, &sortedObjects, true, i); 1804 1811 // create new objects 1812 if (!mSortedObjects[i]) 1813 { 1814 mSortedObjects[i] = new SortableEntryContainer(); 1815 CreateLocalSubdivisionCandidates(tData.mNode->mObjects, &mSortedObjects[i], true, i); 1816 } 1817 1818 // copy list into traversal data list 1805 1819 tData.mSortedObjects[i] = new ObjectContainer(); 1806 tData.mSortedObjects[i]->reserve((int)sortedObjects->size()); 1807 1808 SortableEntryContainer::const_iterator oit, oit_end = sortedObjects->end(); 1809 for (oit = sortedObjects->begin(); oit != oit_end; ++ oit) 1820 tData.mSortedObjects[i]->reserve((int)mSortedObjects[i]->size()); 1821 1822 SortableEntryContainer::const_iterator oit, oit_end = mSortedObjects[i]->end(); 1823 1824 for (oit = mSortedObjects[i]->begin(); oit != oit_end; ++ oit) 1810 1825 { 1811 1826 tData.mSortedObjects[i]->push_back((*oit).mObject); 1812 1827 } 1813 1828 } 1814 1815 delete sortedObjects;1816 1829 } 1817 1830 … … 1885 1898 BvhTraversalData oData(bvhLeaf, 0, prop, nRays); 1886 1899 1900 AssignInitialSortedObjectList(oData); 1901 1902 1887 1903 /////////////////// 1888 1904 //-- add first candidate for object space partition -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1576 r1580 13 13 #include "AxisAlignedBox3.h" 14 14 #include "IntersectableWrapper.h" 15 15 16 16 17 … … 789 790 float EvalViewCellsVolume(const ObjectContainer &objects) const; 790 791 791 /** Creates initial list of sorted objects.792 */ 793 void CreateInitialSortedObjectList(BvhTraversalData &tData);792 /** Assigns or newly creates initial list of sorted objects. 793 */ 794 void AssignInitialSortedObjectList(BvhTraversalData &tData); 794 795 795 796 /** Assigns sorted objects to front and back data. … … 844 845 //-- global termination criteria 845 846 847 /// the minimal accepted global cost ratio 846 848 float mTermMinGlobalCostRatio; 849 //// number of accepted misses of the global cost ratio 847 850 int mTermGlobalCostMissTolerance; 848 849 850 851 /// maximal number of view cells 851 852 int mTermMaxLeaves; … … 882 883 /// stores the kd node intersectables used for pvs 883 884 BvhIntersectableMap mBvhIntersectables; 884 885 /// if the objects should be sorted in one global step 885 886 bool mUseGlobalSorting; 887 888 SortableEntryContainer *mSortedObjects[3]; 886 889 }; 887 890 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1576 r1580 67 67 // set flag for visualization 68 68 newRay->mFlags |= VssRay::ReverseSample; 69 cout << "here9444 " << (int) newRay->mFlags << " " << newRay << endl;69 70 70 // ray is not pushed into the queue => can delete ray 71 71 if (!HandleRay(newRay)) … … 81 81 bool GvsPreprocessor::HandleRay(VssRay *vssRay) 82 82 { 83 cout << "x " << (int)vssRay->mFlags;84 83 const bool storeRaysForViz = true; 85 84 mViewCellsManager->ComputeSampleContribution(*vssRay, true, storeRaysForViz); … … 88 87 if (vssRay->mPvsContribution > 0) 89 88 { 89 // add new ray to ray queue 90 90 mRayQueue.push(vssRay); 91 91 … … 96 96 { 97 97 VssRay *nray = new VssRay(*vssRay); 98 nray->mFlags = vssRay->mFlags; 99 (*vit)->mVssRays.push_back(nray); 100 nray->mFlags = 10; 101 cout << "\nhere58 " << (int)nray->mFlags << " " << (int)vssRay->mFlags << endl; 98 (*vit)->mVssRays.push_back(nray); 102 99 } 103 100 } … … 205 202 206 203 if (!newRay) return 0; 207 newRay->mFlags |= VssRay::BorderSample; 204 205 newRay->mFlags |= VssRay::BorderSample; 206 207 // add new ray to queue 208 208 const bool enqueued = HandleRay(newRay); 209 209 … … 267 267 CastRays(simpleRays, vssRays, false, false); 268 268 269 // set flags 270 VssRayContainer::const_iterator rit, rit_end = vssRays.end(); 271 for (rit = vssRays.begin(); rit != rit_end; ++ rit) 272 {cout << "z"; 273 (*rit)->mFlags |= VssRay::BorderSample; 274 //(*rit)->mOriginObject = currentRay.mTerminationObject; 275 } 269 276 // add to ray queue 270 277 EnqueueRays(vssRays); … … 273 280 int castRays = (int)vssRays.size(); 274 281 275 VssRayContainer::const_iterator rit, rit_end = vssRays.end(); 276 for (rit = vssRays.begin(); rit != rit_end; ++ rit) 277 { 278 (*rit)->mFlags |= VssRay::BorderSample; 279 cout << "here390 " << (int) (*rit)->mFlags << endl; 280 } 281 282 #if 1 282 283 #if 0 283 284 // recursivly subdivide each edge 284 285 for (int i = 0; i < n; ++ i) … … 347 348 { 348 349 const long startTime = GetTime(); 349 350 //cout << "here8"<<endl; 350 351 // generate simple rays 351 352 SimpleRayContainer simpleRays; … … 433 434 /// construct the view cells from the scratch 434 435 ConstructViewCells(); 436 // reset pvs already gathered during view cells construction 437 mViewCellsManager->ResetPvs(); 435 438 cout << "finished view cell construction" << endl; 436 439 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1577 r1580 58 58 mVspTree->mHierarchyManager = this; 59 59 60 mViewSpaceSubdivisionType = KD_BASED_VIEWSPACE_SUBDIV; 60 61 ParseEnvironment(); 61 62 } … … 72 73 mVspTree->mHierarchyManager = this; 73 74 75 mViewSpaceSubdivisionType = KD_BASED_VIEWSPACE_SUBDIV; 74 76 ParseEnvironment(); 75 77 } … … 78 80 void HierarchyManager::ParseEnvironment() 79 81 { 80 char subdivisionStatsLog[100];81 Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats",82 subdivisionStatsLog);83 mSubdivisionStats.open(subdivisionStatsLog);84 85 82 Environment::GetSingleton()->GetFloatValue( 86 83 "Hierarchy.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); … … 109 106 "Hierarchy.Construction.useMultiLevel", mUseMultiLevelConstruction); 110 107 111 mUseMultiLevelConstruction; 108 Environment::GetSingleton()->GetIntValue( 109 "Hierarchy.Construction.levels", mNumMultiLevels); 110 112 111 Debug << "******** Hierachy Manager Parameters ***********" << endl; 113 112 Debug << "max leaves: " << mTermMaxLeaves << endl; … … 117 116 Debug << "min depth for object space subdivision: " << mMinDepthForObjectSpaceSubdivion << endl; 118 117 Debug << "repair queue: " << mRepairQueue << endl; 118 Debug << "number of multilevels: " << mNumMultiLevels << endl; 119 119 Debug << endl; 120 120 } … … 198 198 199 199 200 void HierarchyManager::EvalSubdivisionStats(const SubdivisionCandidate &tData) 201 { 202 const float costDecr = tData.GetRenderCostDecrease(); 203 cout << "here44 " << mHierarchyStats.pvsEntries << endl; 200 void HierarchyManager::EvalSubdivisionStats(const float renderCostDecr) 201 { 202 //cout << "pvs entries " << mHierarchyStats.pvsEntries << endl; 204 203 AddSubdivisionStats(mHierarchyStats.Leaves(), 205 costDecr,204 renderCostDecr, 206 205 mTotalCost, 207 //mPvsEntries208 206 mHierarchyStats.pvsEntries 209 207 ); … … 253 251 else 254 252 { 253 char subdivisionStatsLog[100]; 254 Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats", 255 subdivisionStatsLog); 256 mSubdivisionStats.open(subdivisionStatsLog); 257 255 258 ConstructInterleaved(sampleRays, objects, forcedViewSpace); 256 259 } … … 267 270 268 271 mTotalCost = (float)objects.size(); 272 EvalSubdivisionStats(0); 269 273 Debug << "setting total cost to " << mTotalCost << endl; 270 274 … … 315 319 { 316 320 cout << "\nstarting view space hierarchy construction ... " << endl; 317 321 // hack: reset global cost misses 318 322 mHierarchyStats.mGlobalCostMisses = 0; 319 323 320 324 RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 321 325 SubdivisionCandidate *vsc = … … 346 350 347 351 void HierarchyManager::PrepareBvHierarchy(const VssRayContainer &sampleRays, 348 const ObjectContainer &objects) 349 352 const ObjectContainer &objects) 350 353 { 351 354 const long startTime = GetTime(); … … 387 390 388 391 389 bool HierarchyManager::ApplySubdivisionCandidate(SubdivisionCandidate *sc )392 bool HierarchyManager::ApplySubdivisionCandidate(SubdivisionCandidate *sc, const bool repairQueue) 390 393 { 391 394 const bool globalTerminationCriteriaMet = GlobalTerminationCriteriaMet(sc); … … 406 409 } 407 410 408 if (vspSplit) 409 { 410 VspNode *n = mVspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 411 412 if (n->IsLeaf()) // local or global termination criteria failed 413 return false; 414 } 415 else 416 { 417 if (mObjectSpaceSubdivisionType == KD_BASED_OBJ_SUBDIV) 418 { 419 KdNode *n = mOspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 420 // local or global termination criteria failed 421 if (n->IsLeaf()) 422 return false; 423 } 424 else if (mObjectSpaceSubdivisionType == BV_BASED_OBJ_SUBDIV) 425 { 426 BvhNode *n = mBvHierarchy->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 427 // local or global termination criteria failed 428 if (n->IsLeaf()) 429 return false; 430 } 411 bool success; 412 switch (sc->Type()) 413 { 414 case SubdivisionCandidate::VIEW_SPACE: 415 { 416 VspNode *n = mVspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 417 success = !n->IsLeaf(); // local or global termination criteria failed? 418 } 419 break; 420 case SubdivisionCandidate::OBJECT_SPACE: 421 { 422 if (mObjectSpaceSubdivisionType == KD_BASED_OBJ_SUBDIV) 423 { 424 KdNode *n = mOspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 425 // local or global termination criteria failed 426 success = !n->IsLeaf(); 427 } 428 else if (mObjectSpaceSubdivisionType == BV_BASED_OBJ_SUBDIV) 429 { 430 BvhNode *n = mBvHierarchy->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 431 // local or global termination criteria failed 432 success = !n->IsLeaf(); 433 } 434 } 435 break; 436 default: 437 break; 438 } 439 440 cout << sc->Type() << " "; 441 442 // update stats 443 mHierarchyStats.nodes += 2; 444 445 const int pvsEntries = sc->GetPvsEntriesIncr(); 446 mHierarchyStats.pvsEntries += pvsEntries; 447 448 //cout << "pvs entries: " << pvsEntries << " " << mHierarchyStats.pvsEntries << endl; 449 mHierarchyStats.memory += 0; // TODO 450 451 // subdivision successful 452 EvalSubdivisionStats(sc->GetRenderCostDecrease()); 453 454 // reevaluate candidates affected by the split for view space splits, 455 // this would be object space splits and other way round 456 if (repairQueue) 457 { 458 RepairQueue(); 431 459 } 432 460 … … 507 535 //-- subdivide leaf node 508 536 509 if (ApplySubdivisionCandidate(mCurrentCandidate)) 510 { 511 cout << mCurrentCandidate->Type() << " "; 512 513 // update stats 514 mHierarchyStats.nodes += 2; 515 const int pvsEntries = mCurrentCandidate->GetPvsEntriesIncr(); 516 mHierarchyStats.pvsEntries += pvsEntries; 517 cout << "pvs entries: " << pvsEntries << " " << mHierarchyStats.pvsEntries << endl; 518 mHierarchyStats.memory += 0; // TODO 519 // subdivision successful 520 EvalSubdivisionStats(*mCurrentCandidate); 521 522 // reevaluate candidates affected by the split for view space splits, 523 // this would be object space splits and other way round 524 if (repairQueue) 525 { 526 RepairQueue(); 527 } 528 } 529 537 ApplySubdivisionCandidate(mCurrentCandidate, repairQueue); 538 530 539 // we use objects for evaluating vsp tree construction until 531 540 // a certain depth once a certain depth existiert ... … … 569 578 { 570 579 int i = 0; 580 // main loop 571 581 while (!FinishedConstruction()) 572 582 { 573 583 mCurrentCandidate = NextSubdivisionCandidate(); 574 584 575 /////// ////////////585 /////// 576 586 //-- subdivide leaf node 577 587 578 if (ApplySubdivisionCandidate(mCurrentCandidate)) 579 { 580 cout << mCurrentCandidate->Type() << " "; 581 if (0) cout << "subdividing candidate " << ++ i << " of type " 582 << mCurrentCandidate->Type() << endl; 583 mHierarchyStats.nodes += 2; 584 585 // subdivision successful 586 EvalSubdivisionStats(*mCurrentCandidate); 587 588 // reevaluate candidates affected by the split for view space splits, 589 // this would be object space splits and other way round 590 if (repairQueue) 591 { 592 RepairQueue(); 593 } 594 } 595 588 ApplySubdivisionCandidate(mCurrentCandidate, repairQueue); 596 589 DEL_PTR(mCurrentCandidate); 597 590 } … … 601 594 void HierarchyManager::ResetObjectSpaceSubdivision(const VssRayContainer &sampleRays, 602 595 const ObjectContainer &objects) 603 { 596 { 604 597 #if 0 605 598 DEL_PTR(mBvHierarchy); … … 609 602 PrepareObjectSpaceSubdivision(sampleRays, objects); 610 603 return; 611 #endif 612 604 #else 605 606 // no object space subdivision yet 613 607 if (!ObjectSpaceSubdivisionConstructed()) 614 608 { … … 616 610 } 617 611 612 // object space partition constructed => reconstruct 618 613 switch (mObjectSpaceSubdivisionType) 619 614 { 620 615 case BV_BASED_OBJ_SUBDIV: 621 cout << "\nreseting bv hierarchy" << endl; 622 Debug << "old bv hierarchy:\n " << mBvHierarchy->mBvhStats << endl; 623 624 mHierarchyStats.nodes -= mBvHierarchy->mBvhStats.nodes; 625 mTQueue.Push(mBvHierarchy->Reset(sampleRays, objects)); 626 mTotalCost = mBvHierarchy->mTotalCost; 616 { 617 cout << "\nreseting bv hierarchy" << endl; 618 Debug << "old bv hierarchy:\n " << mBvHierarchy->mBvhStats << endl; 619 620 SubdivisionCandidate *firstCandidate = 621 mBvHierarchy->Reset(sampleRays, objects); 622 623 mTQueue.Push(firstCandidate); 624 mTotalCost = mBvHierarchy->mTotalCost; 625 626 mHierarchyStats.nodes = 2; 627 mHierarchyStats.pvsEntries = 0; 628 EvalSubdivisionStats(0); 629 } 627 630 break; 628 631 … … 633 636 break; 634 637 } 638 #endif 635 639 } 636 640 … … 639 643 const ObjectContainer &objects) 640 644 { 641 DEL_PTR(mBvHierarchy); 642 mBvHierarchy = new BvHierarchy(); 643 mBvHierarchy->mHierarchyManager = this; 645 ViewCellsManager *vc = mVspTree->mViewCellsManager; 646 647 DEL_PTR(mVspTree); 648 mVspTree = new VspTree(); 649 mVspTree->mHierarchyManager = this; 650 mVspTree->mViewCellsManager = vc; 644 651 645 652 PrepareViewSpaceSubdivision(sampleRays, objects); 646 return; 653 654 mHierarchyStats.nodes = 2; 655 mHierarchyStats.pvsEntries = 0; 656 EvalSubdivisionStats(0); 657 647 658 } 648 659 … … 665 676 mVspTree->ComputeBoundingBox(sampleRays, forcedViewSpace); 666 677 667 // use sah for evaluating object space construction for the first run 678 // use sah for evaluating osp tree construction 679 // in the first iteration of the subdivision 680 668 681 mSavedViewSpaceSubdivisionType = mViewSpaceSubdivisionType; 669 682 mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 670 671 const int limit = 4; 683 684 mSavedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 685 //mObjectSpaceSubdivisionType = NO_OBJ_SUBDIV; 686 687 const int limit = mNumMultiLevels; 672 688 int i = 0; 673 689 … … 678 694 while (1) 679 695 { 680 // first run object space subdivision 696 char subdivisionStatsLog[100]; 697 sprintf(subdivisionStatsLog, "tests/i3d/subdivision-%04d.log", i); 698 mSubdivisionStats.open(subdivisionStatsLog); 699 700 // fsubdivide object space first 681 701 ResetObjectSpaceSubdivision(sampleRays, objects); 682 683 702 // process object space candidates 684 703 RunConstruction(false); 685 704 686 if ((++ i) >= limit) 705 // object space subdivision constructed 706 mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 707 708 cout << "iteration " << i << " of " << limit << " finished" << endl; 709 710 mSubdivisionStats.close(); 711 if ((i ++) >= limit) 687 712 break; 688 713 714 sprintf(subdivisionStatsLog, "tests/i3d/subdivision-%04d.log", i); 715 mSubdivisionStats.open(subdivisionStatsLog); 716 689 717 ///////////////// 690 // do view space subdivison with respect to the object space partition 718 // subdivide view space with respect to the objects 719 691 720 ResetViewSpaceSubdivision(sampleRays, objects); 692 693 721 // process view space candidates 694 722 RunConstruction(false); 723 // view space subdivision constructed 695 724 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 696 697 if ((++ i) >= limit) 725 726 cout << "iteration " << i << " of " << limit << " finished" << endl; 727 728 mSubdivisionStats.close(); 729 730 if ((i ++) >= limit) 698 731 break; 699 700 cout << "iteration " << i << " of " << limit << " finished" << endl;701 732 } 702 733 … … 729 760 return mBvHierarchy && mBvHierarchy->GetRoot(); 730 761 default: 731 762 return false; 732 763 } 733 764 } … … 808 839 809 840 // collect list of "dirty" candidates 810 long startTime = GetTime();841 const long startTime = GetTime(); 811 842 812 843 vector<SubdivisionCandidate *> dirtyList; … … 827 858 sc->EvalPriority(); // reevaluate 828 859 829 /* 860 #ifdef _DEBUG 830 861 Debug << "candidate " << sc << " reevaluated\n" 831 862 << "render cost decrease diff " << rcd - sc->GetRenderCostDecrease() 832 << " old: " << rcd << " new " << sc->GetRenderCostDecrease() << endl;*/ 833 if (0) 834 { 835 const float rcDiff = rcd - sc->GetRenderCostDecrease(); 836 mTotalCost += rcDiff; 837 } 863 << " old: " << rcd << " new " << sc->GetRenderCostDecrease() << endl; 864 #endif 838 865 mTQueue.Push(sc); // reinsert 866 cout << "."; 839 867 } 840 868 841 869 long endTime = GetTime(); 842 870 Real timeDiff = TimeDiff(startTime, endTime); 843 844 871 mHierarchyStats.repairTime += timeDiff; 845 872 846 if ( 0) cout << "finished in " << timeDiff * 1e-3f << " secs" << endl;873 if (1) cout << "repaired in " << timeDiff * 1e-3f << " secs" << endl; 847 874 } 848 875 … … 864 891 SubdivisionCandidateContainer::const_iterator sit, sit_end = mCandidateBuffer.end(); 865 892 for (sit = mCandidateBuffer.begin(); sit != sit_end; ++ sit) 866 { cout << ":";893 { 867 894 mTQueue.Push(*sit); 868 895 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1576 r1580 245 245 void RunConstruction(const bool repairQueue); 246 246 247 bool ApplySubdivisionCandidate(SubdivisionCandidate *sc); 247 /** Evaluates the subdivision candidate and executes the split. 248 */ 249 bool ApplySubdivisionCandidate(SubdivisionCandidate *sc, const bool repairQueue); 248 250 249 251 bool FinishedConstruction() const; … … 251 253 SubdivisionCandidate *NextSubdivisionCandidate(); 252 254 255 /** Repairs the dirty entries of the candidate queue. 256 */ 253 257 void RepairQueue(); 254 258 259 /** Collect the list of dirty candidates after the current subdivision candidate 260 split. 261 */ 255 262 void CollectDirtyCandidates(vector<SubdivisionCandidate *> &dirtyList); 256 263 257 void EvalSubdivisionStats(const SubdivisionCandidate &tData); 264 /** Evaluate subdivision stats for log. 265 */ 266 void EvalSubdivisionStats(const float renderCostDecr); 258 267 259 268 void AddSubdivisionStats( … … 328 337 329 338 enum {SEQUENTIAL, INTERLEAVED}; 330 339 /// type of hierarchy construction 340 int mConstructionType; 341 342 /// Type of object space partition 331 343 int mObjectSpaceSubdivisionType; 344 /// Type of view space partition 332 345 int mViewSpaceSubdivisionType; 333 346 334 /// the original osp type 347 //////////// 348 //-- helper variables 349 350 // the original osp type 335 351 int mSavedObjectSpaceSubdivisionType; 352 // the original vsp type 336 353 int mSavedViewSpaceSubdivisionType; 337 338 int mConstructionType; 339 354 /// the current subdivision candidate 355 SubdivisionCandidate *mCurrentCandidate; 356 357 /////////////////// 358 359 360 /////////////////// 361 // Hierarchies 362 363 /// view space hierarchy 340 364 VspTree *mVspTree; 365 /// object space partition kd tree 341 366 OspTree *mOspTree; 367 /// bounding volume hierarchy 342 368 BvHierarchy *mBvHierarchy; 343 369 344 AxisAlignedBox3 mBoundingBox; 345 370 ////////////////////// 371 372 373 /// the traversal queue 346 374 SplitQueue mTQueue; 347 348 SubdivisionCandidate *mCurrentCandidate; 349 350 //////// 375 376 377 ////////// 351 378 //-- global termination criteria 352 379 380 /// the mininal acceptable cost ratio for a split 353 381 float mTermMinGlobalCostRatio; 382 /// the threshold for global cost miss tolerance 354 383 int mTermGlobalCostMissTolerance; 355 384 /// maximum number of leaves 385 int mTermMaxLeaves; 386 356 387 //////////////////// 357 388 358 389 /// keeps track of cost during subdivision 359 390 float mTotalCost; 360 361 int mTotalPvsEntries; 391 /// statistics about the hierarchy 362 392 HierarchyStatistics mHierarchyStats; 363 393 364 394 int mMinDepthForObjectSpaceSubdivion; 365 395 int mMinDepthForViewSpaceSubdivion; 366 367 int mTermMaxLeaves; 396 368 397 ofstream mSubdivisionStats; 369 398 399 /// if the queue should be repaired after a subdivision steps 370 400 bool mRepairQueue; 371 401 372 402 bool mStartWithObjectSpace; 373 403 /** if multi level construction method should be used 404 where we iterate over both hierarchies until we 405 converge to the optimum. 406 */ 374 407 bool mUseMultiLevelConstruction; 408 /// number of iteration steps for multilevel approach 409 int mNumMultiLevels; 375 410 }; 376 411 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1576 r1580 35 35 // HACK 36 36 const static bool SAMPLE_AFTER_SUBDIVISION = true; 37 const static bool CLAMP_TO_BOX = false;37 const static bool CLAMP_TO_BOX = true; 38 38 39 39 template <typename T> class myless … … 814 814 // potentially visible objects 815 815 return vc->AddPvsSample(obj, pdf, contribution); 816 } 817 818 819 void ViewCellsManager::ResetPvs() 820 { 821 if (ViewCellsTreeConstructed()) 822 { 823 mViewCellsTree->ResetPvs(); 824 } 825 else 826 { 827 cout << "view cells tree not constructed" << endl; 828 } 816 829 } 817 830 … … 1841 1854 1842 1855 if (ray.mTerminationObject) 1843 { 1856 { 1844 1857 if (viewcell->GetPvs().GetSampleContribution( 1845 1858 ray.mTerminationObject, … … 2932 2945 if (p < raysOut) 2933 2946 { 2934 cout << "here42 " << (int)(*rit)->mFlags << endl;2935 2947 if ((*rit)->mFlags & VssRay::BorderSample) 2948 { 2936 2949 vcRays.push_back(*rit); 2950 } 2937 2951 else if ((*rit)->mFlags & VssRay::ReverseSample) 2938 2952 vcRays2.push_back(*rit); … … 5309 5323 stream << "<VisibilitySolution>" << endl; 5310 5324 5311 5312 /////////////// 5313 //-- export bounding boxes 5314 //-- The bounding boxes are used to identify 5315 //-- the objects in the rendering engine 5316 5317 stream << "<BoundingBoxes>" << endl; 5318 ObjectContainer::const_iterator oit, oit_end = objects.end(); 5319 5320 for (oit = objects.begin(); oit != oit_end; ++ oit) 5321 { 5325 if (exportPvs) 5326 { 5327 /////////////// 5328 //-- export bounding boxes 5329 //-- The bounding boxes are used to identify 5330 //-- the objects in the rendering engine 5331 5332 stream << "<BoundingBoxes>" << endl; 5333 ObjectContainer::const_iterator oit, oit_end = objects.end(); 5334 5335 for (oit = objects.begin(); oit != oit_end; ++ oit) 5336 { 5322 5337 const AxisAlignedBox3 box = (*oit)->GetBox(); 5323 5338 stream << "<BoundingBox" << " id=\"" << (*oit)->GetId() << "\"" 5324 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 5325 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 5326 } 5327 stream << "</BoundingBoxes>" << endl; 5328 5339 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 5340 5341 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 5342 } 5343 5344 stream << "</BoundingBoxes>" << endl; 5345 } 5329 5346 5330 5347 ////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1576 r1580 517 517 @param exportPvs if the pvs should also be exported 518 518 @param exportRays if sample rays should be exported as well 519 @param maxRays maximum number of rays to export 520 @param prefix the prefix for the output file 519 521 @param visRays additional rays 520 522 */ … … 530 532 VssRayContainer *visRays = NULL) = NULL; 531 533 534 535 void ViewCellsManager::ResetPvs(); 536 537 532 538 protected: 533 539 … … 577 583 void EvaluateViewCellsStats(); 578 584 579 585 580 586 /////////////////////// 581 587 //-- helper functions for view cell visualization -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1577 r1580 26 26 #define COUNT_ORIGIN_OBJECTS 1 27 27 28 /////////// 28 29 ////////////// 29 30 //-- static members 30 31 … … 383 384 384 385 cout << "Extracting polygons from rays ... "; 385 386 long startTime = GetTime(); 386 const long startTime = GetTime(); 387 387 388 388 VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); … … 422 422 { 423 423 // TODO 424 cout << " here5" << endl;424 cout << "not implemented yet" << endl; 425 425 } 426 426 default: … … 1384 1384 SortSubdivisionCandidates(usedRays, axis, minBand, maxBand); 1385 1385 1386 ////////////////// 1386 1387 // go through the lists, count the number of objects left and right 1387 1388 // and evaluate the following cost funcion: … … 1396 1397 float sum = (float)pvsSize * sizeBox; 1397 1398 float minSum = 1e20f; 1398 1399 1399 1400 1400 // if no border can be found, take mid split … … 1406 1406 1407 1407 Intersectable::NewMail(); 1408 1409 1408 RayInfoContainer::const_iterator ri, ri_end = usedRays.end(); 1410 1409 … … 1443 1442 1444 1443 Intersectable::NewMail(); 1445 1446 1444 vector<SortableEntry>::const_iterator ci, ci_end = mLocalSubdivisionCandidates->end(); 1447 1445 … … 1454 1452 Intersectable *tObject = ray->mTerminationObject; 1455 1453 1456 1457 1454 switch ((*ci).type) 1458 1455 { … … 2115 2112 AddObjToPvs(ray->mTerminationObject, cf, pvsFront, pvsBack, totalPvs); 2116 2113 2117 if (COUNT_ORIGIN_OBJECTS) 2114 if (COUNT_ORIGIN_OBJECTS) 2115 { 2118 2116 AddObjToPvs(ray->mOriginObject, cf, pvsFront, pvsBack, totalPvs); 2117 } 2119 2118 } 2120 2119 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1577 r1580 829 829 830 830 AxisAlignedPlane candidatePlane = splitCandidate.mSplitPlane; 831 RayInfoContainer::const_iterator rit, 832 rit_end = splitCandidate.mParentData.mRays->end(); 833 834 // this is the main ray classification loop! 831 832 Intersectable::NewMail(3); 833 KdLeaf::NewMail(3); 834 BvhLeaf::NewMail(3); 835 836 RayInfoContainer::const_iterator rit, rit_end = splitCandidate.mParentData.mRays->end(); 837 838 // this is the main ray classification loop! 835 839 for(rit = splitCandidate.mParentData.mRays->begin(); rit != rit_end; ++ rit) 836 840 { … … 849 853 #endif 850 854 } 851 855 //cout << "pvs entries: " << fPvsSize << " " << bPvsSize << " " << oldPvsSize << endl; 856 852 857 return (int)(fPvsSize + bPvsSize - oldPvsSize); 853 858 } … … 1495 1500 candidatePlane.mPosition, t); 1496 1501 1497 // evaluate contribution of ray endpoint to front and back pvs1498 // with respect to the classification1502 // evaluate contribution of ray endpoint to front 1503 // and back pvs with respect to the classification 1499 1504 UpdateContributionsToPvs(*ray, true, cf, pvsFront, pvsBack, totalPvs); 1500 1505 #if COUNT_ORIGIN_OBJECTS … … 1657 1662 if (!leaf) return; 1658 1663 const int renderCost = countEntries ? 1 : (int)leaf->mObjects.size(); 1659 1664 1660 1665 // leaf in no pvs => new 1661 1666 if (!leaf->Mailed() && !leaf->Mailed(1) && !leaf->Mailed(2)) … … 3124 3129 { 3125 3130 BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 3126 UpdateContributionsToPvs(leaf, cf, pvsFront, pvsBack, totalPvs, true); 3131 UpdateContributionsToPvs(leaf, cf, pvsFront, pvsBack, totalPvs, true); 3127 3132 break; 3128 3133 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.cpp
r1528 r1580 73 73 mFlags = 0; 74 74 Vector3 dir = GetDir(); 75 75 //mFlags |= BorderSample; 76 76 #define BIDIRECTIONAL_RAY 0 77 77 #if BIDIRECTIONAL_RAY -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1579 r1580 129 129 char internKdTree[100]; 130 130 Environment::GetSingleton()->GetStringValue("Preprocessor.kdTreeFilename", internKdTree); 131 //string internKdTree = ReplaceSuffic(filename, ".x3d", ".kd"); 131 132 132 133 //-- initialize external ray casters
Note: See TracChangeset
for help on using the changeset viewer.