Ignore:
Timestamp:
12/05/05 13:47:58 (19 years ago)
Author:
mattausch
Message:

added viewcellsmanager to rsspreprocessor

File:
1 edited

Legend:

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

    r450 r451  
    99#include "VssRay.h" 
    1010#include "RssTree.h" 
    11 #include "ViewCellBsp.h" 
     11#include "ViewCellsManager.h" 
    1212 
    1313static bool useViewSpaceBox = true;//true; 
     
    378378  int totalSamples = 0; 
    379379 
     380  /// Rays used for post processing and visualizations. 
     381  RayContainer storedRays; 
    380382 
    381383  AxisAlignedBox3 *box = new AxisAlignedBox3(mKdTree->GetBox()); 
     
    407409  RssTree *rssTree = NULL; 
    408410 
    409   RayContainer bspRays; 
    410  
    411411  while (totalSamples < mInitialSamples) { 
    412412        int passContributingSamples = 0; 
     
    423423          Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 
    424424                         
    425           sampleContributions = CastRay(viewpoint, direction, mVssRays); 
     425          CastRay(viewpoint, direction, mVssRays); 
    426426                         
    427427                         
     
    473473        ExportPvs("rss-pvs-initial.x3d", rssTree); 
    474474  } 
    475    
     475 
     476  // construct view cells 
     477  mViewCellsManager->Construct(mObjects, mVssRays, mViewSpaceBox); 
     478 
    476479  rssTree = new RssTree; 
    477480  // viewcells = Construct(mVssRays); 
     
    550553        } 
    551554 
     555        //-- prepare traversal rays for view cell intersections 
     556        RayContainer passRays; 
     557 
     558        VssRayContainer::const_iterator it, it_end = vssRays.end(); 
     559         
     560        for (it = vssRays.begin(); it != it_end; ++ it) 
     561                passRays.push_back(new Ray(*(*it))); 
     562         
     563        int sampleContributions = 0; 
     564        int contributingSamples = 0; 
     565 
     566        /// compute view cell contribution of rays 
     567        mViewCellsManager->ComputeSampleContributions(passRays, 
     568                                                                                                  sampleContributions,  
     569                                                                                                  contributingSamples); 
     570         
     571        //-- save rays for post processing 
     572        if (((int)storedRays.size() < mViewCellsManager->GetPostProcessSamples()) || 
     573                ((int)storedRays.size() < mViewCellsManager->GetVisualizationSamples())) 
     574        { 
     575                RayContainer::const_iterator it, it_end = passRays.end(); 
     576 
     577                for (it = passRays.begin(); it != it_end; ++ it) 
     578                        storedRays.push_back(new Ray(*(*it))); 
     579        } 
     580        else 
     581        { 
     582                CLEAR_CONTAINER(passRays); 
     583        } 
     584 
    552585        samples+=num; 
    553586        float pvs = rssTree->GetAvgPvsSize(); 
     
    575608} 
    576609 
    577 void 
    578 RssPreprocessor::CastRay(const BspTree &tree, const VssRay & vssRay) 
    579 { 
    580   //-- cast ray to BSP tree to get intersection with view cells 
    581   Ray ray(vssRay); 
    582   mBspTree->CastRay(ray); 
    583                                  
    584   //if (0 && ray.sourceObject.mObject) 
    585   //sampleContributions +=  
    586   //AddObjectSamples(ray.sourceObject.mObject, ray); 
    587                          
    588   if (!ray.intersections.empty()) // second intersection found 
    589   { 
    590           //sampleContributions +=  
    591           AddObjectSamples(ray.intersections[0].mObject, ray); 
    592   } 
    593 } 
    594  
    595 int 
    596 RssPreprocessor::AddObjectSamples(Intersectable *obj, const Ray &ray) 
    597 { 
    598   int contributingSamples = 0; 
    599   int j; 
    600   
    601   // object can be seen from the view cell => add to view cell pvs 
    602   for (j=0; j < ray.bspIntersections.size(); ++ j) 
    603         {        
    604           BspLeaf *leaf = ray.bspIntersections[j].mLeaf; 
    605           // if ray not in unbounded space 
    606 /*        if (leaf->GetViewCell() != &mUnbounded) 
    607                 contributingSamples +=  
    608                   leaf->GetViewCell()->GetPvs().AddSample(obj);*/ 
    609         } 
    610   
    611   // rays passing through this viewcell 
    612   if (mPass > 1) 
    613         for (j=1; j < ((int)ray.bspIntersections.size() - 1); ++ j)  
    614           { 
    615                 BspLeaf *leaf = ray.bspIntersections[j].mLeaf; 
    616                  
    617         /*      if (leaf->GetViewCell() != &mUnbounded) 
    618                   leaf->GetViewCell()-> 
    619                         AddPassingRay(ray, contributingSamples ? 1 : 0);*/ 
    620           } 
    621    
    622   return contributingSamples; 
    623 } 
Note: See TracChangeset for help on using the changeset viewer.