Changeset 1259 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 08/22/06 22:48:02 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1251 r1259 1590 1590 1591 1591 1592 1593 } 1592 bool BvHierarchy::AddLeafToPvs(BvhLeaf *leaf, 1593 ViewCell *vc, 1594 const float pdf, 1595 float &contribution) 1596 { 1597 // add kd intersecable to pvs 1598 BvhIntersectable *bvhObj = GetOrCreateBvhIntersectable(leaf); 1599 1600 return vc->AddPvsSample(bvhObj, pdf, contribution); 1601 } 1602 1603 1604 } -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1251 r1259 259 259 ObjectContainer mObjects; 260 260 261 /// universal counter 262 int mCounter; 261 263 protected: 262 264 … … 498 500 @returns number of view cells found 499 501 */ 500 int ComputeBoxIntersections(const AxisAlignedBox3 &box, 501 ViewCellContainer &viewCells) const; 502 int ComputeBoxIntersections( 503 const AxisAlignedBox3 &box, 504 ViewCellContainer &viewCells) const; 502 505 503 506 … … 510 513 void SetViewCellsTree(ViewCellsTree *vt) { mViewCellsTree = vt; } 511 514 515 /** Add the bvh leaf to the pvs of the view cell. 516 */ 517 bool AddLeafToPvs( 518 BvhLeaf *leaf, 519 ViewCell *vc, 520 const float pdf, 521 float &contribution); 512 522 513 523 protected: … … 560 570 } 561 571 }; 562 563 572 564 573 /** faster evaluation of split plane cost for kd axis aligned cells. … … 748 757 749 758 float EvalViewCellsVolume(BvhLeaf *leaf) const; 759 750 760 751 761 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1237 r1259 20 20 #include "VspTree.h" 21 21 #include "OspTree.h" 22 #include "BvHierarchy.h" 22 23 23 24 … … 33 34 34 35 35 HierarchyManager::HierarchyManager(VspTree &vspTree, OspTree &ospTree): 36 mVspTree(vspTree), mOspTree(ospTree) 37 { 38 // cross references 39 mVspTree.mOspTree = &ospTree; 40 mOspTree.mVspTree = &vspTree; 41 36 HierarchyManager::HierarchyManager(VspTree &vspTree, OspTree &ospTree) 37 //:mVspTree(vspTree), mOspTree(ospTree) 38 { 42 39 char subdivisionStatsLog[100]; 43 40 Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats", … … 63 60 { 64 61 SubdivisionCandidate *vsc = 65 mVspTree .PrepareConstruction(sampleRays, forcedViewSpace, viewSpaceRays);62 mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, viewSpaceRays); 66 63 mTQueue.Push(vsc); 67 64 68 65 SubdivisionCandidate *osc = 69 mOspTree .PrepareConstruction(sampleRays, objects, forcedViewSpace, objectSpaceRays);66 mOspTree->PrepareConstruction(sampleRays, objects, forcedViewSpace, objectSpaceRays); 70 67 71 68 mTQueue.Push(osc); … … 78 75 79 76 //mTotalCost -= costDecr; 80 // 81 82 AddSubdivisionStats(mOspTree .mOspStats.Leaves() + mVspTree.mVspStats.Leaves(),77 //mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - tData.mPvs; 78 79 AddSubdivisionStats(mOspTree->mOspStats.Leaves() + mVspTree->mVspStats.Leaves(), 83 80 costDecr, 84 81 mTotalCost … … 116 113 PrepareConstruction(sampleRays, objects, forcedViewSpace, *viewSpaceRays, *objectSpaceRays); 117 114 118 mVspTree .mVspStats.Reset();119 mVspTree .mVspStats.Start();115 mVspTree->mVspStats.Reset(); 116 mVspTree->mVspStats.Start(); 120 117 121 118 cout << "Constructing view space / object space tree ... \n"; … … 126 123 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 127 124 128 mVspTree .mVspStats.Stop();125 mVspTree->mVspStats.Stop(); 129 126 } 130 127 … … 139 136 if (vspSplit) 140 137 { 141 VspNode *n = mVspTree .Subdivide(mTQueue, sc, globalTerminationCriteriaMet);138 VspNode *n = mVspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 142 139 } 143 140 else 144 141 { 145 KdNode *n = mOspTree .Subdivide(mTQueue, sc, globalTerminationCriteriaMet);142 KdNode *n = mOspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 146 143 } 147 144 … … 209 206 // during view space partition 210 207 const bool savedCountMethod = mVspTree.mUseKdPvsForHeuristics; 211 const bool savedStoreMethod = mVspTree.mStore KdPvs;208 const bool savedStoreMethod = mVspTree.mStoreObjectPvs; 212 209 213 210 mVspTree.mUseKdPvsForHeuristics = false; 214 mVspTree.mStore KdPvs = false;211 mVspTree.mStoreObjectPvs = false; 215 212 #endif 216 213 217 214 SubdivisionCandidate *vsc = 218 mVspTree .PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays);215 mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 219 216 220 217 // add to queue … … 224 221 cout << "starting vsp contruction ... " << endl; 225 222 226 mVspTree .mVspStats.Reset();227 mVspTree .mVspStats.Start();223 mVspTree->mVspStats.Reset(); 224 mVspTree->mVspStats.Start(); 228 225 229 226 int i = 0; … … 238 235 239 236 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 240 mVspTree.mVspStats.Stop(); 241 237 mVspTree->mVspStats.Stop(); 242 238 243 239 … … 255 251 // compute first candidate 256 252 SubdivisionCandidate *osc = 257 mOspTree .PrepareConstruction(sampleRays, objects, forcedViewSpace, *objectSpaceRays);253 mOspTree->PrepareConstruction(sampleRays, objects, forcedViewSpace, *objectSpaceRays); 258 254 259 255 Debug << "reseting cost, new total cost: " << mTotalCost << endl; 260 mTotalCost = mOspTree .mTotalCost;256 mTotalCost = mOspTree->mTotalCost; 261 257 262 258 mTQueue.Push(osc); 263 259 264 mOspTree .mOspStats.Reset();265 mOspTree .mOspStats.Start();260 mOspTree->mOspStats.Reset(); 261 mOspTree->mOspStats.Start(); 266 262 267 263 startTime = GetTime(); … … 272 268 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 273 269 274 mOspTree .mOspStats.Stop();275 276 float rc = mOspTree .EvalRenderCost(sampleRays);270 mOspTree->mOspStats.Stop(); 271 272 float rc = mOspTree->EvalRenderCost(sampleRays); 277 273 278 274 Debug << "here47 My render cost evalulation: " << rc << endl; … … 280 276 #if 0 281 277 // reset parameters 282 mVspTree .mUseKdPvsForHeuristics = savedCountMethod;283 mVspTree .mStoreKdPvs = savedStoreMethod;278 mVspTree->mUseKdPvsForHeuristics = savedCountMethod; 279 mVspTree->mStoreObjectPvs = savedStoreMethod; 284 280 #endif 285 281 } … … 290 286 AxisAlignedBox3 *forcedViewSpace) 291 287 { 292 // only view space partition288 // construct only view space partition 293 289 // object kd tree is taken for osp 294 290 295 mVspTree .mVspStats.Reset();296 mVspTree .mVspStats.Start();291 mVspTree->mVspStats.Reset(); 292 mVspTree->mVspStats.Start(); 297 293 298 294 RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 299 295 300 296 SubdivisionCandidate *sc = 301 mVspTree .PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays);297 mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 302 298 303 299 mTQueue.Push(sc); … … 310 306 311 307 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 312 mVspTree .mVspStats.Stop();308 mVspTree->mVspStats.Stop(); 313 309 } 314 310 … … 320 316 321 317 322 void HierarchyManager::CollectDirtyCandidates(vector<SubdivisionCandidate *> &dirtyList) 318 void HierarchyManager::CollectObjectSpaceDirtyList(SubdivisionCandidateContainer &dirtyList) 319 { 320 switch (mObjectSpaceSubdivisonType) 321 { 322 case KD_BASED_OBJ_SUBDIV: 323 { 324 OspTree::OspSubdivisionCandidate *sc = 325 dynamic_cast<OspTree::OspSubdivisionCandidate *>(mCurrentCandidate); 326 327 mOspTree->CollectDirtyCandidates(sc, dirtyList); 328 break; 329 } 330 case BV_BASED_OBJ_SUBDIV: 331 { 332 BvHierarchy::BvhSubdivisionCandidate *sc = 333 dynamic_cast<BvHierarchy::BvhSubdivisionCandidate *>(mCurrentCandidate); 334 335 mBvHierarchy->CollectDirtyCandidates(sc, dirtyList); 336 break; 337 } 338 default: 339 break; 340 } 341 } 342 343 344 void HierarchyManager::CollectViewSpaceDirtyList(SubdivisionCandidateContainer &dirtyList) 345 { 346 VspTree::VspSubdivisionCandidate *sc = 347 dynamic_cast<VspTree::VspSubdivisionCandidate *>(mCurrentCandidate); 348 349 mVspTree->CollectDirtyCandidates(sc, dirtyList); 350 } 351 352 353 void HierarchyManager::CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList) 323 354 { 324 355 // we have either a object space or view space split 325 356 if (mCurrentCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) 326 357 { 327 VspTree::VspSubdivisionCandidate *sc = 328 dynamic_cast<VspTree::VspSubdivisionCandidate *>(mCurrentCandidate); 329 330 mVspTree.CollectDirtyCandidates(sc, dirtyList); 358 CollectViewSpaceDirtyList(dirtyList); 331 359 } 332 360 else // object space split 333 { 334 OspTree::OspSubdivisionCandidate *sc = 335 dynamic_cast<OspTree::OspSubdivisionCandidate *>(mCurrentCandidate); 336 337 mOspTree.CollectDirtyCandidates(sc, dirtyList); 361 { 362 CollectObjectSpaceDirtyList(dirtyList); 338 363 } 339 364 } … … 380 405 } 381 406 382 } 407 408 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1239 r1259 39 39 class VspTree; 40 40 class KdTreeStatistics; 41 41 class BvHierarchy; 42 42 43 43 … … 86 86 class HierarchyManager 87 87 { 88 friend VspTree; 89 friend OspTree; 90 friend BvHierarchy; 91 88 92 public: 89 93 /** Constructor taking an object space partition and a view space partition tree. … … 112 116 AxisAlignedBox3 *forcedViewSpace); 113 117 114 public: 115 VspTree &mVspTree; 116 OspTree &mOspTree; 117 118 enum 119 { 120 NO_OBJ_SUBDIV, 121 KD_BASED_OBJ_SUBDIV, 122 BV_BASED_OBJ_SUBDIV 123 }; 124 125 /** The type of object space subdivison 126 */ 127 inline int GetObjectSpaceSubdivisonType() const 128 { 129 return mObjectSpaceSubdivisonType; 130 } 131 118 132 protected: 119 133 … … 143 157 void EvalSubdivisionStats(const SubdivisionCandidate &tData); 144 158 145 void AddSubdivisionStats(const int splits, 159 void AddSubdivisionStats( 160 const int splits, 146 161 const float renderCostDecr, 147 162 const float totalRenderCost); 148 163 164 void CollectObjectSpaceDirtyList(); 165 void CollectViewSpaceDirtyList(); 166 167 bool AddSampleToPvs(Intersectable *obj, 168 const float pdf, 169 float &contribution) const; 170 171 void CollectViewSpaceDirtyList(SubdivisionCandidateContainer &dirtyList); 172 void CollectObjectSpaceDirtyList(SubdivisionCandidateContainer &dirtyList); 173 149 174 150 175 protected: 176 177 int mObjectSpaceSubdivisonType; 178 179 VspTree *mVspTree; 180 OspTree *mOspTree; 181 BvHierarchy *mBvHierarchy; 151 182 152 183 AxisAlignedBox3 mBoundingBox; -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp
r1251 r1259 2712 2712 2713 2713 2714 } 2714 bool OspTree::AddLeafToPvs(KdLeaf *leaf, 2715 ViewCell *vc, 2716 const float pdf, 2717 float &contribution) 2718 { 2719 // add kd intersecable to pvs 2720 KdIntersectable *kdObj = GetOrCreateKdIntersectable(leaf); 2721 2722 return vc->AddPvsSample(kdObj, pdf, contribution); 2723 } 2724 2725 2726 } -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h
r1251 r1259 397 397 void InsertObjects(KdNode *node, const ObjectContainer &objects); 398 398 399 /** Add the leaf to the pvs of the view cell. 400 */ 401 bool AddLeafToPvs( 402 KdLeaf *leaf, 403 ViewCell *vc, 404 const float pdf, 405 float &contribution); 406 399 407 protected: 400 408 … … 596 604 /** Evaluate the contributions of view cell volume of the left and the right view cell. 597 605 */ 598 void EvalRayContribution(KdLeaf *leaf, 599 const VssRay &ray, 600 float &renderCost); 601 void EvalViewCellContribution(KdLeaf *leaf, 602 ViewCell *viewCell, 603 float &renderCost); 606 void EvalRayContribution( 607 KdLeaf *leaf, 608 const VssRay &ray, 609 float &renderCost); 610 611 void EvalViewCellContribution( 612 KdLeaf *leaf, 613 ViewCell *viewCell, 614 float &renderCost); 615 604 616 /** Evaluates the influence on the pvs of the event. 605 617 @param ve the visibility event … … 718 730 RayInfoContainer &rays); 719 731 732 720 733 protected: 721 722 734 723 735 /// pointer to the hierarchy of view cells -
GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h
r1239 r1259 56 56 typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue; 57 57 58 58 typedef vector<SubdivisionCandidate *> SubdivisionCandidateContainer; 59 59 } 60 60 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1233 r1259 21 21 #include "VspTree.h" 22 22 #include "OspTree.h" 23 23 #include "BvHierarchy.h" 24 24 25 25 // should not count origin object for sampling because it disturbs heuristics … … 58 58 mMaxPvsRatio(1.0), 59 59 mViewCellPvsIsUpdated(false), 60 mPreprocessor(NULL), 61 mStoreKdPvs(false) 60 mPreprocessor(NULL) 62 61 { 63 62 mViewSpaceBox.Initialize(); … … 107 106 Environment::GetSingleton()->GetBoolValue("ViewCells.exportPvs", mExportPvs); 108 107 109 Environment::GetSingleton()->GetBoolValue("ViewCells.storeKdPvs", mStoreKdPvs);110 111 112 108 char buf[100]; 113 109 Environment::GetSingleton()->GetStringValue("ViewCells.samplingType", buf); … … 223 219 Debug << "export pvs for view cells: " << mExportPvs << endl; 224 220 225 Debug << "store kd pvs: " << mStoreKdPvs << endl;226 227 221 Debug << endl; 228 222 } … … 877 871 { 878 872 return mExportPvs; 873 } 874 875 876 bool ViewCellsManager::AddSampleToPvs(Intersectable *obj, 877 const Vector3 &hitPoint, 878 ViewCell *vc, 879 const float pdf, 880 float &contribution) const 881 { 882 if (!obj) return false; 883 884 // potentially visible objects 885 return vc->AddPvsSample(obj, pdf, contribution); 879 886 } 880 887 … … 2456 2463 2457 2464 2458 void ViewCellsManager::SetStoreKdPvs(const bool storeKdPvs)2459 {2460 mStoreKdPvs = storeKdPvs;2461 }2462 2463 2464 bool ViewCellsManager::GetStoreKdPVs() const2465 {2466 return mStoreKdPvs;2467 }2468 2469 2470 2465 void ViewCellsManager::UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) 2471 2466 { … … 5681 5676 } 5682 5677 5683 // if addrays is true, sampled entities are stored in the pvs 5684 if (addRays) 5685 { 5686 for (it = viewcells.begin(); it != viewcells.end(); ++ it) 5678 if (!addRays) 5679 return ray.mRelativePvsContribution; 5680 5681 // sampled objects are stored in the pvs 5682 for (it = viewcells.begin(); it != viewcells.end(); ++ it) 5683 { 5684 ViewCell *viewCell = *it; 5685 5686 if (!viewCell->GetValid()) 5687 break; 5688 5689 AddSampleToPvs( 5690 ray.mTerminationObject, 5691 ray.mTermination, 5692 viewCell, 5693 ray.mPdf, 5694 ray.mRelativePvsContribution); 5695 5696 #if SAMPLE_ORIGIN_OBJECTS 5697 5698 AddSampleToPvs( 5699 ray.mOriginObject, 5700 ray.mOrigin, 5701 viewCell, 5702 ray.mPdf, 5703 ray.mRelativePvsContribution); 5704 #endif 5705 } 5706 5707 return ray.mRelativePvsContribution; 5708 } 5709 5710 5711 bool VspOspViewCellsManager::AddSampleToPvs(Intersectable *obj, 5712 const Vector3 &hitPoint, 5713 ViewCell *vc, 5714 const float pdf, 5715 float &contribution) const 5716 { 5717 if (!obj) return false; 5718 5719 switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 5720 { 5721 case HierarchyManager::NO_OBJ_SUBDIV: 5722 // potentially visible objects 5723 return vc->AddPvsSample(obj, pdf, contribution); 5724 5725 case HierarchyManager::KD_BASED_OBJ_SUBDIV: 5687 5726 { 5688 ViewCell *viewcell = *it; 5689 5690 if (viewcell->GetValid()) 5691 { 5692 // if ray not outside of view space 5693 5694 // add kd cell 5695 if (ray.mTerminationObject) 5696 { 5697 if (!mStoreKdPvs) 5698 { 5699 viewcell->AddPvsSample(ray.mTerminationObject, 5700 ray.mPdf, ray.mRelativePvsContribution); 5701 } 5702 else 5703 { 5704 // get current leaf the point is located in 5705 KdLeaf *leaf = mOspTree->GetLeaf(ray.mTermination); 5706 KdIntersectable *entry = mOspTree->GetOrCreateKdIntersectable(leaf); 5707 5708 viewcell->AddPvsSample(entry, ray.mPdf, ray.mRelativePvsContribution); 5709 } 5710 } 5711 5712 #if SAMPLE_ORIGIN_OBJECTS 5713 if (ray.mOriginObject) 5714 { 5715 if (!mStoreKdPvs) 5716 { 5717 viewcell->AddPvsSample(ray.mOriginObject, ray.mPdf, ray.mPvsContribution); 5718 } 5719 else 5720 { 5721 /// get current leaf the point 5722 KdLeaf *leaf = mOspTree->GetLeaf(ray.mOrigin); 5723 KdIntersectable *entry = mOspTree->GetOrCreateKdIntersectable(leaf); 5724 5725 viewcell->AddPvsSample(entry, ray.mPdf, ray.mRelativePvsContribution); 5726 } 5727 } 5728 #endif 5729 } 5730 } 5731 } 5732 5733 return ray.mRelativePvsContribution; 5727 // potentially visible kd cells 5728 KdLeaf *leaf = mOspTree->GetLeaf(hitPoint/*ray->mOriginNode*/); 5729 return mOspTree->AddLeafToPvs(leaf, vc, pdf, contribution); 5730 } 5731 case HierarchyManager::BV_BASED_OBJ_SUBDIV: 5732 { 5733 BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj); 5734 return mBvHierarchy->AddLeafToPvs(leaf, vc, pdf, contribution); 5735 } 5736 default: 5737 return false; 5738 } 5734 5739 } 5735 5740 … … 5811 5816 UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 5812 5817 5813 5814 //--test render cost5815 5816 sprintf(s, "-%09d-eval.log", castSamples);5817 string fileName = string(statsPrefix) + string(s);5818 5819 ViewCellContainer leaves;5820 5821 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves);5822 float rc = 0;5823 ViewCellContainer::const_iterator vit, vit_end = leaves.end();5824 for (vit = leaves.begin(); vit != vit_end; ++ vit)5825 {5826 ViewCell *vc = *vit;5818 /////////////////////////////////////// 5819 //-- temporary matt: test render cost 5820 5821 sprintf(s, "-%09d-eval.log", castSamples); 5822 string fileName = string(statsPrefix) + string(s); 5823 5824 ViewCellContainer leaves; 5825 5826 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 5827 float rc = 0; 5828 ViewCellContainer::const_iterator vit, vit_end = leaves.end(); 5829 for (vit = leaves.begin(); vit != vit_end; ++ vit) 5830 { 5831 ViewCell *vc = *vit; 5827 5832 int pvs = vc->GetPvs().CountObjectsInPvs(); 5828 float vol = vc->GetVolume();5829 rc += pvs * vol;5830 5831 } 5832 5833 float vol = vc->GetVolume(); 5834 rc += pvs * vol; 5835 5836 } 5837 5833 5838 Debug << "\nhere295 " << rc / mVspTree->GetBoundingBox().GetVolume() << endl; 5834 5835 5839 mViewCellsTree->ExportStats(fileName); 5836 5837 5840 cout << "finished" << endl; 5838 5841 … … 5840 5843 } 5841 5844 #endif 5842 ////////////////////////////////// 5843 /*ViewCellsManager *ViewCellsManagerFactory::Create(const string mName) 5844 { 5845 //TODO 5846 return NULL;// new VspBspViewCellsManager(); 5847 }*/ 5848 5849 5850 } 5845 5846 5847 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1201 r1259 36 36 class VspNode; 37 37 class HierarchyManager; 38 class BvHierarchy; 39 38 40 struct AxisAlignedPlane; 39 40 41 struct BspRay; 41 42 … … 490 491 bool GetStoreKdPVs() const; 491 492 493 virtual bool AddSampleToPvs( 494 Intersectable *obj, 495 const Vector3 &hitPoint, 496 ViewCell *vc, 497 const float pdf, 498 float &contribution) const; 499 492 500 protected: 493 501 … … 672 680 bool mExportPvs; 673 681 674 bool mStore KdPvs;682 bool mStoreObjectPvs; 675 683 676 684 VssRayContainer storedRays; … … 1016 1024 BoundingBoxConverter *bconverter); 1017 1025 1026 bool AddSampleToPvs( 1027 Intersectable *obj, 1028 const Vector3 &hitPoint, 1029 ViewCell *vc, 1030 const float pdf, 1031 float &contribution) const; 1018 1032 1019 1033 protected: … … 1050 1064 1051 1065 ///////////////////////////////////////// 1052 /// the view space partition tree. 1066 1067 /// the view space / object partition hierarchies 1053 1068 VspTree *mVspTree; 1054 1069 OspTree *mOspTree; 1070 BvHierarchy *mBvHierarchy; 1055 1071 1056 1072 HierarchyManager *mHierarchyManager; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1251 r1259 18 18 #include "KdTree.h" 19 19 #include "KdIntersectable.h" 20 #include "HierarchyManager.h" 21 #include "BvHierarchy.h" 20 22 #include "OspTree.h" 23 21 24 22 25 namespace GtpVisibilityPreprocessor { … … 358 361 mStoreRays(false), 359 362 mTimeStamp(1), 360 m OspTree(NULL)363 mHierarchyManager(NULL) 361 364 { 362 365 bool randomize = false; … … 397 400 Environment::GetSingleton()->GetBoolValue("VspTree.simulateOctree", mCirculatingAxis); 398 401 399 Environment::GetSingleton()->GetBoolValue("VspTree.useKdPvsForHeuristics", mUseKdPvsForHeuristics);402 //Environment::GetSingleton()->GetBoolValue("VspTree.useKdPvsForHeuristics", mUseKdPvsForHeuristics); 400 403 401 404 char subdivisionStatsLog[100]; … … 433 436 Debug << "maxband: " << mMaxBand << endl; 434 437 435 if (!mUseKdPvsForHeuristics)436 Debug << "pvs heuristics: per object" << endl;437 else438 Debug << "pvs heuristics: per kd node" << endl;439 440 438 mLocalSubdivisionCandidates = new vector<SortableEntry>; 441 439 … … 911 909 912 910 913 bool VspTree::AddKdLeafToPvs(KdLeaf *leaf,914 ViewCell *vc,915 const float pdf,916 float &contribution)917 {918 bool contri = false;919 920 #if 1 // add kd intersecable to pvs921 KdIntersectable *kdObj = mOspTree->GetOrCreateKdIntersectable(leaf);922 923 if (vc->AddPvsSample(kdObj, pdf, contribution))924 {925 return true;926 }927 928 #else // add all objects of kd node929 930 contribution = 0;931 932 ObjectContainer::const_iterator it, it_end = leaf->mObjects.end();933 934 for (it = leaf->mObjects.begin(); it != it_end; ++ it)935 {936 Intersectable *object = *it;937 938 float newcontri;939 940 if (vc->AddPvsSample(object, pdf, newcontri))941 {942 contri = true;943 }944 945 //pdf += newPdf;946 newContri += contribution;947 }948 #endif949 950 return contri;951 }952 911 953 912 … … 977 936 if (obj) 978 937 { 979 if (!mStoreKdPvs) 980 { 981 // potentially visible objects 982 madeContrib = vc->AddPvsSample(obj, ray->mPdf, contribution); 983 } 984 else 985 { 986 // potentially visible kd cells 987 KdLeaf *leaf = mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 988 madeContrib = AddKdLeafToPvs(leaf, vc, ray->mPdf, contribution); 989 } 938 madeContrib = 939 mViewCellsManager->AddSampleToPvs( 940 obj, 941 ray->mTermination, 942 vc, 943 ray->mPdf, 944 contribution); 990 945 991 946 sc += contribution; … … 996 951 if (obj) 997 952 { 998 if (!mStoreKdPvs) 999 { 1000 // potentially visible objects 1001 madeContrib = vc->AddPvsSample(obj, ray->mPdf, contribution); 1002 } 1003 else 1004 { 1005 // potentially visible kd cells 1006 KdLeaf *leaf = mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 1007 madeContrib = AddKdLeafToPvs(leaf, vc, ray->mPdf, contribution); 1008 } 953 madeContrib = 954 mViewCellsManager->AddSampleToPvs( 955 obj, 956 ray->mOrigin, 957 vc, 958 ray->mPdf, 959 contribution); 1009 960 1010 961 sc += contribution; … … 1092 1043 1093 1044 1045 int VspTree::PrepareHeuristics(const VssRay &ray, const bool isTermination) 1046 { 1047 int pvsSize = 0; 1048 1049 Intersectable *obj; 1050 Vector3 pt; 1051 KdNode *node; 1052 1053 ray.GetSampleData(isTermination, pt, &obj, &node); 1054 1055 if (!obj) 1056 return 0; 1057 1058 switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 1059 { 1060 case HierarchyManager::NO_OBJ_SUBDIV: 1061 { 1062 if (!obj->Mailed()) 1063 { 1064 obj->Mail(); 1065 obj->mCounter = 1; 1066 1067 ++ pvsSize; 1068 } 1069 else 1070 { 1071 ++ obj->mCounter; 1072 } 1073 break; 1074 } 1075 case HierarchyManager::KD_BASED_OBJ_SUBDIV: 1076 { 1077 KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 1078 pvsSize += PrepareHeuristics(leaf); 1079 break; 1080 } 1081 case HierarchyManager::BV_BASED_OBJ_SUBDIV: 1082 { 1083 BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj, NULL); 1084 1085 if (!leaf->Mailed()) 1086 { 1087 leaf->Mail(); 1088 leaf->mCounter = 1; 1089 1090 ++ pvsSize; 1091 } 1092 else 1093 { 1094 ++ leaf->mCounter; 1095 } 1096 break; 1097 } 1098 default: 1099 break; 1100 } 1101 1102 return pvsSize; 1103 } 1104 1105 1094 1106 int VspTree::PrepareHeuristics(KdLeaf *leaf) 1095 1107 { … … 1144 1156 RayInfoContainer::const_iterator ri, ri_end = rays.end(); 1145 1157 1146 //-- set all kd nodes / objects as belonging to the front pvs 1147 1158 // set all kd nodes / objects as belonging to the front pvs 1148 1159 for (ri = rays.begin(); ri != ri_end; ++ ri) 1149 1160 { 1150 1161 VssRay *ray = (*ri).mRay; 1151 Intersectable *oObject = ray->mOriginObject; 1152 1153 if (oObject) 1154 { 1155 if (!mUseKdPvsForHeuristics) 1156 { 1157 if (!oObject->Mailed()) 1158 { 1159 oObject->Mail(); 1160 oObject->mCounter = 1; 1161 1162 ++ pvsSize; 1163 } 1164 else 1165 { 1166 ++ oObject->mCounter; 1167 } 1168 } 1169 else 1170 { 1171 KdLeaf *leaf = mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 1172 pvsSize += PrepareHeuristics(leaf); 1173 } 1174 } 1175 1176 Intersectable *tObject = (*ri).mRay->mTerminationObject; 1177 1178 if (tObject) 1179 { 1180 if (!mUseKdPvsForHeuristics) 1181 { 1182 if (!tObject->Mailed()) 1183 { 1184 tObject->Mail(); 1185 tObject->mCounter = 1; 1186 ++ pvsSize; 1187 } 1188 else 1189 { 1190 ++ tObject->mCounter; 1191 } 1192 } 1193 else 1194 { 1195 KdLeaf *leaf = mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode); 1196 pvsSize += PrepareHeuristics(leaf); 1197 } 1198 } 1162 1163 pvsSize += PrepareHeuristics(*ray, true); 1164 pvsSize += PrepareHeuristics(*ray, false); 1199 1165 } 1200 1166 … … 1203 1169 1204 1170 1205 void VspTree::RemoveContriFromPvs(KdLeaf *leaf, int &pvs) const 1206 { 1171 int VspTree::EvalMaxEventContribution(KdLeaf *leaf) const 1172 { 1173 int pvs = 0; 1174 1207 1175 // leaf falls out of right pvs 1208 1176 if (-- leaf->mCounter == 0) … … 1211 1179 } 1212 1180 1213 //-- handle objects which are in several kd leaves separately 1181 //-- separately handle objects which are in several kd leaves 1182 1214 1183 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 1215 1184 … … 1220 1189 if (-- object->mCounter == 0) 1221 1190 { 1222 -- pvs; 1223 } 1224 } 1225 } 1226 1227 1228 void VspTree::AddContriToPvs(KdLeaf *leaf, int &pvs) const 1191 ++ pvs; 1192 } 1193 } 1194 1195 return pvs; 1196 } 1197 1198 1199 int VspTree::EvalMinEventContribution(KdLeaf *leaf) const 1229 1200 { 1230 1201 if (leaf->Mailed()) 1231 return ;1202 return 0; 1232 1203 1233 1204 leaf->Mail(); 1234 1205 1235 1206 // add objects without those which are part of several kd leaves 1236 pvs += ((int)leaf->mObjects.size() - (int)leaf->mMultipleObjects.size());1237 1238 // -- handle objects of several kd leaves separately1207 int pvs = ((int)leaf->mObjects.size() - (int)leaf->mMultipleObjects.size()); 1208 1209 // separately handle objects which are part of several kd leaves 1239 1210 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 1240 1211 … … 1249 1220 ++ pvs; 1250 1221 } 1251 } 1252 } 1253 1254 1255 void VspTree::EvalPvsIncr(const SortableEntry &ci, 1256 int &pvsLeft, 1257 int &pvsRight) const 1222 } 1223 1224 return pvs; 1225 } 1226 1227 1228 int VspTree::EvalMinEventContribution(const VssRay &ray, 1229 const bool isTermination) const 1230 { 1231 Intersectable *obj; 1232 Vector3 pt; 1233 KdNode *node; 1234 1235 ray.GetSampleData(isTermination, pt, &obj, &node); 1236 1237 if (!obj) return 0; 1238 1239 int pvs = 0; 1240 1241 switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 1242 { 1243 case HierarchyManager::NO_OBJ_SUBDIV: 1244 { 1245 if (!obj->Mailed()) 1246 { 1247 obj->Mail(); 1248 ++ pvs; 1249 } 1250 1251 break; 1252 } 1253 case HierarchyManager::KD_BASED_OBJ_SUBDIV: 1254 { 1255 KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 1256 // add contributions of the kd nodes 1257 pvs += EvalMinEventContribution(leaf); 1258 1259 break; 1260 } 1261 case HierarchyManager::BV_BASED_OBJ_SUBDIV: 1262 { 1263 BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 1264 1265 if (!leaf->Mailed()) 1266 { 1267 leaf->Mail(); 1268 ++ pvs; 1269 } 1270 break; 1271 } 1272 default: 1273 break; 1274 } 1275 return pvs; 1276 } 1277 1278 1279 int VspTree::EvalMaxEventContribution(const VssRay &ray, 1280 const bool isTermination) const 1281 { 1282 Intersectable *obj; 1283 Vector3 pt; 1284 KdNode *node; 1285 1286 ray.GetSampleData(isTermination, pt, &obj, &node); 1287 1288 if (!obj) return 0; 1289 1290 int pvs = 0; 1291 1292 switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 1293 { 1294 case HierarchyManager::NO_OBJ_SUBDIV: 1295 { 1296 if (-- obj->mCounter == 0) 1297 ++ pvs; 1298 break; 1299 } 1300 case HierarchyManager::KD_BASED_OBJ_SUBDIV: 1301 { 1302 KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 1303 1304 // add contributions of the kd nodes 1305 pvs += EvalMaxEventContribution(leaf); 1306 break; 1307 } 1308 case HierarchyManager::BV_BASED_OBJ_SUBDIV: 1309 { 1310 BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 1311 1312 if (-- leaf->mCounter == 0) 1313 ++ pvs; 1314 break; 1315 } 1316 default: 1317 break; 1318 } 1319 1320 return pvs; 1321 } 1322 1323 1324 void VspTree::EvalHeuristicsContribution(const SortableEntry &ci, 1325 int &pvsLeft, 1326 int &pvsRight) const 1258 1327 { 1259 1328 VssRay *ray = ci.ray; 1260 1329 1261 Intersectable *oObject = ray->mOriginObject; 1262 Intersectable *tObject = ray->mTerminationObject; 1263 1264 if (oObject) 1265 { 1266 if (!mUseKdPvsForHeuristics) 1267 { 1268 if (ci.type == SortableEntry::ERayMin) 1269 { 1270 if (!oObject->Mailed()) 1271 { 1272 oObject->Mail(); 1273 ++ pvsLeft; 1274 } 1275 } 1276 else if (ci.type == SortableEntry::ERayMax) 1277 { 1278 if (-- oObject->mCounter == 0) 1279 -- pvsRight; 1280 } 1281 } 1282 else // per kd node 1283 { 1284 KdLeaf *node = mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 1285 1286 // add contributions of the kd nodes 1287 if (ci.type == SortableEntry::ERayMin) 1288 { 1289 AddContriToPvs(node, pvsLeft); 1290 } 1291 else if (ci.type == SortableEntry::ERayMax) 1292 { 1293 RemoveContriFromPvs(node, pvsRight); 1294 } 1295 } 1296 } 1297 1298 if (tObject) 1299 { 1300 if (!mUseKdPvsForHeuristics) 1301 { 1302 if (ci.type == SortableEntry::ERayMin) 1303 { 1304 if (!tObject->Mailed()) 1305 { 1306 tObject->Mail(); 1307 ++ pvsLeft; 1308 } 1309 } 1310 else if (ci.type == SortableEntry::ERayMax) 1311 { 1312 if (-- tObject->mCounter == 0) 1313 -- pvsRight; 1314 } 1315 } 1316 else // per kd node 1317 { 1318 KdLeaf *node = mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode); 1319 1320 if (ci.type == SortableEntry::ERayMin) 1321 { 1322 AddContriToPvs(node, pvsLeft); 1323 } 1324 else if (ci.type == SortableEntry::ERayMax) 1325 { 1326 RemoveContriFromPvs(node, pvsRight); 1327 } 1328 } 1330 if (ci.type == SortableEntry::ERayMin) 1331 { 1332 pvsLeft += EvalMinEventContribution(*ray, true); 1333 pvsLeft += EvalMinEventContribution(*ray, false); 1334 } 1335 else 1336 { 1337 pvsRight -= EvalMaxEventContribution(*ray, true); 1338 pvsRight -= EvalMaxEventContribution(*ray, false); 1329 1339 } 1330 1340 } … … 1336 1346 float &position) 1337 1347 { 1348 // get subset of rays 1338 1349 RayInfoContainer usedRays; 1339 1350 … … 1395 1406 for (ci = mLocalSubdivisionCandidates->begin(); ci != ci_end; ++ ci) 1396 1407 { 1397 Eval PvsIncr(*ci, pvsl, pvsr);1408 EvalHeuristicsContribution(*ci, pvsl, pvsr); 1398 1409 1399 1410 // Note: sufficient to compare size of bounding boxes of front and back side? … … 1580 1591 rayInf.ComputeRayIntersection(candidatePlane.mAxis, 1581 1592 candidatePlane.mPosition, t); 1582 1593 /* 1583 1594 if (!mUseKdPvsForHeuristics) 1584 1595 { … … 1591 1602 if (ray->mTerminationObject) 1592 1603 { 1593 KdLeaf *leaf = m OspTree->GetLeaf(ray->mTermination, ray->mTerminationNode);1604 KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode); 1594 1605 UpdateKdLeafPvsContri(leaf, cf, pvsFront, pvsBack, totalPvs); 1595 1606 } … … 1597 1608 if (ray->mOriginObject) 1598 1609 { 1599 KdLeaf *leaf = m OspTree->GetLeaf(ray->mOrigin, ray->mOriginNode);1610 KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 1600 1611 UpdateKdLeafPvsContri(leaf, cf, pvsFront, pvsBack, totalPvs); 1601 1612 } 1602 1613 } 1614 */ 1603 1615 } 1604 1616 … … 2243 2255 2244 2256 2245 int VspTree::EvalPvsSize(const RayInfoContainer &rays) const 2246 { 2247 int pvsSize = 0; 2248 Intersectable::NewMail(); 2249 2250 RayInfoContainer::const_iterator rit, rit_end = rays.end(); 2251 2252 if (!mUseKdPvsForHeuristics) 2253 { 2254 for (rit = rays.begin(); rit != rays.end(); ++ rit) 2255 { 2256 VssRay *ray = (*rit).mRay; 2257 2258 if (ray->mOriginObject) 2259 { 2260 if (!ray->mOriginObject->Mailed()) 2257 int VspTree::EvalPvsContribution(const VssRay &ray, const bool isTermination) const 2258 { 2259 Intersectable *obj; 2260 Vector3 pt; 2261 KdNode *node; 2262 2263 ray.GetSampleData(isTermination, pt, &obj, &node); 2264 2265 if (!obj) return 0; 2266 2267 int pvs = 0; 2268 2269 switch(mHierarchyManager->GetObjectSpaceSubdivisonType()) 2270 { 2271 case HierarchyManager::NO_OBJ_SUBDIV: 2272 { 2273 if (!obj->Mailed()) 2274 { 2275 obj->Mail(); 2276 ++ pvs; 2277 } 2278 2279 break; 2280 } 2281 case HierarchyManager::KD_BASED_OBJ_SUBDIV: 2282 { 2283 KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 2284 2285 if (!leaf->Mailed()) 2286 { 2287 leaf->Mail(); 2288 pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 2289 2290 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 2291 for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 2261 2292 { 2262 ray->mOriginObject->Mail(); 2263 ++ pvsSize; 2264 } 2265 } 2266 if (ray->mTerminationObject) 2267 { 2268 if (!ray->mTerminationObject->Mailed()) 2269 { 2270 ray->mTerminationObject->Mail(); 2271 ++ pvsSize; 2272 } 2273 } 2274 } 2275 } 2276 else // compute pvs from kd nodes 2277 { 2278 KdNode::NewMail(); 2279 2280 for (rit = rays.begin(); rit != rays.end(); ++ rit) 2281 { 2282 VssRay *ray = (*rit).mRay; 2283 2284 if (ray->mTerminationObject) 2285 { 2286 KdLeaf *leaf = mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode); 2287 2288 if (!leaf->Mailed()) 2289 { 2290 leaf->Mail(); 2291 pvsSize += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 2292 2293 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 2294 for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 2293 Intersectable *obj = *oit; 2294 2295 if (!obj->Mailed()) 2295 2296 { 2296 Intersectable *obj = *oit; 2297 2298 if (!obj->Mailed()) 2299 { 2300 obj->Mail(); 2301 ++ pvsSize; 2302 } 2297 obj->Mail(); 2298 ++ pvs; 2303 2299 } 2304 2300 } 2305 2301 } 2306 2302 2307 if (ray->mOriginObject) 2308 { 2309 KdLeaf *leaf = mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 2310 2311 if (!leaf->Mailed()) 2312 { 2313 leaf->Mail(); 2314 pvsSize += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 2315 2316 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 2317 for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 2318 { 2319 Intersectable *obj = *oit; 2320 2321 if (!obj->Mailed()) 2322 { 2323 obj->Mail(); 2324 ++ pvsSize; 2325 } 2326 } 2327 } 2328 } 2329 } 2330 } 2331 2303 break; 2304 } 2305 case HierarchyManager::BV_BASED_OBJ_SUBDIV: 2306 { 2307 BvhLeaf *bvhleaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 2308 2309 if (!bvhleaf->Mailed()) 2310 { 2311 bvhleaf->Mail(); 2312 pvs += (int)bvhleaf->mObjects.size(); 2313 } 2314 2315 break; 2316 } 2317 default: 2318 break; 2319 } 2320 2321 return pvs; 2322 } 2323 2324 2325 int VspTree::EvalPvsSize(const RayInfoContainer &rays) const 2326 { 2327 int pvsSize = 0; 2328 2329 Intersectable::NewMail(); 2330 KdNode::NewMail(); 2331 BvhNode::NewMail(); 2332 2333 RayInfoContainer::const_iterator rit, rit_end = rays.end(); 2334 2335 for (rit = rays.begin(); rit != rays.end(); ++ rit) 2336 { 2337 VssRay *ray = (*rit).mRay; 2338 pvsSize += EvalPvsContribution(*ray, true); 2339 pvsSize += EvalPvsContribution(*ray, false); 2340 } 2341 2332 2342 return pvsSize; 2333 2343 } … … 2806 2816 2807 2817 2808 void VspTree::CollectDirtyCandidates(VspSubdivisionCandidate *sc,2809 vector<SubdivisionCandidate *> &dirtyList)2810 {2811 VspTraversalData &tData = sc->mParentData;2812 VspLeaf *node = tData.mNode;2813 2814 KdLeaf::NewMail();2815 2816 RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end();2817 2818 // add all kd nodes seen by the rays2819 for (rit = tData.mRays->begin(); rit != rit_end; ++ rit)2820 {2821 VssRay *ray = (*rit).mRay;2822 2823 KdLeaf *leaf = mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode);2824 2825 if (!leaf->Mailed())2826 {2827 leaf->Mail();2828 dirtyList.push_back(leaf->mSubdivisionCandidate);2829 }2830 2831 leaf = mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode);2832 2833 if (!leaf->Mailed())2834 {2835 leaf->Mail();2836 dirtyList.push_back(leaf->mSubdivisionCandidate);2837 }2838 }2839 }2840 2841 2842 2818 void VspTree::PreprocessRays(const VssRayContainer &sampleRays, 2843 2819 RayInfoContainer &rays) … … 2965 2941 2966 2942 2967 2968 } 2943 void VspTree::CollectDirtyCandidates(VspSubdivisionCandidate *sc, 2944 vector<SubdivisionCandidate *> &dirtyList) 2945 { 2946 VspTraversalData &tData = sc->mParentData; 2947 VspLeaf *node = tData.mNode; 2948 2949 KdLeaf::NewMail(); 2950 2951 RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end(); 2952 2953 // add all kd nodes seen by the rays 2954 for (rit = tData.mRays->begin(); rit != rit_end; ++ rit) 2955 { 2956 VssRay *ray = (*rit).mRay; 2957 2958 KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 2959 2960 if (!leaf->Mailed()) 2961 { 2962 leaf->Mail(); 2963 dirtyList.push_back(leaf->mSubdivisionCandidate); 2964 } 2965 2966 leaf = mHierarchyManager->mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode); 2967 2968 if (!leaf->Mailed()) 2969 { 2970 leaf->Mail(); 2971 dirtyList.push_back(leaf->mSubdivisionCandidate); 2972 } 2973 } 2974 } 2975 2976 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1251 r1259 31 31 class KdInterior; 32 32 class KdLeaf; 33 class OspTree;33 class HierarchyManager; 34 34 class KdIntersectable; 35 35 class KdTree; … … 759 759 float maxBand); 760 760 761 /** Evaluate pvs size as sociated with the rays.761 /** Evaluate pvs size as induced by the samples. 762 762 */ 763 763 int EvalPvsSize(const RayInfoContainer &rays) const; … … 778 778 float &position); 779 779 780 /** Evaluates the influence on the pvs of thevisibility event ve.780 /** Evaluates the contribution to left and right pvs at a visibility event ve. 781 781 @param ve the visibility event 782 782 @param pvsLeft updates the left pvs 783 783 @param rightPvs updates the right pvs 784 784 */ 785 void EvalPvsIncr(const SortableEntry &ve, 786 int &pvsLeft, 787 int &pvsRight) const; 788 789 void RemoveContriFromPvs(KdLeaf *leaf, int &pvs) const; 790 void AddContriToPvs(KdLeaf *leaf, int &pvs) const; 785 void EvalHeuristicsContribution( 786 const SortableEntry &ve, 787 int &pvsLeft, 788 int &pvsRight) const; 789 790 /** Evaluates contribution of the ray to the left and right pvs. 791 */ 792 int EvalMinEventContribution( 793 const VssRay &ray, const bool isTermination) const; 794 795 int EvalMaxEventContribution( 796 const VssRay &ray, const bool isTermination) const; 797 798 int EvalMinEventContribution(KdLeaf *leaf) const; 799 int EvalMaxEventContribution(KdLeaf *leaf) const; 791 800 792 801 /** Prepares objects for the heuristics. … … 794 803 */ 795 804 int PrepareHeuristics(const RayInfoContainer &rays); 796 805 int PrepareHeuristics(const VssRay &ray, const bool isTermination); 797 806 int PrepareHeuristics(KdLeaf *leaf); 798 807 … … 859 868 int &contributingSamples); 860 869 861 bool AddKdLeafToPvs(KdLeaf *leaf,862 ViewCell *vc,863 const float pvs,864 float &contribution);865 866 870 /** Propagates valid flag up the tree. 867 871 */ … … 898 902 void EvalSubdivisionStats(const SubdivisionCandidate &tData); 899 903 900 SubdivisionCandidate *PrepareConstruction(const VssRayContainer &sampleRays, 901 AxisAlignedBox3 *forcedViewSpace, 902 RayInfoContainer &rays); 904 SubdivisionCandidate *PrepareConstruction( 905 const VssRayContainer &sampleRays, 906 AxisAlignedBox3 *forcedViewSpace, 907 RayInfoContainer &rays); 908 909 /** Add pvs contribution of this ray. 910 */ 911 int EvalPvsContribution(const VssRay &ray, const bool isTermination) const; 903 912 904 913 protected: 905 906 914 907 915 /// pointer to the hierarchy of view cells 908 916 ViewCellsTree *mViewCellsTree; 909 917 910 OspTree *mOspTree; 911 912 bool mUseKdPvsForHeuristics; 913 bool mStoreKdPvs; 914 918 HierarchyManager *mHierarchyManager; 919 //OspTree *mOspTree; 920 //bool mUseKdPvsForHeuristics; 921 915 922 ViewCellsManager *mViewCellsManager; 916 923 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.cpp
r1112 r1259 264 264 } 265 265 266 } 266 267 void VssRay::GetSampleData(const bool isTermination, 268 Vector3 &pt, 269 Intersectable **obj, 270 KdNode **node) const 271 { 272 if (isTermination) 273 { 274 pt = mTermination; 275 *obj = mTerminationObject; 276 *node = mTerminationNode; 277 } 278 else 279 { 280 pt = mOrigin; 281 *obj = mOriginObject; 282 *node = mOriginNode; 283 } 284 } 285 286 287 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h
r1221 r1259 282 282 return SqrMagnitude(diff); 283 283 } 284 285 void GetSampleData( 286 const bool isTerminaton, 287 Vector3 &pt, 288 Intersectable **obj, 289 KdNode **node) const; 290 284 291 friend ostream& operator<< (ostream &s, const VssRay &vssRay); 285 292 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.h
r1233 r1259 266 266 }; 267 267 268 void GetSampleData(const bool isTerminaton, 269 Vector3 &pt, 270 Intersectable **obj, 271 KdNode **node) const; 268 272 269 273 typedef vector<RayInfo> RayInfoContainer;
Note: See TracChangeset
for help on using the changeset viewer.