Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1474 - in trunk: Model/Groups/private scenes


Chronological Thread 
  • From: brownlee@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1474 - in trunk: Model/Groups/private scenes
  • Date: Sun, 15 Jul 2007 23:59:55 -0600 (MDT)

Author: brownlee
Date: Sun Jul 15 23:59:54 2007
New Revision: 1474

Modified:
   trunk/Model/Groups/private/ParticleCGT.cc
   trunk/Model/Groups/private/ParticleCGT.h
   trunk/scenes/particleCGTTest.cc
Log:
merging Grid and CGT in ParticleCGT

Modified: trunk/Model/Groups/private/ParticleCGT.cc
==============================================================================
--- trunk/Model/Groups/private/ParticleCGT.cc   (original)
+++ trunk/Model/Groups/private/ParticleCGT.cc   Sun Jul 15 23:59:54 2007
@@ -18,16 +18,54 @@
 
 #define DISPLAY_BUILD_TIMES true
 
-// #define MAILBOXING
+#ifdef SSE
+#define unpacklo _mm_unpacklo_ps
+#define unpackhi _mm_unpackhi_ps
+inline float getMin(sse_t t)
+{
+  // a = (t0, t0, t1, t1)
+  sse_t a = unpacklo(t,t);
+  // b = (t2, t2, t3, t3)
+  sse_t b = unpackhi(t,t);
+  // c = (min(t0,t2), min(t0, t2), min(t1, t3), min(t1, t3))
+  sse_t c = min4(a, b);
+  // The movehl will move the high 2 values to the low 2 values.
+  // This will allow us to compare min(t0,t2) with min(t1, t3).
+  sse_t min = _mm_min_ss(c, _mm_movehl_ps(c, c));
+  // Return the first value.
+  return *((float*)&min);
+}
+inline float getMax(sse_t t)
+{
+  // a = (t0, t0, t1, t1)
+  sse_t a = unpacklo(t,t);
+  // b = (t2, t2, t3, t3)
+  sse_t b = unpackhi(t,t);
+  // c = (min(t0,t2), min(t0, t2), min(t1, t3), min(t1, t3))
+  sse_t c = max4(a, b);
+  // The movehl will move the high 2 values to the low 2 values.
+  // This will allow us to compare max(t0,t2) with max(t1, t3).
+  sse_t max = _mm_max_ss(c, _mm_movehl_ps(c, c));
+  // Return the first value.
+  return *((float*)&max);
+} 
+#else
+inline float getMin(const sse_t &v)
+{
+  const float *f = (const float *)&v;
+  float m = min(min(f[0],f[1]),min(f[2],f[3]));
+  if (m == 0.f) m = .001;
+  return m;
+}
+inline float getMax(const sse_t &v)
+{
+  const float *f = (const float *)&v;
+  float m = max(max(f[0],f[1]),max(f[2],f[3]));
+  if (m == 0.f) m = .001;
+  return m;
+}
+#endif //SSE
 
-#ifdef MAILBOXING
-struct mailbox_struct {
-  int rayID;
-  vector <int> mailbox;
-  char false_sharing_buffer[128];
-};
-vector <mailbox_struct> mailboxes;
-#endif
 
 void ParticleGrid::newFrame() {}
 
@@ -40,6 +78,340 @@
 
   if (currGroup)
     currGroup->preprocess(context);
