Ignore:
Timestamp:
01/23/06 18:34:47 (18 years ago)
Author:
mattausch
Message:

construction method for view cells

File:
1 edited

Legend:

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

    r569 r570  
    8888 
    8989 
    90 int ViewCellsManager::Construct(VssRayContainer &rays) 
    91 { 
    92 /*      VssPreprocessor preprocessor; 
    93  
    94         VssRayContainer vssRays; 
    95         preprocessor->GenerateVssRays(mConstructionSamples, vssRays); 
    96         Construct(preprocessor->mObjects, vssRays); 
    97  
    98         // add rays to output rays 
    99         while (!vssRays.empty) 
    100         { 
    101                 rays.push_back(vssRays.back()); 
    102                 vssRays.pop_back(); 
    103         } 
    104  
    105         const int importanceRays = 1000000; 
    106         preprocessor->GenerateVssRays(max(importanceRays, mPostProcessSamples); 
    107  
    108         PostProcess(preprocesor->mObjects, importanceRays); 
     90int ViewCellsManager::Construct(Preprocessor *preprocessor, VssRayContainer *outRays) 
     91{ 
     92        SimpleRayContainer simpleRays; 
     93        VssRayContainer constructionRays; 
     94 
     95        preprocessor->GenerateRays(mConstructionSamples, 
     96                                                           Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION, 
     97                                                           simpleRays); 
     98 
     99        Construct(preprocessor->mObjects, constructionRays); 
     100 
     101        int numRays = (int)simpleRays.size(); 
     102 
     103        static Ray traversalRay; 
     104 
     105        // shoot simple ray and add it to construction rays 
     106        while (!simpleRays.empty()) 
     107        { 
     108                SimpleRay sray = simpleRays.back(); 
     109 
     110                // TODO: shoot into kdtree 
     111                constructionRays.push_back(new VssRay(traversalRay)); 
     112 
     113                if (outRays) 
     114                        outRays->push_back(constructionRays.back()); 
     115 
     116                simpleRays.pop_back(); 
     117        } 
     118 
     119        if (!outRays) 
     120                CLEAR_CONTAINER(constructionRays); 
     121 
     122        // guided rays 
     123        VssRayContainer importanceRays; 
     124        const int desiredImportanceRays = max(1000000, mPostProcessSamples); 
     125        preprocessor->GenerateRays(desiredImportanceRays, 
     126                                                           Preprocessor::RSS_BASED_DISTRIBUTION, 
     127                                                           simpleRays); 
     128 
     129        numRays += (int)simpleRays.size(); 
     130 
     131        // shoot simple ray and add it to construction rays 
     132        while (!simpleRays.empty()) 
     133        { 
     134                SimpleRay sray = simpleRays.back(); 
     135 
     136                // TODO: shoot into kdtree 
     137                importanceRays.push_back(new VssRay(traversalRay)); 
     138 
     139                if (outRays) 
     140                        outRays->push_back(importanceRays.back()); 
     141 
     142                simpleRays.pop_back(); 
     143        } 
     144 
     145        if (!outRays) 
     146                CLEAR_CONTAINER(importanceRays); 
     147 
     148        // merge the view cells 
     149        PostProcess(preprocessor->mObjects, importanceRays); 
     150 
    109151        Visualize(preprocessor->mObjects, importanceRays); 
    110152 
    111         // add rays to output rays 
    112         while (!importanceRays.empty) 
    113         { 
    114                 rays.push_back(importanceRays.back()); 
    115                 importanceRays.pop_back(); 
    116         } 
    117 */ 
    118         return (int)rays.size(); 
     153 
     154        return numRays; 
    119155} 
    120156 
     
    130166          return false; 
    131167        } 
    132    
     168 
    133169  return true; 
    134170} 
     
    144180void 
    145181ViewCellsManager::SetValidity( 
    146                                                           int minPvsSize,  
     182                                                          int minPvsSize, 
    147183                                                          int maxPvsSize) const 
    148184{ 
    149185  ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
    150    
     186 
    151187  for (it = mViewCells.begin(); it != it_end; ++ it) { 
    152188        SetValidity(*it, minPvsSize, maxPvsSize); 
     
    161197{ 
    162198  sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 
    163    
     199 
    164200  int start = mViewCells.size()*minValid; 
    165201  int end = mViewCells.size()*maxValid; 
    166    
     202 
    167203  for (int i=0; i < mViewCells.size(); i++) 
    168204        mViewCells[i]->SetValid(i >= start && i <= end); 
     
    542578} 
    543579 
    544 float 
    545 ViewCellsManager::ComputeSampleContributions(VssRay &ray, 
    546                                                                                          const bool addRays 
    547                                                                                          ) 
    548 { 
    549   ViewCellContainer viewcells; 
    550  
    551   ray.mPvsContribution = 0; 
    552   ray.mRelativePvsContribution = 0.0f; 
    553  
    554  static Ray hray; 
     580float ViewCellsManager::ComputeSampleContributions(VssRay &ray, 
     581                                                                                                   const bool addRays) 
     582{ 
     583        ViewCellContainer viewcells; 
     584 
     585        ray.mPvsContribution = 0; 
     586        ray.mRelativePvsContribution = 0.0f; 
     587 
     588        static Ray hray; 
    555589        hray.Init(ray); 
    556590        //hray.mFlags |= Ray::CULL_BACKFACES; 
     
    567601        CastLineSegment(origin, termination, viewcells); 
    568602        //Debug << "constribution: " << (int)viewcells.size() << endl; 
    569         CastLineSegment(origin, termination, viewcells); 
    570  
    571   //Debug << "constribution: " << (int)viewcells.size() << endl; 
    572  
    573   // copy viewcells memory efficiently 
    574   const bool storeViewcells = !addRays; 
    575  
    576   if (storeViewcells) 
    577   { 
    578         ray.mViewCells.reserve(viewcells.size()); 
    579         ray.mViewCells = viewcells; 
    580   } 
    581  
    582   ViewCellContainer::const_iterator it = viewcells.begin(); 
     603 
     604        // copy viewcells memory efficiently 
     605        const bool storeViewcells = !addRays; 
     606 
     607        if (storeViewcells) 
     608        { 
     609                ray.mViewCells.reserve(viewcells.size()); 
     610                ray.mViewCells = viewcells; 
     611        } 
     612 
     613        ViewCellContainer::const_iterator it = viewcells.begin(); 
    583614 
    584615 
     
    605636          } 
    606637        } 
    607    
    608   return ray.mRelativePvsContribution; 
     638 
     639        return ray.mRelativePvsContribution; 
    609640} 
    610641 
     
    15681599} 
    15691600 
     1601 
    15701602int VspKdViewCellsManager::Construct(const ObjectContainer &objects, 
    15711603                                                                         const VssRayContainer &rays) 
     
    19341966} 
    19351967 
    1936  
    1937  
     1968<<<<<<< .mine 
     1969 
     1970======= 
     1971 
     1972 
     1973>>>>>>> .r569 
    19381974int VspBspViewCellsManager::Construct(const ObjectContainer &objects, 
    19391975                                                                          const VssRayContainer &rays) 
     
    22682304  // validy update in preprocessor for all managers) 
    22692305  return ViewCellsManager::ViewPointValid(viewPoint); 
    2270    
     2306 
    22712307  //    return mViewSpaceBox.IsInside(viewPoint) && 
    22722308  //               mVspBspTree->ViewPointValid(viewPoint); 
     
    25082544                        importance = (float)vc->GetPvs().GetSize() / 
    25092545                                (float)mViewCellsStats.maxPvs; 
     2546 
    25102547                } 
    25112548                break; 
Note: See TracChangeset for help on using the changeset viewer.