Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1557 - in trunk: DynLT Model/Groups/private


Chronological Thread 
  • From: brownlee@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1557 - in trunk: DynLT Model/Groups/private
  • Date: Thu, 26 Jul 2007 03:09:29 -0600 (MDT)

Author: brownlee
Date: Thu Jul 26 03:09:28 2007
New Revision: 1557

Modified:
   trunk/DynLT/DynLTCGT.cc
   trunk/Model/Groups/private/ParticleCGT.cc
   trunk/Model/Groups/private/ParticleCGT.h
Log:
fixed a bug whith big spheres and shadows

Modified: trunk/DynLT/DynLTCGT.cc
==============================================================================
--- trunk/DynLT/DynLTCGT.cc     (original)
+++ trunk/DynLT/DynLTCGT.cc     Thu Jul 26 03:09:28 2007
@@ -17,16 +17,16 @@
 void DynLTCGT::intersect(const RenderContext& context,
         RayPacket& packet) const
 {
-       bool common_origin = false;
+       bool common_origin = true;
+       if (packet.getDepth() > 0)
+               common_origin = false;
        if (packet.end() - packet.begin() < 2)
                common_origin = true;
        else
        {
                for (int i = packet.begin() + 1; i < packet.end(); i++)
-               common_origin &= (packet.getOrigin(i-1) == 
packet.getOrigin(i));
+               common_origin &= ((packet.getOrigin(i-1) -  
packet.getOrigin(i))).length() < 0.0001;
        }
-       if (packet.getDepth() > 0)
-               common_origin = false;
        //test for common origin
        if (common_origin)
        {

Modified: trunk/Model/Groups/private/ParticleCGT.cc
==============================================================================
--- trunk/Model/Groups/private/ParticleCGT.cc   (original)
+++ trunk/Model/Groups/private/ParticleCGT.cc   Thu Jul 26 03:09:28 2007
@@ -76,15 +76,11 @@
 
 
 ParticleGrid::ParticleGrid(const ParticleNRRD& pnrrd, Real radius, int ridx,
-                           int cidx_, Material* mat, TexCoordMapper* 
texMappern) :
-  cidx(cidx_),
-  firstTime(true),
-  mutex("generic build mutex"),
-  barrier("CGT build barrier"),
-  buildQueue_resize_mutex("build queue resize mutex"),
-   buildQueue_was_resized(false), texMapper(texMappern)
+                           int cidx_, Material* mat, TexCoordMapper* 
texMappern)
 {
-  unsigned int nparticles = pnrrd.getNParticles();
+ cidx = cidx_;
+ firstTime = true; 
+ unsigned int nparticles = pnrrd.getNParticles();
   cout << "Loading " << nparticles << " particles into ParticleGrid\n";
   unsigned int nvars = pnrrd.getNVars();
   _nvars = pnrrd.getNVars();
@@ -147,10 +143,6 @@
 ParticleGrid::ParticleGrid(int nvarsn, int cidx_, int ridx_) :
   cidx(cidx_),
   firstTime(true),
-  mutex("generic build mutex"),
-  barrier("CGT build barrier"),
-  buildQueue_resize_mutex("build queue resize mutex"),
-  buildQueue_was_resized(false),
   _nvars(nvarsn)
 {
 
@@ -160,8 +152,7 @@
   oldN[0] = oldN[1] = oldN[2] = -1;
 
 
-  particles = NULL;// TODO: FILL PARTICLES FROM CURRGROUP
-  tsparticles = NULL; //TODO:FILL ME
+ // particles = NULL;// TODO: FILL PARTICLES FROM CURRGROUP
 
   //vtx = vtx_;  //TODO: What are these??? gathered from particle data
   //vars = 0;
@@ -244,53 +235,39 @@
   currGroup = group;
 
   //load tsparticles with data from currGroup
-  CDTimeSteppedParticles* tmpTSParticles = &tsparticlesA;//new 
CDTimeSteppedParticles();
   //CDParticle* tmpParticles = //new CDParticle[currGroup->size()];
   //cout << hex << tmpParticles << endl;
-  tmpTSParticles->vtxs = currGroup->size();
-  if (tmpTSParticles->vtxs > MAX_PARTICLES) {
+  vtxs = currGroup->size();
+  if (vtxs > MAX_PARTICLES) {
     cerr << "WARNING: ParticleCGT:  number of particles over maximum size\n";
-    tmpTSParticles->vtxs = MAX_PARTICLES;
+    vtxs = MAX_PARTICLES;
   }
-  tmpTSParticles->max_radius = 0;
-  for(int i = 0; i < tmpTSParticles->vtxs; i++) {
+  max_radius = 0;
+  for(int i = 0; i < vtxs; i++) {
     float radius = ((Sphere*)currGroup->get(i))->getRadius();
     Vector position = ((Sphere*)currGroup->get(i))->getCenter();
-    if (radius > tmpTSParticles->max_radius)
-      tmpTSParticles->max_radius = radius;
+    if (radius > max_radius)
+      max_radius = radius;
     //cout << &tmpParticles[i] << endl;
-    tmpTSParticles->particles[i].sphere = set44(radius, position.z(), 
position.y(),
+    particles[i].sphere = set44(radius, position.z(), position.y(),
                                                 position.x());
     //cout << "sphere position: " << position.x() << " " << position.y() << 
" " << position.z() << endl;
-    tmpTSParticles->particles[i].data = set44(currData[i][3], currData[i][2],
+    particles[i].data = set44(currData[i][3], currData[i][2],
                                               currData[i][1], 
currData[i][0]);
-    tmpTSParticles->particles[i].index = i;
+    particles[i].index = i;
   }
 
   //tmpTSParticles->particles = tmpParticles;
-  tsparticles = tmpTSParticles;
   //TODO: set these values for range culling in the dataset
-  tsparticles->vars_max = set4(FLT_MAX);
-  tsparticles->vars_min = set4(-FLT_MAX);
-  tsparticles->inv_prange = tsparticles->inv_vrange = 
accurateReciprocal(sub4(tsparticles->vars_max, tsparticles->vars_min));
-  max_radius = tmpTSParticles->max_radius;
+   vars_max = set4(FLT_MAX);
+   vars_min = set4(-FLT_MAX);
+   inv_prange =  inv_vrange = accurateReciprocal(sub4( vars_max,  vars_min));
   //inv_prange
   //inv_vrange
   //vars_max
   //vars_min
   //max_radius
 
-  if (tsparticles)
-    {
-      particles = &tsparticles->particles[0];
-      vtxs = tsparticles->vtxs;
-    }
-  else
-    {
-      vtxs = 0;
-    max_radius = 0;
-    }
-
   //static bool firstTime = true;
 
   vector<CellData>& myVector = cellVector;
@@ -338,8 +315,8 @@
   //cout << "tmep: " <<tmep.f[0] << tmep.f[1] << tmep.f[2] << endl;
 
 
-      //bounds = tsparticles->bounds; // TODO: compute bounds from currGroup?
-      //max_radius = tsparticles->max_radius;
+      //bounds =  bounds; // TODO: compute bounds from currGroup?
+      //max_radius =  max_radius;
 //   }
   sse_t epsilon = mul4(bounds.diameter(), set4(8e-3f));
   bounds.min = sub4(bounds.min, epsilon);
@@ -416,7 +393,7 @@
     }
     myCell = &myVector[0];
     
-#if !defined(MACRO_CELLS)
+#if defined(MACRO_CELLS)
 
     const int start_z = 0;
     const int end_z = oldN[2];
@@ -646,10 +623,10 @@
           temp_dv[i] = mul4(dir4[V][i],invDirK);
         }
 
-      sse_t minDu_t = temp_du[0];
-      sse_t minDv_t = temp_dv[0];
-      sse_t maxDu_t = temp_du[0];
-      sse_t maxDv_t = temp_dv[0];
+      sse_t minDu_t = temp_du[ray.begin()];
+      sse_t minDv_t = temp_dv[ray.begin()];
+      sse_t maxDu_t = temp_du[ray.begin()];
+      sse_t maxDv_t = temp_dv[ray.begin()];
 
       for (int i=ray.begin()+1;i<ray.end();i++)
         {
@@ -750,8 +727,10 @@
 
   //Thiago's implementation:
   if (DK == +1) {
+       s_furthest_k = _mm_minus_infty;
     int b = (ray.begin() + 3) & (~3);
     int e = ray.end() & (~3);
+       //compte hit position along k to find furthest k slice, furthest k = 
origin + dir*t;
     if (b == e) {
       float curr_k = ((float4&)s_furthest_k)[0];
       for(int i=ray.begin();i<ray.end();i++) {
@@ -764,11 +743,12 @@
       int i = ray.begin();
       // Do the non aligned in front
       if (i < b) {
+       assert((b-4) >= 0);
         s_furthest_k = add4(load44(&ray.getOrigin(b-4,K)),
                             mul4(load44(&ray.getMinT(b-4)), 
                                  load44(&ray.getDirection(b-4,K))));
         for(int j=0; j<i&4; ++j)
-          ((float4&)s_furthest_k)[j] = ((float4&)s_furthest_k)[3];
+          ((float4&)s_furthest_k)[j] = ((float4&)s_furthest_k)[3]; //Carson: 
.. why is this done?
       }
       // Do the aligned in the middle
       for(i=b; i<e; i+=4)
@@ -783,12 +763,13 @@
           curr_k = max(curr_k, ray.getOrigin(b,K) + 
                        ray.getMinT(i)*ray.getDirection(i,K));
         }
-        ((float4&)s_furthest_k)[0] = curr_k;
+        s_furthest_k = set4(curr_k);
       }
     }
   }
 
-  else {
+  else { //DK == -1
+       s_furthest_k = _mm_infty;
     int b = (ray.begin() + 3) & (~3);
     int e = ray.end() & (~3);
     if (b == e) {
@@ -822,11 +803,19 @@
           curr_k = min(curr_k, ray.getOrigin(b,K) + 
                        ray.getMinT(i)*ray.getDirection(i,K));
         }
-        ((float4&)s_furthest_k)[0] = curr_k;
+        s_furthest_k = set4(curr_k);
       }
     }
   }
 
+   if ( DK == +1 )
+    // Adjust furthest k (in world space)
+     s_furthest_k = add4( s_furthest_k, set4( max_radius ) );
+   else
+     // Adjust furthest k (in world space)
+     s_furthest_k = sub4( s_furthest_k, set4( max_radius ) );
+
+
 
   float k1;
   if (DK == +1)
@@ -1315,6 +1304,8 @@
                    ((float4&)s_furthest_k)[0] = curr_k;
                  }
                }
+               // Adjust furthest k (in world space)
+                s_furthest_k = add4( s_furthest_k, set4( max_radius ) );
 
                k1 = min(k1,(max4f(s_furthest_k) - ((float4&)bounds.min)[K]) 
* scaleN.f[K]);
           } else {
@@ -1361,6 +1352,7 @@
                    ((float4&)s_furthest_k)[0] = curr_k;
                  }
                }