+
+  if (tsparticles)
+    {
+      particles = tsparticles->particles;
+      vtxs = tsparticles->txs;
+    }
+  else
+    max_radius = 0;
+  //static bool firstTime = true;
+
+  vector<CellData> &restrict myVector = cellVector;
+  CellData * myCell;
+
+#ifdef MACRO_CELLS
+  static int oldN_mc[3] = {-1,-1,-1 };
+#endif
+  static int oldN[3] = { -1, -1, -1 };
+
+  static bool first_bounds_set = false;
+
+  //TODO: parallelize, bounds can just be computed from currGroup 
+  if (!tsparticles)
+    {
+      const int startSphere = 0;
+      const int endSphere = vtxs;
+      Box4 &restrict myBounds = bounds;
+      myBounds = getSphereBounds(startSphere);
+      for(int i = startSphere+1; i < endSphere; ++i)
+       extendBoundsBySphere(i, myBounds);
+    }
+  if (tsparticles)
+    {
+      bounds = tsparticles->bounds; // TODO: compute bounds from currGroup?
+      max_radius = tsparticles->max_radius;
+    }
+  sse_t epsilon = mul4(bounds.diameter(), set4(8e-3f));
+  bounds.min = sub4(bounds.min, epsilon);
+  bounds.max = add4(bounds.max, epsilon);
+  if(vtxs == 0)
+    return;
+  diam = bounds.diameter();
+  if (firstTime)
+    {
+#ifdef MACRO_CELLS
+      oldN_mc[0] = N_mc[0];
+      oldN_mc[1] = N_mc[1];
+      oldN_mc[2] = N_mc[2];
+#endif
+      oldN[0] = N[0];
+      oldN[1] = N[1];
+      oldN[2] = N[2];
+    }
+      float factor = resolutionFactor;
+    ALIGN(16)
+      float _diam[4];
+    for (int i=0; i < 4; ++i)
+      _diam[i] = ((float4&)diam)[i];//store4(_diam,diam);
+    N[0] = (int)(powf(factor * vtxs * _diam[0] * _diam[0] / (_diam[1] * 
_diam[2]), 1/3.));
+    N[1] = (int)(powf(factor * vtxs * _diam[1] * _diam[1] / (_diam[0] * 
_diam[2]), 1/3.));
+    N[2] = (int)(powf(factor * vtxs * _diam[2] * _diam[2] / (_diam[1] * 
_diam[0]), 1/3.));
+
+    N[0] = max(N[0],3);
+    N[1] = max(N[1],3);
+    N[2] = max(N[2],3);
+
+    M[0] = N[0]-1;
+    M[1] = N[1]-1;
+    M[2] = N[2]-1;
+
+#ifdef MACRO_CELLS
+    for (int i=0;i<3;i++)
+      {
+        N_mc[i] = ((N[i]-1) / MACRO_CELLS + 1);
+        M_mc[i] = N_mc[i] - 1;
+        N[i] = N_mc[i] * MACRO_CELLS;
+        M[i] = N[i] - 1;
+      }
+#endif
+
+ for (int k=0;k<3;k++)
+      {
+        const int ku = (k==2)?0:k+1;
+        const int kv = (k==0)?2:k-1;
+
+        pcDuStretch[k] = set4(_diam[k]/_diam[ku] * float(N[ku])/float(N[k]));
+        pcDvStretch[k] = set4(_diam[k]/_diam[kv] * float(N[kv])/float(N[k]));
+      }
+    sse_N = set44(0,N[2],N[1],N[0]);
+    sse_M = set44(0,M[2],M[1],M[0]);
+    sse_one_over_N = accurateReciprocal(sse_N);
+  
+    scale = accurateReciprocal(diam);
+    scaleN = mul4(sse_N,accurateReciprocal(diam));
+    scaleM = mul4(sse_M,accurateReciprocal(diam));
+  
+    //If we have a packet wider than X cells we will probably want to split 
it.
+    //lets assume that the values in scaleN are essentially all the same -- 
so use one.
+#define MAX_CELLS_WIDTH 3.0f
+    splitLength = MAX_CELLS_WIDTH / ((float4&)scaleN)[0];
+
+    if (myVector.size() < N[0]*N[1]*N[2]) {
+      int oldSize = myVector.size();
+      myVector.resize(N[0]*N[1]*N[2]);
+    }
+    myCell = &myVector[0];
+    
+#if !defined(MACRO_CELLS)
+    const int start_z = 0;
+    const int end_z = oldN[2];
+    for(int i = oldN[0]*oldN[1]*start_z;i<oldN[0]*oldN[1]*end_z;i++)
+      {
+       myCell[i].particles.resize(0);
+      }
+  for (int z = 0; z < oldN_mc[2]; ++z) {
+    for (int y = 0; y < oldN_mc[1]; ++y) {
+      for (int x=0; x < oldN_mc[0]; x++) {
+        int ofs = x+oldN_mc[0]*(y+oldN_mc[1]*(z));
+        if (cellVector_mc[ofs].ntris > 0) {
+          int id = (x*MACRO_CELLS) + 
+            oldN[0]*( y*MACRO_CELLS + 
+                      oldN[1]*z*MACRO_CELLS);
+          for (int mz=0;mz<MACRO_CELLS;mz++) {
+            for (int my=0;my<MACRO_CELLS;my++) {
+              for (int mx=0;mx<MACRO_CELLS;mx++) {
+               myCell[id].particles.resize(0);
+               id++;
+             }
+             id += oldN[0] - MACRO_CELLS;
+           }
+           id += oldN[0]*(oldN[1]-MACRO_CELLS);
+         }
+#ifdef MCRANGE_CULLING
+          // Reset the macrocells min/max
+          //   minmax[0] --> minimum (x, y, z, r)
+          //   minmax[1] --> maximum (x, y, z, r)
+          //   minmax[2] --> minimum (v0, v1, v2, v3)
+          //   minmax[3] --> maximum (v0, v1, v2, v3)
+          cellVector_mc[ofs].minmax[0]=set4(-FLT_MAX);
+          cellVector_mc[ofs].minmax[1]=set4(FLT_MAX);
+          cellVector_mc[ofs].minmax[2]=set4(-FLT_MAX);
+          cellVector_mc[ofs].minmax[3]=set4(FLT_MAX);
+#endif // MCRANGE_CULLING
+        }
+      }
+    }
+  }
+#endif // macro cell clear
+  const int startTri = 0; //TODO: parallelize
+  const int endTri = vtxs;
+  for (int i = startTri; i < endTri; i++) {
+    // Insert each sphere into exactly one grid cell, based upon the sphere's
+    // center
+    sse_t sphere=getPos(i);
+    sse_t center=mul4(scaleN,sub4(sphere,bounds.min));
+    union {
+      sse_int_t clampedAsInt;
+      int xyz[4];
+    };
+    clampedAsInt=cast4_fi(center);
+
+    int x=xyz[0];
+    int y=xyz[1];
+    int z=xyz[2];
+    int c=x + N[0]*(y + N[1]*z);
+//     for (int z=z0; z<=z1; z++) {
+//       for (int y=y0; y<=y1; y++) {
+//         for (int x=x0; x<=x1; x++) {
+//           ++c;
+//         }
+//         c += N[0] - (x1-x0+1);
+//       }
+//       c += N[0]*(N[1] - (y1-y0+1));
+//     }
+//   }
+#ifdef MACRO_CELLS
+  if (cellVector_mc.size() < N_mc[0]*N_mc[1]*N_mc[2])
+      cellVector_mc.resize(N_mc[0]*N_mc[1]*N_mc[2]);
+  const sse_t mr=set4(max_radius);
+  const sse_t scaled_mr=mul4(scaleN, mr);
+  const float local_max=((const float*)&scaled_mr)[0];
+  assert(local_max > 0);
+  const int max_radius_cellWidth = (int) ceil(local_max);
+
+  //I'm assuming the max radius is less than the size of a macrocell.
+  //otherwise, doing sphere_center is very very stupid.
+  assert(max_radius_cellWidth > 0 && max_radius_cellWidth <= MACRO_CELLS);
+
+  int iz_neg_offset = 0;
+  for (int iz = 0; iz<N_mc[2]; iz++) {
+    const int iz_pos_offset =  max_radius_cellWidth * (iz+1<N_mc[2]);
+    int iy_neg_offset = 0;
+    for (int iy = 0;iy<N_mc[1];iy++) {
+ const int iy_pos_offset =  max_radius_cellWidth * (iy+1<N_mc[1]);
+      int ix_neg_offset = 0;
+      for (int ix = 0;ix<N_mc[0];ix++) {
+        int count = 0;
+#ifdef MCRANGE_CULLING
+        sse_t minmax[4]={ set4(FLT_MAX), set4(-FLT_MAX),
+                          set4(FLT_MAX), set4(-FLT_MAX) };
+#endif // MCRANGE_CULLING
+
+        const int ix_pos_offset =  max_radius_cellWidth * (ix+1<N_mc[0]);
+
+        for (int mz = iz_neg_offset; mz < MACRO_CELLS + iz_pos_offset; mz++) 
{
+          for (int my = iy_neg_offset; my < MACRO_CELLS + iy_pos_offset; 
my++) {
+            int id = idx(ix*MACRO_CELLS+ix_neg_offset,
+                         iy*MACRO_CELLS+my,
+                         iz*MACRO_CELLS+mz);
+
+            for (int mx = ix_neg_offset; mx < MACRO_CELLS + ix_pos_offset; 
mx++)
+              {
+#ifdef MCRANGE_CULLING
+                int size=myVector[id].particles.size();
+                for (int p=0; p<size; ++p) {
+                  // Update min/max:  minmax[0] --> minimum (x, y, z, r)
+                  //                  minmax[1] --> maximum (x, y, z, r)
+                  //                  minmax[2] --> minimum (v0, v1, v2, v3)
+                  //                  minmax[3] --> maximum (v0, v1, v2, v3)
+                  minmax[0]=min4(minmax[0], 
myVector[id].particles[p].sphere);
+                  minmax[1]=max4(minmax[1], 
myVector[id].particles[p].sphere);
+                  minmax[2]=min4(minmax[2], myVector[id].particles[p].data);
+                  minmax[3]=max4(minmax[3], myVector[id].particles[p].data);
+                }
+
+                count += size;
+#else
+                count += myVector[id].particles.size();
+#endif // MCRANGE_CULLING
+                ++id;
+              }
+
+#if !defined(MCRANGE_CULLING)
+            if (count)
+              goto endMacrocell;
+#endif // !defined(MCRANGE_CULLING)
+          }
+        }
+
+#ifdef MCRANGE_CULLING
+        // Set macrocell counts and min/max
+        if (count)
+          set_mc(ix, iy, iz, count, minmax);
+        else {
+          // Empty macrocell:  set all minmax to [-FLT_MAX .. FLT_MAX]
+          minmax[0]=set4(-FLT_MAX);
+          minmax[1]=set4(FLT_MAX);
+          minmax[2]=set4(-FLT_MAX);
+          minmax[3]=set4(FLT_MAX);
+          set_mc(ix, iy, iz, 0, minmax);
+        }
+#else
+      endMacrocell:
+        set_mc(ix, iy, iz, count);
+#endif // MCRANGE_CULLING
+
+        ix_neg_offset = -max_radius_cellWidth;
+      }
+      iy_neg_offset = -max_radius_cellWidth;
+    }
+    iz_neg_offset = -max_radius_cellWidth;
+  }
+
+for (int iz = 0; iz<N_mc[2]; iz++) {
+      for (int iy = 0; iy<N_mc[1]; iy++) {
+#endif // NUM_BUILD_THREADS
+        for (int ix = 0;ix<N_mc[0];ix++) {
+          int count = 0;
+
+#ifdef MCRANGE_CULLING
+          sse_t minmax[4]={ set4(FLT_MAX), set4(-FLT_MAX),
+                            set4(FLT_MAX), set4(-FLT_MAX) };
+#endif // MCRANGE_CULLING
+            
+          int id = (ix*MACRO_CELLS) +
+            N[0]*( iy*MACRO_CELLS + N[1]*iz*MACRO_CELLS);
+          for (int mz=0;mz<MACRO_CELLS;mz++) {
+            for (int my=0;my<MACRO_CELLS;my++) {
+              for (int mx=0;mx<MACRO_CELLS;mx++) {
+#ifdef MCRANGE_CULLING
+                int size=myVector[id].triIDs.size();
+                for (int p=0; p<size; ++p) {
+                  // Update min/max:  minmax[0] --> minimum (x, y, z, r)
+                  //                  minmax[1] --> maximum (x, y, z, r)
+                  //                  minmax[2] --> minimum (v0, v1, v2, v3)
+                  //                  minmax[3] --> maximum (v0, v1, v2, v3)
+                  const sse_t &idat=getPos(myVector[id].triIDs[p]);
+                  const sse_t& ivar=getVar(myVector[id].varIDs[p]);
+                  minmax[0]=min4(minmax[0], idat);
+                  minmax[1]=max4(minmax[1], idat);
+                  minmax[2]=min4(minmax[2], ivar);
+                  minmax[3]=max4(minmax[3], ivar);
+                }
+                  
+                count += size;
+#else
+                count += myVector[id].triIDs.size();
+#endif // MCRANGE_CULLING
+                ++id;
+              }
+                
+#if !defined(MCRANGE_CULLING)
+              if (count)
+                goto endMacrocell;
+#endif // !defined(MCRANGE_CULLING)
+                
+              id += N[0] - MACRO_CELLS;
+            }
+              
+            id += N[0] * (N[1] - MACRO_CELLS);
+          }
+            
+#ifdef MCRANGE_CULLING
+          // Set macrocell counts and min/max
+          if (count)
+            set_mc(ix, iy, iz, count, minmax);
+          else {
+            // Empty macrocell:  set all minmax to [-FLT_MAX .. FLT_MAX]
+            minmax[0]=set4(-FLT_MAX);
+            minmax[1]=set4(FLT_MAX);
+            minmax[2]=set4(-FLT_MAX);
+            minmax[3]=set4(FLT_MAX);
+            set_mc(ix, iy, iz, 0, minmax);
+          }
+#else
+        endMacrocell:
+          set_mc(ix, iy, iz, count);
+#endif // MCRANGE_CULLING
+        }
+      }
+    }
+#endif // MACRO_CELLS
+
+ firstTime = false; 
+
 }
 
 void ParticleGrid::preFrameSetup(int proc, int numProcs)
