Changeset 581 for trunk/VUT/GtpVisibilityPreprocessor/src
- Timestamp:
- 02/02/06 10:03:10 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r580 r581 1206 1206 "bspTree"); 1207 1207 1208 RegisterOption("ViewCells.active", 1209 optInt, 1210 "1000"); 1211 1208 1212 RegisterOption("ViewCells.Construction.samples", 1209 1213 optInt, -
trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h
r573 r581 112 112 }; 113 113 114 114 115 template <typename T> 115 116 int Pvs<T>::Diff(const Pvs<T> &b) … … 134 135 135 136 mEntries = a.mEntries; 136 // todo: copy all elements instead of inserting137 //for (it = a.mEntries.begin(); it != a.mEntries.end(); ++ it)138 // mEntries.insert(*it);139 137 140 138 for (it = b.mEntries.begin(); it != b.mEntries.end(); ++ it) -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp
r580 r581 22 22 bool operator() (T v1, T v2) const 23 23 { 24 return (v1->GetTimeStamp() >v2->GetTimeStamp());24 return (v1->GetTimeStamp() < v2->GetTimeStamp()); 25 25 } 26 26 }; … … 220 220 221 221 222 222 223 /************************************************************************/ 223 224 /* class ViewCellInterior implementation */ … … 471 472 //-- use priority queue to merge leaf pairs 472 473 473 while (!mMergeQueue.empty() && (realNumViewCells > mMergeMinViewCells) && 474 (mMergeQueue.top().GetRenderCost() < mMergeMaxCostRatio * totalCost)) 474 while (!mMergeQueue.empty() && (realNumViewCells > mMergeMinViewCells)) 475 475 { 476 476 //-- reset merge queue if the ratio of current expected cost / real expected cost 477 477 // too small or after a given number of merges 478 if(0)479 478 if ((mergedPerPass > maxMergesPerPass) || 480 479 (avgCostMaxDeviation > mAvgRenderCost / realAvgRenderCost)) … … 611 610 if ((int)viewCells.size() > 1) 612 611 { 612 Debug << "here888" << endl; 613 613 ViewCellInterior *root = new ViewCellInterior(); 614 615 root->SetTimeStamp(mergeStats.merged + 1); 614 616 615 617 ViewCellContainer::const_iterator it, it_end = viewCells.end(); … … 621 623 else if ((int)viewCells.size() == 1) 622 624 { 625 Debug << "here555" << endl; 623 626 mRoot = viewCells[0]; 624 627 } 625 628 629 // TODO delete because makes no sense here 626 630 mergeStats.expectedRenderCost = realExpectedCost; 627 631 mergeStats.deviation = mDeviation; … … 640 644 //TODO: should return sample contributions? 641 645 return mergeStats.merged; 646 } 647 648 649 ViewCell *ViewCellsTree::GetRoot() 650 { 651 return mRoot; 642 652 } 643 653 … … 1217 1227 { 1218 1228 stack<ViewCell *> tstack; 1219 1220 1221 } 1222 1223 1224 void ViewCellsTree::CollectBestViewCellSet(ViewCellContainer &viewCells, const int numViewCells) 1229 1230 while (!tstack.empty()) 1231 { 1232 ViewCell *viewCell = tstack.top(); 1233 tstack.pop(); 1234 1235 if (viewCell->IsLeaf()) 1236 { 1237 1238 } 1239 else 1240 { 1241 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(viewCell); 1242 ComputeCommonPvs(interior); 1243 } 1244 } 1245 } 1246 1247 1248 void ViewCellsTree::CollectBestViewCellSet(ViewCellContainer &viewCells, 1249 const int numViewCells) 1225 1250 { 1226 1251 TraversalQueue tqueue; 1227 1252 tqueue.push(mRoot); 1253 Debug << "here34 " << numViewCells << endl; 1228 1254 while (!tqueue.empty()) 1229 1255 { 1230 1256 ViewCell *vc = tqueue.top(); 1231 1232 1257 tqueue.pop(); 1258 Debug << "here7 " << vc->GetTimeStamp() << endl; 1259 if (vc->IsLeaf()) 1260 { 1261 Debug << "here6" << endl; 1262 viewCells.push_back(vc); 1263 } 1264 else if (viewCells.size() + tqueue.size() < numViewCells) 1265 { Debug << "here4" << endl; 1266 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1267 1268 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1269 1270 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1271 { 1272 tqueue.push(*it); 1273 } 1274 } 1275 } 1276 } 1277 1278 1279 void ViewCellsTree::ComputeCommonPvs(ViewCellInterior *interior) 1280 { 1281 Intersectable::NewMail(); 1282 1283 ViewCellContainer::const_iterator cit, cit_end = interior->mChildren.end(); 1284 1285 ObjectPvsMap::const_iterator oit; 1286 1287 // mail all objects in the leaf sets 1288 for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 1289 { 1290 ViewCell *vc = *cit; 1291 1292 ObjectPvsMap::const_iterator oit_end = vc->GetPvs().mEntries.end(); 1293 1294 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1295 { 1296 if (!(*oit).first->Mailed()) 1297 (*oit).first->Mail(); 1298 1299 (*oit).first->IncMail(); 1300 } 1301 } 1302 1303 interior->GetPvs().mEntries.clear(); 1304 cit_end = interior->mChildren.end(); 1305 1306 // only the objects which are present in all leaf pvs 1307 // should remain in the parent pvs 1308 1309 for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 1310 { 1311 ViewCell *vc = *cit; 1312 1313 ObjectPvsMap::const_iterator oit_end = vc->GetPvs().mEntries.end(); 1314 1315 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1316 { 1317 if ((*oit).first->Mailed((int)interior->mChildren.size())) 1318 { 1319 interior->GetPvs().AddSample((*oit).first, (*oit).second.mSumPdf); 1320 //(*oit)->remove(); 1321 } 1322 } 1323 } 1324 1325 // delete all the objects from the leaf sets which were moved 1326 // to parent pvs 1327 ObjectPvsMap::const_iterator oit_end = interior->GetPvs().mEntries.end(); 1328 1329 for (oit = interior->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1330 { 1331 for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 1332 { 1333 (*cit)->GetPvs().RemoveSample((*oit).first, Limits::Infinity); 1334 } 1233 1335 } 1234 1336 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h
r580 r581 293 293 void CollectBestViewCellSet(ViewCellContainer &viewCells, const int numViewCells); 294 294 295 /** Root of view cells tree. 296 */ 297 ViewCell *GetRoot(); 298 295 299 protected: 296 300 … … 350 354 const int numNewViewCells); 351 355 352 353 354 356 /** merge queue must be reset after some time because expected value 355 357 may not be valid. … … 360 362 */ 361 363 int UpdateMergedViewCells(ViewCellContainer &viewCells); 364 365 void ComputeCommonPvs(ViewCellInterior *interior); 362 366 363 367 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r580 r581 53 53 54 54 environment->GetIntValue("ViewCells.Construction.samplesPerPass", mSamplesPerPass); 55 56 55 environment->GetBoolValue("ViewCells.exportToFile", mExportViewCells); 57 58 56 environment->GetBoolValue("ViewCells.PostProcess.useRaysForMerge", mUseRaysForMerge); 57 58 environment->GetIntValue("ViewCells.active", mNumActiveViewCells); 59 59 60 60 mMinPvsSize = emptyViewCells ? 1 : 0; … … 234 234 235 235 return true; 236 } 237 238 239 bool ViewCellsManager::ViewCellsTreeConstructed() const 240 { 241 return mViewCellsTree->GetRoot(); 236 242 } 237 243 … … 684 690 } 685 691 692 686 693 int ViewCellsManager::GetMinPvsSize() const 687 694 { … … 2066 2073 void VspBspViewCellsManager::CollectViewCells() 2067 2074 { 2068 mVspBspTree->CollectViewCells(mViewCells, true); 2075 // view cells tree constructed 2076 if (!ViewCellsTreeConstructed()) 2077 { 2078 mVspBspTree->CollectViewCells(mViewCells, true); 2079 } 2080 else 2081 { 2082 // we can use the view cells tree hierarchy to get the right set 2083 mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumActiveViewCells); 2084 } 2085 2069 2086 } 2070 2087 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r580 r581 339 339 ViewCellsTree *GetViewCellsTree(); 340 340 341 virtual void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates) = 0; 342 341 virtual void CollectMergeCandidates(const VssRayContainer &rays, 342 vector<MergeCandidate> &candidates) = 0; 343 344 343 345 344 346 protected: 347 348 /** 349 if the view cells tree was already constructed or not. 350 */ 351 bool ViewCellsTreeConstructed() const; 345 352 346 353 int CastPassSamples(const int samplesPerPass, … … 421 428 int mMinPvsSize; 422 429 float mMaxPvsRatio; 430 431 int mNumActiveViewCells; 423 432 424 433 ViewCellsStatistics mViewCellsStats;
Note: See TracChangeset
for help on using the changeset viewer.