- Timestamp:
- 01/23/06 15:58:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r568 r569 124 124 int maxPvsSize) const 125 125 { 126 if ((vc->GetPvs().GetSize() > mMaxPvsSize) || 127 (vc->GetPvs().GetSize() < mMinPvsSize)) 128 { 129 return false; 130 } 131 132 return true; 126 127 if ((vc->GetPvs().GetSize() > maxPvsSize) || 128 (vc->GetPvs().GetSize() < minPvsSize)) 129 { 130 return false; 131 } 132 133 return true; 133 134 } 134 135 … … 141 142 } 142 143 144 void 145 ViewCellsManager::SetValidity( 146 int minPvsSize, 147 int maxPvsSize) const 148 { 149 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 150 151 for (it = mViewCells.begin(); it != it_end; ++ it) { 152 SetValidity(*it, minPvsSize, maxPvsSize); 153 } 154 } 155 156 void 157 ViewCellsManager::SetValidityPercentage( 158 const float minValid, 159 const float maxValid 160 ) 161 { 162 sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 163 164 int start = mViewCells.size()*minValid; 165 int end = mViewCells.size()*maxValid; 166 167 for (int i=0; i < mViewCells.size(); i++) 168 mViewCells[i]->SetValid(i >= start && i <= end); 169 } 170 171 int 172 ViewCellsManager::CountValidViewcells() const 173 { 174 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 175 int valid = 0; 176 for (it = mViewCells.begin(); it != it_end; ++ it) { 177 if ((*it)->GetValid()) 178 valid++; 179 } 180 return valid; 181 } 143 182 144 183 bool ViewCellsManager::LoadViewCells(const string filename, ObjectContainer *objects) … … 171 210 bool ViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 172 211 { 212 if (!ViewCellsConstructed()) 173 213 return mViewSpaceBox.IsInside(viewPoint); 214 else { 215 if (!mViewSpaceBox.IsInside(viewPoint)) 216 return false; 217 ViewCell *viewcell = GetViewCell(viewPoint); 218 if (!viewcell || !viewcell->GetValid()) 219 return false; 220 } 221 return true; 174 222 } 175 223 … … 487 535 for (it = viewcells->begin(); it != viewcells->end(); ++it) { 488 536 ViewCell *viewcell = *it; 489 // if ray not outside of view space 490 viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 537 if (viewcell->GetValid()) { 538 // if ray not outside of view space 539 viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 540 } 491 541 } 492 542 } … … 526 576 if (storeViewcells) 527 577 { 528 529 530 578 ray.mViewCells.reserve(viewcells.size()); 579 ray.mViewCells = viewcells; 580 } 531 581 532 582 ViewCellContainer::const_iterator it = viewcells.begin(); … … 535 585 for (; it != viewcells.end(); ++it) { 536 586 ViewCell *viewcell = *it; 537 // if ray not outside of view space 538 float contribution; 539 if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 540 ray.mPdf, 541 contribution 542 )) 543 ray.mPvsContribution++; 544 ray.mRelativePvsContribution += contribution; 587 if (viewcell->GetValid()) { 588 // if ray not outside of view space 589 float contribution; 590 if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 591 ray.mPdf, 592 contribution 593 )) 594 ray.mPvsContribution++; 595 ray.mRelativePvsContribution += contribution; 596 } 545 597 } 546 598 … … 548 600 for (it = viewcells.begin(); it != viewcells.end(); ++it) { 549 601 ViewCell *viewcell = *it; 550 // if ray not outside of view space 551 viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 552 } 553 602 if (viewcell->GetValid()) { 603 // if ray not outside of view space 604 viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 605 } 606 } 607 554 608 return ray.mRelativePvsContribution; 555 609 } … … 1179 1233 1180 1234 1181 ViewCell *BspViewCellsManager::GetViewCell(const Vector3 &point) 1235 ViewCell *BspViewCellsManager::GetViewCell(const Vector3 &point) const 1182 1236 { 1183 1237 if (!mBspTree) … … 1880 1934 } 1881 1935 1936 1937 1882 1938 int VspBspViewCellsManager::Construct(const ObjectContainer &objects, 1883 1939 const VssRayContainer &rays) … … 2209 2265 bool VspBspViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 2210 2266 { 2211 return mViewSpaceBox.IsInside(viewPoint) && 2212 mVspBspTree->ViewPointValid(viewPoint); 2267 // $$JB -> implemented in viewcellsmanager (slower, but allows dynamic 2268 // validy update in preprocessor for all managers) 2269 return ViewCellsManager::ViewPointValid(viewPoint); 2270 2271 // return mViewSpaceBox.IsInside(viewPoint) && 2272 // mVspBspTree->ViewPointValid(viewPoint); 2213 2273 } 2214 2274 … … 2518 2578 2519 2579 2520 ViewCell *VspBspViewCellsManager::GetViewCell(const Vector3 &point) 2580 ViewCell *VspBspViewCellsManager::GetViewCell(const Vector3 &point) const 2521 2581 { 2522 2582 if (!mVspBspTree)
Note: See TracChangeset
for help on using the changeset viewer.