@@ -47,34 +419,34 @@
   //TODO: Make it so that mailbox memory is loaded on the thread's
   //memory (For NUMA machines), and not all on the primary thread's
   //node's.
-#ifdef MAILBOXING
-  //need to adjust mailboxes if number of threads or number of
-  //primitives changes
+// #ifdef MAILBOXING
+//   //need to adjust mailboxes if number of threads or number of
+//   //primitives changes
   
-  if (!currGroup) return;
+//   if (!currGroup) return;
 
-  //this could be called from rebuild and the serialPreRenderCallback
-  //at the same time.
-  mutex.lock();
-
-  //make the current mailboxes big enough.
-  if (mailboxes.empty() != true)
-    if (mailboxes[0].mailbox.size() < currGroup->getSize())
-      for (size_t i=0; i < mailboxes.size(); ++i)
-        mailboxes[i].mailbox.resize(currGroup->getSize(), -1);
-
-  //make new mailboxes if needed, and make the new ones big enough as well.
-  if (mailboxes.size() < numProcs) {
-    int oldSize = mailboxes.size();
-    mailboxes.resize(numProcs);
-    for (size_t i=max(oldSize-1, 0); i < numProcs; ++i)
-      mailboxes[i].mailbox.resize(max((int)mailboxes[0].mailbox.size(),
-                                      currGroup->getSize()),
-                                  mailboxes[i].rayID);
-  }
+//   //this could be called from rebuild and the serialPreRenderCallback
+//   //at the same time.
+//   mutex.lock();
 
