Changeset 2116
- Timestamp:
- 02/15/07 00:35:41 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 4 added
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Containers.h
r1344 r2116 69 69 70 70 /// vertex index container 71 //typedef std::vector<short> VertexIndexContainer;72 71 typedef std::vector<int> VertexIndexContainer; 73 72 -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h
r2091 r2116 7 7 8 8 9 10 9 #include "Material.h" 11 10 #include "Containers.h" 12 #include "VssRay.h"11 //#include "VssRay.h" 13 12 #include "AxisAlignedBox3.h" 14 13 … … 31 30 class BvHierarchy; 32 31 class TransformedMeshInstance; 32 class MeshInstance; 33 class VssRay; 34 //class Material; 33 35 36 struct VssRayContainer; 34 37 35 38 class Exporter -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2053 r2116 5 5 #include "ViewCellsManager.h" 6 6 #include "SceneGraph.h" 7 #include "Pvs.h"7 //#include "ObjectPvs.h" 8 8 #include "Viewcell.h" 9 9 #include "Beam.h" … … 93 93 94 94 if (mViewCellsManager->GetViewCellPoints()->size()) 95 mPvsStatFrames = mViewCellsManager->GetViewCellPoints()->size();95 mPvsStatFrames = (int)mViewCellsManager->GetViewCellPoints()->size(); 96 96 else 97 97 Environment::GetSingleton()->GetIntValue("Preprocessor.pvsRenderErrorSamples", mPvsStatFrames); -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
r2050 r2116 7 7 #include "Renderer.h" 8 8 #include "Beam.h" 9 #include " Pvs.h"9 #include "ObjectPvs.h" 10 10 11 11 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2053 r2116 11 11 #include "SamplingStrategy.h" 12 12 #include "BvHierarchy.h" 13 #include "Polygon3.h" 13 14 14 15 -
GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h
r2102 r2116 2 2 #define __HASHPVS_H 3 3 4 #include <hash_map>5 #include < vector>4 //#include <hash_map> 5 #include <hash_set> 6 6 #include "common.h" 7 7 #include <math.h> … … 13 13 namespace GtpVisibilityPreprocessor { 14 14 15 class KdNode; 16 class BspNode; 17 class Ray; 18 class Intersectable; 19 class ViewCell; 15 16 template<typename T> 17 struct my_hash_compare 18 { 19 enum 20 { 21 bucket_size = 4, 22 min_buckets = 80 23 }; 24 25 size_t operator()(T a) const 26 { 27 size_t h = (size_t)(a->GetId());// % 2000; 28 //for (; *s; ++s) 29 // h = 5 * h + *s; 30 return h; 31 } 32 33 bool operator()(T a, T b) const 34 { 35 return a < b; 36 } 37 }; 38 39 /* 40 template<typename T> 41 struct gt 42 { 43 bool operator() (T s1, T s2) const 44 { 45 return s1 > s2; 46 } 47 }; 48 */ 49 //#define HASH_SET stdext::hash_set<T, stdext::hash_compare<T, gt<T> > > 50 #define HASH_SET stdext::hash_set<T, my_hash_compare<T> > 51 52 /** Iterator over a hash pvs. 53 */ 54 template<typename T, typename S> 55 class HashPvsIterator 56 { 57 public: 58 59 HashPvsIterator<T, S>() {} 60 61 HashPvsIterator<T, S>(const typename HASH_SET::const_iterator &itCurrent, 62 const typename HASH_SET::const_iterator &itEnd): 63 mItCurrent(itCurrent), mItEnd(itEnd) 64 { 65 } 66 67 bool HasMoreEntries() const 68 { 69 return (mItCurrent != mItEnd); 70 } 71 72 PvsEntry<T, S> Next() 73 { 74 // hack: create new pvs entry 75 return PvsEntry<T, S>(*(mItCurrent) ++, S(0.0)); 76 } 77 78 private: 79 typename HASH_SET::const_iterator mItCurrent; 80 typename HASH_SET::const_iterator mItEnd; 81 }; 20 82 21 83 … … 23 85 mainly from a view cell, but also e.g., from objects. 24 86 */ 25 template<typename T> 26 class HashPvs: public PvsBase<T> 27 { 28 template<typename T> 29 friend class PvsIterator2; 87 template<typename T, typename S> 88 class HashPvs//: public PvsBase<T> 89 { 90 template<typename T, typename S> friend class HashPvsIterator; 30 91 31 92 public: 32 93 94 //HashPvs(): mEntries((Intersectable *)100) {}; 33 95 HashPvs() {}; 34 96 //virtual ~HashPvs() {}; … … 40 102 @returns contribution of sample (0 or 1) 41 103 */ 42 float AddSample(T sample );104 float AddSample(T sample, const float pdf); 43 105 44 106 /** Adds sample to PVS without checking for presence of the sample 45 107 warning: pvs remains unsorted! 46 108 */ 47 void AddSampleDirty(T sample );109 void AddSampleDirty(T sample, const float pdf); 48 110 49 111 /** Adds sample dirty (on the end of the vector) but 50 112 first checks if sample is already in clean part of the pvs. 51 113 */ 52 bool AddSampleDirtyCheck(T sample );114 bool AddSampleDirtyCheck(T sample, const float pdf); 53 115 54 116 /** Sort pvs entries - this should always be called after a … … 61 123 void Clear(const bool trim = true); 62 124 63 //static void Merge(PvsBase &mergedPvs, const PvsBase &a, const PvsBase &b);64 65 125 bool IsDirty() const; 66 126 67 127 bool RequiresResort() const; 68 128 69 //typename PvsIterator<T> GetIterator() const; 70 129 /** Finds sample in PVS. 130 @param checkDirty if dirty part of the pvs should be checked for entry 131 (warning: linear runtime in dirty part) 132 @returns iterator on the sample if found, else the place where 133 it would be added in the sorted vector. 134 */ 135 bool Find(T sample, typename HASH_SET::iterator &it); 136 137 typename HashPvsIterator<T, S> GetIterator() const; 138 139 /** Compute continuous PVS difference 140 */ 141 float GetPvsHomogenity(HashPvs<T, S> &pvs); 142 143 static void Merge(HashPvs<T, S> &mergedPvs, 144 const HashPvs<T, S> &a, 145 const HashPvs<T, S> &b); 146 147 static int GetEntrySizeByte(); 148 static float GetEntrySize(); 149 150 bool GetSampleContribution(T sample, 151 const float pdf, 152 float &contribution); 153 154 int GetSamples() const 155 { 156 return mSamples; 157 } 158 159 void MergeInPlace(const HashPvs<T, S> &a) 160 { 161 cerr << "not implemented yet" << endl; 162 } 163 164 bool RequiresResortLog() const 165 { 166 return false; 167 } 168 169 void Reserve(const int n) 170 { 171 // not necessary 172 } 173 174 /** Sort pvs entries assume that the pvs contains unique entries 175 */ 176 void SimpleSort() 177 { 178 // not necessary 179 } 180 181 int SubtractPvs(const HashPvs<T, S> &pvs) 182 { 183 cerr << "not yet implemented" << endl; 184 return 0; 185 } 186 187 /** Compute continuous PVS difference 188 */ 189 void ComputeContinuousPvsDifference(HashPvs<T, S> &pvs, 190 float &pvsReduction, 191 float &pvsEnlargement) 192 { 193 cerr << "not yet implemented" << endl; 194 } 71 195 protected: 72 196 73 /// vectorof PVS entries74 vector<T>mEntries;197 /// hash table of PVS entries 198 HASH_SET mEntries; 75 199 76 200 /// Number of samples used to create the PVS … … 79 203 80 204 81 template <typename T> 82 int HashPvs<T>::GetSize() const 83 { 84 return 0; 85 } 86 87 88 template <typename T> 89 bool HashPvs<T>::Empty() const 205 template <typename T, typename S> 206 bool HashPvs<T, S>::Find(T sample, typename HASH_SET::iterator &it) 207 { 208 it = mEntries.find(sample); 209 210 // already in map 211 return (it != mEntries.end()); 212 } 213 214 215 template <typename T, typename S> 216 int HashPvs<T, S>::GetSize() const 217 { 218 return (int)mEntries.size(); 219 } 220 221 222 template <typename T, typename S> 223 bool HashPvs<T, S>::Empty() const 224 { 225 return mEntries.empty(); 226 } 227 228 229 template <typename T, typename S> 230 float HashPvs<T, S>::AddSample(T sample, const float pdf) 231 { 232 HASH_SET::iterator it; 233 234 if (Find(sample, it)) 235 return 0.0f; 236 237 mEntries.insert(sample); 238 return 1.0f; 239 } 240 241 242 template <typename T, typename S> 243 void HashPvs<T, S>::AddSampleDirty(T sample, const float pdf) 244 { 245 HASH_SET::iterator it; 246 247 // not yet in map 248 if (!Find(sample, it)) 249 { 250 mEntries.insert(sample); 251 } 252 } 253 254 255 template <typename T, typename S> 256 bool HashPvs<T, S>::AddSampleDirtyCheck(T sample, 257 const float pdf) 258 { 259 HASH_SET::iterator it; 260 261 // already in map 262 if (Find(sample, it)) 263 return false; 264 265 mEntries.insert(sample); 266 return true; 267 } 268 269 270 template <typename T, typename S> 271 void HashPvs<T, S>::Sort() 272 { 273 } 274 275 276 template <typename T, typename S> 277 void HashPvs<T, S>::Clear(const bool trim = true) 278 { 279 mEntries.clear(); 280 } 281 282 283 template <typename T, typename S> 284 bool HashPvs<T, S>::IsDirty() const 90 285 { 91 286 return false; … … 93 288 94 289 95 template <typename T> 96 float HashPvs<T>::AddSample(T sample) 97 { 98 return 0; 99 } 100 101 102 template <typename T> 103 void HashPvs<T>::AddSampleDirty(T sample) 104 { 105 } 106 107 108 template <typename T> 109 bool HashPvs<T>::AddSampleDirtyCheck(T sample) 290 template <typename T, typename S> 291 bool HashPvs<T, S>::RequiresResort() const 110 292 { 111 293 return false; … … 113 295 114 296 115 template <typename T> 116 void HashPvs<T>::Sort() 117 { 118 } 119 120 121 template <typename T> 122 void HashPvs<T>::Clear(const bool trim = true) 123 { 124 } 125 126 127 template <typename T> 128 bool HashPvs<T>::IsDirty() const 129 { 130 return false; 131 } 132 133 134 template <typename T> 135 bool HashPvs<T>::RequiresResort() const 136 { 137 return false; 138 } 139 140 //typename PvsIterator<T> GetIterator() const; 297 template <typename T, typename S> 298 typename HashPvsIterator<T, S> HashPvs<T, S>::GetIterator() const 299 { 300 HashPvsIterator<T, S> pit(mEntries.begin(), mEntries.end()); 301 302 return pit; 303 } 304 305 306 template <typename T, typename S> 307 float HashPvs<T, S>::GetEntrySize() 308 { 309 return (float)(sizeof(T)) / float(1024 * 1024); 310 } 311 312 313 template <typename T, typename S> 314 int HashPvs<T, S>::GetEntrySizeByte() 315 { 316 return sizeof(T); 317 } 318 319 320 template <typename T, typename S> 321 float HashPvs<T, S>::GetPvsHomogenity(HashPvs<T, S> &pvs) 322 { 323 float pvsReduction, pvsEnlargement; 324 325 ComputeContinuousPvsDifference(pvs, pvsReduction, pvsEnlargement); 326 327 return pvsReduction + pvsEnlargement; 328 } 329 330 331 template <typename T, typename S> 332 bool HashPvs<T, S>::GetSampleContribution(T sample, 333 const float pdf, 334 float &contribution) 335 { 336 HASH_SET::iterator it; 337 const bool entryFound = Find(sample, it); 338 339 if (entryFound) 340 { 341 contribution = 0.0f; 342 return false; 343 } 344 else 345 { 346 contribution = 1.0f; 347 return true; 348 } 349 } 350 351 352 template <typename T, typename S> 353 void HashPvs<T, S>::Merge(HashPvs<T, S> &mergedPvs, 354 const HashPvs<T, S> &a, 355 const HashPvs<T, S> &b) 356 { 357 HASH_SET::const_iterator ait, ait_end = a.mEntries.end(); 358 359 for (ait = a.mEntries.begin(); ait != ait_end; ++ ait) 360 { 361 mergedPvs.AddSample(*ait, 1.0f); 362 } 363 364 HASH_SET::const_iterator bit, bit_end = b.mEntries.end(); 365 366 for (bit = b.mEntries.begin(); bit != bit_end; ++ bit) 367 { 368 mergedPvs.AddSample(*bit, 1.0f); 369 } 370 371 //cerr << "not implemented" << endl; 372 } 141 373 142 374 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r2094 r2116 43 43 class ViewCellsParseHandlers; 44 44 class TraversalTree; 45 45 class ObjectPvs; 46 46 47 47 … … 679 679 ViewCellContainer mOldViewCells; 680 680 681 ObjectPvs mOldPvs;681 //ObjectPvs mOldPvs; 682 682 }; 683 683 -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r2113 r2116 3 3 4 4 #include "AxisAlignedBox3.h" 5 #include "Pvs.h"6 5 #include <set> 7 #include "VssRay.h"6 //#include "VssRay.h" 8 7 #include "Mailable.h" 9 8 … … 15 14 class BvhNode; 16 15 class Intersectable; 16 class VssRay; 17 17 struct Face; 18 18 -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectionBoundingBoxConverter.cpp
r2113 r2116 1 1 #include "IntersectionBoundingBoxConverter.h" 2 2 #include "KdTree.h" 3 #include "IntersectableWrapper.h" 3 4 4 5 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r2091 r2116 7 7 #include "ViewCell.h" 8 8 #include "Beam.h" 9 #include "ViewCell.h" 10 #include "IntersectableWrapper.h" 9 11 10 12 … … 85 87 { 86 88 DEL_PTR(mRoot); 87 88 89 CLEAR_CONTAINER(mKdIntersectables); 89 90 } … … 1457 1458 KdTree::GetOrCreateKdIntersectable(KdNode *node) 1458 1459 { 1459 1460 if (node == NULL) 1461 return NULL; 1462 1463 if (node->mIntersectable == NULL) { 1464 // not in map => create new entry 1465 node->mIntersectable = new KdIntersectable(node, GetBox(node)); 1466 mKdIntersectables.push_back(node->mIntersectable); 1467 } 1468 1469 return node->mIntersectable; 1460 if (node == NULL) 1461 return NULL; 1462 1463 if (node->mIntersectable == NULL) 1464 { 1465 // not in map => create new entry 1466 node->mIntersectable = new KdIntersectable(node, GetBox(node)); 1467 mKdIntersectables.push_back(node->mIntersectable); 1468 node->mIntersectable->SetId((int)mKdIntersectables.size()); 1469 } 1470 1471 return node->mIntersectable; 1470 1472 } 1471 1473 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r2113 r2116 8 8 #include "AxisAlignedBox3.h" 9 9 #include "Ray.h" 10 #include "Pvs.h"10 //#include "ObjectPvs.h" 11 11 #include "Viewcell.h" 12 12 #include "VssRay.h" 13 #include "IntersectableWrapper.h"14 13 //#include "IntersectableWrapper.h" 14 #include "gzstream.h" 15 15 16 16 namespace GtpVisibilityPreprocessor { 17 17 18 19 class KdNode;20 class KdLeaf;21 class KdInterior;22 classIntersectable;23 24 25 class KdTree;18 class KdNode; 19 class KdLeaf; 20 class KdInterior; 21 class Intersectable; 22 class KdIntersectable; 23 class Beam; 24 class KdTree; 25 //class KdViewCell; 26 26 27 27 // KdTree *SceneKdTree; … … 213 213 214 214 /** PVS consisting of visible KdTree nodes */ 215 KdPvs mKdPvs;215 //KdPvs mKdPvs; 216 216 217 217 /// pvs of view cells seeing this node. … … 619 619 AxisAlignedBox3 mBox; 620 620 KdTreeStatistics mStat; 621 621 622 public: 622 623 /// stores the kd node intersectables used for pvs -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjExporter.h
r1694 r2116 12 12 #include "Containers.h" 13 13 #include "VssRay.h" 14 #include "ViewCell.h"14 //#include "ViewCell.h" 15 15 16 16 namespace GtpVisibilityPreprocessor { -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp
r2100 r2116 27 27 28 28 29 int MailablePvsData::sMailId = 1; 30 int MailablePvsData::sReservedMailboxes = 1; 31 32 29 33 //////////// 30 34 //-- static members -
GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp
r2053 r2116 16 16 { 17 17 } 18 18 19 19 20 Polygon3::Polygon3(const VertexContainer &vertices): … … 67 68 } 68 69 70 71 Polygon3::~Polygon3() 72 { 73 DEL_PTR(mPlane); 74 } 69 75 70 76 Plane3 Polygon3::GetSupportingPlane()// const -
GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.h
r1420 r2116 3 3 4 4 5 //#include <iostream> 6 //#include <math.h> 7 //#include "common.h" 5 #include <iostream> 6 #include "common.h" 8 7 #include "Containers.h" 9 #include " Mesh.h"8 #include "Vector3.h" 10 9 #include <iomanip> 11 10 … … 18 17 class AxisAlignedBox3; 19 18 class Ray; 20 //typedef Vertex3 Vector3; 19 class Mesh; 20 class MeshInstance; 21 class Material; 22 struct Triangle3; 23 21 24 22 25 /** Class representing a planar convex polygon in 3d. … … 41 44 Polygon3(const Triangle3 &tri); 42 45 43 ~Polygon3() {DEL_PTR(mPlane);}46 ~Polygon3(); 44 47 45 48 /** Copies all the vertices of the face. … … 173 176 174 177 //s << setprecision(6) << "Polygon:\n"; 175 for (it = A.mVertices.begin(); it != A.mVertices.end(); ++it) 178 for (it = A.mVertices.begin(); it != A.mVertices.end(); ++ it) 179 { 176 180 s << *it << " "; 177 181 } 182 178 183 return s; 179 184 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
r2115 r2116 20 20 Name="VCCLCompilerTool" 21 21 Optimization="0" 22 AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost "23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB; "22 AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;Timer" 23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_HASH_PVS" 24 24 MinimalRebuild="TRUE" 25 25 BasicRuntimeChecks="3" … … 72 72 OptimizeForWindowsApplication="TRUE" 73 73 AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;Timer" 74 PreprocessorDefinitions="WIN32;NDEBUG;_LIB "74 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_HASH_PVS" 75 75 ExceptionHandling="TRUE" 76 76 RuntimeLibrary="2" … … 383 383 </File> 384 384 <File 385 RelativePath=".\BitVectorPvs.h"> 386 </File> 387 <File 385 388 RelativePath="..\src\BoostPreprocessorThread.cpp"> 386 389 </File> … … 581 584 </File> 582 585 <File 583 RelativePath=".\ObjectsParser.cpp"> 584 </File> 585 <File 586 RelativePath=".\ObjectsParser.h"> 587 </File> 588 <File 589 RelativePath=".\ObjectsParserXerces.h"> 586 RelativePath=".\ObjectPvs.cpp"> 587 </File> 588 <File 589 RelativePath=".\ObjectPvs.h"> 590 590 </File> 591 591 <File … … 767 767 </File> 768 768 <File 769 RelativePath="..\src\Pvs.cpp">770 </File>771 <File772 769 RelativePath="..\src\Pvs.h"> 773 770 </File> 774 771 <File 775 772 RelativePath=".\PvsBase.h"> 773 </File> 774 <File 775 RelativePath=".\PvsDefinitions.h"> 776 776 </File> 777 777 <File -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r2100 r2116 1 #ifndef __PVS_H 2 #define __PVS_H 3 4 #include <map> 1 #ifndef __VERBOSEPVS_H 2 #define __VERBOSEPVS_H 3 5 4 #include <vector> 6 5 #include "common.h" 7 6 #include <math.h> 7 #include "PvsBase.h" 8 9 8 10 using namespace std; 9 11 10 12 namespace GtpVisibilityPreprocessor { 11 12 class KdNode;13 class BspNode;14 class Ray;15 class Intersectable;16 class ViewCell;17 18 19 /** Information stored with a PVS entry. Consists of the number20 the object was seen from the view cell.21 */22 template<typename T, typename S>23 struct PvsEntry24 {25 public:26 27 PvsEntry() {}28 29 PvsEntry(T sample, const S &data): mObject(sample), mData(data) {}30 31 T mObject;32 S mData;33 34 template<typename T, typename S>35 friend int operator< (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b);36 template<typename T, typename S>37 friend int operator== (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b);38 };39 40 41 template<typename T, typename S>42 int operator< (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b)43 {44 return a.mObject < b.mObject;45 }46 47 template<typename T, typename S>48 int operator== (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b)49 {50 return a.mObject == b.mObject;51 }52 53 54 template<typename T, typename S>55 struct LtSample56 {57 bool operator()(const PvsEntry<T, S> &a, const PvsEntry<T, S> &b) const58 {59 return a.mObject < b.mObject;60 }61 };62 63 template<typename T, typename S>64 int equalSample (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b)65 {66 return a.mObject == b.mObject;67 }68 69 /** Information stored with a PVS entry. Consists of the number70 the object was seen from the view cell.71 */72 struct PvsData {73 public:74 PvsData() {}75 PvsData(const float sumPdf):76 mSumPdf(sumPdf) {}77 78 // $$JB in order to return meaningfull values79 // it assumes that the sum pdf has been normalized somehow!!!80 inline float GetVisibility()81 {82 return mSumPdf;83 }84 85 /// sum of probability density of visible sample rays86 float mSumPdf;87 };88 89 90 class MailablePvsData91 {92 public:93 // sum of probability density of visible sample rays94 float mSumPdf;95 int mCounter;96 97 MailablePvsData() {}98 MailablePvsData(const float sumPdf):99 mSumPdf(sumPdf) {}100 101 // $$JB in order to return meaningfull values102 // it assumes that the sum pdf has been normalized somehow!!!103 float GetVisibility()104 {105 return mSumPdf;106 }107 108 ///////////////109 // Mailing stuff110 111 // last mail id -> warning not thread safe!112 // both mailId and mailbox should be unique for each thread!!!113 static int sMailId;114 static int sReservedMailboxes;115 116 static void NewMail(const int reserve = 1) {117 sMailId += sReservedMailboxes;118 sReservedMailboxes = reserve;119 }120 121 void Mail() { mMailbox = sMailId; }122 bool Mailed() const { return mMailbox == sMailId; }123 124 void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }125 bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }126 127 int IncMail() { return ++ mMailbox - sMailId; }128 129 //////////////////////////////////////////130 131 protected:132 133 int mMailbox;134 135 };136 13 137 14 … … 140 17 { 141 18 public: 142 143 PvsIterator<T, S>() {} 144 19 PvsIterator<T, S>(){} 145 20 PvsIterator<T, S>(const typename vector<PvsEntry<T, S> >::const_iterator &itCurrent, 146 21 const typename vector<PvsEntry<T, S> >::const_iterator &itEnd): … … 158 33 return *(mItCurrent ++); 159 34 } 160 35 161 36 private: 162 37 typename vector<PvsEntry<T, S> >::const_iterator mItCurrent; … … 169 44 */ 170 45 template<typename T, typename S> 171 class Pvs 172 { 173 template<typename T, typename S> 174 friend class PvsIterator; 46 class VerbosePvs 47 { 48 template<typename T, typename S> friend class PvsIterator; 175 49 176 50 public: 177 51 178 Pvs(): mSamples(0), mEntries(), mLastSorted(0), mQueriesSinceSort(0) {}52 VerbosePvs(): mSamples(0), mEntries(), mLastSorted(0), mQueriesSinceSort(0) {} 179 53 180 54 /** creates pvs and initializes it with the given entries. 181 55 Assumes that entries are sorted- 182 56 */ 183 Pvs(const vector<PvsEntry<T, S> > &samples);184 virtual ~ Pvs() {};57 VerbosePvs(const vector<PvsEntry<T, S> > &samples); 58 virtual ~VerbosePvs() {}; 185 59 186 60 /** Compresses PVS lossless or lossy. … … 214 88 Warning: very slow! 215 89 */ 216 void MergeInPlace(const Pvs<T, S> &a);90 void MergeInPlace(const VerbosePvs<T, S> &a); 217 91 218 92 /** Difference of pvs to pvs b. 219 93 @returns number of different entries. 220 94 */ 221 int Diff(const Pvs<T, S> &b);95 int Diff(const VerbosePvs<T, S> &b); 222 96 223 97 /** Finds sample in PVS. … … 246 120 first checks if sample is already in clean part of the pvs. 247 121 */ 248 bool AddSampleDirtyCheck(T sample, const float pdf); //, float &contribution);122 bool AddSampleDirtyCheck(T sample, const float pdf); 249 123 250 124 /** Sort pvs entries - this should always be called after a … … 260 134 @returns PvsData 261 135 */ 262 typename std::vector<PvsEntry<T, S> >::iterator AddSample2(T sample, const float pdf); 136 typename std::vector<PvsEntry<T, S> >::iterator 137 AddSample2(T sample, const float pdf); 263 138 264 139 /** Subtracts one pvs from another one. … … 266 141 @returns new pvs size 267 142 */ 268 int SubtractPvs(const Pvs<T, S> &pvs);143 int SubtractPvs(const VerbosePvs<T, S> &pvs); 269 144 270 145 /** Returns PVS data, i.e., how often it was seen from the view cell, … … 284 159 /** Compute continuous PVS difference 285 160 */ 286 void ComputeContinuousPvsDifference( Pvs<T, S> &pvs,161 void ComputeContinuousPvsDifference(VerbosePvs<T, S> &pvs, 287 162 float &pvsReduction, 288 163 float &pvsEnlargement); … … 299 174 /** Compute continuous PVS difference 300 175 */ 301 float GetPvsHomogenity(Pvs<T, S> &pvs); 302 303 static void Merge(Pvs<T, S> &mergedPvs, const Pvs<T, S> &a, const Pvs<T, S> &b); 176 float GetPvsHomogenity(VerbosePvs<T, S> &pvs); 177 178 static void Merge(VerbosePvs<T, S> &mergedPvs, 179 const VerbosePvs<T, S> &a, 180 const VerbosePvs<T, S> &b); 304 181 305 182 int GetSamples() const … … 320 197 const int dirtySize = n - mLastSorted; 321 198 322 #define LOG2E 1.442695040f 199 const double LOG2E = 1.442695040f; 323 200 324 201 const float logN = log((float)max(1, n))/LOG2E; … … 344 221 } 345 222 346 347 223 int GetLastSorted() const 348 224 { … … 354 230 protected: 355 231 356 static void Merge( Pvs<T, S> &mergedPvs,232 static void Merge(VerbosePvs<T, S> &mergedPvs, 357 233 const typename std::vector<PvsEntry<T, S> >::const_iterator &aBegin, 358 234 const typename std::vector<PvsEntry<T, S> >::const_iterator &aEnd, … … 362 238 const int bSamples); 363 239 240 ////////////////////////////// 241 364 242 /// vector of PVS entries 365 243 vector<PvsEntry<T, S> > mEntries; … … 376 254 377 255 template <typename T, typename S> 378 Pvs<T, S>::Pvs(const vector<PvsEntry<T, S> > &samples)256 VerbosePvs<T, S>::VerbosePvs(const vector<PvsEntry<T, S> > &samples) 379 257 { 380 258 mEntries.reserve(samples.size()); … … 386 264 387 265 template <typename T, typename S> 388 void Pvs<T, S>::Sort()389 { 390 std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted;391 std::vector<PvsEntry<T, S> >::iterator it_end = mEntries.end();266 void VerbosePvs<T, S>::Sort() 267 { 268 vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted; 269 vector<PvsEntry<T, S> >::iterator it_end = mEntries.end(); 392 270 393 271 // throw out double entries … … 411 289 412 290 template <typename T, typename S> 413 void Pvs<T, S>::SimpleSort()291 void VerbosePvs<T, S>::SimpleSort() 414 292 { 415 293 // sort(mEntries.begin(), mEntries.end()); 416 std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted;294 vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted; 417 295 418 296 sort(it, mEntries.end()); … … 431 309 template <typename T, typename S> 432 310 void 433 Pvs<T, S>::ComputeContinuousPvsDifference(Pvs<T, S> &b,311 VerbosePvs<T, S>::ComputeContinuousPvsDifference(VerbosePvs<T, S> &b, 434 312 float &pvsReduction, 435 313 float &pvsEnlargement) … … 439 317 440 318 // Uses sum of log differences, which corresponds to entropy 441 std::vector<PvsEntry<T, S> >::iterator it;319 vector<PvsEntry<T, S> >::iterator it; 442 320 443 321 for (it = b.mEntries.begin(); it != b.mEntries.end(); ++ it) … … 514 392 515 393 template <typename T, typename S> 516 int Pvs<T, S>::Diff(constPvs<T, S> &b)394 int VerbosePvs<T, S>::Diff(const VerbosePvs<T, S> &b) 517 395 { 518 396 int dif = 0; … … 533 411 534 412 template <typename T, typename S> 535 void Pvs<T, S>::MergeInPlace(constPvs<T, S> &a)413 void VerbosePvs<T, S>::MergeInPlace(const VerbosePvs<T, S> &a) 536 414 { 537 415 // early exit … … 559 437 560 438 template <typename T, typename S> 561 void Pvs<T, S>::Merge(Pvs<T, S> &mergedPvs, const Pvs<T, S> &a, const Pvs<T, S> &b) 562 { 563 std::vector<PvsEntry<T, S> >::const_iterator ait = a.mEntries.begin(), ait_end = a.mEntries.end(); 564 std::vector<PvsEntry<T, S> >::const_iterator bit = b.mEntries.begin(), bit_end = b.mEntries.end(); 439 void VerbosePvs<T, S>::Merge(VerbosePvs<T, S> &mergedPvs, 440 const VerbosePvs<T, S> &a, 441 const VerbosePvs<T, S> &b) 442 { 443 std::vector<PvsEntry<T, S> >::const_iterator ait = 444 a.mEntries.begin(), ait_end = a.mEntries.end(); 445 std::vector<PvsEntry<T, S> >::const_iterator bit = 446 b.mEntries.begin(), bit_end = b.mEntries.end(); 565 447 566 448 Merge(mergedPvs, … … 573 455 574 456 template <typename T, typename S> 575 void Pvs<T, S>::Merge(Pvs<T, S> &mergedPvs,457 void VerbosePvs<T, S>::Merge(VerbosePvs<T, S> &mergedPvs, 576 458 const typename std::vector<PvsEntry<T, S> >::const_iterator &aBegin, 577 459 const typename std::vector<PvsEntry<T, S> >::const_iterator &aEnd, … … 627 509 628 510 629 template <typename T, typename S> void Pvs<T, S>::Clear(const bool trim = true)511 template <typename T, typename S> void VerbosePvs<T, S>::Clear(const bool trim = true) 630 512 { 631 513 mEntries.clear(); … … 640 522 641 523 642 template <typename T, typename S> void Pvs<T, S>::Trim()524 template <typename T, typename S> void VerbosePvs<T, S>::Trim() 643 525 { 644 526 vector<PvsEntry<T,S> >(mEntries).swap(mEntries); … … 647 529 648 530 template <typename T, typename S> 649 bool Pvs<T, S>::Find(T sample,531 bool VerbosePvs<T, S>::Find(T sample, 650 532 typename vector<PvsEntry<T, S> >::iterator &it, 651 533 const bool checkDirty) … … 684 566 685 567 template <typename T, typename S> 686 void Pvs<T, S>::GetData(const int index, T &entry, S &data)568 void VerbosePvs<T, S>::GetData(const int index, T &entry, S &data) 687 569 { 688 570 std::vector<PvsEntry<T, S> >::iterator i = mEntries.begin(); … … 695 577 696 578 template <typename T, typename S> 697 float Pvs<T, S>::AddSample(T sample, const float pdf)579 float VerbosePvs<T, S>::AddSample(T sample, const float pdf) 698 580 { 699 581 ++ mSamples; … … 719 601 720 602 template <typename T, typename S> 721 void Pvs<T, S>::AddSampleDirty(T sample, const float pdf)603 void VerbosePvs<T, S>::AddSampleDirty(T sample, const float pdf) 722 604 { 723 605 ++ mSamples; … … 727 609 728 610 template <typename T, typename S> 729 typename vector< PvsEntry<T, S> >::iterator Pvs<T, S>::AddSample2(T sample,611 typename vector< PvsEntry<T, S> >::iterator VerbosePvs<T, S>::AddSample2(T sample, 730 612 const float pdf) 731 613 { … … 751 633 752 634 753 /** Adds sample dirty (on the end of the vector) but754 first checks if sample is already in clean part of the pvs.755 */756 635 template <typename T, typename S> 757 bool Pvs<T, S>::AddSampleDirtyCheck(T sample,636 bool VerbosePvs<T, S>::AddSampleDirtyCheck(T sample, 758 637 const float pdf) 759 638 //,float &contribution) … … 784 663 785 664 template <typename T, typename S> 786 bool Pvs<T, S>::GetSampleContribution(T sample,665 bool VerbosePvs<T, S>::GetSampleContribution(T sample, 787 666 const float pdf, 788 667 float &contribution) … … 806 685 807 686 template <typename T, typename S> 808 bool Pvs<T, S>::RemoveSample(T sample, const float pdf)687 bool VerbosePvs<T, S>::RemoveSample(T sample, const float pdf) 809 688 { 810 689 -- mSamples; … … 831 710 832 711 template <typename T, typename S> 833 int Pvs<T, S>::SubtractPvs(constPvs<T, S> &pvs)712 int VerbosePvs<T, S>::SubtractPvs(const VerbosePvs<T, S> &pvs) 834 713 { 835 714 const int samples = mSamples - pvs.mSamples; … … 849 728 850 729 template <typename T, typename S> 851 void Pvs<T, S>::CollectEntries(std::vector<T> &entries)730 void VerbosePvs<T, S>::CollectEntries(std::vector<T> &entries) 852 731 { 853 732 std::vector<PvsEntry<T, S> >:: … … 861 740 862 741 template <typename T, typename S> 863 void Pvs<T, S>::NormalizeMaximum()742 void VerbosePvs<T, S>::NormalizeMaximum() 864 743 { 865 744 std::vector<PvsEntry<T, S> >:: … … 880 759 (*it)->second.sumPdf *= maxSum; 881 760 } 882 883 } 884 885 886 template <typename T, typename S> 887 float Pvs<T, S>::GetEntrySize() 761 } 762 763 764 template <typename T, typename S> 765 float VerbosePvs<T, S>::GetEntrySize() 888 766 { 889 767 return (float)(sizeof(T) + sizeof(S)) / float(1024 * 1024); … … 892 770 893 771 template <typename T, typename S> 894 int Pvs<T, S>::GetEntrySizeByte()772 int VerbosePvs<T, S>::GetEntrySizeByte() 895 773 { 896 774 return sizeof(T) + sizeof(S); … … 899 777 900 778 template <typename T, typename S> 901 float Pvs<T, S>::GetPvsHomogenity(Pvs<T, S> &pvs)779 float VerbosePvs<T, S>::GetPvsHomogenity(VerbosePvs<T, S> &pvs) 902 780 { 903 781 float pvsReduction, pvsEnlargement; 904 782 905 783 ComputeContinuousPvsDifference(pvs, pvsReduction, pvsEnlargement); 906 907 784 return pvsReduction + pvsEnlargement; 908 785 } … … 910 787 911 788 template <typename T, typename S> 912 typename PvsIterator<T, S> Pvs<T, S>::GetIterator() const789 typename PvsIterator<T, S> VerbosePvs<T, S>::GetIterator() const 913 790 { 914 791 PvsIterator<T, S> pit(mEntries.begin(), mEntries.end()); 915 916 792 return pit; 917 793 } 918 794 919 920 ///////////////////////////////////////921 922 /** Class instantiating the Pvs template for kd tree nodes.923 */924 class KdPvs: public Pvs<KdNode *, PvsData>925 {926 public:927 int Compress();928 };929 930 931 ////////////932 //-- typedefs933 934 typedef PvsEntry<Intersectable *, PvsData> ObjectPvsEntry;935 typedef std::vector<ObjectPvsEntry> ObjectPvsEntries;936 typedef Pvs<ViewCell *, MailablePvsData> ViewCellPvs;937 typedef PvsIterator<Intersectable *, PvsData> ObjectPvsIterator;938 939 940 class ObjectPvs: public Pvs<Intersectable *, PvsData>941 {942 public:943 /** Counts object int the pvs. Different to method "GetSize", not944 only the raw container size is returned,945 but the individual contributions of the entries are summed up.946 */947 float EvalPvsCost() const;948 949 friend ostream &operator<<(ostream &s, const ObjectPvs &p)950 {951 ObjectPvsIterator pit = p.GetIterator();952 953 while (pit.HasMoreEntries())954 {955 const ObjectPvsEntry &entry = pit.Next();956 Intersectable *obj = entry.mObject;957 958 cout << obj << " ";959 }960 961 return s;962 }963 };964 965 966 967 795 } 968 796 -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r2076 r2116 569 569 570 570 #if 1 571 cout<<"view cell cast time:"<<viewCellCastTimer.TotalTime()<<" s"<<endl; 572 cout<<"pvs time:"<<pvsTimer.TotalTime()<<" s"<<endl; 573 cout<<"halton time:"<<haltonTimer.TotalTime()<<" s"<<endl; 574 // cout<<"obj time:"<<objTimer.TotalTime()<<" s"<<endl; 571 const float vcTime = viewCellCastTimer.TotalTime(); 572 const float pvsTime = pvsTimer.TotalTime(); 573 const float haltonTime = haltonTimer.TotalTime(); 574 575 cout << "view cell cast time: " << vcTime << " s" << endl; 576 cout << "pvs time: " << pvsTime << " s" << endl; 577 cout << "halton time: "<< haltonTime << " s" << endl; 578 // cout<<"obj time:"<<objTimer.TotalTime()<<" s"<<endl; 579 580 Debug << "view cell cast time: " << vcTime << " s" << endl; 581 Debug << "pvs time: " << pvsTime << " s" << endl; 582 Debug << "halton time: "<< haltonTime << " s" << endl; 575 583 #endif 576 584 } -
GTP/trunk/Lib/Vis/Preprocessing/src/SimpleRay.h
r2105 r2116 40 40 SimpleRay(const Vector3 &o, 41 41 const Vector3 &d, 42 const shortdistribution,42 const unsigned char distribution, 43 43 const float weight, 44 44 const unsigned char flags = F_BIDIRECTIONAL -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
r2066 r2116 21 21 Optimization="0" 22 22 AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost" 23 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;NO_QT "23 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;NO_QT;USE_HASH_PVS" 24 24 MinimalRebuild="TRUE" 25 25 BasicRuntimeChecks="3" … … 81 81 OptimizeForWindowsApplication="TRUE" 82 82 AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\MultiLevelRayTracing;Timer" 83 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;NO_QT "83 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;NO_QT;USE_HASH_PVS" 84 84 RuntimeLibrary="2" 85 85 EnableEnhancedInstructionSet="2" -
GTP/trunk/Lib/Vis/Preprocessing/src/TraversalTree.h
r2093 r2116 8 8 #include "AxisAlignedBox3.h" 9 9 #include "Ray.h" 10 #include "Pvs.h"11 #include "Viewcell.h"12 #include "VssRay.h"13 #include "IntersectableWrapper.h"10 //#include "ObjectPvs.h" 11 //#include "Viewcell.h" 12 //#include "VssRay.h" 13 //#include "IntersectableWrapper.h" 14 14 15 15 … … 17 17 18 18 19 20 21 22 23 24 25 26 27 19 class TraversalNode; 20 class TraversalLeaf; 21 class TraversalInterior; 22 class Intersectable; 23 class Beam; 24 25 class TraversalTree; 26 27 // TraversalTree *SceneTraversalTree; 28 28 29 29 // -------------------------------------------------------------- -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r1999 r2116 8 8 #include "Material.h" 9 9 #include "gzstream.h" 10 10 #include "ObjectPvs.h" 11 11 12 12 namespace GtpVisibilityPreprocessor { … … 24 24 class ViewCellLeaf; 25 25 26 27 //class ObjectPvs; 26 28 27 29 … … 282 284 } 283 285 284 //////////285 //-- mailing stuff286 287 // static void NewMail(const int reserve = 1)288 // {289 // sMailId += sReservedMailboxes;290 // sReservedMailboxes = reserve;291 // }292 293 // void Mail() { mMailbox = sMailId; }294 // bool Mailed() const { return mMailbox == sMailId; }295 296 // void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }297 // bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }298 299 // int IncMail() { return ++ mMailbox - sMailId; }300 301 302 // last mail id -> warning not thread safe!303 // both mailId and mailbox should be unique for each thread!!!304 305 //static int sMailId;306 //static int sReservedMailboxes;307 286 308 287 int GetFilteredPvsSize() const -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2115 r2116 28 28 29 29 30 30 31 #define USE_RAY_LENGTH_AS_CONTRIBUTION 0 31 32 #define DIST_WEIGHTED_CONTRIBUTION 0 … … 170 171 } 171 172 172 Debug << "casting initial strategies: "; 173 173 Debug << "casting strategies: "; 174 174 for (int i = 0; i < (int)mStrategies.size(); ++ i) 175 175 Debug << mStrategies[i] << " "; … … 730 730 { 731 731 long startTime = GetTime(); 732 732 733 733 SimpleRayContainer simpleRays; 734 734 … … 1018 1018 1019 1019 1020 ViewCellsManager *ViewCellsManager::LoadViewCells(const string &filename,1021 ObjectContainer &pvsObjects,1022 bool finalizeViewCells,1023 BoundingBoxConverter *bconverter)1024 1025 {1026 ObjectContainer dummys;1027 1028 return LoadViewCells(filename,1029 pvsObjects,1030 dummys,1031 finalizeViewCells,1032 bconverter);1033 }1034 1020 1035 1021 … … 1059 1045 } 1060 1046 1047 //cout << "viewcells parsed " <<endl; 1048 1061 1049 if (0) 1062 1050 { … … 1127 1115 if (mUseKdPvs) 1128 1116 { 1129 vector<KdIntersectable *>::iterator kit, kit_end = 1130 GetPreprocessor()->mKdTree->mKdIntersectables.end(); 1117 vector<KdIntersectable *>::iterator kit, kit_end = GetPreprocessor()->mKdTree->mKdIntersectables.end(); 1131 1118 1132 1119 int id = 0; … … 1138 1125 obj->SetId(id); 1139 1126 1140 stream << "<BoundingBox" << " id=\"" << id<< "\""1141 << " min=\"" 1142 << " max=\"" 1127 stream << "<BoundingBox" << " id=\"" << id << "\"" 1128 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 1129 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 1143 1130 } 1144 1131 } … … 1154 1141 //-- the bounding boxes 1155 1142 1156 stream << "<BoundingBox" << " id=\"" << (*oit)->GetId()<< "\""1157 << " min=\"" 1158 << " max=\"" 1143 stream << "<BoundingBox" << " id=\"" << (*oit)->GetId() << "\"" 1144 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 1145 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 1159 1146 } 1160 1147 } … … 1560 1547 1561 1548 castSamples += samplesPerPass; 1562 //HashPvs<int> dummy;1563 1549 1564 1550 Real timeDiff = TimeDiff(startTime, GetTime()); … … 2070 2056 const bool useHitObjects) 2071 2057 { 2072 float sum = 0.0f; 2073 2074 VssRayContainer::const_iterator it, it_end = rays.end(); 2075 2076 for (it = rays.begin(); it != it_end; ++ it) 2077 { 2078 if (!ViewCellsConstructed()) { 2079 // view cells not yet constructed 2080 // just take the lenghts of the rays as contributions 2081 if ((*it)->mTerminationObject) 2082 sum += (*it)->Length(); 2083 } else { 2084 sum += ComputeSampleContribution(*(*it), addRays, storeViewCells, useHitObjects); 2085 } 2086 } 2087 2088 //cout<<"view cell cast time:"<<viewCellCastTimer.TotalTime()<<" s"<<endl; 2089 // cout<<"pvs time:"<<pvsTimer.TotalTime()<<" s"<<endl; 2090 2091 return sum; 2058 float sum = 0.0f; 2059 2060 VssRayContainer::const_iterator it, it_end = rays.end(); 2061 2062 for (it = rays.begin(); it != it_end; ++ it) 2063 { 2064 if (!ViewCellsConstructed()) 2065 { 2066 // view cells not yet constructed 2067 // just take the lenghts of the rays as contributions 2068 if ((*it)->mTerminationObject) 2069 { 2070 sum += (*it)->Length(); 2071 } 2072 } 2073 else 2074 { 2075 sum += ComputeSampleContribution(*(*it), addRays, storeViewCells, useHitObjects); 2076 } 2077 } 2078 2079 cout << "view cell cast time: " << viewCellCastTimer.TotalTime() << " s" << endl; 2080 Debug << "view cell cast time: " << viewCellCastTimer.TotalTime() << " s" << endl; 2081 2082 cout << "pvs time: " << pvsTimer.TotalTime() << " s" << endl; 2083 Debug << "pvs time: " << pvsTimer.TotalTime() << " s" << endl; 2084 2085 return sum; 2092 2086 } 2093 2087 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r2115 r2116 7 7 #include "Containers.h" 8 8 #include "ViewCell.h" 9 #include "ViewCellBsp.h"9 //#include "ViewCellBsp.h" 10 10 11 11 namespace GtpVisibilityPreprocessor { … … 43 43 struct AxisAlignedPlane; 44 44 struct BspRay; 45 46 47 48 49 struct PvsFilterStatistics { 45 class BspTree; 46 47 48 49 struct PvsFilterStatistics 50 { 50 51 PvsFilterStatistics(): 51 mAvgFilterRadius(0.0f), mLocalFilterCount(0), mGlobalFilterCount(0) {} 52 mAvgFilterRadius(0.0f), mLocalFilterCount(0), mGlobalFilterCount(0) {} 53 52 54 float mAvgFilterRadius; 53 55 int mLocalFilterCount; 54 56 int mGlobalFilterCount; 55 56 }; 57 57 }; 58 58 59 /** Probably Visible Set 59 60 */ … … 61 62 { 62 63 public: 63 64 65 66 67 68 69 64 /// root of view cells tree 65 ViewCell *mViewCell; 66 67 // input parameter is the render budget for the PrVs 68 float mRenderBudget; 69 70 // some characteristic values could be stored as well 70 71 }; 71 72 … … 85 86 { 86 87 public: 87 88 struct PerViewCellStat { 89 float pvsSize; 90 float relPvsIncrease; 91 }; 92 93 struct SamplesStatistics { 94 int mRays; 95 int mViewCells; 96 int mContributingRays; 97 int mPvsContributions; 98 void Reset() { 99 mRays = 0; 100 mViewCells = 0; 101 mContributingRays = 0; 102 mPvsContributions = 0; 88 89 struct PerViewCellStat 90 { 91 float pvsSize; 92 float relPvsIncrease; 103 93 }; 104 }; 105 106 struct PvsStatistics 94 95 struct SamplesStatistics 107 96 { 108 float minPvs; 109 float maxPvs; 110 float avgPvs; 111 float avgPvsEntries; 112 113 float avgFilteredPvs; 114 float avgFilteredPvsEntries; 115 116 float avgFilterContribution; 117 float avgFilterRadius; 118 float avgFilterRatio; 119 float avgRelPvsIncrease; 120 float devRelPvsIncrease; 121 int viewcells; 97 int mRays; 98 int mViewCells; 99 int mContributingRays; 100 int mPvsContributions; 101 void Reset() 102 { 103 mRays = 0; 104 mViewCells = 0; 105 mContributingRays = 0; 106 mPvsContributions = 0; 107 }; 108 }; 109 110 struct PvsStatistics 111 { 112 float minPvs; 113 float maxPvs; 114 float avgPvs; 115 float avgPvsEntries; 116 117 float avgFilteredPvs; 118 float avgFilteredPvsEntries; 119 120 float avgFilterContribution; 121 float avgFilterRadius; 122 float avgFilterRatio; 123 float avgRelPvsIncrease; 124 float devRelPvsIncrease; 125 int viewcells; 122 126 }; 123 127 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h
r2115 r2116 27 27 class BvHierarchy; 28 28 class HierarchyManager; 29 class ObjectPvs; 30 class BspNode; 29 31 30 32 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r2073 r2116 619 619 // update scalar pvs size value 620 620 ObjectPvs &pvs = viewCell->GetPvs(); 621 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.EvalPvsCost(), pvs.GetSize()); 621 mViewCellsManager->UpdateScalarPvsSize(viewCell, 622 pvs.EvalPvsCost(), 623 pvs.GetSize()); 622 624 623 625 mVspStats.contributingSamples += conSamp; -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r2066 r2116 16 16 #include "RayCaster.h" 17 17 #include "SamplingStrategy.h" 18 18 #include "ViewCellBsp.h" 19 19 20 20 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.cpp
r1966 r2116 1 1 #include "VssRay.h" 2 2 #include "AxisAlignedBox3.h" 3 #include "Ray.h" 4 3 5 4 6 namespace GtpVisibilityPreprocessor { -
GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h
r2014 r2116 3 3 4 4 #include <vector> 5 6 #include "Vector3.h" 7 #include "Containers.h" 8 5 9 using namespace std; 6 #include "Vector3.h" 7 #include "Ray.h" 8 #include "Containers.h" 10 9 11 10 12 namespace GtpVisibilityPreprocessor { … … 13 15 class Intersectable; 14 16 class KdNode; 17 class Ray; 15 18 16 19 #define ABS_CONTRIBUTION_WEIGHT 0.0f -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r1789 r2116 32 32 #include "IntersectableWrapper.h" 33 33 #include <assert.h> 34 34 #include "Polygon3.h" 35 35 36 36 namespace GtpVisibilityPreprocessor { -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r2115 r2116 1 /*#ifdef GTP_INTERNAL2 #ifndef USE_QT3 #define USE_QT 14 #else5 #define USE_QT 06 #endif7 #endif8 */9 10 1 #define USE_THREADS 0 11 2 … … 29 20 #include "SceneGraph.h" 30 21 #include "GlobalLinesRenderer.h" 22 #include "PvsDefinitions.h" 31 23 32 24 #include "ViewCellsManager.h" … … 227 219 228 220 221 if (HASH_PVS) 222 Debug << "using hash pvs" << endl; 223 else 224 Debug << "using verbose pvs" << endl; 225 229 226 ///////////// 230 227 //-- load scene
Note: See TracChangeset
for help on using the changeset viewer.