Changeset 2117
- Timestamp:
- 02/15/07 13:19:17 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BitVectorPvs.h
r2116 r2117 13 13 typedef vector<bool> bit_vector; 14 14 15 15 16 /** Iterator over a bitvector pvs. 16 17 */ 17 #if 018 18 template<typename T, typename S> 19 19 class BitVectorPvsIterator … … 21 21 public: 22 22 23 HashPvsIterator<T, S>() {}24 25 HashPvsIterator<T, S>(const typename HASH_SET::const_iterator &itCurrent,26 const typename HASH_SET::const_iterator &itEnd):27 mItCurrent(it Current), mItEnd(itEnd)23 BitVectorPvsIterator<T, S>(const typename bit_vector::const_iterator &itBegin, 24 const typename bit_vector::const_iterator &itEnd 25 //,const int lastElement 26 ): 27 mItCurrent(itBegin), mItEnd(itEnd), mDistance(0)//, mLastElement 28 28 { 29 29 } … … 31 31 bool HasMoreEntries() const 32 32 { 33 return (mItCurrent != mItEnd); 34 } 35 36 PvsEntry<T, S> Next() 33 // find next element in bit vector 34 // warning: has to do traversal each time 35 typename bit_vector::const_iterator itNext = mItCurrent; 36 37 for (;(itNext != mItEnd) && !(*itNext); ++ itNext); 38 39 return (itNext != mItEnd); 40 } 41 42 T Next(S &pdf) 43 { 44 return Next(); 45 } 46 47 T Next() 37 48 { 38 49 // hack: create new pvs entry 39 return PvsEntry<T, S>(*(mItCurrent) ++, S(0.0)); 40 } 41 50 for (; !(*mItCurrent); ++ mItCurrent, ++ mDistance); 51 52 T sample = sObjects[mDistance]; 53 54 ++ mDistance; 55 ++ mItCurrent; 56 57 return sample; 58 } 59 60 61 // vector of objects corresponding to pvs entries 62 static vector<T> sObjects; 63 42 64 private: 43 typename HASH_SET::const_iterator mItCurrent; 44 typename HASH_SET::const_iterator mItEnd; 65 66 typename bit_vector::const_iterator mItCurrent; 67 //typename bit_vector::const_iterator mItNext; 68 typename bit_vector::const_iterator mItEnd; 69 70 // note: store distance explicitly because I 71 // don't know how efficient 72 // std::distance is on specialisation of vector<bool> 73 int mDistance; 45 74 }; 46 #endif 47 48 #if 0 75 76 49 77 /** Pvs implemented as bitvector 50 78 */ … … 56 84 public: 57 85 58 //HashPvs(): mEntries((Intersectable *)100) {}; 59 HashPvs() {}; 86 BitVectorPvs(); 60 87 //virtual ~HashPvs() {}; 61 88 … … 92 119 93 120 /** Finds sample in PVS. 94 @param checkDirty if dirty part of the pvs should be checked for entry 95 (warning: linear runtime in dirty part) 96 @returns iterator on the sample if found, else the place where 97 it would be added in the sorted vector. 98 */ 99 bool Find(T sample, typename HASH_SET::iterator &it); 100 101 typename HashPvsIterator<T, S> GetIterator() const; 121 */ 122 bool Find(T sample); 123 124 typename BitVectorPvsIterator<T, S> GetIterator() const; 102 125 103 126 /** Compute continuous PVS difference 104 127 */ 105 float GetPvsHomogenity( HashPvs<T, S> &pvs);106 107 static void Merge( HashPvs<T, S> &mergedPvs,108 const HashPvs<T, S> &a,109 const HashPvs<T, S> &b);128 float GetPvsHomogenity(BitVectorPvs<T, S> &pvs); 129 130 static void Merge(BitVectorPvs<T, S> &mergedPvs, 131 const BitVectorPvs<T, S> &a, 132 const BitVectorPvs<T, S> &b); 110 133 111 134 static int GetEntrySizeByte(); … … 121 144 } 122 145 123 void MergeInPlace(const HashPvs<T, S> &a)146 void MergeInPlace(const BitVectorPvs<T, S> &a) 124 147 { 125 148 cerr << "not implemented yet" << endl; … … 133 156 void Reserve(const int n) 134 157 { 158 mEntries.reserve(n); 159 } 160 161 /** Sort pvs entries assume that the pvs contains unique entries 162 */ 163 void SimpleSort() 164 { 135 165 // not necessary 136 166 } 137 167 138 /** Sort pvs entries assume that the pvs contains unique entries 139 */ 140 void SimpleSort() 141 { 142 // not necessary 143 } 144 145 int SubtractPvs(const HashPvs<T, S> &pvs) 168 int SubtractPvs(const BitVectorPvs<T, S> &pvs) 146 169 { 147 170 cerr << "not yet implemented" << endl; … … 151 174 /** Compute continuous PVS difference 152 175 */ 153 void ComputeContinuousPvsDifference( HashPvs<T, S> &pvs,176 void ComputeContinuousPvsDifference(BitVectorPvs<T, S> &pvs, 154 177 float &pvsReduction, 155 178 float &pvsEnlargement) … … 157 180 cerr << "not yet implemented" << endl; 158 181 } 182 183 184 static void SetPvsSize(const int pvsSize) { sPvsSize = pvsSize; }; 185 159 186 protected: 160 187 161 188 /// hash table of PVS entries 162 HASH_SETmEntries;189 bit_vector mEntries; 163 190 164 191 /// Number of samples used to create the PVS 165 192 int mSamples; 193 194 public: 195 static int sPvsSize; 166 196 }; 167 197 168 198 169 199 template <typename T, typename S> 170 bool HashPvs<T, S>::Find(T sample, typename HASH_SET::iterator &it) 171 { 172 it = mEntries.find(sample); 173 174 // already in map 175 return (it != mEntries.end()); 176 } 177 178 179 template <typename T, typename S> 180 int HashPvs<T, S>::GetSize() const 181 { 182 return (int)mEntries.size(); 183 } 184 185 186 template <typename T, typename S> 187 bool HashPvs<T, S>::Empty() const 188 { 189 return mEntries.empty(); 190 } 191 192 193 template <typename T, typename S> 194 float HashPvs<T, S>::AddSample(T sample, const float pdf) 195 { 196 HASH_SET::iterator it; 197 198 if (Find(sample, it)) 200 BitVectorPvs<T, S>::BitVectorPvs() 201 { 202 // initialize bit vector 203 mEntries.reserve(sPvsSize); 204 mEntries.resize(sPvsSize); 205 206 // set pvs entries to false 207 Clear(); 208 } 209 210 211 template <typename T, typename S> 212 bool BitVectorPvs<T, S>::Find(T sample) 213 { 214 return mEntries[sample->GetId()]; 215 } 216 217 218 template <typename T, typename S> 219 int BitVectorPvs<T, S>::GetSize() const 220 { 221 int size = 0; 222 bit_vector::const_iterator bit, bit_end = mEntries.end(); 223 224 for (bit = mEntries.begin(); bit != bit_end; ++ bit) 225 { 226 if (*bit) ++ size; 227 } 228 229 return size; 230 } 231 232 233 template <typename T, typename S> 234 bool BitVectorPvs<T, S>::Empty() const 235 { 236 bit_vector::const_iterator bit, bit_end = mEntries.end(); 237 238 for (bit = mEntries.begin(); bit != bit_end; ++ bit) 239 { 240 if (*bit) return false; 241 } 242 243 return true; 244 } 245 246 247 template <typename T, typename S> 248 float BitVectorPvs<T, S>::AddSample(T sample, const float pdf) 249 { 250 if (Find(sample)) 199 251 return 0.0f; 200 252 201 mEntries.insert(sample); 253 mEntries[sample->GetId()] = true; 254 202 255 return 1.0f; 203 256 } … … 205 258 206 259 template <typename T, typename S> 207 void HashPvs<T, S>::AddSampleDirty(T sample, const float pdf) 208 { 209 HASH_SET::iterator it; 210 211 // not yet in map 212 if (!Find(sample, it)) 213 { 214 mEntries.insert(sample); 215 } 216 } 217 218 219 template <typename T, typename S> 220 bool HashPvs<T, S>::AddSampleDirtyCheck(T sample, 260 void BitVectorPvs<T, S>::AddSampleDirty(T sample, const float pdf) 261 { 262 if (!Find(sample)) 263 { 264 mEntries[sample->GetId()] = true; 265 } 266 } 267 268 269 template <typename T, typename S> 270 bool BitVectorPvs<T, S>::AddSampleDirtyCheck(T sample, 221 271 const float pdf) 222 272 { 223 HASH_SET::iterator it; 224 225 // already in map 226 if (Find(sample, it)) 273 if (Find(sample)) 227 274 return false; 228 275 229 mEntries .insert(sample);276 mEntries[sample->GetId()] = true; 230 277 return true; 231 278 } … … 233 280 234 281 template <typename T, typename S> 235 void HashPvs<T, S>::Sort() 236 { 237 } 238 239 240 template <typename T, typename S> 241 void HashPvs<T, S>::Clear(const bool trim = true) 242 { 243 mEntries.clear(); 244 } 245 246 247 template <typename T, typename S> 248 bool HashPvs<T, S>::IsDirty() const 282 void BitVectorPvs<T, S>::Sort() 283 { 284 } 285 286 287 template <typename T, typename S> 288 void BitVectorPvs<T, S>::Clear(const bool trim = true) 289 { 290 bit_vector::iterator bit, bit_end = mEntries.end(); 291 for (bit = mEntries.begin(); bit != bit_end; ++ bit) 292 { 293 (*bit) = false; 294 } 295 } 296 297 298 template <typename T, typename S> 299 bool BitVectorPvs<T, S>::IsDirty() const 249 300 { 250 301 return false; … … 253 304 254 305 template <typename T, typename S> 255 bool HashPvs<T, S>::RequiresResort() const306 bool BitVectorPvs<T, S>::RequiresResort() const 256 307 { 257 308 return false; … … 260 311 261 312 template <typename T, typename S> 262 typename HashPvsIterator<T, S> HashPvs<T, S>::GetIterator() const263 { 264 HashPvsIterator<T, S> pit(mEntries.begin(), mEntries.end());313 typename BitVectorPvsIterator<T, S> BitVectorPvs<T, S>::GetIterator() const 314 { 315 BitVectorPvsIterator<T, S> pit(mEntries.begin(), mEntries.end()); 265 316 266 317 return pit; … … 269 320 270 321 template <typename T, typename S> 271 float HashPvs<T, S>::GetEntrySize()272 { 273 return (float)(sizeof( T)) / float(1024 * 1024);274 } 275 276 277 template <typename T, typename S> 278 int HashPvs<T, S>::GetEntrySizeByte()279 { 280 return sizeof( T);281 } 282 283 284 template <typename T, typename S> 285 float HashPvs<T, S>::GetPvsHomogenity(HashPvs<T, S> &pvs)322 float BitVectorPvs<T, S>::GetEntrySize() 323 { 324 return (float)(sizeof(bool)) / float(1024 * 1024); 325 } 326 327 328 template <typename T, typename S> 329 int BitVectorPvs<T, S>::GetEntrySizeByte() 330 { 331 return sizeof(bool); 332 } 333 334 335 template <typename T, typename S> 336 float BitVectorPvs<T, S>::GetPvsHomogenity(BitVectorPvs<T, S> &pvs) 286 337 { 287 338 float pvsReduction, pvsEnlargement; … … 294 345 295 346 template <typename T, typename S> 296 bool HashPvs<T, S>::GetSampleContribution(T sample,347 bool BitVectorPvs<T, S>::GetSampleContribution(T sample, 297 348 const float pdf, 298 349 float &contribution) 299 350 { 300 HASH_SET::iterator it; 301 const bool entryFound = Find(sample, it); 351 const bool entryFound = Find(sample); 302 352 303 353 if (entryFound) … … 315 365 316 366 template <typename T, typename S> 317 void HashPvs<T, S>::Merge(HashPvs<T, S> &mergedPvs, 318 const HashPvs<T, S> &a, 319 const HashPvs<T, S> &b) 320 { 367 void BitVectorPvs<T, S>::Merge(BitVectorPvs<T, S> &mergedPvs, 368 const BitVectorPvs<T, S> &a, 369 const BitVectorPvs<T, S> &b) 370 { 371 bit_vector::iterator bit, bit_end = mergedPvs.mEntries.end(); 372 bit_vector::const_iterator bitA = a.mEntries.begin(), bitB = b.mEntries.begin(); 373 374 for (bit = mergedPvs.mEntries.begin(); bit != bit_end; ++ bit, ++ bitA, ++ bitB) 375 { 376 (*bit) = (*bitA) | (*bitB); 377 } 378 } 379 380 381 template<typename T, typename S> 382 int BitVectorPvs<T, S>::sPvsSize = 0; 383 384 template<typename T, typename S> 385 vector<T> BitVectorPvsIterator<T, S>::sObjects; 386 321 387 } 322 388 323 389 #endif 324 390 325 }326 327 #endif328 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2116 r2117 678 678 return; 679 679 680 /*ObjectPvsIterator pit = vc->GetPvs().GetIterator();681 682 // output PVS of view cell683 while (pit.HasMoreEntries())684 {685 ObjectPvsEntry entry = pit.Next();686 687 Intersectable *intersect = entry.mObject;688 689 if (intersect->Mailed())690 continue;691 692 intersect->Mail();693 //m.mDiffuseColor = RgbColor(1, 0, 0);694 m = RandomMaterial();695 exporter->SetForcedMaterial(m);696 697 exporter->ExportIntersectable(intersect);698 }*/699 680 ObjectContainer::const_iterator oit, oit_end = objects.end(); 700 681 … … 1028 1009 while (pit.HasMoreEntries()) 1029 1010 { 1030 ObjectPvsEntry entry = pit.Next(); 1031 1032 Intersectable *intersect = entry.mObject; 1033 1011 Intersectable *intersect = pit.Next(); 1012 1034 1013 BvhLeaf *bv = intersect->mBvhLeaf; 1035 1014 -
GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h
r2116 r2117 70 70 } 71 71 72 PvsEntry<T, S> Next()72 T Next(S &pdf) 73 73 { 74 74 // hack: create new pvs entry 75 return PvsEntry<T, S>(*(mItCurrent) ++, S(0.0)); 75 return *(mItCurrent) ++; 76 } 77 78 T Next() 79 { 80 // hack: create new pvs entry 81 return *(mItCurrent) ++; 76 82 } 77 83 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r2094 r2117 1877 1877 while (pit.HasMoreEntries()) 1878 1878 { 1879 const ObjectPvsEntry &entry= pit.Next();1880 1881 if ( entry.mObject->Type() != Intersectable::BVH_INTERSECTABLE)1882 cout << "error " << entry.mObject->Type() << endl;1883 1884 BvhNode *intersect = static_cast<BvhNode *>( entry.mObject);1879 Intersectable *obj = pit.Next(); 1880 1881 if (obj->Type() != Intersectable::BVH_INTERSECTABLE) 1882 cout << "error " << obj->Type() << endl; 1883 1884 BvhNode *intersect = static_cast<BvhNode *>(obj); 1885 1885 BvhNode *activeNode; 1886 1886 … … 1937 1937 while (pit.HasMoreEntries()) 1938 1938 { 1939 const ObjectPvsEntry &entry = pit.Next(); 1940 1941 Intersectable *object = entry.mObject; 1939 Intersectable *object = pit.Next(); 1940 1942 1941 if (!object->Mailed()) 1943 1942 { -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r2116 r2117 1464 1464 { 1465 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()); 1466 const int id = (int)mKdIntersectables.size(); 1467 KdIntersectable *kdObj = new KdIntersectable(node, GetBox(node));; 1468 node->mIntersectable = kdObj; 1469 1470 mKdIntersectables.push_back(kdObj); 1471 kdObj->SetId(id); 1472 1473 #ifdef USE_BIT_PVS 1474 // hack: for kd pvs the kd intersecables are the pvs objects 1475 ObjectPvsIterator::sObjects.push_back(kdObj); 1476 #endif 1469 1477 } 1470 1478 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r2116 r2117 202 202 } 203 203 204 /** \sa KdNode::IsLeaf() */ 204 /** \sa KdNode::IsLeaf() 205 */ 205 206 virtual bool IsLeaf() const { return true; } 206 207 207 208 208 / ** pointers to occluders contained in this node */209 /// pointers to occluders contained in this node 209 210 ObjectContainer mObjects; 210 211 211 / ** Ray set description of the rays passing through this node */212 /// Ray set description of the rays passing through this node 212 213 PassingRaySet mPassingRays; 213 214 214 / ** PVS consisting of visible KdTree nodes */215 /// PVS consisting of visible KdTree nodes 215 216 //KdPvs mKdPvs; 216 217 -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.h
r2116 r2117 31 31 while (pit.HasMoreEntries()) 32 32 { 33 const ObjectPvsEntry &entry = pit.Next(); 34 Intersectable *obj = entry.mObject; 35 33 Intersectable *obj = pit.Next(); 36 34 cout << obj << " "; 37 35 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2115 r2117 729 729 char buf[100]; 730 730 731 731 if (mLoadViewCells) 732 732 { 733 734 #ifdef USE_BIT_PVS 735 // HACK: for kd pvs, set pvs size to maximal number of kd nodes 736 vector<KdLeaf *> leaves; 737 preprocessor->mKdTree->CollectLeaves(leaves); 738 739 ObjectPvs::SetPvsSize((int)leaves.size()); 740 #endif 741 733 742 Environment::GetSingleton()->GetStringValue("ViewCells.filename", buf); 734 743 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
r2116 r2117 21 21 Optimization="0" 22 22 AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;Timer" 23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_ HASH_PVS"23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_BIT_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;USE_ HASH_PVS"74 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_BIT_PVS" 75 75 ExceptionHandling="TRUE" 76 76 RuntimeLibrary="2" … … 383 383 </File> 384 384 <File 385 RelativePath=".\BitVectorPvs.cpp"> 386 </File> 387 <File 385 388 RelativePath=".\BitVectorPvs.h"> 386 389 </File> … … 588 591 <File 589 592 RelativePath=".\ObjectPvs.h"> 593 </File> 594 <File 595 RelativePath=".\ObjectsParser.cpp"> 596 </File> 597 <File 598 RelativePath=".\ObjectsParser.h"> 590 599 </File> 591 600 <File -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r2116 r2117 29 29 } 30 30 31 const PvsEntry<T, S> &Next() 32 { 33 return *(mItCurrent ++); 31 T Next(S &pdf) 32 { 33 pdf = (*mItCurrent).mData; 34 return (*(mItCurrent ++)).mObject; 35 } 36 37 T Next() 38 { 39 return (*(mItCurrent ++)).mObject; 34 40 } 35 41 -
GTP/trunk/Lib/Vis/Preprocessing/src/PvsBase.h
r2116 r2117 19 19 public: 20 20 21 PvsEntry() {}22 21 PvsEntry(): mObject(NULL), mData(0) {} 22 PvsEntry(T sample): mObject(sample), mData(0) {} 23 23 PvsEntry(T sample, const S &data): mObject(sample), mData(data) {} 24 24 -
GTP/trunk/Lib/Vis/Preprocessing/src/PvsDefinitions.h
r2116 r2117 12 12 #include "HashPvs.h" 13 13 14 #define HASH_PVS 114 #define PVS_TYPE 0 15 15 16 16 namespace GtpVisibilityPreprocessor { … … 19 19 } 20 20 21 #else 21 #endif 22 23 #ifdef USE_VERBOSE_PVS 22 24 23 25 #include "Pvs.h" 24 26 25 #define HASH_PVS 027 #define PVS_TYPE 1 26 28 27 29 namespace GtpVisibilityPreprocessor { … … 29 31 typedef PvsIterator<Intersectable *, PvsData> ObjectPvsIterator; 30 32 } 33 #endif 34 35 36 #ifdef USE_BIT_PVS 37 38 #include "BitVectorPvs.h" 39 40 #define PVS_TYPE 2 41 42 namespace GtpVisibilityPreprocessor { 43 typedef BitVectorPvs<Intersectable *, PvsData> DefaultPvs; 44 typedef BitVectorPvsIterator<Intersectable *, PvsData> ObjectPvsIterator; 45 } 46 31 47 #endif 32 48 -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
r2116 r2117 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;USE_ HASH_PVS"23 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;NO_QT;USE_BIT_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;USE_ HASH_PVS"83 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;NO_QT;USE_BIT_PVS" 84 84 RuntimeLibrary="2" 85 85 EnableEnhancedInstructionSet="2" -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r2100 r2117 65 65 while (pit.HasMoreEntries()) 66 66 { 67 ObjectPvsEntry entry= pit.Next();68 69 if (! entry.mObject->Mailed())70 { 71 entry.mObject->Mail();67 Intersectable *obj = pit.Next(); 68 69 if (!obj->Mailed()) 70 { 71 obj->Mail(); 72 72 ++ count; 73 73 } … … 92 92 while (pit.HasMoreEntries()) 93 93 { 94 ObjectPvsEntry entry = pit.Next(); 95 entry.mObject->Mail(); 94 pit.Next()->Mail(); 96 95 } 97 96 … … 100 99 while (pit.HasMoreEntries()) 101 100 { 102 ObjectPvsEntry entry = pit.Next(); 103 104 Intersectable *obj = entry.mObject; 105 if (!obj->Mailed()) 101 if (!pit.Next()->Mailed()) 106 102 ++ pvs; 107 103 } … … 847 843 while (pit.HasMoreEntries()) 848 844 { 849 ObjectPvsEntry entry = pit.Next(); 850 851 Intersectable *obj = entry.mObject; 845 Intersectable *obj = pit.Next(); 852 846 853 847 obj->Mail(); … … 859 853 while (pit2.HasMoreEntries()) 860 854 { 861 ObjectPvsEntry entry = pit2.Next(); 862 Intersectable *obj = entry.mObject; 863 855 Intersectable *obj = pit2.Next(); 856 864 857 // test if object already considered 865 858 if (!obj->Mailed()) … … 1681 1674 while (pit.HasMoreEntries()) 1682 1675 { 1683 const ObjectPvsEntry &entry = pit.Next(); 1684 Intersectable *obj = entry.mObject; 1685 obj->Mail(); 1676 pit.Next()->Mail(); 1686 1677 } 1687 1678 } … … 1695 1686 while (pit.HasMoreEntries()) 1696 1687 { 1697 const ObjectPvsEntry &entry = pit.Next(); 1698 Intersectable *obj = entry.mObject; 1699 1700 obj->IncMail(); 1688 pit.Next()->IncMail(); 1701 1689 } 1702 1690 } … … 1705 1693 interior->GetPvs().Clear(false); 1706 1694 1695 PvsData pvsData; 1696 1707 1697 // only the objects which are present in all leaf pvs 1708 1698 // should remain in the parent pvs … … 1716 1706 while (pit.HasMoreEntries()) 1717 1707 { 1718 ObjectPvsEntry entry = pit.Next();1719 1720 if ( entry.mObject->Mailed(mail))1708 Intersectable *obj = pit.Next(pvsData); 1709 1710 if (obj->Mailed(mail)) 1721 1711 { 1722 interior->GetPvs().AddSample( entry.mObject, entry.mData.mSumPdf);1712 interior->GetPvs().AddSample(obj, pvsData.mSumPdf); 1723 1713 } 1724 1714 } … … 1733 1723 1734 1724 ObjectPvs newPvs; 1735 1725 1736 1726 while (pit.HasMoreEntries()) 1737 1727 { 1738 const ObjectPvsEntry &entry = pit.Next(); 1739 Intersectable *obj = entry.mObject; 1740 1741 /*if (obj->Mailed(mail)) 1742 { 1743 vc->GetPvs().RemoveSample(entry.mObject, Limits::Infinity)) 1744 }*/ 1728 Intersectable *obj = pit.Next(pvsData); 1729 1745 1730 if (!obj->Mailed(mail)) 1746 1731 { 1747 newPvs.AddSampleDirty(obj, entry.mData.mSumPdf);1732 newPvs.AddSampleDirty(obj, pvsData.mSumPdf); 1748 1733 } 1749 1734 } … … 1872 1857 while (oit.HasMoreEntries()) 1873 1858 { 1874 ObjectPvsEntry entry = oit.Next(); 1875 Intersectable *intersect = entry.mObject; 1859 Intersectable *intersect = oit.Next(); 1876 1860 1877 1861 if (!intersect->Mailed()) … … 2390 2374 while (it.HasMoreEntries()) 2391 2375 { 2392 ObjectPvsEntry entry = it.Next(); 2393 Intersectable *obj = entry.mObject; 2376 Intersectable *obj = it.Next(); 2394 2377 2395 2378 // hack: just output full pvs … … 2408 2391 else 2409 2392 { 2410 stream << entry.mObject->GetId() << " ";2393 stream << obj->GetId() << " "; 2411 2394 } 2412 2395 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r2116 r2117 283 283 return mPvsCost; 284 284 } 285 286 285 287 286 int GetFilteredPvsSize() const -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2116 r2117 681 681 if (mUseKdPvs) 682 682 { 683 KdNode *node = GetPreprocessor()->mKdTree->GetPvsNode(isTermination ?684 683 KdNode *node = GetPreprocessor()-> 684 mKdTree->GetPvsNode(isTermination ? ray.mTermination : ray.mOrigin); 685 685 return GetPreprocessor()->mKdTree->GetOrCreateKdIntersectable(node); 686 686 } … … 1278 1278 1279 1279 ViewCellContainer viewCells; 1280 1280 1281 cout << "objects size: " << ObjectPvsIterator::sObjects.size() << endl; 1282 cout << "pvs size: " << ObjectPvs::sPvsSize << endl; 1283 1281 1284 // $$ JB hack - the collect best viewcells does not work? 1282 1285 #if 0 … … 2612 2615 2613 2616 2614 void 2615 ViewCellsManager::SortViewCellPvs() 2616 { 2617 2618 ViewCellContainer::iterator it, it_end = mViewCells.end(); 2619 for (it = mViewCells.begin(); it != it_end; ++ it) { 2620 ObjectPvs &pvs = (*it)->GetPvs(); 2621 if (pvs.RequiresResortLog()) 2622 pvs.SimpleSort(); 2623 } 2624 } 2617 void ViewCellsManager::SortViewCellPvs() 2618 { 2619 ViewCellContainer::iterator it, it_end = mViewCells.end(); 2620 2621 for (it = mViewCells.begin(); it != it_end; ++ it) 2622 { 2623 ObjectPvs &pvs = (*it)->GetPvs(); 2624 if (pvs.RequiresResortLog()) 2625 pvs.SimpleSort(); 2626 } 2627 } 2628 2625 2629 2626 2630 void ViewCellsManager::ComputeViewCellContribution(ViewCell *viewCell, … … 2630 2634 const bool addSamplesToPvs) 2631 2635 { 2632 2633 2636 // check if we are outside of view space 2637 // $$JB tmp commented to speedup up computations 2634 2638 #if 0 2635 2636 return;2639 if (!obj || !viewCell->GetValid()) 2640 return; 2637 2641 #endif 2638 2639 2640 // if ray not outside of view space 2641 float relContribution = 0.0f; 2642 float absContribution = 0.0f; 2643 bool hasAbsContribution; 2644 2645 // todo: maybe not correct for kd node pvs 2646 if (addSamplesToPvs) { 2647 hasAbsContribution = viewCell->GetPvs().AddSampleDirtyCheck(obj, 2648 ray.mPdf); 2649 //hasAbsContribution = viewCell->GetPvs().AddSample(obj,ray.mPdf); 2650 } 2651 else { 2652 hasAbsContribution = viewCell->GetPvs().GetSampleContribution( 2653 obj, 2654 ray.mPdf, 2655 relContribution); 2656 } 2657 2658 // $$ clear the relative contribution as it is currently not correct anyway 2659 // relContribution = 0.0f; 2660 2661 if (hasAbsContribution) { 2662 ++ ray.mPvsContribution; 2663 absContribution = relContribution = 1.0f; 2664 if (viewCell->GetPvs().RequiresResort()) 2665 viewCell->GetPvs().SimpleSort(); 2642 2643 // if ray not outside of view space 2644 float relContribution = 0.0f; 2645 float absContribution = 0.0f; 2646 bool hasAbsContribution; 2647 2648 // todo: maybe not correct for kd node pvs 2649 if (addSamplesToPvs) 2650 { 2651 hasAbsContribution = viewCell->GetPvs(). 2652 AddSampleDirtyCheck(obj, ray.mPdf); 2653 //hasAbsContribution = viewCell->GetPvs().AddSample(obj,ray.mPdf); 2654 } 2655 else 2656 { 2657 hasAbsContribution = 2658 viewCell->GetPvs().GetSampleContribution(obj, 2659 ray.mPdf, 2660 relContribution); 2661 } 2662 2663 // $$ clear the relative contribution as it is currently not correct anyway 2664 // relContribution = 0.0f; 2665 2666 if (hasAbsContribution) 2667 { 2668 ++ ray.mPvsContribution; 2669 absContribution = relContribution = 1.0f; 2670 2671 if (viewCell->GetPvs().RequiresResort()) 2672 viewCell->GetPvs().SimpleSort(); 2666 2673 2667 2674 #if CONTRIBUTION_RELATIVE_TO_PVS_SIZE 2668 relContribution /= viewcell->GetPvs().GetSize();2675 relContribution /= viewcell->GetPvs().GetSize(); 2669 2676 #endif 2670 2677 2671 2678 #if DIST_WEIGHTED_CONTRIBUTION 2672 // recalculate the contribution - weight the 1.0f contribution by the sqr distance to the2673 // object-> a new contribution in the proximity of the viewcell has a larger weight!2674 relContribution /= SqrDistance(GetViewCellBox(viewcell).Center(),2675 2676 2679 // recalculate the contribution - weight the 1.0f contribution by the sqr distance to the 2680 // object-> a new contribution in the proximity of the viewcell has a larger weight! 2681 relContribution /= 2682 SqrDistance(GetViewCellBox(viewcell).Center(), ray.mTermination); 2683 2677 2684 #endif 2678 2685 } 2679 2686 2680 2687 #if SUM_RAY_CONTRIBUTIONS || AVG_RAY_CONTRIBUTIONS 2681 2688 ray.mRelativePvsContribution += relContribution; 2682 2689 #else 2683 2684 2685 ray.mRelativePvsContribution = relContribution;2690 // recalculate relative contribution - use max of Rel Contribution 2691 if (ray.mRelativePvsContribution < relContribution) 2692 ray.mRelativePvsContribution = relContribution; 2686 2693 #endif 2687 2694 } … … 3287 3294 while (pit.HasMoreEntries()) 3288 3295 { 3289 ObjectPvsEntry entry = pit.Next(); 3290 3291 Intersectable *object = entry.mObject; 3292 object->Mail(); 3296 pit.Next()->Mail(); 3293 3297 } 3294 3298 … … 3301 3305 { 3302 3306 // now go through the pvs again 3303 ObjectPvsEntry entry = pit2.Next(); 3304 Intersectable *object = entry.mObject; 3307 Intersectable *object = pit2.Next(); 3305 3308 3306 3309 // Vector3 center = object->GetBox().Center(); … … 3385 3388 while (pit.HasMoreEntries()) 3386 3389 { 3387 ObjectPvsEntry entry = pit.Next(); 3388 Intersectable *object = entry.mObject; 3389 object->Mail(); 3390 pit.Next()->Mail(); 3390 3391 } 3391 3392 } … … 3447 3448 ObjectContainer objects; 3448 3449 3450 PvsData pvsData; 3451 3449 3452 while (pit.HasMoreEntries()) { 3450 ObjectPvsEntry entry = pit.Next();3453 Intersectable *object = pit.Next(pvsData); 3451 3454 3452 Intersectable *object = entry.mObject;3453 3455 // compute filter size based on the distance and the numebr of samples 3454 3456 AxisAlignedBox3 box = object->GetBox(); … … 3457 3459 float globalRadius = distance*globalC; 3458 3460 3459 int objectSamples = (int) entry.mData.mSumPdf;3461 int objectSamples = (int)pvsData.mSumPdf; 3460 3462 float localRadius = MAX_FLOAT; 3461 3463 … … 3525 3527 if (!mUseKdPvs) 3526 3528 { 3529 PvsData pvsData; 3530 3527 3531 // copy the base pvs to the new pvs 3528 3532 pit = basePvs.GetIterator(); 3529 3533 while (pit.HasMoreEntries()) 3530 3534 { 3531 ObjectPvsEntry entry = pit.Next();3532 pvs.AddSampleDirty( entry.mObject, entry.mData.mSumPdf);3535 Intersectable *obj = pit.Next(pvsData); 3536 pvs.AddSampleDirty(obj, pvsData.mSumPdf); 3533 3537 } 3534 3538 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r2116 r2117 382 382 383 383 384 // resort pvss after a pass of the algorithm 385 void 386 SortViewCellPvs(); 387 388 // map the ray intersection objects from triangles to high level objects... 389 void 390 DeterminePvsObjects( 391 VssRayContainer &rays, 392 const bool useHitObjects = false); 384 // resort pvss after a pass of the algorithm 385 void SortViewCellPvs(); 386 387 // map the ray intersection objects from triangles to high level objects... 388 void DeterminePvsObjects(VssRayContainer &rays, 389 const bool useHitObjects = false); 393 390 394 391 /** Sets validity of view cell … … 404 401 405 402 406 /** set valid viewcells in the range of pvs. sorts the viewcells407 408 403 /** Set valid viewcells in the range of pvs. sorts the viewcells 404 according to the pvs and then pickups those in the ranges 405 */ 409 406 void SetValidityPercentage(const float minValid, const float maxValid); 410 407 … … 420 417 */ 421 418 int GetMinPvsSize() const; 419 422 420 /** Returns maximal ratio. i.e., currentPVs / maxPvs, 423 421 where pvs is still considered valid. 424 422 */ 425 423 float GetMaxPvsRatio() const; 424 426 425 /** Exports view cell geometry. 427 426 */ 428 virtual void ExportViewCellGeometry( 429 Exporter *exporter, 430 ViewCell *vc, 431 const AxisAlignedBox3 *box, 432 const AxisAlignedPlane *clipPlane = NULL 433 ) const = 0; 427 virtual void ExportViewCellGeometry(Exporter *exporter, 428 ViewCell *vc, 429 const AxisAlignedBox3 *box, 430 const AxisAlignedPlane *clipPlane = NULL 431 ) const = 0; 434 432 435 433 /** Brings the view cells into their final state, computes meshes and volume. … … 446 444 float &avgRenderCost); 447 445 448 449 446 /** Returns hierarchy of the view cells. 450 447 */ … … 488 485 /** Evaluautes histogram for a given number of view cells. 489 486 */ 490 void EvalViewCellHistogramForPvsSize(const string filename, const int nViewCells); 487 void EvalViewCellHistogramForPvsSize(const string filename, 488 const int nViewCells); 491 489 492 490 void EvalViewCellHistogramForPvsSize(const string filename, … … 500 498 of the hierarchy. 501 499 */ 502 void UpdateScalarPvsSize(ViewCell *vc, const float pvsCost, const int entriesInPvs) const; 500 void UpdateScalarPvsSize(ViewCell *vc, 501 const float pvsCost, 502 const int entriesInPvs) const; 503 503 504 504 /** Returns bounding box of a view cell. … … 508 508 /** Exports bounding boxes of objects to file. 509 509 */ 510 bool ExportBoundingBoxes(const string filename, const ObjectContainer &objects) const; 510 bool ExportBoundingBoxes(const string filename, 511 const ObjectContainer &objects) const; 511 512 512 513 /** Load the bounding boxes into the container. 513 514 */ 514 bool LoadBoundingBoxes(const string filename, IndexedBoundingBoxContainer &boxes) const; 515 bool LoadBoundingBoxes(const string filename, 516 IndexedBoundingBoxContainer &boxes) const; 515 517 516 518 /** Returns true if pvs should be exported together with the view cells. … … 523 525 const ViewCellContainer &viewCells) const; 524 526 527 /** Compress the view cells. 528 */ 525 529 virtual void CompressViewCells(); 526 530 … … 616 620 /** Returns the bounding box of filter width. 617 621 */ 618 AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, const float width) const; 622 AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, 623 const float width) const; 619 624 620 625 ////////////////////////////////////////////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r2116 r2117 218 218 } 219 219 220 221 if (HASH_PVS) 222 Debug << "using hash pvs" << endl; 223 else 224 Debug << "using verbose pvs" << endl; 220 Debug << "using pvs type " << PVS_TYPE << endl; 225 221 226 222 /////////////
Note: See TracChangeset
for help on using the changeset viewer.