-  mutex.unlock();
-#endif
+//   //make the current mailboxes big enough.
+//   if (mailboxes.empty() != true)
+//     if (mailboxes[0].mailbox.size() < currGroup->getSize())
+//       for (size_t i=0; i < mailboxes.size(); ++i)
+//         mailboxes[i].mailbox.resize(currGroup->getSize(), -1);
+
+//   //make new mailboxes if needed, and make the new ones big enough as 
well.
+//   if (mailboxes.size() < numProcs) {
+//     int oldSize = mailboxes.size();
+//     mailboxes.resize(numProcs);
+//     for (size_t i=max(oldSize-1, 0); i < numProcs; ++i)
+//       mailboxes[i].mailbox.resize(max((int)mailboxes[0].mailbox.size(),
+//                                       currGroup->getSize()),
+//                                   mailboxes[i].rayID);
+//   }
+
+//   mutex.unlock();
+// #endif
 
 } 
 

Modified: trunk/Model/Groups/private/ParticleCGT.h
==============================================================================
--- trunk/Model/Groups/private/ParticleCGT.h    (original)
+++ trunk/Model/Groups/private/ParticleCGT.h    Sun Jul 15 23:59:54 2007
@@ -76,14 +76,153 @@
 
     float splitLength; //above this length we split packets.
 
