Changeset 2012


Ignore:
Timestamp:
01/22/07 16:00:07 (17 years ago)
Author:
bittner
Message:

vss ray updates

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp

    r2008 r2012  
    1212#include "PreprocessorThread.h" 
    1313#include "CombinedPreprocessor.h" 
     14#include "RayCaster.h" 
    1415 
    1516 
     
    6667  mPass = 0; 
    6768   
    68  
     69  vector<VssRayContainer> rayBuffer; 
     70  rays.reserve(mSamplesPerPass); 
     71  rayBuffer.reserve(2*mSamplesPerPass); 
    6972   
    70   vector<VssRayContainer> rayBuffer; 
    71    
    72  
    7373  long startTime = GetTime(); 
    7474  for (int i=0; i < mTotalSamples; i += mSamplesPerPass, mPass++) { 
    75  
     75        mRayCaster->InitPass(); 
     76         
    7677        cout<<"Progress : "<<(100.0f*i)/mTotalSamples<<"%"<<endl; 
    7778        rays.clear(); 
    7879        vssRays.clear(); 
     80         
    7981         
    8082        mMixtureDistribution->GenerateSamples(mSamplesPerPass, rays); 
     
    124126        } 
    125127 
     128#if 0 
    126129        cerr<<"deleting rays"<<endl; 
    127130        //clear all unreferenced rays 
     
    131134        } 
    132135        cerr<<"done."<<endl; 
    133            
     136#endif   
    134137         
    135138        //      if (!mMixtureDistribution->RequiresRays()) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2011 r2012  
    11871187        } 
    11881188         
     1189        mRayCaster->ReserveVssRayPool(2*mSamplesPerPass); 
     1190         
    11891191        return true; 
    11901192} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r2008 r2012  
    262262        ///////////////////////// 
    263263 
    264         GlobalLinesRenderer *mGlobalLinesRenderer; 
    265         RayCaster *mRayCaster; 
    266         /// samples used for construction of the BSP view cells tree. 
     264  GlobalLinesRenderer *mGlobalLinesRenderer; 
     265  RayCaster *mRayCaster; 
     266  /// samples used for construction of the BSP view cells tree. 
    267267        int mBspConstructionSamples; 
    268268        /// samples used for construction of the VSP OSP tree. 
     
    274274 
    275275 
     276   
    276277        /// if box around view space should be used 
    277278        bool mUseViewSpaceBox; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp

    r2008 r2012  
    291291 
    292292          if (!pruneInvalidRays || hitA.mObject) { 
    293                 VssRay *vssRay = new VssRay( 
    294                                                                         !castDoubleRay ? simpleRay.mOrigin : clipB, 
    295                                                                         hitA.mPoint, 
    296                                                                         hitB.mObject, 
    297                                                                         hitA.mObject, 
    298                                                                         mPreprocessor.mPass, 
    299                                                                         simpleRay.mPdf 
    300                                                                         ); 
     293                VssRay *vssRay = mVssRayPool.Alloc(); 
     294 
     295                *vssRay = VssRay( 
     296                                                 !castDoubleRay ? simpleRay.mOrigin : clipB, 
     297                                                 hitA.mPoint, 
     298                                                 hitB.mObject, 
     299                                                 hitA.mObject, 
     300                                                 mPreprocessor.mPass, 
     301                                                 simpleRay.mPdf 
     302                                                 ); 
    301303 
    302304                if (validA) 
     
    317319          if (castDoubleRay && (!pruneInvalidRays || hitB.mObject)) 
    318320                { 
    319                   VssRay *vssRay = new VssRay( 
    320                                                                           clipA, 
    321                                                                           hitB.mPoint, 
    322                                                                           hitA.mObject, 
    323                                                                           hitB.mObject, 
    324                                                                           mPreprocessor.mPass, 
    325                                                                           simpleRay.mPdf 
    326                                                                           ); 
     321                  VssRay *vssRay = mVssRayPool.Alloc(); 
     322                  *vssRay = VssRay( 
     323                                                   clipA, 
     324                                                   hitB.mPoint, 
     325                                                   hitA.mObject, 
     326                                                   hitB.mObject, 
     327                                                   mPreprocessor.mPass, 
     328                                                   simpleRay.mPdf 
     329                                                   ); 
    327330                  if (validB) 
    328331                        vssRay->mFlags |= VssRay::Valid; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h

    r1996 r2012  
    6464  SortRays(SimpleRayContainer &rays); 
    6565 
    66          
     66 
     67 
     68  // pool of vss rays to be used in one pass of the sampling 
     69  struct VssRayPool { 
     70        VssRayPool():mRays(), mIndex(0) {} 
     71        void Reserve(const int number) { 
     72          mRays.reserve(number); 
     73        } 
     74        void Clear() { 
     75          mIndex = 0; 
     76        } 
     77        VssRay *Alloc() { 
     78          return &mRays[mIndex++]; 
     79        } 
     80        vector<VssRay> mRays; 
     81        int mIndex; 
     82  }; 
     83 
     84   
     85  VssRayPool mVssRayPool; 
     86 
     87  void ReserveVssRayPool(const int n) { 
     88        mVssRayPool.Reserve(n); 
     89  } 
     90   
     91  void InitPass() { 
     92        mVssRayPool.Clear(); 
     93  } 
     94 
    6795 
    6896protected: 
     
    114142                                                   Vector3 &clippedTermination); 
    115143         
    116         const Preprocessor &mPreprocessor; 
     144 
     145 
     146 
     147   
     148 
     149  const Preprocessor &mPreprocessor; 
    117150}; 
    118151 
Note: See TracChangeset for help on using the changeset viewer.