Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r625 - in branches/itanium2: Core/Geometry Interface Model/Instances Model/Primitives


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r625 - in branches/itanium2: Core/Geometry Interface Model/Instances Model/Primitives
  • Date: Fri, 14 Oct 2005 11:38:09 -0600 (MDT)

Author: bigler
Date: Fri Oct 14 11:38:07 2005
New Revision: 625

Modified:
   branches/itanium2/Core/Geometry/PointVector.h
   branches/itanium2/Core/Geometry/Ray.h
   branches/itanium2/Interface/HitInfo.h
   branches/itanium2/Interface/RayPacket.h
   branches/itanium2/Model/Instances/Instance.cc
   branches/itanium2/Model/Instances/InstanceRST.cc
   branches/itanium2/Model/Instances/InstanceRST.h
   branches/itanium2/Model/Instances/InstanceST.cc
   branches/itanium2/Model/Primitives/Parallelogram.cc
   branches/itanium2/Model/Primitives/Parallelogram.h
   branches/itanium2/Model/Primitives/Sphere.cc
Log:

More fixes for Real == float.

Core/Geometry/PointVector.h

  Made divides of 1./num to be 1/num since num was of type Real.

Core/Geometry/Ray.h

  normalizeDirection should return Real not double.

Interface/HitInfo.h

  Changed double to Real.  Cast T_EPSILON to Real.

Interface/RayPacket.h

  Made divides of 1./num to be 1/num since num was of type Real.

  Compare with 0 instead of 0.0.
  
Model/Instances/Instance.cc
Model/Instances/InstanceRST.cc
Model/Instances/InstanceRST.h
Model/Instances/InstanceST.cc
Model/Primitives/Parallelogram.cc
Model/Primitives/Parallelogram.h
Model/Primitives/Sphere.cc

  Made divides of 1./num to be 1/num since num was of type Real.

  Changed double to Real.

  Cast constants to Real.

  Compare with 0 instead of 0.0 and 1 instead of 1.0.


Modified: branches/itanium2/Core/Geometry/PointVector.h
==============================================================================
--- branches/itanium2/Core/Geometry/PointVector.h       (original)
+++ branches/itanium2/Core/Geometry/PointVector.h       Fri Oct 14 11:38:07 
2005
@@ -1,3 +1,10 @@
+/*
+
+  PointT and VectorT are made to be templated with floating point
+  types.  If you use an integral type, you could get into trouble with
+  certain functions that compute division.  Be warned!
+
+*/
 
 #ifndef Manta_Core_PointVector_h
 #define Manta_Core_PointVector_h
@@ -6,7 +13,11 @@
 #include <Core/Math/Expon.h>
 #include <Core/Math/MinMax.h>
 #include <Core/Math/MiscMath.h>
+
+#include <sgi_stl_warnings_off.h>
 #include <iosfwd>