+    TimeSteppedParticles* tsparticles;
+    Particle* particles;
+    
+    int vtxs;
+    sse_t vmin, vmax;
+    
+#ifdef COLOR_MAPPING
+    int cidx;
+    void setCidx(int new_cidx)
+      {
+       cidx = new_cidx;
+      }
+#endif //COLOR_MAPPING
+    mutable float max_radius;
+
+    void extendBoundsBySphere(int i,Box4 &bounds) const
+  {
+    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];
+    if (my_radius>max_radius)
+
+//   //this could be called fr
+      max_radius=my_radius;
+
+    bounds.extend(sphere);
+  }
+ inline Box4 getSphereBounds(int i)
+  {
+    Box4 tmp; tmp.setEmpty(); extendBoundsBySphere(i,tmp); return tmp;
+  }
+  sse_t &getPos(int i) const
+  {
+    assert(particles);
+    assert(0 <= i && i < vtxs);
+    return particles[i].sphere;
+  }
+
+  sse_t &getVar(int i) const
+  {
+    assert(particles);
+    assert(0 <= i && i < vtxs);
+    return particles[i].data;
+  }
+
+ // 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=simd(min[0], min[1], min[2], min[3]);
+      vmin=simd(min[4], min[5], min[6], min[7]);
+    } else {
+      dmin=set4(-FLT_MAX);
+      vmin=set4(-FLT_MAX);
+    }
+
+    if (max) {
+      dmax=simd(max[0], max[1], max[2], max[3]);
+      vmax=simd(max[4], max[5], max[6], max[7]);
+    } else {
+      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]) {
+    // min/max (x, y, z)
+    union {
+      sse_t bsse;
+      float bf[4];
+    };
+
+    bsse=tsparticles->bounds.min;
+    min[0]=bf[0];
+    min[1]=bf[1];
+    min[2]=bf[2];
+    min[3]=0.f;
+
+    bsse=tsparticles->bounds.max;
+    max[0]=bf[0];
+    max[1]=bf[1];
+    max[2]=bf[2];
+    max[3]=tsparticles->max_radius;
+
+    // min/max (v0, v1, v2, v3)
+    union {
+      sse_t vsse;
+      float vf[4];
+    };
+
+    vsse=tsparticles->vars_min;
+    min[4]=vf[0];
+    min[5]=vf[1];
+    min[6]=vf[2];
+    min[7]=vf[3];
+
+    vsse=tsparticles->vars_max;
+    max[4]=vf[0];
+    max[5]=vf[1];
+    max[6]=vf[2];
+    max[7]=vf[3];
+  }
+
+ template<bool SHADOWS_ONLY, bool COMMON_ORIGIN, bool SQUARE_PACKETS
+  inline bool intersectSphere(const sse_t& sphere,
+#ifdef COLOR_MAPPING
+                              const sse_t& data,
+#endif // COLOR_MAPPING
+                              RayPacket &ray,
+                              const int pack_begin = 0,
+                              int pack_end = -1) const;
+    
+
     struct CellData {
-      vector<int> triIDs;
-      //vector<Particle> particles;
+      vector<Particle> particles;
     };
 
 #ifdef NUM_BUILD_THREADS
     struct location_primitive {
       int gridLocation;
+
       int which_primitive;
     };
     vector<location_primitive*> buildQueues;
