Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r552 - in branches/itanium2: Core/Geometry Interface Model/Groups


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r552 - in branches/itanium2: Core/Geometry Interface Model/Groups
  • Date: Thu, 15 Sep 2005 13:45:15 -0600 (MDT)

Author: bigler
Date: Thu Sep 15 13:45:14 2005
New Revision: 552

Modified:
   branches/itanium2/Core/Geometry/PointVector.cc
   branches/itanium2/Interface/RayPacket.h
   branches/itanium2/Model/Groups/FrustumKDTree.cc
Log:

Core/Geometry/PointVector.cc

  Added ostream operators for 2D vectors and points.

Interface/RayPacket.h

  Code formatting.  Not tabs, trailing white space, or lines too long.

Model/Groups/FrustumKDTree.cc

  Compute the frustum_direction for PacketFrustum.

  Oodles of additional debug print statements.

  Fixed the overlap test case.  You need to have overlap in all
  dimensions rather than at least one to have overlap.


Modified: branches/itanium2/Core/Geometry/PointVector.cc
==============================================================================
--- branches/itanium2/Core/Geometry/PointVector.cc      (original)
+++ branches/itanium2/Core/Geometry/PointVector.cc      Thu Sep 15 13:45:14 
2005
@@ -21,11 +21,24 @@
   }
   
   // Explicit instantiations for ostream operators
+
+  // 3D Vectors
   template std::ostream& operator<<(std::ostream& os, const VectorT<double, 
3>&);
   template std::ostream& operator<<(std::ostream& os, const VectorT<float, 
3>&);
   template std::ostream& operator<<(std::ostream& os, const VectorT<int, 
3>&);
   
+  // 3D Points
   template std::ostream& operator<<(std::ostream& os, const PointT<double, 
3>&);
   template std::ostream& operator<<(std::ostream& os, const PointT<float, 
3>&);
   template std::ostream& operator<<(std::ostream& os, const PointT<int, 3>&);
+
+  // 2D Vectors
+  template std::ostream& operator<<(std::ostream& os, const VectorT<double, 
2>&);
+  template std::ostream& operator<<(std::ostream& os, const VectorT<float, 
2>&);
+  template std::ostream& operator<<(std::ostream& os, const VectorT<int, 
2>&);
+
+  // 2D Points
+  template std::ostream& operator<<(std::ostream& os, const PointT<double, 
2>&);
+  template std::ostream& operator<<(std::ostream& os, const PointT<float, 
2>&);
+  template std::ostream& operator<<(std::ostream& os, const PointT<int, 2>&);
 }

Modified: branches/itanium2/Interface/RayPacket.h
==============================================================================
--- branches/itanium2/Interface/RayPacket.h     (original)
+++ branches/itanium2/Interface/RayPacket.h     Thu Sep 15 13:45:14 2005
@@ -28,10 +28,10 @@
       // HaveFrame          = 0x100,
       HaveNormals           = 0x200,
       HaveUnitNormals       = 0x300,
-                                                     
+
       HaveInverseDirections = 0x800, // signMask and inverseDirection 
computed.
-                       ConstantDirections    = 0xc00  // All of the rays 
have the same signMask
-               };
+      ConstantDirections    = 0xc00  // All of the rays have the same 
signMask
+    };
 
 
     inline RayPacket(RayPacketData& data, int size, int depth, int flags);
@@ -50,12 +50,12 @@
     int getFlags() const {
       return flags;
     }
-               
-               bool getFlags( int flag ) const { return (flags & flag) == 
flag; };
-               
+
+    bool getFlags( int flag ) const { return (flags & flag) == flag; };
+
     int setFlags(int new_flags)
     {
-        flags = new_flags;
+      flags = new_flags;
     }
     void setFlag(int flag) {
       flags |= flag;
@@ -92,14 +92,14 @@
       Color   ambientLight;
       Color   light;
 
-                       double importance; // for ray pruning
+      double importance; // for ray pruning
 
       int shadowBegin, shadowEnd;
       int whichEye;
-                       
-                       // Mask describing ray direction, 0==negative 
1==positive
-                       // This is set at the same time as inverse direction.
-      int signMask[3]; 
+
+      // Mask describing ray direction, 0==negative 1==positive
+      // This is set at the same time as inverse direction.
+      int signMask[3];
     };
 
     const Element& get(int which) const {
@@ -149,8 +149,10 @@
     {
       if(flags & HaveHitPositions)
         return;
-      for(int i=0;i<size;i++)
-        data[i].hitPosition = data[i].ray.origin() + data[i].ray.direction() 
* data[i].hitInfo.minT();
+      for(int i=0;i<size;i++) {
+        data[i].hitPosition = data[i].ray.origin() +
+          data[i].ray.direction() * data[i].hitInfo.minT();
+      }
       flags |= HaveHitPositions;
     }
     void computeInverseDirections()
@@ -162,7 +164,9 @@
                                           1./data[i].ray.direction().y(),
                                           1./data[i].ray.direction().z());
 
-        // Set the sign mask at the same time.
+        // Set the sign mask at the same time.  This shouldn't be done
+        // here.  It should be done in a different function or a
+        // function of a different name.
         data[i].signMask[0] = (data[i].inverseDirection[0] < 0.0);
         data[i].signMask[1] = (data[i].inverseDirection[1] < 0.0);
         data[i].signMask[2] = (data[i].inverseDirection[2] < 0.0);
@@ -261,6 +265,6 @@
     : data(&data.data[0]), size(size), depth(depth), flags(flags)
   {
   }