+#include <sgi_stl_warnings_on.h>
+
 #include <math.h>
 
 namespace Manta {
@@ -131,14 +142,14 @@
       return *this;
     }
     VectorT<T, Dim> operator/(T s) const {
-      T inv_s = 1./s;
+      T inv_s = 1/s;
       VectorT<T, Dim> result;
       for(int i=0;i<Dim;i++)
         result.data[i] = data[i] * inv_s;
       return result;
     }
     VectorT<T, Dim>& operator/=(T s) {
-      T inv_s = 1./s;
+      T inv_s = 1/s;
       for(int i=0;i<Dim;i++)
         data[i] *= inv_s;
       return *this;
@@ -165,13 +176,13 @@
 
     T normalize() {
       T l = length();
-      T scale = 1./l;
+      T scale = 1/l;
       *this *= scale;
       return l;
     }
     VectorT<T, Dim> normal() const {
       T l = length();
-      T scale = 1./l;
+      T scale = 1/l;
       return *this * scale;
     }
     T minComponent() const {
@@ -206,7 +217,7 @@
     VectorT<T, Dim> inverse() const {
       VectorT<T, Dim> result;
       for(int i=0;i<Dim;i++)
-        result.data[i] = 1./data[i];
+        result.data[i] = 1/data[i];
       return result;
     }
     VectorT<T, Dim> absoluteValue() const {

Modified: branches/itanium2/Core/Geometry/Ray.h
==============================================================================
--- branches/itanium2/Core/Geometry/Ray.h       (original)
+++ branches/itanium2/Core/Geometry/Ray.h       Fri Oct 14 11:38:07 2005
@@ -44,7 +44,7 @@
     const Vector& direction() const {
       return dir;
     }
-    double normalizeDirection() {
+    Real normalizeDirection() {
       return dir.normalize();
     }
   private:

Modified: branches/itanium2/Interface/HitInfo.h
==============================================================================
--- branches/itanium2/Interface/HitInfo.h       (original)
+++ branches/itanium2/Interface/HitInfo.h       Fri Oct 14 11:38:07 2005
@@ -36,10 +36,10 @@
     const Material* material;
     const Primitive* primitive;
     const TexCoordMapper* tex;
-    double scale;
-    double inv_scale;
+    Real scale;
+    Real inv_scale;
     MPTscale(const Material* material, const Primitive* primitive,
-                                                const TexCoordMapper* tex, 
double scale, double inv_scale)
+                                                const TexCoordMapper* tex, 
Real scale, Real inv_scale)
       : material(material), primitive(primitive), tex(tex),
                        scale(scale), inv_scale(inv_scale)
     {
@@ -60,7 +60,7 @@
       hitMatl = 0;
       min_t = MAXT;
     }
-    inline void reset(double min) {
+    inline void reset(Real min) {
       hitMatl = 0;
       min_t = min;
     }
@@ -79,20 +79,20 @@
     Real minT() const {
       return min_t;
     }
-    void scaleT(double scale) {
+    void scaleT(Real scale) {
       if(hitMatl != 0)
                                min_t *= scale;
     }
-    void overrideT(double new_mint) {
+    void overrideT(Real new_mint) {
       min_t = new_mint;
     }
                
-    bool hit(double t, const Material* matl, const Primitive* prim,
+    bool hit(Real t, const Material* matl, const Primitive* prim,
                                                 const TexCoordMapper* tex) {
-      if(t<T_EPSILON)
+      if(t < (Real)T_EPSILON)
                                return false;
       if(t < min_t){
-                               min_t=t;
+                               min_t = t;
                                hitMatl = matl;
                                hitPrim = prim;
                                hitTex = tex;
@@ -101,7 +101,7 @@
                                return false;
       }
     }
-    void set_hit(double t, const Material* matl, const Primitive* prim,
+    void set_hit(Real t, const Material* matl, const Primitive* prim,
                  const TexCoordMapper* tex) {
       min_t=t;
       hitMatl = matl;

Modified: branches/itanium2/Interface/RayPacket.h
==============================================================================
--- branches/itanium2/Interface/RayPacket.h     (original)
+++ branches/itanium2/Interface/RayPacket.h     Fri Oct 14 11:38:07 2005
@@ -160,16 +160,16 @@
       if(flags & HaveInverseDirections)
         return;
       for(int i=0;i<size;i++) {
-        data[i].inverseDirection = Vector(1./data[i].ray.direction().x(),
-                                          1./data[i].ray.direction().y(),
-                                          1./data[i].ray.direction().z());
+        data[i].inverseDirection = Vector(1/data[i].ray.direction().x(),
+                                          1/data[i].ray.direction().y(),
+                                          1/data[i].ray.direction().z());
 
         // 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);
+        data[i].signMask[0] = (data[i].inverseDirection[0] < 0);
+        data[i].signMask[1] = (data[i].inverseDirection[1] < 0);
+        data[i].signMask[2] = (data[i].inverseDirection[2] < 0);
       }
       flags |= HaveInverseDirections;
     }

Modified: branches/itanium2/Model/Instances/Instance.cc
==============================================================================
--- branches/itanium2/Model/Instances/Instance.cc       (original)
+++ branches/itanium2/Model/Instances/Instance.cc       Fri Oct 14 11:38:07 
2005
@@ -44,8 +44,8 @@
   RayPacketData raydata;
   RayPacket instance_rays(raydata, rays.getSize(), rays.getDepth(),
                          rays.getFlags());
-  double scales[RayPacket::MaxSize];
-  double inv_scales[RayPacket::MaxSize];
+  Real scales[RayPacket::MaxSize];
+  Real inv_scales[RayPacket::MaxSize];
 
   if(rays.getFlags() & RayPacket::ConstantOrigin){
     RayPacket::Element& e0 = rays.get(0);
@@ -58,9 +58,9 @@
 
                Vector dir = transform_inv * e.ray.direction();
                
-      double length = dir.length();
+      Real length = dir.length();
       inv_scales[i] = length;
-      double ilength = 1./length;
+      Real ilength = 1/length;
       scales[i] = ilength;
       te.ray.set(o, dir*ilength);
       te.hitInfo.reset(e.hitInfo.minT()*length);
@@ -73,9 +73,9 @@
       Point o = transform_inv * e.ray.origin();
       Vector dir = transform_inv * e.ray.direction();
 
-      double length = dir.length();
+      Real length = dir.length();
       inv_scales[i] = length;
-      double ilength = 1./length;
+      Real ilength = 1/length;
       scales[i] = ilength;
       te.ray.set(o, dir*ilength);
       te.hitInfo.reset(e.hitInfo.minT()*length);
@@ -87,10 +87,10 @@
     RayPacket::Element& te = instance_rays.get(i);
     if(te.hitInfo.wasHit()){
       // Instance was hit
-      double s = scales[i];
+      Real s = scales[i];
       if(e.hitInfo.hit(te.hitInfo.minT()*s, material, this, tex)){
                  // Instance is now the closest
-                 double is = inv_scales[i];
+                 Real is = inv_scales[i];
                  e.hitInfo.scratchpad<MPTscale>() = 
MPTscale(te.hitInfo.hitMaterial(),
                                                                              
                                                           
te.hitInfo.hitPrimitive(),
                                                                              
                                                           
te.hitInfo.hitTexCoordMapper(),
@@ -102,7 +102,7 @@
 
 void Instance::computeNormal(const RenderContext& context, RayPacket& rays) 
const
 {
-  double old_minT[RayPacket::MaxSize];
+  Real old_minT[RayPacket::MaxSize];
   Ray old_rays[RayPacket::MaxSize];
 
   // Save the original rays
@@ -112,10 +112,10 @@
     Point o    = transform_inv * e.ray.origin();        
     Vector dir = transform_inv * e.ray.direction();
 
-    double scale = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
+    Real scale = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
     e.ray.set(o, dir*scale);
     old_minT[i] = e.hitInfo.minT();
-    double inv_scale = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
+    Real inv_scale = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
     e.hitInfo.scaleT(inv_scale);
   }
   rays.resetFlag(RayPacket::HaveHitPositions);
@@ -165,7 +165,7 @@
 void Instance::computeTexCoords2(const RenderContext& context,
                               RayPacket& rays) const
 {
-  double old_minT[RayPacket::MaxSize];
+  Real old_minT[RayPacket::MaxSize];
   Ray old_rays[RayPacket::MaxSize];
 
   // Save the original rays
@@ -176,10 +176,10 @@
     Point o    = transform_inv * e.ray.origin();
     Vector dir = transform_inv * e.ray.direction();
 
-    double scale = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
+    Real scale = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
     e.ray.set(o, dir*scale);
     old_minT[i] = e.hitInfo.minT();
-    double inv_scale = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
+    Real inv_scale = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
     e.hitInfo.scaleT(inv_scale);
   }
   rays.resetFlag(RayPacket::HaveHitPositions);
@@ -207,7 +207,7 @@
 void Instance::computeTexCoords3(const RenderContext& context,
                               RayPacket& rays) const
 {
-  double old_minT[RayPacket::MaxSize];
+  Real old_minT[RayPacket::MaxSize];
   Ray old_rays[RayPacket::MaxSize];
 
   // Save the original rays
@@ -218,10 +218,10 @@
     Point o    = transform_inv * e.ray.origin();
     Vector dir = transform_inv * e.ray.direction();
 
-    double scale = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
+    Real scale = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
     e.ray.set(o, dir*scale);
     old_minT[i] = e.hitInfo.minT();
-    double inv_scale = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
+    Real inv_scale = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
     e.hitInfo.scaleT(inv_scale);
   }
   rays.resetFlag(RayPacket::HaveHitPositions);

Modified: branches/itanium2/Model/Instances/InstanceRST.cc
==============================================================================
--- branches/itanium2/Model/Instances/InstanceRST.cc    (original)
+++ branches/itanium2/Model/Instances/InstanceRST.cc    Fri Oct 14 11:38:07 
2005
@@ -20,15 +20,16 @@
   // but this seems easier:  pass in the three axes and make sure that the
   // transformed lengths are all the same
   Vector v1 = transform * Vector(1,0,0);
-  double l1 = v1.normalize();
+  Real l1 = v1.normalize();
   Vector v2 = transform * Vector(0,1,0);
-  double l2 = v2.normalize();
+  Real l2 = v2.normalize();
   Vector v3 = transform * Vector(0,0,1);
-  double l3 = v3.normalize();
+  Real l3 = v3.normalize();
   
   scale = l1;
-  inv_scale = 1./l1;
-  if(SCIRun::Abs(l1-l2)/SCIRun::Abs(l1) > 1.e-10 || 
SCIRun::Abs(l1-l3)/SCIRun::Abs(l1) > 1.e-10) {
+  inv_scale = 1/l1;
+  if(SCIRun::Abs(l1-l2)/SCIRun::Abs(l1) > (Real)1.e-10 ||
+     SCIRun::Abs(l1-l3)/SCIRun::Abs(l1) > (Real)1.e-10) {
     ostringstream msg;
     msg << "Nonuniform scale for InstanceRST, scalefactor=[" << l1 << ' '
                  << l2 << ' ' << l3 << ']';
@@ -105,7 +106,7 @@
 
 void InstanceRST::computeNormal(const RenderContext& context, RayPacket& 
rays) const
 {
-  double old_minT[RayPacket::MaxSize];
+  Real old_minT[RayPacket::MaxSize];
   Ray old_rays[RayPacket::MaxSize];
 
   // Save the original rays
@@ -169,7 +170,7 @@
 void InstanceRST::computeTexCoords2(const RenderContext& context,
                               RayPacket& rays) const
 {
-  double old_minT[RayPacket::MaxSize];
+  Real old_minT[RayPacket::MaxSize];
   Ray old_rays[RayPacket::MaxSize];
 
   // Save the original rays
@@ -209,7 +210,7 @@
 void InstanceRST::computeTexCoords3(const RenderContext& context,
                               RayPacket& rays) const
 {
-  double old_minT[RayPacket::MaxSize];
+  Real old_minT[RayPacket::MaxSize];
   Ray old_rays[RayPacket::MaxSize];
 
   // Save the original rays

Modified: branches/itanium2/Model/Instances/InstanceRST.h
==============================================================================
--- branches/itanium2/Model/Instances/InstanceRST.h     (original)
+++ branches/itanium2/Model/Instances/InstanceRST.h     Fri Oct 14 11:38:07 
2005
@@ -44,8 +44,8 @@
         AffineTransform transform;
         AffineTransform transform_inv;
 
-        double scale;
-    double inv_scale;
+    Real scale;
+    Real inv_scale;
   };
 }
 

Modified: branches/itanium2/Model/Instances/InstanceST.cc
==============================================================================
--- branches/itanium2/Model/Instances/InstanceST.cc     (original)
+++ branches/itanium2/Model/Instances/InstanceST.cc     Fri Oct 14 11:38:07 
2005
@@ -16,7 +16,7 @@
     uniform_scale = true;
   else
     uniform_scale = false;
-  inv_scale = Vector(1./scale.x(), 1./scale.y(), 1./scale.z());
+  inv_scale = Vector(1/scale.x(), 1/scale.y(), 1/scale.z());
 }
 
 InstanceST::~InstanceST()
@@ -41,10 +41,10 @@
   RayPacketData raydata;
   RayPacket instance_rays(raydata, rays.getSize(), rays.getDepth(), 
rays.getFlags());
 
-  double scales[RayPacket::MaxSize];
-  double inv_scales[RayPacket::MaxSize];
+  Real scales[RayPacket::MaxSize];
+  Real inv_scales[RayPacket::MaxSize];
   if(uniform_scale){
-    double iscale = inv_scale.x();
+    Real iscale = inv_scale.x();
     if(rays.getFlags() & RayPacket::ConstantOrigin){
       RayPacket::Element& e = rays.get(0);
       Point o( Vector(e.ray.origin()-translation)*iscale );
@@ -70,9 +70,9 @@
                  RayPacket::Element& e = rays.get(i);
                  RayPacket::Element& te = instance_rays.get(i);
                  Vector dir(e.ray.direction()*inv_scale);
-                 double length = dir.length();
+                 Real length = dir.length();
                  inv_scales[i] = length;
-                 double ilength = 1./length;
+                 Real ilength = 1/length;
                  scales[i] = ilength;
                  te.ray.set(o, dir*ilength);
                  te.hitInfo.reset(e.hitInfo.minT()*length);
@@ -82,9 +82,9 @@
                  RayPacket::Element& e = rays.get(i);
                  RayPacket::Element& te = instance_rays.get(i);
                  Vector dir(e.ray.direction()*inv_scale);
-                 double length = dir.length();
+                 Real length = dir.length();
                  scales[i] = length;
-                 double ilength = 1./length;
+                 Real ilength = 1/length;
                  inv_scales[i] = ilength;
                  
te.ray.set(Point((Vector(e.ray.origin())-translation)*inv_scale),
                                                 dir*ilength);
@@ -94,7 +94,7 @@
   }
   instance->intersect(context, instance_rays);
   if(uniform_scale){
-    double s = scale.x();
+    Real s = scale.x();
     for(int i=0;i<rays.getSize();i++){
       RayPacket::Element& e = rays.get(i);
       RayPacket::Element& te = instance_rays.get(i);
@@ -113,16 +113,17 @@
       RayPacket::Element& e = rays.get(i);
       RayPacket::Element& te = instance_rays.get(i);
       if(te.hitInfo.wasHit()){
-       // Instance was hit
-       double s = scales[i];
-       if(e.hitInfo.hit(te.hitInfo.minT()*s, material, this, tex)){
-         // Instance is now the closest
-         double is = inv_scales[i];
-         e.hitInfo.scratchpad<MPTscale>() = 
MPTscale(te.hitInfo.hitMaterial(),
-                                                     
te.hitInfo.hitPrimitive(),
-                                                     
te.hitInfo.hitTexCoordMapper(),
-                                                     s, is);
-       }
+        // Instance was hit
+        Real s = scales[i];
+        if(e.hitInfo.hit(te.hitInfo.minT()*s, material, this, tex)){
+          // Instance is now the closest
+          Real is = inv_scales[i];
+          e.hitInfo.scratchpad<MPTscale>() =
+            MPTscale(te.hitInfo.hitMaterial(),
+                     te.hitInfo.hitPrimitive(),
+                     te.hitInfo.hitTexCoordMapper(),
+                     s, is);
+        }
       }
     }
   }
@@ -130,12 +131,12 @@
 
 void InstanceST::computeNormal(const RenderContext& context, RayPacket& 
rays) const
 {
-  double old_minT[RayPacket::MaxSize];
+  Real old_minT[RayPacket::MaxSize];
   Point old_origins[RayPacket::MaxSize];
   Ray old_rays[RayPacket::MaxSize];
   if(uniform_scale){
     // Save the original origins and minT
-    double is = inv_scale.x();
+    Real is = inv_scale.x();
     for(int i=0;i<rays.getSize();i++){
       RayPacket::Element& e = rays.get(i);
       old_origins[i] = e.ray.origin();
@@ -149,11 +150,11 @@
       RayPacket::Element& e = rays.get(i);
       old_rays[i] = e.ray;
       Vector dir(e.ray.direction()*inv_scale);
-      double ilength = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
+      Real ilength = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
       e.ray.set(Point((Vector(e.ray.origin())-translation)*inv_scale),
                dir*ilength);
       old_minT[i] = e.hitInfo.minT();
-      double length = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
+      Real length = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
       e.hitInfo.scaleT(length);
     }
   }
@@ -211,12 +212,12 @@
 void InstanceST::computeTexCoords2(const RenderContext& context,
                               RayPacket& rays) const
 {
-  double old_minT[RayPacket::MaxSize];
+  Real old_minT[RayPacket::MaxSize];
   Point old_origins[RayPacket::MaxSize];
   Ray old_rays[RayPacket::MaxSize];
   if(uniform_scale){
     // Save the original origins and minT
-    double is = inv_scale.x();
+    Real is = inv_scale.x();
     for(int i=0;i<rays.getSize();i++){
       RayPacket::Element& e = rays.get(i);
       old_origins[i] = e.ray.origin();
@@ -230,11 +231,11 @@
       RayPacket::Element& e = rays.get(i);
       old_rays[i] = e.ray;
       Vector dir(e.ray.direction()*inv_scale);
-      double ilength = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
+      Real ilength = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
       e.ray.set(Point((Vector(e.ray.origin())-translation)*inv_scale),
                dir*ilength);
       old_minT[i] = e.hitInfo.minT();
-      double length = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
+      Real length = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
       e.hitInfo.scaleT(length);
     }
   }
@@ -270,12 +271,12 @@
 void InstanceST::computeTexCoords3(const RenderContext& context,
                               RayPacket& rays) const
 {
-  double old_minT[RayPacket::MaxSize];
+  Real old_minT[RayPacket::MaxSize];
   Point old_origins[RayPacket::MaxSize];
   Ray old_rays[RayPacket::MaxSize];
   if(uniform_scale){
     // Save the original origins and minT
-    double is = inv_scale.x();
+    Real is = inv_scale.x();
     for(int i=0;i<rays.getSize();i++){
       RayPacket::Element& e = rays.get(i);
       old_origins[i] = e.ray.origin();
@@ -289,11 +290,11 @@
       RayPacket::Element& e = rays.get(i);
       old_rays[i] = e.ray;
       Vector dir(e.ray.direction()*inv_scale);
-      double ilength = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
+      Real ilength = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
       e.ray.set(Point((Vector(e.ray.origin())-translation)*inv_scale),
                dir*ilength);
       old_minT[i] = e.hitInfo.minT();
-      double length = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
+      Real length = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
       e.hitInfo.scaleT(length);
     }
   }

Modified: branches/itanium2/Model/Primitives/Parallelogram.cc
==============================================================================
--- branches/itanium2/Model/Primitives/Parallelogram.cc (original)
+++ branches/itanium2/Model/Primitives/Parallelogram.cc Fri Oct 14 11:38:07 
2005
@@ -44,49 +44,49 @@
 {
   if(rays.getFlags() & RayPacket::ConstantOrigin && rays.getSize()>1){
     RayPacket::Element& e0 = rays.get(0);
-    double num = d-Dot(normal, e0.ray.origin());
+    Real num = d-Dot(normal, e0.ray.origin());
     Point a(e0.ray.origin()-anchor);
-    double o1 = Dot(a, v1);
-    double o2 = Dot(a, v2);
+    Real o1 = Dot(a, v1);
+    Real o2 = Dot(a, v2);
     for(int i=0;i<rays.getSize();i++){
       RayPacket::Element& e = rays.get(i);
-      double dt=Dot(e.ray.direction(), normal);
-      if(Abs(dt) < 1.e-6)
-       continue;
-      double t=num/dt;
+      Real dt=Dot(e.ray.direction(), normal);
+      if(Abs(dt) < (Real)1.e-6)
+        continue;
+      Real t=num/dt;
       if(t>e.hitInfo.minT())
-       continue;
+        continue;
       Vector vi(e.ray.direction()*t);
-      double a1 = Dot(v1, vi)+o1;
-      if (a1 < 0.0 || a1 > 1.0)
-       continue;
-      double a2 = Dot(v2, vi)+o2;
-      if (a2 < 0.0 || a2 > 1.0)
-       continue;
-      
+      Real a1 = Dot(v1, vi)+o1;
+      if (a1 < 0 || a1 > 1)
+        continue;
+      Real a2 = Dot(v2, vi)+o2;
+      if (a2 < 0 || a2 > 1)
+        continue;
+
       if(e.hitInfo.hit(t, material, this, tex))
-       e.hitInfo.scratchpad<Point>() = Point(a1, a2, 0);
+        e.hitInfo.scratchpad<Point>() = Point(a1, a2, 0);
     }
   } else {
     for(int i=0;i<rays.getSize();i++){
       RayPacket::Element& e = rays.get(i);
-      double dt=Dot(e.ray.direction(), normal);
-      if(Abs(dt) < 1.e-6)
-       continue;
-      double t=(d-Dot(normal, e.ray.origin()))/dt;
+      Real dt=Dot(e.ray.direction(), normal);
+      if(Abs(dt) < (Real)1.e-6)
+        continue;
+      Real t=(d-Dot(normal, e.ray.origin()))/dt;
       if(t>e.hitInfo.minT())
-       continue;
+        continue;
       Point p(e.ray.origin()+e.ray.direction()*t);
       Vector vi(p-anchor);
-      double a1 = Dot(v1, vi);
-      if (a1 < 0.0 || a1 > 1.0)
-       continue;
-      double a2 = Dot(v2, vi);
-      if (a2 < 0.0 || a2 > 1.0)
-       continue;
-      
+      Real a1 = Dot(v1, vi);
+      if (a1 < 0 || a1 > 1)
+        continue;
+      Real a2 = Dot(v2, vi);
+      if (a2 < 0 || a2 > 1)
+        continue;
+
       if(e.hitInfo.hit(t, material, this, tex))
-       e.hitInfo.scratchpad<Point>() = Point(a1, a2, 0);
+        e.hitInfo.scratchpad<Point>() = Point(a1, a2, 0);
     }
   }
 }

Modified: branches/itanium2/Model/Primitives/Parallelogram.h
==============================================================================
--- branches/itanium2/Model/Primitives/Parallelogram.h  (original)
+++ branches/itanium2/Model/Primitives/Parallelogram.h  Fri Oct 14 11:38:07 
2005
@@ -25,7 +25,7 @@
     Point anchor;
     Vector v1, v2;
     Vector normal;
-    double d;
+    Real d;
   };
 }
 

Modified: branches/itanium2/Model/Primitives/Sphere.cc
==============================================================================
--- branches/itanium2/Model/Primitives/Sphere.cc        (original)
+++ branches/itanium2/Model/Primitives/Sphere.cc        Fri Oct 14 11:38:07 
2005
@@ -178,7 +178,11 @@
     Real angle = Clamp(n.z(), (Real)-1, (Real)1);
     Real theta = Acos(angle);
     Real phi = Atan2(n.x(), n.y());
-    e.texCoords = Point((phi+M_PI)*(1./(2*M_PI)), theta*(1./M_PI), 0);
+    Real x = (phi+(Real)M_PI)*((Real)0.5*(Real)M_1_PI);
+    Real y = theta*(Real)M_1_PI;
+    e.texCoords = Point(x,
+                        y,
+                        0);
   }
   rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
 }
@@ -193,7 +197,9 @@
     Real angle = Clamp(n.z(), (Real)-1, (Real)1);
     Real theta = Acos(angle);
     Real phi = Atan2(n.x(), n.y());
-    e.texCoords = Point((phi+M_PI)*(1./(2*M_PI)), theta*(1./M_PI), 0);
+    e.texCoords = Point((phi+(Real)M_PI)*((Real)0.5*(Real)M_1_PI),
+                        theta*(Real)M_1_PI,
+                        0);
   }
   rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
 }




  • [MANTA] r625 - in branches/itanium2: Core/Geometry Interface Model/Instances Model/Primitives, bigler, 10/14/2005

Archive powered by MHonArc 2.6.16.

Top of page