@@ -93,7 +232,12 @@
 
     static void newFrame();
 #ifdef MACRO_CELLS
-    vector<int> cellVector_mc;
+    struct MCData
+    {
+      int ntris;
+      sse_t minmax[4];
+    };
+    vector<MCData> cellVector_mc;
     inline int get_mc(int idx[3]) const
     {
       int x = idx[0];
@@ -107,9 +251,10 @@
       assert(z < N_mc[2]);
       int ofs = x+N_mc[0]*(y+N_mc[1]*(z));
       assert(ofs < cellVector_mc.size());
-      return cellVector_mc[ofs];
+      return cellVector_mc[ofs].ntris;
     }
-    inline void set_mc(int x, int y, int z, int d)
+#ifdef MCRANGE_CULLING
+    inline void set_mc(int x, int y, int z, int d, sse_t* minmax)
     {
       assert(x >= 0);
       assert(y >= 0);
@@ -119,9 +264,42 @@
       assert(z < N_mc[2]);
       int ofs = x+N_mc[0]*(y+N_mc[1]*(z));
       assert(ofs < cellVector_mc.size());
-      cellVector_mc[ofs] = d;
+      cellVector_mc[ofs].ntris = d;
+      cellVector_mc[ofs].minmax[0]=minmax[0];
+      cellVector_mc[ofs].minmax[1]=minmax[1];
+      cellVector_mc[ofs].minmax[2]=minmax[2];
+      cellVector_mc[ofs].minmax[3]=minmax[3];
     }
