Ignore:
Timestamp:
01/23/06 15:58:00 (18 years ago)
Author:
bittner
Message:

viewcell validy setting functions extended

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r568 r569  
    124124                                                                         int maxPvsSize) const 
    125125{ 
    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; 
    133134} 
    134135 
     
    141142} 
    142143 
     144void 
     145ViewCellsManager::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 
     156void 
     157ViewCellsManager::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 
     171int 
     172ViewCellsManager::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} 
    143182 
    144183bool ViewCellsManager::LoadViewCells(const string filename, ObjectContainer *objects) 
     
    171210bool ViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 
    172211{ 
     212  if (!ViewCellsConstructed()) 
    173213        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; 
    174222} 
    175223 
     
    487535  for (it = viewcells->begin(); it != viewcells->end(); ++it) { 
    488536        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        } 
    491541  } 
    492542} 
     
    526576  if (storeViewcells) 
    527577  { 
    528           ray.mViewCells.reserve(viewcells.size()); 
    529           ray.mViewCells = viewcells; 
    530           } 
     578        ray.mViewCells.reserve(viewcells.size()); 
     579        ray.mViewCells = viewcells; 
     580  } 
    531581 
    532582  ViewCellContainer::const_iterator it = viewcells.begin(); 
     
    535585  for (; it != viewcells.end(); ++it) { 
    536586        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        } 
    545597  } 
    546598 
     
    548600        for (it = viewcells.begin(); it != viewcells.end(); ++it) { 
    549601          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   
    554608  return ray.mRelativePvsContribution; 
    555609} 
     
    11791233 
    11801234 
    1181 ViewCell *BspViewCellsManager::GetViewCell(const Vector3 &point) 
     1235ViewCell *BspViewCellsManager::GetViewCell(const Vector3 &point) const 
    11821236{ 
    11831237  if (!mBspTree) 
     
    18801934} 
    18811935 
     1936 
     1937 
    18821938int VspBspViewCellsManager::Construct(const ObjectContainer &objects, 
    18831939                                                                          const VssRayContainer &rays) 
     
    22092265bool VspBspViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 
    22102266{ 
    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); 
    22132273} 
    22142274 
     
    25182578 
    25192579 
    2520 ViewCell *VspBspViewCellsManager::GetViewCell(const Vector3 &point) 
     2580ViewCell *VspBspViewCellsManager::GetViewCell(const Vector3 &point) const 
    25212581{ 
    25222582        if (!mVspBspTree) 
Note: See TracChangeset for help on using the changeset viewer.