+               s_furthest_k = sub4( s_furthest_k, set4( max_radius ) );
 
                k1 = max(k1,(min4f(s_furthest_k) - ((float4&)bounds.min)[K]) 
* scaleN.f[K]);
               }
@@ -1471,7 +1463,18 @@
   //   }
   // else
   //   cout << count <<"  ";
-  traverse<false, true, false>(packet, context);
+       bool common_origin = true;
+        if (packet.end() - packet.begin() < 2)
+                common_origin = true;
+        else
+        {
+                for (int i = packet.begin() + 1; i < packet.end(); i++)
+                common_origin &= (packet.getOrigin(i-1) == 
packet.getOrigin(i));
+        }
+        if (packet.getDepth() > 0)
+                common_origin = false;
+  if (common_origin)
+        traverse<false, true, false>(packet, context);
 }
 
 std::ostream &operator<< (std::ostream &o, const Box4 &v) {

Modified: trunk/Model/Groups/private/ParticleCGT.h
==============================================================================
--- trunk/Model/Groups/private/ParticleCGT.h    (original)
+++ trunk/Model/Groups/private/ParticleCGT.h    Thu Jul 26 03:09:28 2007
@@ -36,25 +36,18 @@
 
 namespace Manta
 {
+       // bounding box
   struct MANTA_ALIGN(16) Box4: public AlignedAllocator<Box4>
   {
-    sse_t min, max;  //NO, it goes 0,x,y,z.  the first one is the unused 
one... 0,1,2 floats are the xyz.  3 is undefined?
+    sse_t min, max;  //stored as xyz0
     sse_t diameter() const { return sub4(max,min); }
     void extend(sse_t sphere) {
       sse_union s;
       s.sse = sphere;
-      //TODO: optimiize this ugly code
-      //TODO: I think it is infact 
       sse_t sMin = sub4(s.sse, set4(s.f[3])); // sphere min = position - 
radius
       sse_t sMax = add4(s.sse, set4(s.f[3])); // sphere max = position + 
radius
       min = min4(min, sMin);
       max = max4(max, sMax);
-      /*
-        sse_t mask = cmp4_lt(sMin, min);
-        min = or4((mask, sMin), andnot4(mask, min));
-        mask = cmp4_gt(sMax, max);
-        max = or4((mask, sMax), andnot4(mask, max));
-      */
     }
     void setEmpty()
     {
@@ -62,6 +55,8 @@
       max = set44(-FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX);
     }
   };
+  
+  //particle with sphere data
   struct MANTA_ALIGN(16) CDParticle : public AlignedAllocator<CDParticle>
   {   
     sse_t sphere;  // x,y,z,r  (postion, radius)
@@ -69,26 +64,25 @@
     int index;  //index in currGroup
   };
 
-
-  struct MANTA_ALIGN(16) CDTimeSteppedParticles : public 
AlignedAllocator<CDTimeSteppedParticles>
-  {
-    Box4 bounds;
-    sse_t inv_vrange;
-    sse_t inv_prange;
-    sse_t vars_max;
-    sse_t vars_min;
-    CDParticle particles[MAX_PARTICLES];
-    int vtxs;
-    float max_radius;
-  };
-
   std::ostream &operator<< (std::ostream &o, const Box4 &v);
+  
+  struct CellData {
+         vector<CDParticle> particles;
+  };
 
   struct ParticleGrid : public AccelerationStructure,
                         public AlignedAllocator<ParticleGrid>,
-                       public LitMaterial, public TexCoordMapper
+                       public LitMaterial,  public TexCoordMapper
   {
-    Box4 bounds;
+         Box4 bounds;
+         sse_t inv_vrange;
+         sse_t inv_prange;
+         sse_t vars_max;
+         sse_t vars_min;
+         CDParticle particles[MAX_PARTICLES];
+         int vtxs;
+         float max_radius;

     sse_union sse_M, sse_N;
     sse_t sse_one_over_N;
     sse_union diam,  // diameter of grid
@@ -109,11 +103,8 @@
     static float resolutionFactor;
 
     float splitLength; //above this length we split packets.
-    CDTimeSteppedParticles tsparticlesA;
-    CDTimeSteppedParticles* tsparticles;
-    CDParticle* particles;
     
-    int vtxs;
+   
     sse_t dmin, dmax;
     sse_t vmin, vmax;
     
@@ -122,21 +113,13 @@
     {
       cidx = new_cidx;
     }
-    mutable float max_radius;
 
-    void extendBoundsBySphere(int i,Box4 &bounds) const
+    void extendBoundsBySphere(int i,Box4 &bounds)
     {
       const sse_t sphere = getPos(i);
-      //    union {
-      //   float radius[4];
-      //   sse_t vec_radius;
-      // };
-    
-      // vec_radius = splat4(sphere,3);
-      //const float my_radius=radius[0];
       sse_union tmp;
       tmp.sse = sphere;
-      float my_radius = tmp.f[3]; // Carson: modified because radius[0] 
seems like x coord to me..
+      float my_radius = tmp.f[3]; 
       if (my_radius>max_radius)
         //this could be called fr
         max_radius=my_radius;
@@ -147,14 +130,14 @@
     {
       Box4 tmp; tmp.setEmpty(); extendBoundsBySphere(i,tmp); return tmp;
     }
-    sse_t &getPos(int i) const
+    sse_t &getPos(int i)
     {
       assert(particles);
       assert(0 <= i && i < vtxs);
       return particles[i].sphere;
     }
 
-    sse_t &getVar(int i) const
+    sse_t &getVar(int i)
     {
       assert(particles);
       assert(0 <= i && i < vtxs);
@@ -164,15 +147,6 @@
     // These are attached to the key strokes that change the valid ranges
     void setMinMaxVars(float* min=0, float* max=0)
     {
-      /*
-        cerr<<"enter:\n";
-        cerr<<"  dmin = "<<dmin<<'\n';
-        cerr<<"  dmax = "<<dmax<<'\n';
-        cerr<<'\n';
-        cerr<<"  vmin = "<<vmin<<'\n';
-        cerr<<"  vmax = "<<vmax<<'\n';
-        cerr<<'\n';
-      */
 
       if (min) {
         dmin=set44(min[0], min[1], min[2], min[3]);
@@ -189,17 +163,6 @@
         dmax=set4(FLT_MAX);
         vmax=set4(FLT_MAX);
       }
-
-      /*
-        cerr<<"exit:\n";
-        cerr<<"  dmin = "<<dmin<<'\n';
-        cerr<<"  dmax = "<<dmax<<'\n';
-        cerr<<'\n';
-        cerr<<"  vmin = "<<vmin<<'\n';
-        cerr<<"  vmax = "<<vmax<<'\n';
-        cerr<<'\n';
-        cerr<<'\n';
-      */
     }
 
     void getMinMaxValues(float min[8], float max[8]) {
@@ -210,18 +173,18 @@
       };
       //BBox bbox;
       //PreprocessContext tmp;
-      Box4 bounds = tsparticles->bounds;
-      bsse=bounds.min;
+      Box4 nbounds = bounds;
+      bsse=nbounds.min;
       min[0]=bf[0];
       min[1]=bf[1];
       min[2]=bf[2];
       min[3]=0.f;
 
-      bsse=bounds.max;
+      bsse=nbounds.max;
       max[0]=bf[0];
       max[1]=bf[1];
       max[2]=bf[2];
-      max[3]=tsparticles->max_radius;
+      max[3]=max_radius;
 
       // min/max (v0, v1, v2, v3)
       union {
@@ -229,33 +192,19 @@
         float vf[4];
       };
 
-      vsse=tsparticles->vars_min;
+      vsse=vars_min;
       min[4]=vf[0];
       min[5]=vf[1];
       min[6]=vf[2];
       min[7]=vf[3];
 
-      vsse=tsparticles->vars_max;
+      vsse=vars_max;
       max[4]=vf[0];
       max[5]=vf[1];
       max[6]=vf[2];
       max[7]=vf[3];
     }
-    
-
-    struct CellData {
-      vector<CDParticle> particles;
-    };
 
-#ifdef NUM_BUILD_THREADS
-    struct location_primitive {
-      int gridLocation;
-
-      int which_primitive;
-    };
-    vector<location_primitive*> buildQueues;
-    vector<int>buildQueue_sizes;
-#endif //NUM_BUILD_THREADS
     vector <CellData> cellVector;
 
     static void newFrame();
@@ -283,7 +232,7 @@
     }
 #ifdef MCRANGE_CULLING
     inline void set_mc(int x, int y, int z, int d, sse_t* minmax)
-    {l
+    {
         assert(x >= 0);
       assert(y >= 0);
       assert(z >= 0);
@@ -399,19 +348,13 @@
     int _nvars;  //number variables per element in nrrd file, used for dynlt 
scratchpad
    TexCoordMapper* texMapper; 
    bool firstTime;
-    SCIRun::Mutex mutex;
     int done_count;
-    SCIRun::Barrier barrier;
-    SCIRun::Mutex buildQueue_resize_mutex;
-    bool buildQueue_was_resized;
 
 #ifdef MACRO_CELLS
     int oldN_mc[3];
 #endif
     int oldN[3];
-    int buildQueueCapacity;
 
-    double startGlobalBuildTime;
   };
 
 } // end namespace Manta




  • [MANTA] r1557 - in trunk: DynLT Model/Groups/private, brownlee, 07/26/2007

Archive powered by MHonArc 2.6.16.

Top of page