Ignore:
Timestamp:
11/29/05 00:01:43 (19 years ago)
Author:
mattausch
Message:

added vview cell manager functionality

File:
1 edited

Legend:

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

    r438 r439  
    99#include "VssRay.h" 
    1010#include "VssTree.h" 
    11  
     11#include "ViewCellsManager.h" 
    1212 
    1313bool useViewSpaceBox = true;//true; 
     
    451451  } 
    452452         
    453   //-- construct BSP view cells 
    454   if (ViewCell::sHierarchy == ViewCell::BSP)  
    455   { 
    456           const int bspSamples = min((int)mVssRays.size(), mBspConstructionSamples); 
    457                  
    458           Debug << "bpssamples: " << bspSamples << endl; 
    459           for (int i = 0; i < bspSamples; ++ i) 
    460                   bspRays.push_back(new Ray(*mVssRays[i])); 
    461           
    462           //-- construct BSP tree using the samples 
    463           mBspTree = new BspTree(&mUnbounded);   
    464  
    465           ObjectContainer objects; 
    466           mSceneGraph->CollectObjects(&objects); 
    467           mBspTree->Construct(objects, bspRays); 
    468         } 
     453  ObjectContainer objects; 
     454  mSceneGraph->CollectObjects(&objects); 
     455 
     456  //mViewCellsManager->Construct(mVssRays, objects); 
    469457 
    470458  vssTree = new VssTree; 
     
    541529 
    542530        // cast rays into BSP tree 
    543         if (ViewCell::sHierarchy == ViewCell::BSP)  
     531        /*if (ViewCell::sHierarchy == ViewCell::BSP)  
    544532          { 
    545533                for (int i = 0; i < (int)vssRays.size(); ++ i) 
     
    548536                  } 
    549537          } 
    550  
     538*/ 
    551539        samples+=num; 
    552540        float pvs = vssTree->GetAvgPvsSize(); 
     
    562550  delete vssTree; 
    563551 
    564   if (ViewCell::sHierarchy == ViewCell::BSP)  
    565         { 
    566           Debug << mBspTree->GetStatistics(); 
    567  
    568           ObjectContainer objects; 
    569           ExportSplits(objects, bspRays, 10000); 
    570           ExportBspPvs(objects, bspRays, 10000); 
    571  
    572           BspViewCellsStatistics stat; 
    573           mBspTree->EvaluateViewCellsStats(stat); 
    574           Debug << "original view cell partition:\n" << stat << endl; 
    575  
    576           // clear BSP samples 
    577           CLEAR_CONTAINER(bspRays); 
    578         } 
    579  
    580552  return true; 
    581553} 
    582  
    583 void VssPreprocessor::CastRay(const BspTree &tree, const VssRay & vssRay) 
    584 { 
    585   //-- cast ray to BSP tree to get intersection with view cells 
    586   Ray ray(vssRay); 
    587   mBspTree->CastRay(ray); 
    588                                  
    589   //if (0 && ray.sourceObject.mObject) 
    590   //sampleContributions +=  
    591   //AddObjectSamples(ray.sourceObject.mObject, ray); 
    592                          
    593   if (!ray.intersections.empty()) // second intersection found 
    594   { 
    595           //sampleContributions +=  
    596           AddObjectSamples(ray.intersections[0].mObject, ray); 
    597   } 
    598 } 
    599  
    600 int VssPreprocessor::AddObjectSamples(Intersectable *obj, const Ray &ray) 
    601 { 
    602   int contributingSamples = 0; 
    603   int j; 
    604   
    605   // object can be seen from the view cell => add to view cell pvs 
    606   for (j=0; j < ray.bspIntersections.size(); ++ j) 
    607         {        
    608           BspLeaf *leaf = ray.bspIntersections[j].mLeaf; 
    609           // if ray not in unbounded space 
    610           if (leaf->GetViewCell() != &mUnbounded) 
    611                 contributingSamples +=  
    612                   leaf->GetViewCell()->GetPvs().AddSample(obj); 
    613         } 
    614   
    615   // rays passing through this viewcell 
    616   if (mPass > 1) 
    617         for (j=1; j < ((int)ray.bspIntersections.size() - 1); ++ j)  
    618           { 
    619                 BspLeaf *leaf = ray.bspIntersections[j].mLeaf; 
    620                  
    621                 if (leaf->GetViewCell() != &mUnbounded) 
    622                   leaf->GetViewCell()-> 
    623                         AddPassingRay(ray, contributingSamples ? 1 : 0); 
    624           } 
    625    
    626   return contributingSamples; 
    627 } 
Note: See TracChangeset for help on using the changeset viewer.