Changeset 1867


Ignore:
Timestamp:
12/08/06 17:10:14 (17 years ago)
Author:
bittner
Message:

merge, global lines, rss sampling updates

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

Legend:

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

    r1824 r1867  
    22752275  halton.GenerateNext(); 
    22762276   
    2277   return mMin + size*Vector3(halton.GetNumber(1), 
    2278                                                          halton.GetNumber(2), 
    2279                                                          halton.GetNumber(3)); 
    2280  
     2277  return GetRandomPoint(Vector3(halton.GetNumber(1), 
     2278                                                                halton.GetNumber(2), 
     2279                                                                halton.GetNumber(3))); 
     2280   
    22812281#else 
    2282   return mMin + Vector3(RandomValue(0.0f, size.x), 
    2283                                                 RandomValue(0.0f, size.y), 
    2284                                                 RandomValue(0.0f, size.z)); 
     2282  return GetRandomPoint(Vector3(RandomValue(0.0f, 1.0f), 
     2283                                                                RandomValue(0.0f, 1.0f), 
     2284                                                                RandomValue(0.0f, 1.0f))); 
    22852285#endif 
    22862286} 
    22872287 
     2288Vector3 
     2289AxisAlignedBox3::GetRandomPoint(const Vector3 &r) const 
     2290{ 
     2291  return mMin + Size()*r; 
     2292} 
    22882293 
    22892294Vector3 AxisAlignedBox3::GetRandomSurfacePoint() const 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h

    r1824 r1867  
    181181 
    182182 
     183  Vector3 GetRandomPoint(const Vector3 &r) const; 
    183184  Vector3 GetRandomPoint() const; 
    184185  Vector3 GetRandomSurfacePoint() const; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BoostPreprocessorThread.cpp

    r1457 r1867  
    3333{ 
    3434  mThread = new boost::thread(*this); 
     35   
     36  PreprocessorThread::InitThread(); 
     37} 
     38 
     39int 
     40BoostPreprocessorThread::GetCurrentThreadId() const 
     41{ 
     42  // $$ temporary implementation 
     43  return 0; 
    3544} 
    3645 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BoostPreprocessorThread.h

    r1457 r1867  
    2525        void operator()(); 
    2626 
     27  int 
     28  GetCurrentThreadId() const; 
     29 
    2730protected: 
    2831 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1844 r1867  
    2727#define USE_VOLUMES_FOR_HEURISTICS 1 
    2828 
    29 //int BvhNode::sMailId = 10000; //2147483647; 
    30 //int BvhNode::sReservedMailboxes = 1; 
     29  //int BvhNode::sMailId = 10000; //2147483647; 
     30  //int BvhNode::sReservedMailboxes = 1; 
    3131 
    3232BvHierarchy *BvHierarchy::BvhSubdivisionCandidate::sBvHierarchy = NULL; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1843 r1867  
    15761576                "bsp_construction_input=", 
    15771577                "fromViewCells"); 
    1578  
     1578         
    15791579        RegisterOption("BspTree.subdivisionStats", 
    15801580                                        optString, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h

    r1764 r1867  
    136136  void SetWireframe() { mWireframe = true; } 
    137137  void SetFilled() { mWireframe = false; } 
    138  
     138   
    139139  void SetForcedMaterial(const Material &m) { 
    140140    mForcedMaterial = m; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Halton.h

    r860 r1867  
    77namespace GtpVisibilityPreprocessor { 
    88 
    9 class Halton2 { 
    10   static float _invBases[2]; 
    11   float _prev[2]; 
    12    
    13   float halton(float baseRec, float prev) const { 
    14         float r = 1 - prev - 1e-10f; 
    15         if (baseRec < r) 
    16           return prev + baseRec; 
     9inline float halton(float baseRec, float prev) { 
     10  float r = 1 - prev - 1e-10f; 
     11  if (baseRec < r) 
     12        return prev + baseRec; 
    1713        float h = baseRec; 
    1814        float hh; 
     
    2218        } while (h >= r); 
    2319        return prev + hh + h - 1; 
     20} 
     21 
     22template<int T> 
     23class Halton { 
     24  float _invBases[T]; 
     25  float _prev[T]; 
     26   
     27public: 
     28   
     29  void Reset() { 
     30        for (int i=0; i < T; i++)  
     31          _prev[i] = 0; 
    2432  } 
     33   
     34  Halton() { 
     35        for (int i=0; i < T; i++) { 
     36          int base = FindPrime(i+1); 
     37          if (base == 1) 
     38                base++; 
     39          _invBases[i] = 1.0f/base; 
     40        } 
     41        Reset(); 
     42  } 
     43   
     44  void 
     45  GetNext(float *a) { 
     46        for (int i=0; i < T; i++) { 
     47          a[i] = halton(_invBases[i], _prev[i]); 
     48          _prev[i] = a[i]; 
     49        } 
     50  } 
     51   
     52}; 
     53 
     54class Halton2 { 
     55  static float _invBases[2]; 
     56  float _prev[2]; 
    2557   
    2658public: 
     
    69101 */ 
    70102inline int FindPrime(const int index) { 
    71   if(index < 1) { 
    72         cerr<<"FindPrime: The argument must be non-negative."<<endl; 
    73         return -1; 
    74   } 
     103  //  if (index < 1) { 
     104  //    cerr<<"FindPrime: The argument must be non-negative."<<endl; 
     105  //    return -1; 
     106  //  } 
     107 
     108  const int primes[] = {-1, 1, 3, 5, 7, 11, 13}; 
     109  if (index <= 6) 
     110        return primes[index]; 
     111 
    75112  int prime = 1; 
    76113  int found = 1; 
     
    115152        int copyOfIndex = index; 
    116153        if((base >= 2) && (index >= 1)) { 
    117         // changed by matt 
    118         //if(base >= 2 & index >= 1) { 
    119154          while(copyOfIndex > 0) { 
    120155                N1 = (copyOfIndex / base); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp

    r1786 r1867  
    9393 
    9494        return ProcessRay( 
    95                 simpleRay, 
    96                 hitA, 
    97                 hitB, 
    98                 vssRays, 
    99                 box, 
    100                 castDoubleRay, 
    101                 pruneInvalidRays 
    102                 ); 
     95                                          simpleRay, 
     96                                          hitA, 
     97                                          hitB, 
     98                                          vssRays, 
     99                                          box, 
     100                                          castDoubleRay, 
     101                                          pruneInvalidRays 
     102                                          ); 
    103103} 
    104104 
  • GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp

    r1829 r1867  
    2929{ 
    3030        if (simpleRay.mType == Ray::GLOBAL_RAY) 
    31                 return CastGlobalRay(simpleRay, vssRays, box, pruneInvalidRays); 
     31          return CastGlobalRay(simpleRay, vssRays, box, pruneInvalidRays); 
    3232         
    3333        //cout << "internal ray" << endl; 
     
    8787  static Ray ray; 
    8888  int hits = 0; 
    89         mPreprocessor.SetupRay(ray, simpleRay.mOrigin, simpleRay.mDirection); 
    90  
    91         float tmin, tmax; 
    92         if (!(box.ComputeMinMaxT(ray, &tmin, &tmax) && (tmin < tmax))) 
    93                 return 0; 
    94  
    95         // shift the ray origin to tmin 
    96         //      Vector3 origin = ray.Extrap(tmin); 
    97         //      mPreprocessor.SetupRay(ray, origin, simpleRay.mDirection); 
    98         ray.SetType(Ray::GLOBAL_RAY); 
    99         ray.mFlags &= ~Ray::CULL_BACKFACES; 
    100  
    101  
    102         VssRay *vssRay; 
    103          
     89  mPreprocessor.SetupRay(ray, simpleRay.mOrigin, simpleRay.mDirection); 
     90   
     91  float tmin, tmax; 
     92  if (!(box.ComputeMinMaxT(ray, &tmin, &tmax) && (tmin < tmax))) 
     93        return 0; 
     94   
     95  // shift the ray origin to tmin 
     96  //    Vector3 origin = ray.Extrap(tmin); 
     97  //    mPreprocessor.SetupRay(ray, origin, simpleRay.mDirection); 
     98  ray.SetType(Ray::GLOBAL_RAY); 
     99  ray.mFlags &= ~Ray::CULL_BACKFACES; 
     100   
     101 
     102  VssRay *vssRay; 
     103   
    104104  if (mKdTree->CastRay(ray)) { 
    105                 // sort intersections 
    106                 ray.SortIntersections(); 
    107                 //cout<<"I="<<ray.intersections.size()<<endl; 
    108  
    109                  
    110                 Ray::Intersection &hit = ray.intersections[0]; 
    111  
    112                 if (DotProd(hit.mNormal, ray.GetDir()) < 0) { 
    113                         // insert intial segment 
    114                         vssRay = new VssRay( 
    115                                                                                                         ray.Extrap(tmin), 
    116                                                                                                         ray.Extrap(hit.mT), 
    117                                                                                                         NULL, 
    118                                                                                                         hit.mObject, 
    119                                                                                                         mPreprocessor.mPass, 
    120                                                                                                         simpleRay.mPdf 
    121                                                                                                         ); 
    122                         vssRay->mFlags |= VssRay::Valid; 
    123                         vssRays.push_back(vssRay); 
    124                         ++hits; 
     105        // sort intersections 
     106        ray.SortIntersections(); 
     107        //      cout<<"I="<<ray.intersections.size()<<endl; 
     108         
     109         
     110        Ray::Intersection &hit = ray.intersections[0]; 
     111         
     112        if (DotProd(hit.mNormal, ray.GetDir()) < 0) { 
     113          //      cout<<"F:"<<tmin<<" "<<hit.mT<<endl; 
     114          // insert intial segment 
     115          vssRay = new VssRay( 
     116                                                  ray.Extrap(tmin), 
     117                                                  ray.Extrap(hit.mT), 
     118                                                  NULL, 
     119                                                  hit.mObject, 
     120                                                  mPreprocessor.mPass, 
     121                                                  simpleRay.mPdf 
     122                                                  ); 
     123 
     124          vssRay->mFlags |= VssRay::Valid; 
     125          vssRays.push_back(vssRay); 
     126          ++hits; 
     127        } 
     128                                 
     129        hit = ray.intersections[ray.intersections.size()-1]; 
     130        if (DotProd(hit.mNormal, ray.GetDir()) > 0) { 
     131          //      cout<<"L:"<<tmax<<" "<<hit.mT<<endl; 
     132           
     133          // insert termination segment 
     134          vssRay = new VssRay( 
     135                                                  ray.Extrap(tmax), 
     136                                                  ray.Extrap(hit.mT), 
     137                                                  NULL, 
     138                                                  hit.mObject, 
     139                                                  mPreprocessor.mPass, 
     140                                                  simpleRay.mPdf 
     141                                                  ); 
     142          vssRay->mFlags |= VssRay::Valid; 
     143          vssRays.push_back(vssRay); 
     144          ++hits; 
     145        } 
     146         
     147        // insert the rest of segments 
     148        for (int i=0; i < ray.intersections.size() - 1; i++) { 
     149          Ray::Intersection &hitA = ray.intersections[i]; 
     150          Ray::Intersection &hitB = ray.intersections[i + 1]; 
     151          if (hitB.mT - hitA.mT > Limits::Small) { 
     152                if (DotProd(hitA.mNormal, ray.GetDir()) > 0 && 
     153                        DotProd(hitB.mNormal, ray.GetDir()) < 0 
     154                        ) { 
     155                   
     156                  vssRay = new VssRay( 
     157                                                          ray.Extrap(hitA.mT), 
     158                                                          ray.Extrap(hitB.mT), 
     159                                                          hitA.mObject, 
     160                                                        hitB.mObject, 
     161                                                          mPreprocessor.mPass, 
     162                                                          simpleRay.mPdf 
     163                                                          ); 
     164                  vssRay->mFlags |= VssRay::Valid; 
     165                  vssRays.push_back(vssRay); 
     166                  ++hits; 
     167                   
     168                  vssRay = new VssRay( 
     169                                                          ray.Extrap(hitB.mT), 
     170                                                          ray.Extrap(hitA.mT), 
     171                                                          hitB.mObject, 
     172                                                          hitA.mObject, 
     173                                                          mPreprocessor.mPass, 
     174                                                          simpleRay.mPdf 
     175                                                          ); 
     176                   
     177                  vssRay->mFlags |= VssRay::Valid; 
     178                  vssRays.push_back(vssRay); 
     179                  ++hits; 
    125180                } 
    126                                  
    127                 hit = ray.intersections[ray.intersections.size()-1]; 
    128                 if (DotProd(hit.mNormal, ray.GetDir()) > 0) { 
    129                          
    130                         // insert termination segment 
    131                         vssRay = new VssRay( 
    132                                                                                                         ray.Extrap(tmax), 
    133                                                                                                         ray.Extrap(hit.mT), 
    134                                                                                                         NULL, 
    135                                                                                                         hit.mObject, 
    136                                                                                                         mPreprocessor.mPass, 
    137                                                                                                         simpleRay.mPdf 
    138                                                                                                         ); 
    139                         vssRay->mFlags |= VssRay::Valid; 
    140                         vssRays.push_back(vssRay); 
    141                         ++hits; 
    142                 } 
    143                  
    144                 // insert the rest of segments 
    145                 for (int i=0; i < ray.intersections.size() - 1; i++) { 
    146                         Ray::Intersection &hitA = ray.intersections[i]; 
    147                         Ray::Intersection &hitB = ray.intersections[i + 1]; 
    148                         if (DotProd(hitA.mNormal, ray.GetDir()) > 0 && 
    149                                         DotProd(hitB.mNormal, ray.GetDir()) < 0 
    150                                         ) { 
    151                                  
    152                                 vssRay = new VssRay( 
    153                                                                                                                 ray.Extrap(hitA.mT), 
    154                                                                                                                 ray.Extrap(hitB.mT), 
    155                                                                                                                 hitA.mObject, 
    156                                                                                                                 hitB.mObject, 
    157                                                                                                                 mPreprocessor.mPass, 
    158                                                                                                                 simpleRay.mPdf 
    159                                                                                                                 ); 
    160                                 vssRay->mFlags |= VssRay::Valid; 
    161                                 vssRays.push_back(vssRay); 
    162                                 ++hits; 
    163                                  
    164                                 vssRay = new VssRay( 
    165                                                                                                                 ray.Extrap(hitB.mT), 
    166                                                                                                                 ray.Extrap(hitA.mT), 
    167                                                                                                                 hitB.mObject, 
    168                                                                                                                 hitA.mObject, 
    169                                                                                                                 mPreprocessor.mPass, 
    170                                                                                                                 simpleRay.mPdf 
    171                                                                                                                 ); 
    172                                  
    173                                 vssRay->mFlags |= VssRay::Valid; 
    174                                 vssRays.push_back(vssRay); 
    175                                 ++hits; 
    176                         } 
    177                 } 
    178         } 
    179          
    180         return hits; 
     181          } 
     182        } 
     183  } 
     184   
     185  return hits; 
    181186} 
    182187 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r1763 r1867  
    66#include <set> 
    77#include "VssRay.h" 
     8#include "Mailable.h" 
    89 
    910namespace GtpVisibilityPreprocessor { 
     
    7475   
    7576  Intersectable():  
    76   mMailbox(0),  
     77        mMailbox(0),  
    7778  //mReferences(0),  
    7879  mBvhLeaf(0),  
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp

    r1824 r1867  
    3131                if (ray.GetType() == Ray::LOCAL_RAY && !ray.intersections.empty()) { 
    3232                        ray.intersections[0] = Ray::Intersection(nearestT, 
    33                                                                                                                                                                                         nearestNormal, 
    34                                                                                                                                                                                         this, 
    35                                                                                                                                                                                         0); 
     33                                                                                                        nearestNormal, 
     34                                                                                                        this, 
     35                                                                                                        0); 
    3636                } 
    3737                else { 
    3838                        ray.intersections.push_back(Ray::Intersection(nearestT, 
    39                                                                                                                                                                                                                 nearestNormal, 
    40                                                                                                                                                                                                                 this, 
    41                                                                                                                                                                                                                 0)); 
     39                                                                                                                  nearestNormal, 
     40                                                                                                                  this, 
     41                                                                                                                  0)); 
    4242                } 
    4343                 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r1824 r1867  
    677677          ObjectContainer::const_iterator mi; 
    678678          for ( mi = leaf->mObjects.begin(); 
    679                                         mi != leaf->mObjects.end(); 
    680                                         mi++) { 
    681                         Intersectable *object = *mi; 
    682                         if (!object->Mailed() ) { 
    683                                 object->Mail(); 
    684                                 if (ray.mFlags & Ray::STORE_TESTED_OBJECTS) 
    685                                         ray.testedObjects.push_back(object); 
    686                                  
    687                                 static int oi=1; 
    688                                 if (MeshDebug)  
    689                                         cout<<"Object "<<oi++; 
    690                                  
    691                                 hits += object->CastRay(ray); 
    692                                  
    693                                 if (MeshDebug) { 
    694                                         if (!ray.intersections.empty())  
    695                                                 cout<<"nearest t="<<ray.intersections[0].mT<<endl; 
    696                                         else 
    697                                                 cout<<"nearest t=-INF"<<endl; 
    698                                 }          
    699                         } 
     679                        mi != leaf->mObjects.end(); 
     680                        mi++) { 
     681                Intersectable *object = *mi; 
     682                if (!object->Mailed() ) { 
     683                  object->Mail(); 
     684                  if (ray.mFlags & Ray::STORE_TESTED_OBJECTS) 
     685                        ray.testedObjects.push_back(object); 
     686                   
     687                  static int oi=1; 
     688                  if (MeshDebug)  
     689                        cout<<"Object "<<oi++; 
     690                   
     691                  hits += object->CastRay(ray); 
     692                   
     693                  if (MeshDebug) { 
     694                        if (!ray.intersections.empty())  
     695                          cout<<"nearest t="<<ray.intersections[0].mT<<endl; 
     696                        else 
     697                          cout<<"nearest t=-INF"<<endl; 
     698                  }        
     699                } 
    700700          } 
    701701           
    702702          if (hits && ray.GetType() == Ray::LOCAL_RAY) 
    703                         if (ray.intersections[0].mT <= maxt) 
    704                                 break; 
     703                if (ray.intersections[0].mT <= maxt) 
     704                  break; 
    705705           
    706706          // get the next node from the stack 
    707707          if (tStack.empty()) 
    708                         break; 
     708                break; 
    709709           
    710710          entp = extp; 
    711711          mint = maxt; 
    712712          if (ray.GetType() == Ray::LINE_SEGMENT && mint > 1.0f) 
    713                         break; 
     713                break; 
    714714           
    715715          RayTraversalData &s  = tStack.top(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r1832 r1867  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 30. XI 15:32:50 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: pá 8. XII 16:33:20 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r1824 r1867  
    99bool MeshDebug = false; 
    1010 
    11 int Intersectable::sMailId = 1;//2147483647; 
    12 int Intersectable::sReservedMailboxes = 1; 
     11  //int Intersectable::sMailId = 1;//2147483647; 
     12  //int Intersectable::sReservedMailboxes = 1; 
    1313 
    1414struct SortableVertex { 
     
    370370    return Ray::INTERSECTION_OUT_OF_LIMITS; 
    371371   
    372   if (t >= nearestT) { 
     372  if ((ray.GetType() == Ray::LOCAL_RAY) && (t >= nearestT)) { 
    373373    return Ray::INTERSECTION_OUT_OF_LIMITS; // no intersection was found 
    374374  } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/MutualVisibility.cpp

    r1328 r1867  
    160160  } 
    161161 
     162  //  int id = Mailable::GetThreadId(); 
    162163  for (i=0; i < 4; i++) { 
    163164    RaySample *sample = &shaft.mSamples[i]; 
    164165    for (j=0; j < sample->mIntersections.size(); j++) { 
    165166      if (sample->mIntersections[j].mObject->IncMail() == 4) { 
    166         cerr<<"T"; 
    167         shaft.mError = 0.0f; 
    168         return; 
     167                cerr<<"T"; 
     168                shaft.mError = 0.0f; 
     169                return; 
    169170      } 
    170171    } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1827 r1867  
    3030namespace GtpVisibilityPreprocessor { 
    3131 
    32 const static bool ADDITIONAL_GEOMETRY_HACK = false; 
    33  
    34  
     32  const static bool ADDITIONAL_GEOMETRY_HACK = false; 
     33 
     34  Preprocessor *preprocessor = NULL; 
     35   
    3536// HACK: Artificially modify scene to watch rendercost changes 
    3637static void AddGeometry(SceneGraph *scene) 
     
    443444        Environment::GetSingleton()->GetIntValue("Preprocessor.rayCastMethod", rayCastMethod); 
    444445        vector<FaceParentInfo> *fi =  
    445                 ((rayCastMethod == RayCaster::INTEL_RAYCASTER) && mLoadMeshes) ? 
    446                 &mFaceParents : NULL; 
    447  
     446          ((rayCastMethod == RayCaster::INTEL_RAYCASTER) && mLoadMeshes) ? 
     447          &mFaceParents : NULL; 
     448         
    448449        if (files == 1)  
    449         { 
     450          { 
    450451                if (strstr(filename.c_str(), ".x3d")) 
    451                 { 
     452                  { 
    452453                        parser = new X3dParser; 
    453454                         
     
    984985int 
    985986Preprocessor::GenerateRays(const int number, 
    986                                                                                                          const SamplingStrategy &strategy, 
    987                                                                                                         SimpleRayContainer &rays) 
    988 { 
    989         return strategy.GenerateSamples(number, rays); 
     987                                                  SamplingStrategy &strategy, 
     988                                                  SimpleRayContainer &rays) 
     989{ 
     990  return strategy.GenerateSamples(number, rays); 
    990991} 
    991992 
     
    10961097        if (rayCastMethod == 0) 
    10971098        { 
     1099                cout << "ray cast method: internal" << endl; 
    10981100                mRayCaster = new InternalRayCaster(*this, mKdTree); 
    1099                 cout << "ray cast method: internal" << endl; 
    11001101        } 
    11011102        else 
    11021103        { 
    11031104#ifdef GTP_INTERNAL 
    1104                 mRayCaster = new IntelRayCaster(*this, externKdTree); 
    1105                 cout << "ray cast method: intel" << endl; 
     1105          cout << "ray cast method: intel" << endl; 
     1106          mRayCaster = new IntelRayCaster(*this, externKdTree); 
    11061107#endif 
    11071108        } 
    1108  
     1109         
    11091110        return true; 
    11101111} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r1786 r1867  
    99 
    1010 
    11  
    1211namespace GtpVisibilityPreprocessor { 
    13  
     12  class PreprocessorThread; 
     13   
    1414class RenderSimulator; 
    1515class SceneGraph; 
     
    122122 
    123123        virtual int 
    124                 GenerateRays(const int number, 
    125                 const SamplingStrategy &strategy, 
    126                 SimpleRayContainer &rays); 
    127  
    128         virtual int GenerateRays(const int number, 
    129                 const int raysType, 
    130                 SimpleRayContainer &rays); 
     124        GenerateRays(const int number, 
     125                                SamplingStrategy &strategy, 
     126                                 SimpleRayContainer &rays); 
     127 
     128  virtual int GenerateRays(const int number, 
     129                                                   const int raysType, 
     130                                                   SimpleRayContainer &rays); 
    131131 
    132132        bool GenerateRayBundle(SimpleRayContainer &rayBundle, 
     
    136136 
    137137        virtual void CastRays(SimpleRayContainer &rays, 
    138                 VssRayContainer &vssRays, 
    139                 const bool castDoubleRays, 
    140                 const bool pruneInvalidRays = true); 
     138                                                  VssRayContainer &vssRays, 
     139                                                  const bool castDoubleRays, 
     140                                                  const bool pruneInvalidRays = true); 
    141141 
    142142        /** Returns a view cells manager of the given name. 
     
    207207 
    208208  GlRendererBuffer *renderer; 
     209 
     210  void SetThread(PreprocessorThread *t) { 
     211        mThread = t; 
     212  } 
     213 
     214  PreprocessorThread *GetThread() const { 
     215        return mThread; 
     216  } 
    209217 
    210218protected: 
     
    237245        /// if box around view space should be used 
    238246        bool mUseViewSpaceBox; 
     247 
     248  PreprocessorThread *mThread; 
    239249}; 
    240250 
     251  extern Preprocessor *preprocessor; 
    241252 
    242253} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/PreprocessorThread.cpp

    r1583 r1867  
    88namespace GtpVisibilityPreprocessor { 
    99 
     10 
     11vector<PreprocessorThread *> PreprocessorThread::sThreads; 
    1012 
    1113PreprocessorThread::PreprocessorThread(Preprocessor *p): 
  • GTP/trunk/Lib/Vis/Preprocessing/src/PreprocessorThread.h

    r1457 r1867  
    22#define __PREPROCESSOR_THREAD_H 
    33 
    4  
     4#include <vector> 
     5using namespace std; 
    56namespace GtpVisibilityPreprocessor  
    67{ 
    78 
    89class Preprocessor; 
     10 
    911 
    1012/** This class represents a preprocessor thread. 
     
    1315{ 
    1416public: 
     17  static vector<PreprocessorThread *> sThreads; 
     18   
    1519  PreprocessorThread(Preprocessor *p); 
    1620  virtual ~PreprocessorThread(); 
    1721   
    18   virtual void InitThread() {} 
     22  virtual void InitThread() { 
     23        sThreads.push_back(this); 
     24  } 
    1925  virtual void RunThread() {} 
    2026   
    2127  virtual void Main(); 
    22    
     28 
     29  // This function has to be defined by the thread library used... 
     30  virtual int GetCurrentThreadId() const = 0; 
     31 
    2332protected: 
    2433   
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r1845 r1867  
    592592 
    593593        // only check clean part 
    594         //mLastSorted = 0; 
     594        // $$ TMP JB 
     595        // mLastSorted = 0; 
    595596        vector<PvsEntry<T, S> >::iterator sorted_end = mEntries.begin() + mLastSorted; 
    596597 
     
    606607                vector<PvsEntry<T, S> >::const_iterator dit, dit_end = mEntries.end(); 
    607608 
    608                 for (dit = sorted_end; (dit != dit_end) && ((*dit).mObject != sample); ++ dit); 
    609  
     609                for (dit = sorted_end; (dit != dit_end) && ((*dit).mObject != sample); ++ dit) ; 
     610                 
    610611                if ((dit != mEntries.end()) && ((*dit).mObject == sample)) 
    611612                        found = true; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.cpp

    r1832 r1867  
    327327QtGlRendererWidget::RenderPvs() 
    328328{ 
    329    
     329         
    330330  Intersectable::NewMail(); 
    331331 
     
    345345        // copy the pvs so that it can be filtered... 
    346346         
    347         ObjectPvs &pvs = mPvsCache.mPvs; 
     347        //      mPvsCache.mPvs; 
    348348         
    349349        if (mPvsCache.mViewCell != viewcell) { 
     
    352352           
    353353          if (mUseSpatialFilter) { 
    354                         // 9.11. 2006 -> experiment with new spatial filter 
     354                // 9.11. 2006 -> experiment with new spatial filter 
    355355#if 0 
    356                         mViewCellsManager->ApplySpatialFilter(mKdTree, 
    357                                                                                                                                                                                 mSpatialFilterSize* 
    358                                                                                                                                                                                 Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 
    359                                                                                                                                                                                 pvs); 
     356                mViewCellsManager->ApplySpatialFilter(mKdTree, 
     357                                                                                          mSpatialFilterSize* 
     358                                                                                          Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 
     359                                                                                          mPvsCache.mPvs); 
    360360#else 
    361                         // mSpatialFilter size is in range 0.001 - 0.1 
    362                         mViewCellsManager->ApplyFilter2(viewcell, 
    363                                                                                                                                                         mUseFilter, 
    364                                                                                                                                                         100*mSpatialFilterSize, 
    365                                                                                                                                                         pvs, 
    366                                                                                                                                                         &mPvsCache.filteredBoxes 
    367                                                                                                                                                         ); 
     361                // mSpatialFilter size is in range 0.001 - 0.1 
     362                mViewCellsManager->ApplyFilter2(viewcell, 
     363                                                                                mUseFilter, 
     364                                                                                100*mSpatialFilterSize, 
     365                                                                                mPvsCache.mPvs, 
     366                                                                                &mPvsCache.filteredBoxes 
     367                                                                                ); 
    368368#endif 
    369369          } else 
    370                 pvs = viewcell->GetPvs(); 
    371  
     370                mPvsCache.mPvs = viewcell->GetPvs(); 
     371           
    372372          emit PvsUpdated(); 
    373373        } 
     
    378378                        RenderBox(mPvsCache.filteredBoxes[i]); 
    379379        } else { 
    380                 ObjectPvsIterator it = pvs.GetIterator(); 
     380                ObjectPvsIterator it = mPvsCache.mPvs.GetIterator(); 
    381381                 
    382                 mPvsSize = pvs.GetSize(); 
     382                mPvsSize = mPvsCache.mPvs.GetSize(); 
    383383                for (; it.HasMoreEntries(); ) { 
    384384                        ObjectPvsEntry entry = it.Next(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtPreprocessorThread.cpp

    r1770 r1867  
    2929} 
    3030 
     31int 
     32QtPreprocessorThread::GetCurrentThreadId() const 
     33{ 
     34  QThread *thread = currentThread(); 
     35  for (int i=0; i < sThreads.size(); i++) 
     36        if (sThreads[i] == (QtPreprocessorThread *)thread) 
     37          return i+1; 
     38  return 0; 
    3139} 
     40 
     41} 
     42 
    3243 
    3344#endif 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtPreprocessorThread.h

    r1842 r1867  
    1616  ~QtPreprocessorThread(); 
    1717   
    18   void InitThread() {} 
     18  void InitThread() { 
     19        PreprocessorThread::InitThread(); 
     20  } 
    1921  void RunThread() { 
    2022        start(QThread::LowPriority); 
    2123  } 
    22    
     24 
     25  // This function has to be defined by the thread library used... 
     26  virtual int GetCurrentThreadId() const; 
     27 
    2328   
    2429protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Ray.cpp

    r1584 r1867  
    1414// that are converted to canonical space and thus the mailbox 
    1515// rayID identification does not work for them! 
    16 int 
    17 Ray::genID = 1; 
    18  
    19 // Precompute some Ray parameters. Most of them is used for 
    20 // ropes traversal. 
     16  int 
     17  Ray::genID = 1; 
     18   
     19   
     20  int 
     21  SimpleRay::sSimpleRayId = 1; 
     22   
    2123 
    2224void 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Ray.h

    r1824 r1867  
    316316struct SimpleRay 
    317317{ 
     318  int mId; 
    318319  Vector3 mOrigin; 
    319320  Vector3 mDirection; 
    320321  float mPdf; 
    321         int mType; 
    322          
    323   SimpleRay(): mType(Ray::LOCAL_RAY) {} 
     322  int mType; 
     323 
     324  static int sSimpleRayId; 
     325  SimpleRay(): mType(Ray::LOCAL_RAY) { 
     326        mId = sSimpleRayId++; 
     327  } 
     328   
    324329  SimpleRay(const Vector3 &o, const Vector3 &d, const float p=1.0f): 
    325                 mOrigin(o), mDirection(d), mPdf(p), mType(Ray::LOCAL_RAY) {} 
     330        mOrigin(o), mDirection(d), mPdf(p), mType(Ray::LOCAL_RAY) {      
     331        mId = sSimpleRayId++; 
     332  } 
    326333         
    327334  Vector3 Extrap(const float t) const { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp

    r1824 r1867  
    3939/** Checks if ray is valid, (e.g., not in empty view space or outside the view space) 
    4040*/ 
    41 bool RayCaster::ValidateRay(const Vector3 &origin, 
    42                                                         const Vector3 &direction, 
    43                                                         const AxisAlignedBox3 &box, 
    44                                                         Intersection &hit) 
     41bool 
     42RayCaster::ValidateRay(const Vector3 &origin, 
     43                                           const Vector3 &direction, 
     44                                           const AxisAlignedBox3 &box, 
     45                                           Intersection &hit) 
    4546{ 
    46         if (!hit.mObject)  { 
    47           // compute intersection with the scene bounding box 
     47  if (!hit.mObject)  { 
     48        // compute intersection with the scene bounding box 
    4849#if EXACT_BOX_CLIPPING 
    49           static Ray ray; 
    50           mPreprocessor.SetupRay(ray, origin, direction); 
    51            
    52           float tmin, tmax; 
    53           if (box.ComputeMinMaxT(ray, &tmin, &tmax) && (tmin < tmax)) { 
    54                 hit.mPoint = ray.Extrap(tmax); 
    55           } 
    56           else { 
    57                 //              cout<<" invalid hp "<<tmin<<" "<<tmax<<endl; 
    58                 //              cout<<" box "<<box<<endl; 
    59                 //              cout<<" origin "<<origin<<endl; 
    60                 //              cout<<" direction "<<direction<<endl; 
    61                 //              cout<< "inv dir"<<ray.GetInvDir()<<endl; 
    62                 return false; 
    63           } 
     50        static Ray ray; 
     51        mPreprocessor.SetupRay(ray, origin, direction); 
     52         
     53        float tmin, tmax; 
     54        if (box.ComputeMinMaxT(ray, &tmin, &tmax) && (tmin < tmax)) { 
     55          hit.mPoint = ray.Extrap(tmax); 
     56        } 
     57        else { 
     58          //            cout<<" invalid hp "<<tmin<<" "<<tmax<<endl; 
     59          //            cout<<" box "<<box<<endl; 
     60          //            cout<<" origin "<<origin<<endl; 
     61          //            cout<<" direction "<<direction<<endl; 
     62          //            cout<< "inv dir"<<ray.GetInvDir()<<endl; 
     63          return false; 
     64        } 
    6465#else 
    65           hit.mPoint = origin + direction*Magnitude(box.Diagonal()); 
     66        hit.mPoint = origin + direction*Magnitude(box.Diagonal()); 
    6667#endif 
    67         } 
    68         else if (mPreprocessor.mDetectEmptyViewSpace) { 
    69           if (DotProd(hit.mNormal, direction) >= 0) {    
     68  } 
     69  else 
     70        if (mPreprocessor.mDetectEmptyViewSpace) { 
     71          if (DotProd(hit.mNormal, direction) >= -Limits::Small) {       
    7072                hit.mObject = NULL; 
    7173                return false; 
    7274          } 
    7375        } 
    74          
    75         return true; 
     76   
     77  return true; 
    7678} 
    7779 
    7880 
    79 int RayCaster::ProcessRay(const SimpleRay &simpleRay, 
    80                                                   Intersection &hitA, 
    81                                                   Intersection &hitB, 
    82                                                   VssRayContainer &vssRays, 
    83                                                   const AxisAlignedBox3 &box, 
    84                                                   const bool castDoubleRay, 
    85                                                   const bool pruneInvalidRays) 
     81int 
     82RayCaster::ProcessRay(const SimpleRay &simpleRay, 
     83                                          Intersection &hitA, 
     84                                          Intersection &hitB, 
     85                                          VssRayContainer &vssRays, 
     86                                          const AxisAlignedBox3 &box, 
     87                                          const bool castDoubleRay, 
     88                                          const bool pruneInvalidRays) 
    8689{ 
    8790        int hits = 0; 
     
    9093        Debug<<"PRA"<<flush; 
    9194#endif 
     95 
     96        // regardless of the pruneInvalidRays setting reject rays whic degenerate to a point 
     97        if (EpsilonEqualV3(hitA.mPoint, hitB.mPoint, Limits::Small)) 
     98          return 0; 
    9299         
    93         if (pruneInvalidRays) 
    94         { 
     100        if (pruneInvalidRays) { 
    95101          if (!hitA.mObject && !hitB.mObject) { 
    96102                return 0; 
     
    100106        const bool validA =  
    101107          ValidateRay(simpleRay.mOrigin, simpleRay.mDirection, box, hitA); 
    102  
     108         
     109        const bool validB = castDoubleRay &&  
     110          ValidateRay(simpleRay.mOrigin, -simpleRay.mDirection, box, hitB); 
     111         
    103112#if DEBUG_RAYCAST 
    104113        Debug<<"PR1"<<flush; 
    105114#endif 
    106115         
    107         if (!validA && pruneInvalidRays) 
    108           { 
     116        // reset both contributions 
     117        if (!validA || !validB) { 
     118          if (pruneInvalidRays) 
    109119                return 0; 
    110           } 
     120          // reset both contributions of this ray 
     121          hitA.mObject = NULL; 
     122          hitB.mObject = NULL; 
     123        } 
     124           
    111125         
    112         const bool validB = castDoubleRay &&  
    113           ValidateRay(simpleRay.mOrigin, -simpleRay.mDirection, box, hitB); 
    114          
    115         if (!validB && pruneInvalidRays) 
    116           { 
    117                 return 0; 
    118         } 
    119  
    120         const bool validSample = !pruneInvalidRays || (hitA.mObject != hitB.mObject); 
    121  
     126        const bool validSample = true; 
     127        // 8.11. 2007 JB 
     128        // degenerate rays checked by geometrical constraint... 
     129        //      !pruneInvalidRays || (hitA.mObject != hitB.mObject); 
    122130         
    123131#if DEBUG_RAYCAST 
     
    126134 
    127135        if (validSample) { 
    128           if (!pruneInvalidRays || hitA.mObject)  
    129                 { 
    130                   VssRay *vssRay = new VssRay( 
    131                                                                           hitB.mPoint, 
    132                                                                           hitA.mPoint, 
    133                                                                           hitB.mObject, 
    134                                                                           hitA.mObject, 
    135                                                                           mPreprocessor.mPass, 
    136                                                                           simpleRay.mPdf 
    137                                                                           ); 
    138                   if (validA) 
    139                         vssRay->mFlags |= VssRay::Valid; 
    140                   vssRays.push_back(vssRay); 
    141                   ++ hits; 
    142                   //cout << "vssray 1: " << *vssRay << " " << vssRay->mTermination - vssRay->mOrigin << endl; 
    143                 } 
    144  
     136          if (!pruneInvalidRays || hitA.mObject) { 
     137                VssRay *vssRay = new VssRay( 
     138                                                                        hitB.mPoint, 
     139                                                                        hitA.mPoint, 
     140                                                                        hitB.mObject, 
     141                                                                        hitA.mObject, 
     142                                                                        mPreprocessor.mPass, 
     143                                                                        simpleRay.mPdf 
     144                                                                        ); 
     145                 
     146                if (validA) 
     147                  vssRay->mFlags |= VssRay::Valid; 
     148                vssRay->mGeneratingRayId = simpleRay.mId; 
     149                vssRays.push_back(vssRay); 
     150                ++ hits; 
     151                //cout << "vssray 1: " << *vssRay << " " << vssRay->mTermination - vssRay->mOrigin << endl; 
     152          } 
     153           
    145154#if DEBUG_RAYCAST 
    146         Debug<<"PR3"<<flush; 
     155          Debug<<"PR3"<<flush; 
    147156#endif 
    148157 
     
    150159                { 
    151160                  VssRay *vssRay = new VssRay( 
    152                                                                                                                                         hitA.mPoint, 
    153                                                                                                                                         hitB.mPoint, 
    154                                                                                                                                         hitA.mObject, 
    155                                                                                                                                         hitB.mObject, 
    156                                                                                                                                         mPreprocessor.mPass, 
    157                                                                                                                                         simpleRay.mPdf 
    158                                                                                                                                         ); 
     161                                                                          hitA.mPoint, 
     162                                                                          hitB.mPoint, 
     163                                                                          hitA.mObject, 
     164                                                                          hitB.mObject, 
     165                                                                          mPreprocessor.mPass, 
     166                                                                          simpleRay.mPdf 
     167                                                                          ); 
    159168                  if (validB) 
    160                                 vssRay->mFlags |= VssRay::Valid; 
     169                        vssRay->mFlags |= VssRay::Valid; 
    161170                   
     171                  vssRay->mGeneratingRayId = simpleRay.mId; 
    162172                  vssRays.push_back(vssRay); 
    163173                  ++ hits; 
     
    165175                } 
    166176        } 
    167  
     177         
    168178#if DEBUG_RAYCAST 
    169179        Debug<<"PR4"<<flush; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r1824 r1867  
    1313#include "GlRenderer.h" 
    1414#include "SamplingStrategy.h" 
    15  
     15#include "PreprocessorThread.h" 
    1616 
    1717 
     
    1919 
    2020 
    21 static bool useViewSpaceBox = false; 
    22 static bool use2dSampling = false; 
    23  
    24  
    25 // not supported anymore! 
    26 static bool fromBoxVisibility = false; 
     21  const bool pruneRays = false; 
     22   
     23 
    2724 
    2825#define ADD_RAYS_IN_PLACE 1 
     
    6259RssPreprocessor::GenerateRays( 
    6360                                                          const int number, 
    64                                                           const int sampleType, 
    65                                                           SimpleRayContainer &rays 
    66                                                           ) 
     61                                                          SamplingStrategy &strategy, 
     62                                                          SimpleRayContainer &rays) 
    6763{ 
    6864  int result = 0; 
     
    7066  Debug<<"Generate rays...\n"<<flush; 
    7167 
    72   switch (sampleType) { 
     68  switch (strategy.mType) { 
    7369  case SamplingStrategy::RSS_BASED_DISTRIBUTION: 
    7470  case SamplingStrategy::RSS_SILHOUETTE_BASED_DISTRIBUTION: 
    7571                if (mRssTree) { 
    76                         result = GenerateImportanceRays(mRssTree, number, rays); 
     72                  result = GenerateImportanceRays(mRssTree, number, rays); 
    7773                } 
    7874                break; 
    7975                 
    8076  default: 
    81                 result = Preprocessor::GenerateRays(number, sampleType, rays); 
    82   } 
    83  
     77        result = Preprocessor::GenerateRays(number, strategy, rays); 
     78  } 
     79   
    8480  //  rays.NormalizePdf(); 
    8581  Debug<<"done.\n"<<flush; 
     
    413409{ 
    414410  // now evaluate the ratios for the next pass 
    415 #define TIME_WEIGHT 0.5f 
     411#define TIME_WEIGHT 0.0f 
    416412  for (int i=0; i < distributions.size(); i++) { 
    417413        distributions[i]->mRatio = distributions[i]->mContribution/ 
     
    437433 
    438434  Randomize(0); 
     435 
     436  if (1) { 
     437        Exporter *exporter = Exporter::GetExporter("samples.wrl"); 
     438    exporter->SetFilled(); 
     439        Halton<4> halton; 
     440 
     441//      for (int i=1; i < 7; i++)  
     442//        cout<<i<<" prime= "<<FindPrime(i)<<endl; 
     443         
     444        Material mA, mB; 
     445        mA.mDiffuseColor = RgbColor(1, 0, 0); 
     446        mB.mDiffuseColor = RgbColor(0, 1, 0); 
     447         
     448        for (int i=0; i < 10000; i++) { 
     449          float r[4]; 
     450          halton.GetNext(r); 
     451          Vector3 v1 = UniformRandomVector(r[0], r[1]); 
     452          Vector3 v2 = UniformRandomVector(r[2], r[3]); 
     453 
     454          const float size =0.002f; 
     455          AxisAlignedBox3 box(v1-Vector3(size), v1+Vector3(size)); 
     456          exporter->SetForcedMaterial(mA); 
     457          exporter->ExportBox(box); 
     458          AxisAlignedBox3 box2(v2-Vector3(size), v2+Vector3(size)); 
     459 
     460          exporter->SetForcedMaterial(mB); 
     461          exporter->ExportBox(box2); 
     462        } 
     463        delete exporter; 
     464  } 
     465   
     466   
     467  cout<<"COMPUTATION THREAD="<<GetThread()->GetCurrentThreadId()<<endl<<flush; 
    439468   
    440469  // use ray buffer to export ray animation 
    441   const bool useRayBuffer = false; 
     470  const bool useRayBuffer = true; 
    442471   
    443472  vector<VssRayContainer> rayBuffer(50); 
     
    467496                mDistributions.push_back(new RssBasedDistribution(*this)); 
    468497 
    469  
    470         if (1) { 
    471                 //  mDistributions.push_back(new SpatialBoxBasedDistribution(*this)); 
    472                 //  mDistributions.push_back(new DirectionBasedDistribution(*this)); 
    473                 mDistributions.push_back(new ObjectDirectionBasedDistribution(*this)); 
    474                 //  mDistributions.push_back(new ReverseObjectBasedDistribution(*this)); 
    475                 mDistributions.push_back(new ObjectBasedDistribution(*this)); 
    476                 mDistributions.push_back(new ReverseViewSpaceBorderBasedDistribution(*this)); 
    477         } else { 
    478                 mDistributions.push_back(new GlobalLinesDistribution(*this)); 
    479         } 
     498   
     499  if (1) { 
     500        mDistributions.push_back(new SpatialBoxBasedDistribution(*this)); 
     501//      //  mDistributions.push_back(new DirectionBasedDistribution(*this)); 
     502//      mDistributions.push_back(new ObjectDirectionBasedDistribution(*this)); 
     503//      //  mDistributions.push_back(new ReverseObjectBasedDistribution(*this)); 
     504//      mDistributions.push_back(new ObjectBasedDistribution(*this)); 
     505//      mDistributions.push_back(new ReverseViewSpaceBorderBasedDistribution(*this)); 
     506  } else { 
     507        mDistributions.push_back(new GlobalLinesDistribution(*this)); 
     508        mDistributions.push_back(new SpatialBoxBasedDistribution(*this)); 
     509  } 
    480510   
    481511  if (mLoadInitialSamples) { 
     
    500530                if (mDistributions[i]->mType != SamplingStrategy::RSS_BASED_DISTRIBUTION) 
    501531                  GenerateRays(mInitialSamples/count, 
    502                                                                          mDistributions[i]->mType, 
    503                                                                         rays); 
    504  
     532                                           *mDistributions[i], 
     533                                          rays); 
     534           
    505535        } else { 
    506536          int rayType = SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION; 
     
    511541                  rayType = SamplingStrategy::DIRECTION_BASED_DISTRIBUTION; 
    512542          cout<<"Generating rays..."<<endl; 
    513           GenerateRays(mRssSamplesPerPass, rayType, rays); 
     543 
     544          Preprocessor::GenerateRays(mRssSamplesPerPass, rayType, rays); 
    514545        } 
    515546         
    516547         
    517548        cout<<"Casting initial rays..."<<endl<<flush; 
    518         CastRays(rays, mVssRays, true); 
     549        CastRays(rays, mVssRays, true, pruneRays); 
    519550 
    520551        ExportObjectRays(mVssRays, 1546); 
     
    578609        // cull viewcells with PVS > median (0.5f) 
    579610        //mViewCellsManager->SetValidityPercentage(0, 0.5f);  
    580         mViewCellsManager->SetValidityPercentage(0, 1.0f);  
     611        //      mViewCellsManager->SetValidityPercentage(0, 1.0f);  
    581612        Debug<<"Valid viewcells after set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
    582613 
     
    584615        mViewCellsManager->PrintPvsStatistics(mStats); 
    585616 
     617 
     618        if (0) { 
     619          char str[64]; 
     620          sprintf(str, "tmp/v-"); 
     621           
     622          // visualization 
     623          const bool exportRays = true; 
     624          const bool exportPvs = true; 
     625          ObjectContainer objects; 
     626          mViewCellsManager->ExportSingleViewCells(objects, 
     627                                                                                           1000, 
     628                                                                                           false, 
     629                                                                                           exportPvs, 
     630                                                                                           exportRays, 
     631                                                                                           10000, 
     632                                                                                           str); 
     633        } 
     634           
    586635        ComputeRenderError(); 
    587636  } 
     637 
     638  //  return 1; 
    588639   
    589640  rssPass++; 
     
    618669        } 
    619670  } 
    620    
    621    
     671 
     672  // keep only rss 
     673  mDistributions.resize(1); 
    622674 
    623675  while (1) { 
     
    646698                if (mDistributions[i]->mRatio != 0) { 
    647699                  GenerateRays(int(mRssSamplesPerPass*mDistributions[i]->mRatio), 
    648                                            mDistributions[i]->mType, 
     700                                           *mDistributions[i], 
    649701                                           rays); 
    650702                   
    651703                  rays.NormalizePdf((float)rays.size()); 
    652704                   
    653                   CastRays(rays, tmpVssRays, true); 
     705                  CastRays(rays, tmpVssRays, true, pruneRays); 
    654706                  castRays += (int)rays.size(); 
    655                    
     707 
     708                  cout<<"Computing sample contributions..."<<endl<<flush; 
     709 
    656710#if ADD_RAYS_IN_PLACE  
    657711                  mDistributions[i]->mContribution = 
     
    661715                        mViewCellsManager->ComputeSampleContributions(tmpVssRays, false, true); 
    662716#endif 
     717                  cout<<"done."<<endl; 
    663718                } 
    664719 
    665720                mDistributions[i]->mTime = TimeDiff(t1, GetTime()); 
    666                 mDistributions[i]->mRays = (int)rays.size(); 
     721                //              mDistributions[i]->mRays = (int)rays.size(); 
     722                mDistributions[i]->mRays = (int)tmpVssRays.size() + 1; 
    667723                //              mStats<<"#RssRelContrib"<<endl<<contributions[0]/nrays[0]<<endl; 
    668724                vssRays.insert(vssRays.end(), tmpVssRays.begin(), tmpVssRays.end() ); 
     
    686742          cout<<"Generating rays..."<<endl; 
    687743 
    688           GenerateRays(mRssSamplesPerPass, rayType, rays); 
     744          Preprocessor::GenerateRays(mRssSamplesPerPass, rayType, rays); 
    689745          cout<<"done."<<endl; 
    690746 
     
    843899 
    844900 
    845   if (useRayBuffer&& mExportRays && mUseImportanceSampling) { 
     901  if (useRayBuffer && mExportRays && mUseImportanceSampling) { 
    846902        char filename[64]; 
    847903        sprintf(filename, "rss-rays-i.x3d"); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.h

    r1785 r1867  
    125125  /** Redefininition of the get sample rays method from the preprocessor */ 
    126126  int 
    127   GenerateRays( 
    128                            const int number, 
    129                            const int sampleType, 
    130                            SimpleRayContainer &rays 
    131                            ); 
    132  
     127  GenerateRays(const int number, 
     128                           SamplingStrategy &strategy, 
     129                           SimpleRayContainer &rays); 
     130   
    133131}; 
    134132 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp

    r1841 r1867  
    352352        leaf->dirBBox.Initialize(); 
    353353        leaf->dirBBox.SetMin(2, 0.0f); 
    354         leaf->dirBBox.SetMax(2, 1.0f); 
     354        leaf->dirBBox.SetMax(2, 0.0f); 
    355355        mRoots[0] = leaf; 
    356356        stat.nodes = 1; 
     
    12371237  node->axis = axis; 
    12381238  node->position = info.position; 
    1239   //  node->bbox = box; 
    1240   //  node->dirBBox = GetDirBBox(leaf); 
    1241    
     1239 
     1240  node->bbox = GetBBox(leaf); 
     1241  node->dirBBox = GetDirBBox(leaf); 
    12421242   
    12431243  RssTreeLeaf *back = new RssTreeLeaf(node, info.raysBack); 
     
    12451245 
    12461246   
    1247   // update halton generator 
    1248   back->halton.index = leaf->halton.index; 
    1249   front->halton.index = leaf->halton.index; 
    12501247   
    12511248  // replace a link from node's parent 
     
    18101807  int leaves = 0; 
    18111808 
     1809  for (int i=0; i < mRoots.size(); i++) 
     1810        UpdateImportance(mRoots[i]); 
     1811   
    18121812  while (!tstack.empty()) { 
    18131813    RssTreeNode *node = tstack.top(); 
    1814     tstack.pop(); 
    1815                  
     1814        tstack.pop(); 
     1815         
    18161816    if (node->IsLeaf()) { 
    18171817          leaves++; 
    18181818          RssTreeLeaf *leaf = (RssTreeLeaf *)node; 
    1819           UpdatePvsSize(leaf); 
     1819          // updated above already 
     1820          //      UpdatePvsSize(leaf); 
    18201821           
    18211822          sumPvsSize += leaf->GetPvsSize(); 
     
    18411842          sumImportance += imp; 
    18421843           
    1843  
    18441844        } else { 
    18451845          RssTreeInterior *in = (RssTreeInterior *)node; 
    1846           // both nodes for directional splits 
    18471846          tstack.push(in->front); 
    18481847          tstack.push(in->back); 
     
    18581857  stat.avgWeightedRayContribution = sumWeightedRayContribution/(float)sumRays; 
    18591858  stat.rayRefs = (int)sumRays; 
    1860 } 
    1861  
    1862  
     1859   
     1860} 
     1861 
     1862void 
     1863RssTree::UpdateImportance( 
     1864                                                  RssTreeNode *node) 
     1865{ 
     1866  if (node->IsLeaf()) { 
     1867        UpdatePvsSize((RssTreeLeaf *)node); 
     1868  } else { 
     1869        RssTreeInterior *in = (RssTreeInterior *)node; 
     1870        UpdateImportance(in->front); 
     1871        UpdateImportance(in->back); 
     1872        node->mImportance = in->front->mImportance + in->back->mImportance; 
     1873  } 
     1874} 
     1875 
     1876// generate a single ray described by parameters in a unit cube 
     1877void 
     1878RssTree::GenerateRay(float *params, SimpleRayContainer &rays) 
     1879{ 
     1880  RssTreeNode *node; 
     1881   
     1882  // works only with single root now! 
     1883  node = mRoots[0]; 
     1884   
     1885  while (!node->IsLeaf()) { 
     1886        RssTreeInterior *in = (RssTreeInterior *)node; 
     1887        // decide whether to go left or right 
     1888        int axis = in->axis; 
     1889        float pos = in->GetRelativePosition();  
     1890         
     1891        float r = in->back->GetImportance()/(in->back->GetImportance() + in->front->GetImportance()); 
     1892         
     1893        //      cout<<"axis="<<axis<<" pos="<<pos<<endl; 
     1894        //      cout<<GetBBox(in)<<endl; 
     1895        //      cout<<GetDirBBox(in)<<endl; 
     1896        //      cout<<"********"<<endl; 
     1897         
     1898        if (params[axis] < r) { 
     1899          node = in->back; 
     1900          params[axis] = params[axis] / pos; 
     1901        } else { 
     1902          node = in->front; 
     1903          params[axis] = (params[axis] - pos) / ( 1.0f - pos); 
     1904        } 
     1905  } 
     1906 
     1907  //  cout<<params[0]<<" "<<params[1]<<" "<<params[2]<<" "<<params[3]<<" "<<params[4]<<endl; 
     1908   
     1909  GenerateLeafRay(params, rays, node->bbox, node->dirBBox); 
     1910} 
    18631911 
    18641912int 
     
    18671915                                          SimpleRayContainer &rays) 
    18681916{ 
     1917 
     1918   
     1919 
     1920 
    18691921  stack<RssTreeNode *> tstack; 
    18701922  PushRoots(tstack); 
     
    21952247  for (int i=0; i < numberOfRays; i++) { 
    21962248        //      Debug<<i<<flush; 
    2197  
    2198         Vector3 origin, direction; 
    2199         Vector3 dirVector; 
    2200          
    2201         Vector3 pVector; 
    2202         Vector3 dVector; 
    2203          
    2204         bool useHalton = false; 
    2205          
    2206          
    2207         if (useHalton) { 
    2208           // generate a random 5D vector 
    2209           pVector = Vector3(leaf->halton.GetNumber(1), 
    2210                                                 leaf->halton.GetNumber(2), 
    2211                                                 leaf->halton.GetNumber(3)); 
    2212            
    2213           dVector = Vector3(leaf->halton.GetNumber(4), 
    2214                                                 leaf->halton.GetNumber(5), 
    2215                                                 0.0f); 
    2216            
    2217           leaf->halton.GenerateNext(); 
    2218         } else { 
    2219           pVector = Vector3(RandomValue(0.0f, 1.0f), 
    2220                                                 RandomValue(0.0f, 1.0f), 
    2221                                                 RandomValue(0.0f, 1.0f)); 
    2222            
    2223           dVector = Vector3(RandomValue(0.0f, 1.0f), 
    2224                                                 RandomValue(0.0f, 1.0f), 
    2225                                                 0.0f); 
    2226         } 
    2227          
    2228         origin = box.GetPoint(pVector); 
    2229         dirVector = dirBox.GetPoint(dVector); 
    2230          
    2231         direction = VssRay::GetInvDirParam(dirVector.x, dirVector.y); 
    2232          
    2233         //      float dist = Min(avgLength*0.5f, Magnitude(GetBBox(leaf).Size())); 
    2234         float dist = 0.0f; 
    2235         float minT, maxT; 
    2236  
    2237         // compute interection of the ray with the box 
    2238 #if 1 
    2239         if (box.ComputeMinMaxT(origin, direction, &minT, &maxT) && minT < maxT) 
    2240           dist = (maxT + 1e-2*boxSize); 
    2241 #else 
    2242         dist = 0.5f*boxSize; 
    2243 #endif 
    2244  
    2245         origin += direction*dist; 
    2246          
    2247 #if 0 
    2248         static int counter = 0; 
    2249         //      Debug<<counter++<<flush; 
    2250  
    2251         if (counter > 10374968) { 
    2252           Debug<<"size="<<rays.size()<<endl; 
    2253           Debug<<"capacity="<<rays.capacity()<<endl; 
    2254           Debug<<"o="<<origin<<endl; 
    2255           Debug<<"d="<<direction<<endl; 
    2256         } 
    2257 #endif   
    2258         //Debug<<"dir vector.x="<<dirVector.x<<"direction'.x="<<atan2(direction.x, direction.y)<<endl; 
    2259         rays.push_back(SimpleRay(origin, direction)); 
    2260         //      Debug<<endl; 
    2261          
     2249        float r[5]; 
     2250         
     2251        r[0] = RandomValue(0.0f, 1.0f); 
     2252        r[1] = RandomValue(0.0f, 1.0f); 
     2253        r[2] = RandomValue(0.0f, 1.0f); 
     2254        r[3] = RandomValue(0.0f, 1.0f); 
     2255        r[4] = RandomValue(0.0f, 1.0f); 
     2256         
     2257        GenerateLeafRay(r, rays, box, dirBox); 
    22622258  } 
    22632259 
     
    22692265        rays[i].mPdf = p; 
    22702266  } 
     2267} 
     2268 
     2269void 
     2270RssTree::GenerateLeafRay( 
     2271                                                 float *params, 
     2272                                                 SimpleRayContainer &rays, 
     2273                                                 const AxisAlignedBox3 &box, 
     2274                                                 const AxisAlignedBox3 &dirBBox 
     2275                                                 ) 
     2276{ 
     2277  Vector3 origin = bbox.GetPoint(Vector3(params[0], params[1], params[2])); 
     2278  Vector3 dirVector = dirBBox.GetPoint(Vector3(params[3], params[4], 0.0f)); 
     2279  Vector3 direction = VssRay::GetInvDirParam(dirVector.x, dirVector.y); 
     2280   
     2281  //    float dist = Min(avgLength*0.5f, Magnitude(GetBBox(leaf).Size())); 
     2282  float dist = 0.0f; 
     2283  float minT, maxT; 
     2284   
     2285  float boxSize = Magnitude(bbox.Size()); 
     2286  // compute interection of the ray with the box 
     2287#if 1 
     2288  if (bbox.ComputeMinMaxT(origin, direction, &minT, &maxT) && minT < maxT) 
     2289        dist = (maxT + 1e-2*boxSize); 
     2290#else 
     2291  dist = 0.5f*boxSize; 
     2292#endif 
     2293   
     2294  origin += direction*dist; 
     2295   
     2296   
     2297  //Debug<<"dir vector.x="<<dirVector.x<<"direction'.x="<<atan2(direction.x, direction.y)<<endl; 
     2298  rays.push_back(SimpleRay(origin, direction)); 
    22712299} 
    22722300 
     
    23782406          Vector3 dVector; 
    23792407 
    2380           bool useHalton = true; 
    2381            
    2382           if (useHalton) { 
    2383                 // generate a random 5D vector 
    2384                 pVector = Vector3(leaf->halton.GetNumber(1), 
    2385                                                   leaf->halton.GetNumber(2), 
    2386                                                   leaf->halton.GetNumber(3)); 
    2387                  
    2388                 dVector = Vector3(leaf->halton.GetNumber(4), 
    2389                                                   leaf->halton.GetNumber(5), 
    2390                                                   0.0f); 
    2391                  
    2392                 leaf->halton.GenerateNext(); 
    2393           } else { 
    2394                 pVector = Vector3(RandomValue(0.0f, 1.0f), 
    2395                                                   RandomValue(0.0f, 1.0f), 
    2396                                                   RandomValue(0.0f, 1.0f)); 
    2397                  
    2398                 dVector = Vector3(RandomValue(0.0f, 1.0f), 
    2399                                                   RandomValue(0.0f, 1.0f), 
    2400                                                   0.0f); 
    2401           } 
     2408          pVector = Vector3(RandomValue(0.0f, 1.0f), 
     2409                                                RandomValue(0.0f, 1.0f), 
     2410                                                RandomValue(0.0f, 1.0f)); 
     2411           
     2412          dVector = Vector3(RandomValue(0.0f, 1.0f), 
     2413                                                RandomValue(0.0f, 1.0f), 
     2414                                                0.0f); 
     2415           
    24022416           
    24032417          origin = box.GetPoint(pVector); 
     
    26252639          if (node->IsLeaf()) { 
    26262640                RssTreeLeaf *leaf = (RssTreeLeaf *)node; 
    2627                 //              prunned += PruneRaysRandom(leaf, ratio); 
     2641                // prunned += PruneRaysRandom(leaf, ratio); 
    26282642                prunned += PruneRaysContribution(leaf, ratio); 
    26292643          } else { 
     
    26532667{ 
    26542668 
    2655  
     2669  float param[5]; 
     2670 
     2671  for (int i=0; i < numberOfRays; i++) { 
     2672        halton.GetNext(param); 
     2673        GenerateRay(param, rays); 
     2674  } 
     2675 
     2676  return rays.size(); 
     2677   
    26562678  vector<RssTreeLeaf *> leaves; 
    26572679 
     
    28642886         
    28652887        // $$  
    2866         sumWeights = (float)leaf->mTotalRays; 
     2888        // sumWeights = leaf->mTotalRays; 
    28672889 
    28682890        //$$ test 30.11. 2006  
     
    28902912 
    28912913float 
    2892 RssTreeLeaf::GetImportance()  const 
     2914RssTreeNode::GetImportance()  const 
    28932915{ 
    28942916  //  return sqr(mImportance); 
     
    31293151 
    31303152 
    3131 } 
     3153 
     3154 
     3155 
     3156} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.h

    r1832 r1867  
    137137public: 
    138138 
     139 
    139140  struct RayInfo 
    140141  { 
     
    162163        } 
    163164 
     165         
    164166#define USE_ORIGIN 1 
    165167         
     
    312314  AxisAlignedBox3 dirBBox; 
    313315 
    314    
     316  // evaluated importance of this node 
     317  float mImportance; 
     318 
    315319  inline RssTreeNode(RssTreeInterior *p); 
    316320 
     
    328332  } 
    329333 
    330    
     334  float GetImportance() const; 
     335 
    331336         
    332337}; 
     
    339344{ 
    340345public: 
    341   // plane in local modelling coordinates 
     346  // plane in world coordinates 
    342347  float position; 
    343348 
     
    359364  virtual int GetAccessTime() { 
    360365    return lastAccessTime; 
     366  } 
     367 
     368  float GetRelativePosition() const { 
     369        if (axis < 3) 
     370          return (position - bbox.Min(axis))/bbox.Size(axis); 
     371        else 
     372          return (position - dirBBox.Min(axis-3))/dirBBox.Size(axis-3); 
    361373  } 
    362374 
     
    423435         
    424436  bool mValidPvs; 
    425   float mImportance; 
    426    
    427   HaltonSequence halton; 
    428  
     437   
    429438  Beam mBeam; 
    430439   
     
    490499  } 
    491500 
    492   float GetImportance() const; 
    493501   
    494502  float GetSqrRayContribution() const { 
     
    621629   
    622630   
    623    
     631  Halton<5> halton; 
     632   
     633 
    624634  ///////////////////////////// 
    625635  // Basic properties 
     
    10861096  PushRoots(stack<RayTraversalData> &st, RssTreeNode::RayInfo &info) const; 
    10871097 
    1088  
     1098  void 
     1099  UpdateImportance( 
     1100                                   RssTreeNode *node); 
     1101 
     1102  void 
     1103  GenerateRay(float *params, SimpleRayContainer &rays); 
     1104 
     1105  void 
     1106  GenerateLeafRay( 
     1107                                  float *params, 
     1108                                  SimpleRayContainer &rays, 
     1109                                  const AxisAlignedBox3 &box, 
     1110                                  const AxisAlignedBox3 &dirBBox 
     1111                                  ); 
     1112         
    10891113}; 
    10901114 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r1824 r1867  
    2222int 
    2323SamplingStrategy::GenerateSamples(const int number, 
    24                                                                   SimpleRayContainer &rays) const 
     24                                                                  SimpleRayContainer &rays) 
    2525{ 
    2626        SimpleRay ray; 
     
    6767 
    6868 
    69 bool ObjectBasedDistribution::GenerateSample(SimpleRay &ray) const 
     69bool ObjectBasedDistribution::GenerateSample(SimpleRay &ray) 
    7070{ 
    7171        Vector3 origin, direction;  
     
    9999 
    100100 
    101 bool ObjectDirectionBasedDistribution::GenerateSample(SimpleRay &ray) const 
     101bool ObjectDirectionBasedDistribution::GenerateSample(SimpleRay &ray) 
    102102{        
    103103        Vector3 origin, direction;  
     
    127127 
    128128 
    129 bool DirectionBasedDistribution::GenerateSample(SimpleRay &ray) const 
     129bool DirectionBasedDistribution::GenerateSample(SimpleRay &ray) 
    130130{        
    131131        Vector3 origin, direction;  
     
    147147 
    148148 
    149 bool DirectionBoxBasedDistribution::GenerateSample(SimpleRay &ray) const 
     149bool DirectionBoxBasedDistribution::GenerateSample(SimpleRay &ray) 
    150150{ 
    151151        Vector3 origin, direction;  
     
    171171 
    172172 
    173 bool SpatialBoxBasedDistribution::GenerateSample(SimpleRay &ray) const 
    174 { 
    175         Vector3 origin, direction;  
    176  
    177         mPreprocessor.mViewCellsManager->GetViewPoint(origin); 
    178         direction = mPreprocessor.mKdTree->GetBox().GetRandomPoint() - origin; 
    179         //cout << "z"; 
    180         const float c = Magnitude(direction); 
    181  
    182         if (c <= Limits::Small)  
    183                 return false; 
    184  
    185         const float pdf = 1.0f; 
    186  
    187         direction *= 1.0f / c; 
    188         ray = SimpleRay(origin, direction, pdf); 
    189  
    190         return true; 
    191 } 
    192  
    193  
    194 bool ReverseObjectBasedDistribution::GenerateSample(SimpleRay &ray) const 
     173bool SpatialBoxBasedDistribution::GenerateSample(SimpleRay &ray) 
     174{ 
     175  Vector3 origin, direction;  
     176 
     177  float r[6]; 
     178  halton.GetNext(r); 
     179  mPreprocessor.mViewCellsManager->GetViewPoint(origin, Vector3(r[0],r[1],r[2])); 
     180   
     181  direction = mPreprocessor.mKdTree->GetBox().GetRandomPoint(Vector3(r[3], 
     182                                                                                                                                         r[4], 
     183                                                                                                                                         r[5]) 
     184                                                                                                                                         ) - origin; 
     185  //cout << "z"; 
     186  const float c = Magnitude(direction); 
     187   
     188  if (c <= Limits::Small)  
     189        return false; 
     190   
     191  const float pdf = 1.0f; 
     192   
     193  direction *= 1.0f / c; 
     194  ray = SimpleRay(origin, direction, pdf); 
     195   
     196  return true; 
     197} 
     198 
     199 
     200bool ReverseObjectBasedDistribution::GenerateSample(SimpleRay &ray) 
    195201{ 
    196202        Vector3 origin, direction;  
     
    230236 
    231237 
    232 bool ViewCellBorderBasedDistribution::GenerateSample(SimpleRay &ray) const 
     238bool ViewCellBorderBasedDistribution::GenerateSample(SimpleRay &ray) 
    233239{ 
    234240        Vector3 origin, direction;  
     
    274280 
    275281#if 0 
    276 bool ObjectsInteriorDistribution::GenerateSample(SimpleRay &ray) const 
     282bool ObjectsInteriorDistribution::GenerateSample(SimpleRay &ray) 
    277283{ 
    278284        Vector3 origin, direction;  
     
    306312 
    307313 
    308 bool ReverseViewSpaceBorderBasedDistribution::GenerateSample(SimpleRay &ray) const 
     314bool ReverseViewSpaceBorderBasedDistribution::GenerateSample(SimpleRay &ray) 
    309315{ 
    310316        Vector3 origin, direction;  
     
    344350 
    345351 
    346 bool ViewSpaceBorderBasedDistribution::GenerateSample(SimpleRay &ray) const 
     352bool ViewSpaceBorderBasedDistribution::GenerateSample(SimpleRay &ray) 
    347353{ 
    348354        Vector3 origin, direction;  
     
    381387 
    382388bool 
    383 RssBasedDistribution::GenerateSample(SimpleRay &ray) const 
     389RssBasedDistribution::GenerateSample(SimpleRay &ray) 
    384390{ 
    385391  return false; 
     
    388394 
    389395bool 
    390 GlobalLinesDistribution::GenerateSample(SimpleRay &ray) const 
    391 { 
    392         Vector3 origin, termination, direction;  
    393          
    394         origin = mPreprocessor.mViewCellsManager->GetViewSpaceBox().GetRandomSurfacePoint(); 
    395  
    396         termination = mPreprocessor.mViewCellsManager->GetViewSpaceBox().GetRandomSurfacePoint(); 
     396GlobalLinesDistribution::GenerateSample(SimpleRay &ray)  
     397{ 
     398  Vector3 origin, termination, direction;  
     399 
     400  float radius = 0.5f*Magnitude(mPreprocessor.mViewCellsManager->GetViewSpaceBox().Size()); 
     401  Vector3 center = mPreprocessor.mViewCellsManager->GetViewSpaceBox().Center(); 
     402 
     403  const int tries = 1000; 
     404  int i; 
     405  for (i=0; i < tries; i++) { 
     406        float r[4]; 
     407        halton.GetNext(r); 
     408         
     409#if 0 
     410#if 0 
     411        r[0] = RandomValue(0,1); 
     412        r[1] = RandomValue(0,1); 
     413        r[2] = RandomValue(0,1); 
     414        r[3] = RandomValue(0,1); 
     415#else 
     416        r[0] = mHalton.GetNumber(1); 
     417        r[1] = mHalton.GetNumber(2); 
     418        r[2] = mHalton.GetNumber(3); 
     419        r[3] = mHalton.GetNumber(4); 
     420        mHalton.GenerateNext(); 
     421#endif 
     422#endif 
     423        origin = center + (radius*UniformRandomVector(r[0], r[1])); 
     424        termination = center + (radius*UniformRandomVector(r[2], r[3])); 
    397425         
    398426        direction = termination - origin; 
    399427        //direction = UniformRandomVector(); 
    400  
    401  
    402         // $$ jb the pdf is yet not correct for all sampling methods! 
    403         const float c = Magnitude(direction); 
    404         if (c <= Limits::Small)  
    405                 return false; 
    406          
    407          
    408         direction *= 1.0f / c; 
    409          
    410         // a little offset 
    411         //      origin += direction * 0.001f; 
    412          
    413         // $$ jb the pdf is yet not correct for all sampling methods! 
    414         const float pdf = 1.0f; 
    415  
     428         
     429         
     430        // $$ jb the pdf is yet not correct for all sampling methods! 
     431        const float c = Magnitude(direction); 
     432        if (c <= Limits::Small)  
     433          return false; 
     434         
     435        direction *= 1.0f / c; 
     436 
     437        // check if the ray intersects the view space box 
     438        static Ray ray; 
     439        ray.Init(origin, direction, Ray::LOCAL_RAY);     
     440         
     441        float tmin, tmax; 
     442        if (mPreprocessor.mViewCellsManager-> 
     443                GetViewSpaceBox().ComputeMinMaxT(ray, &tmin, &tmax) && (tmin < tmax)) 
     444          break; 
     445  } 
     446   
     447  if (i!=tries) { 
     448        // $$ jb the pdf is yet not correct for all sampling methods! 
     449        const float pdf = 1.0f; 
     450         
     451         
    416452        ray = SimpleRay(origin, direction, pdf); 
    417453        ray.mType = Ray::GLOBAL_RAY; 
    418454        return true; 
    419 } 
    420  
    421 } 
    422  
    423  
     455  } 
     456   
     457  return false; 
     458} 
     459 
     460} 
     461 
     462 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h

    r1824 r1867  
    22#define _SamplingStategy_H__ 
    33 
     4#include "Halton.h" 
    45 
    56namespace GtpVisibilityPreprocessor { 
     
    4647        */ 
    4748 
    48         virtual int GenerateSamples(const int number, SimpleRayContainer &rays) const; 
    49  
    50 private: 
    51  
    52         virtual bool GenerateSample(SimpleRay &ray) const = 0; 
     49        virtual int GenerateSamples(const int number, SimpleRayContainer &rays); 
     50 
     51private: 
     52 
     53        virtual bool GenerateSample(SimpleRay &ray) = 0; 
    5354 
    5455public: 
     
    7778 
    7879private: 
    79   virtual bool GenerateSample(SimpleRay &ray) const; 
     80  virtual bool GenerateSample(SimpleRay &ray); 
    8081}; 
    8182 
     
    9192 
    9293private: 
    93   virtual bool GenerateSample(SimpleRay &ray) const; 
     94  virtual bool GenerateSample(SimpleRay &ray); 
    9495}; 
    9596 
     
    103104         } 
    104105private: 
    105         virtual bool GenerateSample(SimpleRay &ray) const; 
     106        virtual bool GenerateSample(SimpleRay &ray); 
    106107}; 
    107108 
     
    115116  } 
    116117private: 
    117   virtual bool GenerateSample(SimpleRay &ray) const; 
     118  virtual bool GenerateSample(SimpleRay &ray); 
    118119}; 
    119120 
     
    128129            
    129130private: 
    130            virtual bool GenerateSample(SimpleRay &ray) const; 
     131           virtual bool GenerateSample(SimpleRay &ray); 
    131132}; 
    132133 
     
    135136{ 
    136137 public: 
    137          SpatialBoxBasedDistribution(const Preprocessor &preprocessor): 
    138            SamplingStrategy(preprocessor){ 
    139            mType = DIRECTION_BOX_BASED_DISTRIBUTION; 
    140          } 
    141             
    142 private: 
    143            virtual bool GenerateSample(SimpleRay &ray) const; 
     138  Halton<6> halton; 
     139  SpatialBoxBasedDistribution(const Preprocessor &preprocessor): 
     140        SamplingStrategy(preprocessor){ 
     141        mType = DIRECTION_BOX_BASED_DISTRIBUTION; 
     142  } 
     143   
     144private: 
     145           virtual bool GenerateSample(SimpleRay &ray); 
    144146}; 
    145147 
     
    154156          
    155157private: 
    156          virtual bool GenerateSample(SimpleRay &ray) const; 
     158         virtual bool GenerateSample(SimpleRay &ray); 
    157159}; 
    158160 
     
    167169          
    168170private: 
    169          virtual bool GenerateSample(SimpleRay &ray) const; 
     171         virtual bool GenerateSample(SimpleRay &ray); 
    170172}; 
    171173 
     
    180182 
    181183 
    182   virtual int GenerateSamples(const int number, SimpleRayContainer &ray) const { 
     184  virtual int GenerateSamples(const int number, SimpleRayContainer &ray) { 
    183185        // TBD!!! 
    184186        return 0; 
     
    186188 
    187189private: 
    188   virtual bool GenerateSample(SimpleRay &ray) const; 
     190  virtual bool GenerateSample(SimpleRay &ray); 
    189191   
    190192}; 
     
    197199        SamplingStrategy(preprocessor) {} 
    198200   
    199   virtual bool GenerateSample(SimpleRay &ray) const; 
     201  virtual bool GenerateSample(SimpleRay &ray); 
    200202}; 
    201203 
     
    203205{ 
    204206public: 
     207  Halton<4> halton; 
     208  //HaltonSequence mHalton; 
     209 
    205210  GlobalLinesDistribution(const Preprocessor &preprocessor): 
    206                 SamplingStrategy(preprocessor) { 
    207                 mType = GLOBAL_LINES_DISTRIBUTION; 
    208         } 
    209    
    210   virtual bool GenerateSample(SimpleRay &ray) const; 
     211        SamplingStrategy(preprocessor) { 
     212        mType = GLOBAL_LINES_DISTRIBUTION; 
     213  } 
     214   
     215  virtual bool GenerateSample(SimpleRay &ray); 
    211216}; 
    212217 
     
    221226         SamplingStrategy(preprocessor) {} 
    222227          
    223          virtual bool GenerateSample(SimpleRay &ray) const; 
     228         virtual bool GenerateSample(SimpleRay &ray); 
    224229}; 
    225230*/ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Triangle3.cpp

    r1715 r1867  
    2929 
    3030 
    31 int Triangle3::CastRay(const Ray &ray, float &t, const float nearestT, Vector3 &normal) const 
     31int 
     32Triangle3::CastRay(const Ray &ray, 
     33                                   float &t, 
     34                                   const float nearestT, 
     35                                   Vector3 &normal) const 
    3236{ 
    3337#if 0 
     
    3842 
    3943        Polygon3 poly(vertices); 
     44 
     45        int dummy = poly.CastRay(ray, t, nearestT); 
     46        normal = poly.GetNormal(); 
    4047         
    41         int dummy = poly.CastRay(ray, t, nearestT); 
    42  
    43         cout << "polyversion code: " << dummy << " t: " << t << " nearestT: " << nearestT << endl; 
     48        //      cout << "polyversion code: " << dummy << " t: " << t << " nearestT: " << nearestT << endl; 
    4449        return dummy; 
    4550#endif 
     
    8388    t = a / b; 
    8489 
    85     if (t < 0.0) // ray goes away from triangle 
     90    if (t <= Limits::Small) // ray goes away from triangle 
    8691        { 
    87                 return Ray::NO_INTERSECTION; // => no intersect 
     92          return Ray::INTERSECTION_OUT_OF_LIMITS; 
    8893        } 
    8994        // already found nearer intersection 
     
    113118        const float wu = DotProd(w, u); 
    114119    const float wv = DotProd(w, v); 
    115     const float D = uv * uv - uu * vv; 
     120 
     121 
     122        const float D = uv * uv - uu * vv; 
    116123 
    117124    // get and test parametric coords 
    118125    const float s = (uv * wv - vv * wu) / D; 
    119126 
    120     if ((s < 0.0) || (s > 1.0)) // pt is outside triangle 
     127    if ((s < -Limits::Small) || (s > 1.0f + Limits::Small)) // pt is outside triangle 
    121128        {        
    122129        return Ray::NO_INTERSECTION; 
     
    125132        const float s2 = (uv * wu - uu * wv) / D; 
    126133 
    127     if ((s2 < 0.0) || ((s + s2) > 1.0)) // pt is outside triangle 
     134    if ((s2 < -Limits::Small) || ((s + s2) > 1.0f + Limits::Small)) // pt is outside triangle 
    128135        {        
    129136        return Ray::NO_INTERSECTION; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Vector3.cpp

    r1832 r1867  
    196196#define USE_HALTON 0 
    197197 
     198 
    198199Vector3 
    199200UniformRandomVector() 
     
    209210   r2 = RandomValue(0.0f, 1.0f); 
    210211#endif 
    211     
     212 
     213   return UniformRandomVector(r1, r2); 
     214} 
     215 
     216Vector3 
     217UniformRandomVector(const float r1, const float r2) 
     218{ 
    212219   float cosTheta = 1.0f - 2*r1; 
    213          float sinTheta = sqrt(1 - sqr(cosTheta)); 
    214          float fi = 2.0f*M_PI*r2; 
    215    
    216          Vector3 dir(sinTheta*sin(fi), 
    217                                                          cosTheta, 
    218                                                          sinTheta*cos(fi)); 
    219    
    220   return dir; 
     220   float sinTheta = sqrt(1 - sqr(cosTheta)); 
     221   float fi = 2.0f*M_PI*r2; 
     222    
     223   Vector3 dir(sinTheta*sin(fi), 
     224                           cosTheta, 
     225                           sinTheta*cos(fi)); 
     226    
     227   return dir; 
     228} 
     229 
     230 
     231Vector3 
     232CosineRandomVector(const Vector3 &normal) 
     233{ 
     234  //  float r1 = RandomValue(0.0f, 1.0f); 
     235  //  float r2 = RandomValue(0.0f, 1.0f); 
     236  float r1, r2; 
     237   
     238#if USE_HALTON  
     239  halton2.GetNext(r1, r2); 
     240#else 
     241   r1 = RandomValue(0.0f, 1.0f); 
     242   r2 = RandomValue(0.0f, 1.0f); 
     243#endif 
     244 
     245   float theta = 2.0f*M_PI*r2; 
     246   float radius = sqrt(r1); 
     247   float x = radius*sin(theta); 
     248   float z = radius*cos(theta); 
     249   float y = sqrt(1.0f - x*x - z*z); 
     250 
     251    
     252   Vector3 dir(x, 
     253                           y, 
     254                           z); 
     255    
     256    
     257   //  return Normalize(dir); 
     258    
     259   Matrix4x4 m = RotationVectorsMatrix( 
     260                                                                           normal, 
     261                                                                           Vector3(0,1,0)); 
     262   Matrix4x4 mi = Invert(m); 
     263   m = m*RotationVectorsMatrix( 
     264                                                           Vector3(0,1,0), 
     265                                                           Normalize(dir))*mi; 
     266   
     267   return TransformNormal(m, normal); 
    221268} 
    222269 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Vector3.h

    r1579 r1867  
    233233  friend inline int EpsilonEqualV3(const Vector3 &v1, const Vector3 &v2); 
    234234 
     235  friend Vector3 CosineRandomVector(const Vector3 &normal); 
    235236  friend Vector3 UniformRandomVector(const Vector3 &normal); 
    236237  friend Vector3 UniformRandomVector(); 
    237    
     238 
     239  friend Vector3 
     240  UniformRandomVector(const float r1, const float r2); 
     241 
     242  friend Vector3 UniformRandomVector(const Vector3 &normal, 
     243                                                                         const float r1, 
     244                                                                         const float r2 
     245                                                                         ); 
     246 
    238247 
    239248}; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1843 r1867  
    3434                                           myless<vector<ViewCell *>::value_type> > TraversalQueue; 
    3535 
    36 int ViewCell::sMailId = 10000;//2147483647; 
    37 int ViewCell::sReservedMailboxes = 1; 
     36  int ViewCell::sMailId = 10000;//2147483647; 
     37  int ViewCell::sReservedMailboxes = 1; 
    3838 
    3939 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r1842 r1867  
    284284        //-- mailing stuff 
    285285 
    286         static void NewMail(const int reserve = 1)  
    287         { 
    288                 sMailId += sReservedMailboxes; 
    289                 sReservedMailboxes = reserve; 
    290         } 
    291  
    292         void Mail() { mMailbox = sMailId; } 
    293         bool Mailed() const { return mMailbox == sMailId; } 
    294  
    295         void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } 
    296         bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; } 
    297  
    298         int IncMail() { return ++ mMailbox - sMailId; } 
     286  //    static void NewMail(const int reserve = 1)  
     287  //    { 
     288  //            sMailId += sReservedMailboxes; 
     289  //            sReservedMailboxes = reserve; 
     290  //    } 
     291 
     292  //    void Mail() { mMailbox = sMailId; } 
     293  //    bool Mailed() const { return mMailbox == sMailId; } 
     294 
     295  //    void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } 
     296  //    bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; } 
     297 
     298  //    int IncMail() { return ++ mMailbox - sMailId; } 
    299299 
    300300 
    301301        // last mail id -> warning not thread safe! 
    302302        // both mailId and mailbox should be unique for each thread!!! 
    303         static int sMailId; 
    304         static int sReservedMailboxes; 
     303 
     304  //static int sMailId; 
     305  //static int sReservedMailboxes; 
    305306         
    306307  int GetFilteredPvsSize() const { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1846 r1867  
    15001500bool ViewCellsManager::GetViewPoint(Vector3 &viewPoint) const 
    15011501{ 
    1502         viewPoint = mViewSpaceBox.GetRandomPoint(); 
    1503         return true; 
     1502  viewPoint = mViewSpaceBox.GetRandomPoint(); 
     1503  return true; 
     1504} 
     1505 
     1506bool ViewCellsManager::GetViewPoint(Vector3 &viewPoint, const Vector3 &params) const 
     1507{ 
     1508  viewPoint = mViewSpaceBox.GetRandomPoint(params); 
     1509  return true; 
    15041510} 
    15051511 
     
    15321538 
    15331539 
    1534 float ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays, 
    1535                                                                                                    const bool addRays,                                                                   
    1536                                                                                                    const bool storeViewCells) 
    1537 { 
    1538         // view cells not yet constructed 
    1539         if (!ViewCellsConstructed()) 
    1540                 return 0.0f; 
    1541          
    1542         float sum = 0.0f; 
    1543         VssRayContainer::const_iterator it, it_end = rays.end(); 
    1544          
    1545         for (it = rays.begin(); it != it_end; ++ it)  
    1546         { 
    1547                 sum += ComputeSampleContribution(*(*it), addRays, storeViewCells); 
    1548         } 
    1549  
    1550         return sum; 
     1540float 
     1541ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays, 
     1542                                                                                         const bool addRays, 
     1543                                                                                         const bool storeViewCells) 
     1544{ 
     1545  // view cells not yet constructed 
     1546  if (!ViewCellsConstructed()) 
     1547        return 0.0f; 
     1548   
     1549  float sum = 0.0f; 
     1550  VssRayContainer::const_iterator it, it_end = rays.end(); 
     1551   
     1552  for (it = rays.begin(); it != it_end; ++ it)  
     1553        { 
     1554          sum += ComputeSampleContribution(*(*it), addRays, storeViewCells); 
     1555        } 
     1556   
     1557  return sum; 
    15511558} 
    15521559 
     
    20062013 
    20072014float ViewCellsManager::ComputeSampleContribution(VssRay &ray, 
    2008                                                                                                                                                                                                         const bool addRays, 
    2009                                                                                                                                                                                                         const bool storeViewCells) 
    2010 { 
    2011         ViewCellContainer viewcells; 
    2012  
    2013         ray.mPvsContribution = 0; 
    2014         ray.mRelativePvsContribution = 0.0f; 
    2015  
    2016         static Ray hray; 
    2017         hray.Init(ray); 
    2018         //hray.mFlags |= Ray::CULL_BACKFACES; 
    2019         //Ray hray(ray); 
    2020  
    2021         float tmin = 0, tmax = 1.0; 
    2022  
    2023         if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 
    2024                 return 0; 
    2025  
    2026         Vector3 origin = hray.Extrap(tmin); 
    2027         Vector3 termination = hray.Extrap(tmax); 
    2028  
    2029         ViewCell::NewMail(); 
    2030  
    2031         //      if (ray.mPdf!=1.0f) 
    2032         //        cout<<ray.mPdf<<" "; 
    2033          
    2034          
    2035         // traverse the view space subdivision 
    2036         CastLineSegment(origin, termination, viewcells); 
    2037  
    2038         if (storeViewCells) 
     2015                                                                                                  const bool addRays, 
     2016                                                                                                  const bool storeViewCells) 
     2017{ 
     2018  ray.mPvsContribution = 0; 
     2019  ray.mRelativePvsContribution = 0.0f; 
     2020 
     2021  if (ray.mTerminationObject==NULL) 
     2022        return 0.0f; 
     2023   
     2024  ViewCellContainer viewcells; 
     2025   
     2026 
     2027 
     2028   
     2029  static Ray hray; 
     2030  hray.Init(ray); 
     2031  //hray.mFlags |= Ray::CULL_BACKFACES; 
     2032  //Ray hray(ray); 
     2033   
     2034  float tmin = 0, tmax = 1.0; 
     2035   
     2036  if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 
     2037        return 0; 
     2038   
     2039  Vector3 origin = hray.Extrap(tmin); 
     2040  Vector3 termination = hray.Extrap(tmax); 
     2041   
     2042  ViewCell::NewMail(); 
     2043   
     2044  //    if (ray.mPdf!=1.0f) 
     2045  //      cout<<ray.mPdf<<" "; 
     2046   
     2047   
     2048  // traverse the view space subdivision 
     2049  CastLineSegment(origin, termination, viewcells); 
     2050   
     2051  if (storeViewCells) 
    20392052        {       // copy viewcells memory efficiently 
    2040                 ray.mViewCells.reserve(viewcells.size()); 
    2041                 ray.mViewCells = viewcells; 
    2042         } 
    2043          
    2044         Intersectable *obj = GetIntersectable(ray, true); 
    2045                  
    2046         ViewCellContainer::const_iterator it = viewcells.begin(); 
    2047          
    2048         for (; it != viewcells.end(); ++ it)  
    2049         { 
    2050                 ViewCell *viewcell = *it; 
    2051                 // tests if view cell is in valid view space 
    2052                 if (viewcell->GetValid()) 
    2053                 { 
    2054                         float contribution; 
    2055  
    2056                         if (ray.mTerminationObject)  
    2057                         {                        
    2058                                 if (viewcell->GetPvs().GetSampleContribution(obj, 
    2059                                         ray.mPdf, 
    2060                                         contribution)) 
    2061                                 { 
    2062                                         ++ ray.mPvsContribution; 
    2063                                         ray.mRelativePvsContribution += contribution; 
    2064                                         // $$ test of different contribution measure 
    2065                                         //                                      ray.mRelativePvsContribution += 1.0f/(viewcell->GetPvs().GetSize() + 10.0f); 
    2066  
    2067                                 } 
     2053          ray.mViewCells.reserve(viewcells.size()); 
     2054          ray.mViewCells = viewcells; 
     2055        } 
     2056   
     2057  Intersectable *obj = GetIntersectable(ray, true); 
     2058   
     2059  ViewCellContainer::const_iterator it = viewcells.begin(); 
     2060   
     2061  for (; it != viewcells.end(); ++ it)  
     2062        { 
     2063          ViewCell *viewcell = *it; 
     2064          // tests if view cell is in valid view space 
     2065          if (viewcell->GetValid()) 
     2066                { 
     2067                  float contribution; 
     2068                   
     2069                  if (ray.mTerminationObject)  {                         
     2070                        if (viewcell->GetPvs().GetSampleContribution(obj, 
     2071                                                                                                                 ray.mPdf, 
     2072                                                                                                                 contribution)) { 
     2073                          ++ ray.mPvsContribution; 
    20682074                        } 
    20692075                         
     2076                        ray.mRelativePvsContribution += contribution; 
     2077                        // $$ test of different contribution measure 
     2078                        //                                      ray.mRelativePvsContribution += 1.0f/(viewcell->GetPvs().GetSize() + 10.0f); 
     2079                         
     2080                  } 
     2081                   
    20702082#if SAMPLE_ORIGIN_OBJECTS 
    2071  
    2072                         // for directional sampling it is important to count only contributions 
    2073                         // made in one direction!!! 
     2083                   
     2084                  // for directional sampling it is important to count only contributions 
     2085                  // made in one direction!!! 
    20742086                        // the other contributions of this sample will be counted for the oposite ray! 
    20752087 
     
    20962108                        { 
    20972109                                // if view point is valid, add new object to the pvs 
    2098                                 if (ray.mTerminationObject) 
     2110                          if (ray.mTerminationObject) 
    20992111                                {  
    2100                                         viewcell->GetPvs().AddSample(obj, ray.mPdf); 
     2112                                  viewcell->GetPvs().AddSample(obj, ray.mPdf); 
    21012113                                }                                
    21022114#if SAMPLE_ORIGIN_OBJECTS 
     
    60356047 
    60366048#define PVS_ADD_DIRTY 1 
    6037 float VspOspViewCellsManager::ComputeSampleContribution(VssRay &ray, 
    6038                                                                                                                 const bool addRays, 
    6039                                                                                                                 const bool storeViewCells) 
    6040 { 
    6041         ViewCellContainer viewcells; 
    6042  
    6043         ray.mPvsContribution = 0; 
    6044         ray.mRelativePvsContribution = 0.0f; 
     6049float 
     6050VspOspViewCellsManager::ComputeSampleContribution(VssRay &ray, 
     6051                                                                                                  const bool addRays, 
     6052                                                                                                  const bool storeViewCells) 
     6053{ 
     6054  ray.mPvsContribution = 0; 
     6055  ray.mRelativePvsContribution = 0.0f; 
     6056   
     6057  if (ray.mTerminationObject==NULL) 
     6058        return 0.0f; 
     6059   
     6060  ViewCellContainer viewcells; 
     6061   
    60456062 
    60466063        static Ray hray; 
     
    60756092 
    60766093        Intersectable *terminationObj = GetIntersectable(ray, true); 
     6094 
     6095#if SAMPLE_ORIGIN_OBJECTS 
    60776096        Intersectable *originObj = GetIntersectable(ray, false); 
     6097#endif 
    60786098 
    60796099        for (; it != viewcells.end(); ++ it)  
     
    60876107                        if (terminationObj)  
    60886108                        { 
    6089                                 // todo: maybe not correct for kd node pvs 
    6090                                 if (viewcell->GetPvs().GetSampleContribution( 
    6091                                                         terminationObj, ray.mPdf, contribution)) 
     6109                          // todo: maybe not correct for kd node pvs 
     6110                          if (viewcell->GetPvs().GetSampleContribution( 
     6111                                                                                                                   terminationObj, ray.mPdf, contribution)) 
    60926112                                { 
    6093                                         ++ ray.mPvsContribution; 
     6113                                  ++ ray.mPvsContribution; 
    60946114                                } 
    6095  
    6096                                 ray.mRelativePvsContribution += contribution; 
     6115                           
     6116                          ray.mRelativePvsContribution += contribution; 
    60976117                        } 
    60986118 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1845 r1867  
    307307        */ 
    308308        virtual bool GetViewPoint(Vector3 &viewPoint) const; 
     309   
     310  virtual bool GetViewPoint(Vector3 &viewPoint, const Vector3 &params) const; 
    309311 
    310312        /** Returns true if this view point is in the valid view space. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h

    r1824 r1867  
    1414class KdNode; 
    1515 
    16 #define ABS_CONTRIBUTION_WEIGHT 0.5f 
     16#define ABS_CONTRIBUTION_WEIGHT 0.9f 
    1717 
    1818class VssRay { 
     
    3030  }; 
    3131 
     32  // Id of the generating SimpleRay 
     33  int mGeneratingRayId; 
     34   
    3235  static int mailID; 
    3336  int mMailbox; 
     
    6972  // sum of relative ray contributions per object 
    7073  float mRelativePvsContribution; 
    71  
    7274 
    7375  // weighted contribution to the pvs (based on the pass the ray was casted at) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/default.env

    r1824 r1867  
    2525#filename ../data/soda/soda.dat 
    2626#filename ../data/test1/test2.x3d 
    27 #filename ../data/soda/soda5.dat 
     27# filename ../data/soda/soda5.dat 
    2828#filename ../data/PowerPlant/ppsection1/part_a/g0.ply 
    2929#filename ../data/PowerPlant/ppsection1/part_b/g0.ply 
     
    5353        pvsRenderErrorSamples 0 
    5454#       pvsRenderErrorSamples 1000 
    55         quitOnFinish true 
     55        quitOnFinish false 
    5656        computeVisibility true 
    5757 
     
    9090RssPreprocessor { 
    9191        samplesPerPass 1000 
    92         initialSamples 3000000 
    93         vssSamples 100000000 
    94         vssSamplesPerPass 5000000 
     92        initialSamples 1000000 
     93        vssSamples 20000000 
     94        vssSamplesPerPass 1000000 
    9595        useImportanceSampling true 
    9696 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1842 r1867  
    4848using namespace GtpVisibilityPreprocessor; 
    4949 
    50 Preprocessor *preprocessor = NULL; 
    5150GlRendererWidget *rendererWidget = NULL; 
    5251 
     
    266265        PreprocessorThread *pt; 
    267266 
    268  
    269267#if USE_QT 
    270268        // create a qt application first (must be created before any opengl widget ...) 
     
    280278#endif 
    281279 
     280        preprocessor->SetThread(pt); 
     281         
    282282        bool guiSupported = false; 
    283283 
  • GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro

    r1832 r1867  
    107107InternalRayCaster.cpp IntelRayCaster.cpp \ 
    108108RayCaster.cpp PreprocessorFactory.cpp GvsPreprocessor.cpp \ 
    109 Trackball.cpp ObjExporter.cpp SubdivisionCandidate.cpp QtGlViewer.cpp 
     109Trackball.cpp ObjExporter.cpp SubdivisionCandidate.cpp QtGlViewer.cpp Mailable.cpp 
    110110 
    111111 
  • GTP/trunk/Lib/Vis/Preprocessing/src/run_test2

    r1829 r1867  
    4141 
    4242$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    43  -rss_use_importance+ -rss_update_subdivision+ -rss_split=hybrid -hybrid_depth=10 \ 
     43 -rss_use_importance+ -rss_use_rss_tree+ -rss_update_subdivision+ -rss_split=hybrid -hybrid_depth=10 \ 
    4444 -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-i-combined-update-ccb12-nn.log \ 
    4545-preprocessor_histogram_file=$PREFIX-i-combined-update-ccb12-nn.hlog 
     
    6060 
    6161 
    62 # $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    63 # -rss_use_importance+ -rss_use_rss_tree- -view_cells_filter_max_size=1 \ 
    64 #  -preprocessor_stats=$PREFIX-i-mixed-b1.log \ 
    65 #  -preprocessor_histogram_file=$PREFIX-i-mixed-b1.hlog 
     62$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     63 -rss_use_importance+ -rss_use_rss_tree- -view_cells_filter_max_size=1 \ 
     64 -preprocessor_stats=$PREFIX-i-mixed-b1-n.log \ 
     65 -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n.hlog 
    6666 
    6767 
Note: See TracChangeset for help on using the changeset viewer.