Changeset 1743 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 11/13/06 15:34:15 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1742 r1743 1517 1517 1518 1518 1519 Intersectable *HierarchyManager::GetIntersectable(Intersectable *obj, 1520 const Vector3 &point) const 1521 { 1522 1523 if (!obj) 1524 return NULL; 1525 1526 switch (mObjectSpaceSubdivisionType) 1527 { 1528 case HierarchyManager::KD_BASED_OBJ_SUBDIV: 1529 { 1530 KdLeaf *leaf = mOspTree->GetLeaf(point, NULL); 1531 return mOspTree->GetOrCreateKdIntersectable(leaf); 1532 } 1533 case HierarchyManager::BV_BASED_OBJ_SUBDIV: 1534 { 1535 BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj); 1536 return mBvHierarchy->GetOrCreateBvhIntersectable(leaf); 1537 } 1538 default: 1539 return obj; 1540 } 1541 } 1542 1519 1543 Intersectable *HierarchyManager::GetIntersectable(const VssRay &ray, 1520 1544 const bool isTermination) const 1521 1545 { 1522 1523 Intersectable *obj; 1546 Intersectable *obj = NULL; 1524 1547 Vector3 pt; 1525 1548 KdNode *node; … … 1527 1550 ray.GetSampleData(isTermination, pt, &obj, &node); 1528 1551 1529 if (!obj) return NULL; 1552 if (!obj) 1553 return NULL; 1530 1554 1531 1555 switch (mObjectSpaceSubdivisionType) … … 1533 1557 case HierarchyManager::KD_BASED_OBJ_SUBDIV: 1534 1558 { 1535 1559 KdLeaf *leaf = mOspTree->GetLeaf(pt, node); 1536 1560 return mOspTree->GetOrCreateKdIntersectable(leaf); 1537 1561 } … … 1542 1566 } 1543 1567 default: 1544 return obj; 1545 } 1568 break; 1569 } 1570 return obj; 1546 1571 } 1547 1572 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1736 r1743 269 269 */ 270 270 Intersectable *GetIntersectable(const VssRay &ray, const bool isTermination) const; 271 271 272 Intersectable *GetIntersectable(Intersectable *obj, 273 const Vector3 &point) const; 274 272 275 /** Export object space partition bounding boxes. 273 276 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r1736 r1743 102 102 //////////////////////////////////////////////////// 103 103 virtual AxisAlignedBox3 GetBox() const = 0; 104 virtual int CastRay( GtpVisibilityPreprocessor::Ray &ray) = 0;104 virtual int CastRay(Ray &ray) = 0; 105 105 106 106 virtual bool IsConvex() const = 0; -
GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
r1737 r1743 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 9. XI 13:27:5820063 # Generated by qmake (2.00a) (Qt 4.1.2) on: po 13. XI 15:12:57 2006 4 4 # Project: preprocessor.pro 5 5 # Template: app -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1740 r1743 1084 1084 i ++; 1085 1085 } 1086 if (i % 10000 == 0) 1086 1087 if (rays.size() > 10000 && i % 10000 == 0) 1087 1088 cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r"; 1088 1089 } 1089 cout<<endl; 1090 1091 if (rays.size() > 10000) { 1092 cout<<endl; 1090 1093 1091 1094 long t2 = GetTime(); … … 1096 1099 else 1097 1100 cout << rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl; 1098 #endif 1101 #endif 1102 } 1099 1103 } 1100 1104 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.cpp
r1737 r1743 286 286 287 287 // Render PVS 288 ObjectPvsMap::const_iterator it = viewcell->GetPvs().mEntries.begin(); 289 290 pvsSize = viewcell->GetPvs().mEntries.size(); 291 292 for (; it != viewcell->GetPvs().mEntries.end(); ++ it) { 293 Intersectable *object = (*it).first; 288 ObjectPvsIterator it = viewcell->GetPvs().GetIterator(); 289 290 pvsSize = viewcell->GetPvs().GetSize(); 291 292 for (; it.HasMoreEntries(); ) { 293 ObjectPvsEntry entry = it.Next(); 294 Intersectable *object = entry.mObject; 294 295 RenderIntersectable(object); 295 296 } … … 348 349 349 350 // Render PVS 350 ObjectPvs Map::const_iterator it = viewcell->GetPvs().mEntries.begin();351 352 for (; it != viewcell->GetPvs().mEntries.end(); ++ it) {353 Intersectable *object = (*it).first;351 ObjectPvsIterator it = viewcell->GetPvs().GetIterator(); 352 for (; it.HasMoreEntries(); ) { 353 ObjectPvsEntry entry = it.Next(); 354 Intersectable *object = entry.mObject; 354 355 RenderIntersectable(object); 355 356 } … … 958 959 PrVs prvs; 959 960 960 if ( !mUseFilter) {961 if (1 || !mUseFilter) { 961 962 viewcell = mViewCellsManager->GetViewCell(mViewPoint, true); 962 963 } else { … … 968 969 if (viewcell) { 969 970 // copy the pvs so that it can be filtered... 970 ObjectPvs pvs = viewcell->GetPvs(); 971 972 if (mUseSpatialFilter) { 973 // 9.11. 2006 -> experiment with new spatial filter 971 972 ObjectPvs &pvs = mPvsCache.mPvs; 973 974 if (mPvsCache.mViewCell != viewcell) { 975 mPvsCache.Reset(); 976 mPvsCache.mViewCell = viewcell; 977 978 if (mUseSpatialFilter) { 979 // 9.11. 2006 -> experiment with new spatial filter 974 980 #if 0 975 976 mSpatialFilterSize*977 Magnitude(mViewCellsManager->GetViewSpaceBox().Size()),978 pvs);981 mViewCellsManager->ApplySpatialFilter(mKdTree, 982 mSpatialFilterSize* 983 Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 984 pvs); 979 985 #else 980 981 982 983 984 986 // mSpatialFilter size is in range 0.001 - 0.1 987 mViewCellsManager->ApplyFilter2(viewcell, 988 mUseFilter, 989 100*mSpatialFilterSize, 990 pvs); 985 991 #endif 986 } 987 988 989 ObjectPvsMap::const_iterator it = pvs.mEntries.begin(); 990 991 mPvsSize = pvs.mEntries.size(); 992 993 for (; it != pvs.mEntries.end(); ++ it) { 994 Intersectable *object = (*it).first; 992 } else 993 pvs = viewcell->GetPvs(); 994 } 995 996 // Render PVS 997 ObjectPvsIterator it = pvs.GetIterator(); 998 999 mPvsSize = pvs.GetSize(); 1000 1001 for (; it.HasMoreEntries(); ) { 1002 ObjectPvsEntry entry = it.Next(); 1003 Intersectable *object = entry.mObject; 995 1004 996 1005 if (mRenderVisibilityEstimates) { 997 float visibility = mTransferFunction*log10((*it).second.mSumPdf + 1); // /5.0f 1006 1007 float visibility = mTransferFunction*log10(entry.mData.mSumPdf + 1); // /5.0f 998 1008 glColor3f(visibility, 0.0f, 0.0f); 999 1009 mUseForcedColors = true; … … 1021 1031 } 1022 1032 1023 if ( mUseFilter)1033 if (0 && mUseFilter) 1024 1034 mViewCellsManager->DeleteLocalMergeTree(viewcell); 1035 1025 1036 } else { 1026 1037 ObjectContainer::const_iterator oi = mObjects.begin(); … … 1741 1752 1742 1753 //const int p = vc->GetPvs().CountObjectsInPvs(); 1743 const int p = vc->GetPvs(). Size();1754 const int p = vc->GetPvs().GetSize(); 1744 1755 if (p > maxPvs) 1745 1756 maxPvs = p; … … 1759 1770 } else { 1760 1771 // const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs); 1761 const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs(). Size() / (float)maxPvs);1772 const float importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().GetSize() / (float)maxPvs); 1762 1773 c = RgbColor(importance, 1.0f - importance, 0.0f); 1763 1774 } -
GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.h
r1694 r1743 169 169 void SetCutScene(bool); 170 170 171 171 }; 172 173 174 struct PvsCache { 175 PvsCache():mViewCell(NULL) {} 176 Reset() { mViewCell = NULL; mPvs.Clear(); } 177 ViewCell *mViewCell; 178 ObjectPvs mPvs; 172 179 }; 173 180 … … 205 212 float mManipulatorLastQuat[4]; 206 213 float mManipulatorScale; 214 PvsCache mPvsCache; 207 215 208 216 QtRendererControlWidget *mControlWidget; … … 300 308 void SetUseFilter(bool b) { 301 309 mUseFilter = b; 310 mPvsCache.Reset(); 302 311 updateGL(); 303 312 } … … 305 314 void SetUseSpatialFilter(bool b) { 306 315 mUseSpatialFilter = b; 316 mPvsCache.Reset(); 307 317 updateGL(); 308 318 } -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp
r1715 r1743 9 9 #include "ViewCellsManager.h" 10 10 #include "RenderSimulator.h" 11 #include "VssRay.h" 11 12 12 13 … … 30 31 } 31 32 32 Intersectable *33 SamplingPreprocessor::CastRay(34 const Vector3 &origin,35 const Vector3 &direction36 )37 {38 AxisAlignedBox3 box = mViewCellsManager->GetViewSpaceBox();39 40 AxisAlignedBox3 sbox = box;41 sbox.Enlarge(Vector3(-Limits::Small));42 if (!sbox.IsInside(origin))43 return 0;44 45 Vector3 point, normal;46 Intersectable *object;47 33 48 // cast ray to KD tree to find intersection with other objects49 #if 050 object = CastSimpleRay(origin,51 direction,52 mKdTree->GetBox(),53 point,54 normal55 );56 #endif57 58 if (mDetectEmptyViewSpace && DotProd(normal, direction) >= 0) {59 object = NULL;60 }61 62 return object;63 }64 65 void66 SamplingPreprocessor::HoleSamplingPass()67 {68 vector<KdLeaf *> leaves;69 mKdTree->CollectLeaves(leaves);70 71 // go through all the leaves and evaluate their passing contribution72 for (int i=0 ; i < leaves.size(); i++) {73 KdLeaf *leaf = leaves[i];74 cout<<leaf->mPassingRays<<endl;75 }76 }77 34 78 35 … … 127 84 ConstructViewCells(); 128 85 } 129 86 87 int intersectables, faces; 88 mSceneGraph->GetStatistics(intersectables, faces); 89 130 90 int samples = 0; 131 91 int i=0; 132 92 while (samples < mTotalSamples) { 133 for (i=0; i < mSamplesPerPass; i++, samples++) { 93 for (i=0; i < mSamplesPerPass;) { 94 SimpleRayContainer rays; 95 VssRayContainer vssRays; 96 vector<ViewCell *> viewcells; 97 for (; rays.size() < 16; ) { 98 if (i%10000 == 0) 99 cout<<"+"; 100 101 Vector3 origin, direction; 102 mViewCellsManager->GetViewPoint( origin ); 103 104 direction = UniformRandomVector(); 105 ViewCell *viewcell = mViewCellsManager->GetViewCell(origin); 106 107 if (viewcell && viewcell->GetValid()) { 108 viewcells.push_back(viewcell); 109 // cast rays in both directions to make the number of samples comparable 110 // with the global sampling method which also casts a "double" ray per sample 111 rays.push_back(SimpleRay(origin, direction)); 112 i++; 113 samples++; 114 } 115 } 134 116 135 if (i%10000 == 0) 136 cout<<"+"; 137 138 Vector3 origin, direction; 139 mViewCellsManager->GetViewPoint(origin); 140 direction = UniformRandomVector(); 117 CastRays(rays, 118 vssRays, 119 true, 120 false); 141 121 142 143 ViewCell *viewcell = mViewCellsManager->GetViewCell(origin); 144 145 if (viewcell && viewcell->GetValid()) { 146 // cast rays in both directions to make the number of samples comparable 147 // with the global sampling method which also casts a "double" ray per sample 148 for (int j=0; j < 2; j++) { 149 Intersectable *object = CastRay(origin, direction); 150 if (object) { 151 // if ray not outside of view space 122 if (vssRays.size()!=32) { 123 cerr<<"wrong number of rays "<<vssRays.size()<<endl; 124 exit(1); 125 } 126 127 for (int j=0; j < vssRays.size(); j++) { 128 Intersectable *obj = mViewCellsManager->GetIntersectable(*(vssRays[j]), true); 129 if (obj) { 130 // if ray not outside of view space 152 131 float contribution; 153 132 int pvsContribution = 0; 154 133 float relativePvsContribution = 0; 155 if (object) { 156 float pdf = 1.0f; 157 if (viewcell->GetPvs().GetSampleContribution(object, 158 pdf, 159 contribution)) 160 ++pvsContribution; 161 relativePvsContribution += contribution; 162 viewcell->GetPvs().AddSample(object, pdf); 163 } 164 } 165 direction = -direction; 134 float pdf = 1.0f; 135 ViewCell *viewcell = viewcells[j/2]; 136 if (viewcell->GetPvs().GetSampleContribution(obj, 137 pdf, 138 contribution)) 139 ++pvsContribution; 140 relativePvsContribution += contribution; 141 viewcell->GetPvs().AddSample(obj, pdf); 166 142 } 167 143 } 144 168 145 169 146 if (samples > mTotalSamples) 170 147 break; 171 148 } 172 149 150 Debug<<"Valid viewcells before set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 151 mViewCellsManager->SetValidity(0, intersectables/2); 152 Debug<<"Valid viewcells after set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 153 173 154 // mVssRays.PrintStatistics(mStats); 174 155 mStats << -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.h
r1221 r1743 34 34 const Ray::Intersection &source); 35 35 36 /** Refined sampling for finding "holes", i.e., difficult visibility.37 */38 void39 HoleSamplingPass();40 36 41 37 42 Intersectable *43 CastRay(44 const Vector3 &origin,45 const Vector3 &direction46 );47 38 48 39 /** Verify if the exact visibility for this object was established. -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1742 r1743 314 314 } 315 315 316 Intersectable * 317 ViewCellsManager::GetIntersectable(const VssRay &ray, const bool isTermination) const 318 { 319 return isTermination ? ray.mTerminationObject : ray.mOriginObject; 320 } 316 321 317 322 void … … 2591 2596 // first determine the average size of the filter 2592 2597 2598 pvs = viewCell->GetPvs(); 2593 2599 Intersectable::NewMail(); 2594 2600 2595 2601 ObjectPvsIterator pit = pvs.GetIterator(); 2596 2602 … … 2712 2718 ObjectContainer::const_iterator noi = objects.begin(); 2713 2719 for (; noi != objects.end(); ++ noi) { 2714 2715 2716 2717 2720 Intersectable *o = *noi; 2721 // $$ JB warning: pdfs are not correct at this point! 2722 nPvs.AddSample(o, Limits::Small); 2723 nPvsSize ++; 2718 2724 } 2719 2725 } … … 2721 2727 2722 2728 pvs.MergeInPlace(nPvs); 2723 2729 2724 2730 Intersectable::NewMail(); 2725 2731 } … … 5093 5099 } 5094 5100 5101 Intersectable * 5102 VspOspViewCellsManager::GetIntersectable(const VssRay &ray, const bool isTermination) const 5103 { 5104 return mHierarchyManager->GetIntersectable(ray, isTermination); 5105 } 5095 5106 5096 5107 HierarchyManager *VspOspViewCellsManager::CreateHierarchyManager(const string &hierarchyType) -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1740 r1743 178 178 ViewCell *ExtrudeViewCell(const Triangle3 &baseTri, const float height) const; 179 179 180 181 virtual Intersectable * 182 GetIntersectable(const VssRay &ray, const bool isTermination) const; 183 180 184 /** Sets maximal number of samples used for the 181 185 construction of the view cells. … … 1067 1071 ViewCell *GenerateViewCell(Mesh *mesh = NULL) const; 1068 1072 1073 virtual Intersectable * 1074 GetIntersectable(const VssRay &ray, const bool isTermination) const; 1075 1069 1076 bool ViewCellsConstructed() const; 1070 1077 -
GTP/trunk/Lib/Vis/Preprocessing/src/default.env
r1737 r1743 51 51 # type render 52 52 detectEmptyViewSpace true 53 #pvsRenderErrorSamples 054 pvsRenderErrorSamples 100053 pvsRenderErrorSamples 0 54 # pvsRenderErrorSamples 1000 55 55 quitOnFinish true 56 56 computeVisibility true … … 75 75 76 76 SamplingPreprocessor { 77 totalSamples 10000000 77 totalSamples 100000000 78 78 samplesPerPass 1000000 79 79 } … … 82 82 samplesPerPass 1000 83 83 initialSamples 2000000 84 vssSamples 5000000084 vssSamples 100000000 85 85 # vssSamples 1000000 86 86 vssSamplesPerPass 3000000
Note: See TracChangeset
for help on using the changeset viewer.