-#endif
+  inline const sse_t* getMCMinMax(int idx[3]) const
+  {
+    int x = idx[0];
+    int y = idx[1];
+    int z = idx[2];
+    assert(x >= 0);
+    assert(y >= 0);
+    assert(z >= 0);
+    assert(x < N_mc[0]);
+    assert(y < N_mc[1]);
+    assert(z < N_mc[2]);
+    int ofs = x+N_mc[0]*(y+N_mc[1]*(z));
+    assert(ofs < cellVector_mc.size());
+    return cellVector_mc[ofs].minmax;
+  }
+#else
+      inline void set_mc(int x, int y, int z, int d)
+  {
+    assert(x >= 0);
+    assert(y >= 0);
+    assert(z >= 0);
+    assert(x < N_mc[0]);
+    assert(y < N_mc[1]);
+    assert(z < N_mc[2]);
+    int ofs = x+N_mc[0]*(y+N_mc[1]*(z));
+    assert(ofs < cellVector_mc.size());
+    cellVector_mc[ofs].ntris = d;
+  }
+#endif // MCRANGE_CULLING
+#endif // MACROCELLS
     inline int idx(int x, int y, int z) const
     {
       assert(x >= 0);
@@ -142,6 +320,7 @@
       cell.max = mul4(set44(0.f,z+1.0f,y+1.0f,x+1.0f),oneOverN);
       return cell;
     }
+
     inline Box4 worldCellBounds(int x, int y, int z)
     {
       Box4 cell;
@@ -164,6 +343,16 @@
       oldN_mc[0] = oldN_mc[1] = oldN_mc[2] = -1;
 #endif
       oldN[0] = oldN[1] = oldN[2] = -1;
+
+
+      particles = Null;// TODO: FILL PARTICLES FROM CURRGROUP
+      tspaticles = NULL; //TODO:FILL ME
+
+      vtx = vtx_;  //TODO: What are these??? gathered from particle data
+      vars = 0;
+      vtxs = vtxs_;  // number of spheres
+
+      setMinMaxVars();
     }
 
     virtual ~ParticleGrid() {}

Modified: trunk/scenes/particleCGTTest.cc
==============================================================================
--- trunk/scenes/particleCGTTest.cc     (original)
+++ trunk/scenes/particleCGTTest.cc     Sun Jul 15 23:59:54 2007
@@ -79,7 +79,7 @@
        Material* lam = new Lambertian(Color(RGB(1,0,0)));
         Primitive* prim = new Cube(lam, Vector(-0.4, -0.3, 0.2), 
Vector(0.41, 0.3, 1.0));
        ParticleNRRD reader;
-       reader.readFile("~/");
+       reader.readFile("/home/collab/brownlee/2300.nrrd");
        cout << "NVars: " << reader.getNVars() << endl;
        int nvars = reader.getNVars();
        for(int i = 0; i < reader.getNParticles(); i++)




  • [MANTA] r1474 - in trunk: Model/Groups/private scenes, brownlee, 07/16/2007

Archive powered by MHonArc 2.6.16.

Top of page