-}
+} // end namespace Manta
 
 #endif

Modified: branches/itanium2/Model/Groups/FrustumKDTree.cc
==============================================================================
--- branches/itanium2/Model/Groups/FrustumKDTree.cc     (original)
+++ branches/itanium2/Model/Groups/FrustumKDTree.cc     Thu Sep 15 13:45:14 
2005
@@ -57,7 +57,24 @@
   frustum_bound[2] = bound2_;
   frustum_bound[3] = bound3_;
 
-  // Compute frustum_direction from the bounds
+  // Compute frustum_direction from the bounds.  We're going to assume
+  // that the bounds are all pointing in the same direction.  There's
+  // some code later that can be commented in to make sure.
+  frustum_direction[0] = (frustum_bound[0][0] < 0.0);
+  frustum_direction[1] = (frustum_bound[0][1] < 0.0);
+  frustum_direction[2] = (frustum_bound[0][2] < 0.0);
+
+  if (debug_level > 0) {
+    // Make sure that the frustum_direction values are all the same
+    // for all the bounds.
+    for(int b = 1; b < 4; ++b) {
+      for(int c = 0; c < 3; ++c) {
+        if (frustum_direction[c] != (frustum_bound[b][c] < 0)) {
+          cerr << "frustum_direction["<<c<<"] != 
(frustum_bound["<<b<<"]["<<c<<"] < 0)("<<(frustum_bound[b][c] < 0)<<")\n";
+        }
+      }
+    }
+  }
 
   if (debug_level > 0) {
     cerr << "frustum_origin = "<<frustum_origin<<"\n";
@@ -65,7 +82,6 @@
       cerr << "frustum_bound["<<i<<"] = "<<frustum_bound[i]<<"\n";
     }
     for (int i=0;i<3;++i) {
-      frustum_direction[i] = 0;
       cerr << "frustum_direction["<<i<<"] = "<<frustum_direction[i]<<"\n";
     }
   }
@@ -120,11 +136,15 @@
 
   // Determine the split plane direction.
   unsigned int axis = node->axis();
+  if (debug_level > 0) cerr << "split axis = "<<axis<<"\n";
 
   // Determine the axes of the split plane.
   unsigned int plane_axis[2];
   plane_axis[0] = (axis+1)%3;
   plane_axis[1] = (axis+2)%3;
+  if (debug_level > 0)
+    for(int a = 0; a < 2; ++a)
+      cerr << "plane_axis["<<a<<"] = "<<plane_axis[a]<<"\n";
 
   
/////////////////////////////////////////////////////////////////////////////
   // Find the edges of the intersection of the node_bounds with split plane.
@@ -132,10 +152,16 @@
   Real max_edge[2]; // position of edges: dc,bc -- max edges for plane axis 
0,1
 
   for (int i=0;i<2;++i) {
+    // Here node_bounds[0] is node_bounds.max() and node_bounds[1] is
+    // node_bounds.min().
     min_edge[i] = node_bounds[0][plane_axis[i]];
     max_edge[i] = node_bounds[1][plane_axis[i]];
   }
 
+  if (debug_level > 0)
+    for(int a = 0; a < 2; ++a)
+      cerr << "min_edge["<<a<<"] = "<<min_edge[a]<<",\tmax_edge["<<a<<"] = 
"<<max_edge[a]<<"\n";
+
   
/////////////////////////////////////////////////////////////////////////////
   // Intersect each of the frustum bounding rays with the split plane.
 
@@ -158,12 +184,15 @@
     // Compute the intersection point.
     pt += (frustum.bound(i)*t);
 
+    if (debug_level > 0) cerr << "t["<<i<<"] = "<<t<<",\tpt = "<<pt<<"\n";
+
     // Compute the 2D bounds on the plane. --- CAN WE USE FMIN and
     // FMAX instr's for this?
     for (int j=0;j<2;++j) {
       n[j] = SCIRun::Max( n[j], pt[plane_axis[j]] );
       f[j] = SCIRun::Min( f[j], pt[plane_axis[j]] );
     }
+    if (debug_level > 0) cerr << "n = "<<n<<",\tf = "<<f<<"\n";
   }
 
   
/////////////////////////////////////////////////////////////////////////////
@@ -174,6 +203,8 @@
   above[0] = (f[0] >= max_edge[0]);
   above[1] = (f[1] >= max_edge[1]);
 
+  if (debug_level > 0) cerr << "above[0] = "<<above[0]<<", above[1] = 
"<<above[1]<<"\n";
+
   // Doesn't handle "on-edge" or "on-corner" overlap.
 
   // In the case that n[0] == min_edge[0] or f[0] == max_edge[0]
@@ -181,7 +212,9 @@
   // Not classifing these as INTERSECT_BOTH allows a deeper node to be 
choosen
   // as a candidate starting point.
 
-  if ( ((n[0] > min_edge[0]) && !above[0]) ||
+  // In order to overlap we need to have overlap in both dimensions.
+  // If there isn't overlap in any dimension we don't have overlap.
+  if ( ((n[0] > min_edge[0]) && !above[0]) &&
        ((n[1] > min_edge[1]) && !above[1]) ) {
     if (debug_level > 0) cerr << "Overlap test tripped\n";
     return INTERSECT_BOTH;




  • [MANTA] r552 - in branches/itanium2: Core/Geometry Interface Model/Groups, bigler, 09/15/2005

Archive powered by MHonArc 2.6.16.

Top of page