Changeset 569


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

viewcell validy setting functions extended

Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
9 edited

Legend:

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

    r563 r569  
    202202                                                        0.0f); 
    203203   
    204   //  viewcells->GetViewPoint(mViewPoint); 
    205  
    206   mViewPoint =  mSceneGraph->GetBox().GetPoint(pVector); 
     204  mViewCellsManager->GetViewPoint(mViewPoint); 
     205 
     206  // mViewPoint =  mSceneGraph->GetBox().GetPoint(pVector); 
    207207   
    208208  mViewDirection = Normalize(Vector3(sin(dVector.x), 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Makefile

    r563 r569  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.0) on: ?t 19. I 16:46:41 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.0) on: po 23. I 11:09:15 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp

    r567 r569  
    489489          "#TotalSamples\n" <<totalSamples<<endl<< 
    490490          "#RssSamples\n" <<rssSamples<<endl; 
    491          
    492  
     491 
     492        { 
     493          VssRayContainer contributingRays; 
     494          mVssRays.GetContributingRays(contributingRays, mPass); 
     495          mStats<<"#NUM_CONTRIBUTING_RAYS\n"<<(int)contributingRays.size()<<endl; 
     496        } 
     497         
    493498        mVssRays.PrintStatistics(mStats); 
    494499        mViewCellsManager->PrintPvsStatistics(mStats); 
     
    543548   
    544549  // viewcells->UpdatePVS(newVssRays); 
    545    
    546  
     550  Debug<<"Valid viewcells before set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
     551  // cull viewcells with PVS > median (0.5f) 
     552  mViewCellsManager->SetValidityPercentage(0, 0.5f);  
     553  Debug<<"Valid viewcells after set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
     554   
    547555  while (1) { 
    548556        SimpleRayContainer rays; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.cpp

    r567 r569  
    336336          GetRoot(objects[i])->bbox = objects[i]->GetBox(); 
    337337        } 
    338  
    339338        stat.nodes = i; 
     339        stat.leaves = i; 
    340340  } else { 
    341341        mRoots.resize(1); 
     
    347347        mRoots[0] = leaf; 
    348348        stat.nodes = 1; 
     349        stat.leaves = 1; 
    349350  } 
    350351 
     
    356357           
    357358          // first construct a leaf that will get subdivide 
    358           RssTreeLeaf *leaf = (RssTreeLeaf *) GetRoot(info.GetObject()); 
     359          RssTreeLeaf *leaf = (RssTreeLeaf *) GetRoot(info.GetSourceObject()); 
    359360 
    360361          leaf->AddRay(info); 
     
    10941095   
    10951096  stat.nodes+=2; 
     1097  stat.leaves += 1; 
    10961098  stat.splits[axis]++; 
    10971099 
     
    14101412  stack<RayTraversalData> tstack; 
    14111413 
    1412   RssTreeNode *root = GetRoot(info.GetObject()); 
     1414  RssTreeNode *root = GetRoot(info.GetSourceObject()); 
    14131415  tstack.push(RayTraversalData(root, info)); 
    14141416   
     
    15501552 
    15511553  stat.nodes -= collapsedNodes - 1; 
     1554  stat.leaves -= collapsedNodes/2 - 1; 
    15521555  stat.rayRefs -= totalRayCount - rayCount; 
    15531556   
     
    27712774{ 
    27722775  if (mPerObjectTree && object) { 
    2773         int id = object->GetId(); 
    2774         if (id >= mRoots.size()) 
     2776        int id = object->GetId()-1; 
     2777        if (id < 0 || id >= mRoots.size()) { 
     2778          Debug<<"Error: object Id out of range, Id="<<id<<" roots.size()="<<mRoots.size()<< 
     2779                endl<<flush; 
    27752780          id = mRoots.size()-1; // $$ last tree is used by all unsigned objects 
     2781        } 
    27762782        return mRoots[id]; 
    27772783  } else 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.h

    r516 r569  
    4242  // total number of nodes 
    4343  int nodes; 
     44  // number of leaves 
     45  int leaves; 
    4446  // number of splits along each of the axes 
    4547  int splits[7]; 
     
    9092  int Nodes() const {return nodes;} 
    9193  int Interior() const { return nodes/2; } 
    92   int Leaves() const { return (nodes/2) + 1; } 
     94  int Leaves() const { return Nodes() - Interior(); } 
    9395 
    9496  void Reset() { 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h

    r564 r569  
    137137        bool GetValid() const; 
    138138 
     139  static bool SmallerPvs(const ViewCell *a, 
     140                                                 const ViewCell *b) { 
     141        return a->GetPvs().GetSize() < b->GetPvs().GetSize(); 
     142  } 
     143 
    139144protected: 
    140145 
  • 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) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r564 r569  
    182182 
    183183        /** Get a viewcell containing the specified point */ 
    184         virtual ViewCell *GetViewCell(const Vector3 &point) = 0; 
     184        virtual ViewCell *GetViewCell(const Vector3 &point) const = 0; 
    185185   
    186186        virtual void PrintPvsStatistics(ostream &s); 
     
    267267                                                         int maxPvsSize) const; 
    268268 
     269  /** sets validy of all viewcells */ 
     270        virtual void SetValidity( 
     271                                                         int minPvsSize,  
     272                                                         int maxPvsSize) const; 
     273 
     274  /** set valid viewcells in the range of pvs. sorts the viewcells 
     275          according to the pvs and then pickups those in the ranges */ 
     276   
     277  void 
     278  SetValidityPercentage( 
     279                                                const float minValid, 
     280                                                const float maxValid 
     281                                                ); 
     282 
     283  int 
     284  CountValidViewcells() const; 
     285 
    269286        /** Returns maximal allowed pvs size. 
    270287        */ 
     
    417434 
    418435        /** Get a viewcell containing the specified point */ 
    419         ViewCell *GetViewCell(const Vector3 &point); 
     436        ViewCell *GetViewCell(const Vector3 &point) const; 
    420437 
    421438        void CreateMesh(ViewCell *vc); 
     
    482499        */ 
    483500        //  virtual void PrintStatistics(ostream &s) const; 
    484         ViewCell *GetViewCell(const Vector3 &point) { return NULL; } 
     501        ViewCell *GetViewCell(const Vector3 &point) const { return NULL; } 
    485502 
    486503        float GetProbability(ViewCell *viewCell); 
     
    540557                                                ViewCellContainer &viewcells); 
    541558 
    542         ViewCell *GetViewCell(const Vector3 &point) { return NULL; } 
     559        ViewCell *GetViewCell(const Vector3 &point) const { return NULL; } 
    543560 
    544561        float GetProbability(ViewCell *viewCell); 
     
    600617        float GetRendercost(ViewCell *viewCell, float objRendercost) const; 
    601618         
    602         ViewCell *GetViewCell(const Vector3 &point); 
     619        ViewCell *GetViewCell(const Vector3 &point) const; 
    603620 
    604621        bool GetViewPoint(Vector3 &viewPoint) const; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/default.env

    r567 r569  
    1313#;../data/vienna/vienna-plane.x3d 
    1414# filename ../data/vienna/viewcells-25-sel.x3d 
    15 # filename ../data/atlanta/atlanta2.x3d 
     15filename ../data/atlanta/atlanta2.x3d 
    1616#filename ../data/soda/soda.dat 
    17 filename ../data/soda/soda5.dat 
     17# filename ../data/soda/soda5.dat 
    1818} 
    1919 
     
    2525#       type vss 
    2626        type rss 
    27         detectEmptyViewSpace true 
     27        detectEmptyViewSpace false 
    2828        pvsRenderErrorSamples 10000 
    2929 
     
    9797RssTree { 
    9898        epsilon         1e-6 
    99         perObjectTree true 
     99        perObjectTree false 
    100100 
    101101        maxDepth        40 
     
    200200        } 
    201201         
    202         filename ../data/soda/viewcells_soda5-2.xml 
    203 #       filename ../data/atlanta/viewcells_atlanta2.xml 
     202#       filename ../data/soda/viewcells_soda5-2.xml 
     203        filename ../data/atlanta/viewcells_atlanta2.xml 
    204204#       filename ../data/atlanta/atlanta_viewcells_large.x3d 
    205205#       filename ../data/vienna/viewcells-25-sel.x3d 
Note: See TracChangeset for help on using the changeset viewer.