Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1248 - in trunk: Core/Color Core/Geometry Interface Model/Groups Model/Materials include scenes


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1248 - in trunk: Core/Color Core/Geometry Interface Model/Groups Model/Materials include scenes
  • Date: Wed, 6 Dec 2006 08:15:07 -0700 (MST)

Author: bigler
Date: Wed Dec  6 08:15:05 2006
New Revision: 1248

Modified:
   trunk/Core/Color/ColorSpace_fancy.h
   trunk/Core/Geometry/Vector.h
   trunk/Core/Geometry/VectorT.h
   trunk/Interface/RayPacket.h
   trunk/Model/Groups/Build_OnLogn_cc.cc
   trunk/Model/Materials/Lambertian.cc
   trunk/Model/Materials/Phong.cc
   trunk/include/RayPacketParameters.h.CMakeTemplate
   trunk/scenes/objviewer.cc
Log:

Core/Color/ColorSpace_fancy.h
Interface/RayPacket.h
Model/Groups/Build_OnLogn_cc.cc
include/RayPacketParameters.h.CMakeTemplate

  Fixes for some of the changes in operators in Vector and VectorT.

  When you create a function similar to this, you can get into problem
  with anonymous enums.

  template<typename S>
  Vector operator+(S s, const Vector& v);

  The basic problem is when you try to do something like this:

  enum {
    MyType = 1
    };

  int stuff = MyType-1;

  MyType's type is anonymous, and because of this, the compiler tries
  to match < anonymous-type > - <int> with the Vector operator+(S s,
  Vector) function.  You, of course get a compiler error.  You can fix
  this in one of two ways.

  1. Name the enum type.  In GCC, named enums have their own type and
     the Vector operator can be disregarded when looking for operator
     matches.

  enum MyEnums {
    MyType = 1
  };

  2. Cast the enum to another type when doing math operations:

  int stuff = static_cast<int>(MyType) - 1;

  Many of the changes I've made do #1, but on occation I do #2.  I'm
  not sure what the convention should be, besides scope.  If the enum
  has a far reach or would require many changes of type #2, do #1.

Core/Geometry/Vector.h
Core/Geometry/VectorT.h

  Make +,-,* operators consistent.  There should now be the same set
  of functions for +,-, and *.

  class Vector {
    Vector  operatorX (const Vector& v) const;
    Vector& operatorX=(const Vector& v);
    Vector  operatorX (Real s) const;
    Vector& operatorX=(Real s);
    template<typename S> Vector  operatorX (S s) const;
    template<typename S> Vector& operatorX=(S s);
  };

  template<typename S>
  Vector operatorX(S s, const Vector& v);

Model/Materials/Lambertian.cc

  Rearange some code to match Phong.cc.

  Use mask = shadowRays.wereNotHitSSE instead of computing it inlined.

Model/Materials/Phong.cc

  Don't use the maskedStore functions.  They seem to be slower on my
  machine.  I'll investigate this further.

  Add more comments.


scenes/objviewer.cc

  Fix VectorT operator use.


Modified: trunk/Core/Color/ColorSpace_fancy.h
==============================================================================
--- trunk/Core/Color/ColorSpace_fancy.h (original)
+++ trunk/Core/Color/ColorSpace_fancy.h Wed Dec  6 08:15:05 2006
@@ -11,10 +11,12 @@
   std::string ColorSpace<Traits>::toString() const {
     std::ostringstream out;
     out << "ColorSpace("<<NumComponents<<")(";
-    for(int i=0;i<NumComponents-1;i++)
+    // If you do math with an enum, you should do a cast to in
+    // integral type.
+    for(int i=0;i<static_cast<int>(NumComponents)-1;i++)
       out << data[i] << ", ";
     if (NumComponents > 0)
-      out << data[NumComponents-1] << ")";
+      out << data[static_cast<int>(NumComponents)-1] << ")";
     return out.str();
   }
 

Modified: trunk/Core/Geometry/Vector.h
==============================================================================
--- trunk/Core/Geometry/Vector.h        (original)
+++ trunk/Core/Geometry/Vector.h        Wed Dec  6 08:15:05 2006
@@ -148,6 +148,33 @@
       data[2] += s;
       return *this;
     }
+    template<typename S >
+    Vector operator+(S s) const
+    {
+      Real scalar = static_cast<Real>(s);
+      Vector result(data[0] + scalar,
+                    data[1] + scalar,
+                    data[2] + scalar);
+      return result;
+    }
+    template<typename S >
+    Vector operator+=(S s)
+    {
+      Real scalar = static_cast<Real>(s);
+      data[0] += scalar;
+      data[1] += scalar;
+      data[2] += scalar;
+      return *this;
+    }
+
+    // Unary operator
+    Vector operator-() const {
+      Vector result;
+      result.data[0] = -data[0];
+      result.data[1] = -data[1];
+      result.data[2] = -data[2];
+      return result;
+    }
 
     // - operator
     Vector operator-(const Vector& v) const {
@@ -176,13 +203,24 @@
       data[2] -= s;
       return *this;
     }
-    Vector operator-() const {
-      Vector result;
-      result.data[0] = -data[0];
-      result.data[1] = -data[1];
-      result.data[2] = -data[2];
+    template<typename S >
+    Vector operator-(S s) const
+    {
+      Real scalar = static_cast<Real>(s);
+      Vector result(data[0] - scalar,
+                    data[1] - scalar,
+                    data[2] - scalar);
       return result;
     }
+    template<typename S >
+    Vector operator-=(S s)
+    {
+      Real scalar = static_cast<Real>(s);
+      data[0] -= scalar;
+      data[1] -= scalar;
+      data[2] -= scalar;
+      return *this;
+    }
 
     // * operator
     Vector operator*(const Vector& v) const {
@@ -211,7 +249,25 @@
       data[2] *= s;
       return *this;
     }
-
+    template<typename S >
+    Vector operator*(S s) const
+    {
+      Real scalar = static_cast<Real>(s);
+      Vector result(data[0] * scalar,
+                    data[1] * scalar,
+                    data[2] * scalar);
+      return result;
+    }
+    template<typename S >
+    Vector operator*=(S s)
+    {
+      Real scalar = static_cast<Real>(s);
+      data[0] *= scalar;
+      data[1] *= scalar;
+      data[2] *= scalar;
+      return *this;
+    }
+    
     // / operator
     Vector operator/(const Vector& v) const {
       Vector result;
@@ -395,8 +451,8 @@
     // data without having to use a function (hopefully).
     template<typename S >
     friend Vector operator*(S s, const Vector& v);
-    template<typename S >
-    friend Vector operator*(const Vector& v, S s);
+//     template<typename S >
+//     friend Vector operator*(const Vector& v, S s);
     friend Real   Dot(const Vector& v1, const Vector& v2);
     friend Vector Cross(const Vector& v1, const Vector& v2);
     friend Vector Min(const Vector& v1, const Vector& v2);
@@ -412,7 +468,10 @@
   };
 
 
-  // Two multiplication by a scalar operators.
+  ///////////////////////////////////////////////////////
+  // Outside of the class (ie. Manta namespace)
+
+  // Scalar * Vector
   template<typename S >
   inline Vector operator*(S s, const Vector& v)
   {
@@ -424,16 +483,6 @@
   }
 
   template<typename S >
-  inline Vector operator*(const Vector& v, S s)
-  {
-    Real scalar = static_cast<Real>(s);
-    Vector result(v.data[0] * scalar,
-                  v.data[1] * scalar,
-                  v.data[2] * scalar);
-    return result;
-  }
-
-  template<typename S >
   inline Vector operator+(S s, const Vector& v)
   {
     Real scalar = static_cast<Real>(s);
@@ -444,17 +493,6 @@
   }
 
   template<typename S >
-  inline Vector operator+(const Vector& v, S s)
-  {
-    Real scalar = static_cast<Real>(s);
-    Vector result(v.data[0] + scalar,
-                  v.data[1] + scalar,
-                  v.data[2] + scalar);
-    return result;
-  }
-
-#if 0
-  template<typename S >
   inline Vector operator-(S s, const Vector& v)
   {
     Real scalar = static_cast<Real>(s);
@@ -464,16 +502,6 @@
     return result;
   }
 
-  template<typename S >
-  inline Vector operator-(const Vector& v, S s)
-  {
-    Real scalar = static_cast<Real>(s);
-    Vector result(v.data[0] - scalar,
-                  v.data[1] - scalar,
-                  v.data[2] - scalar);
-    return result;
-  }
-#endif
   inline Real Dot(const Vector& v1, const Vector& v2)
   {
     return (v1.data[0] * v2.data[0] +
@@ -524,7 +552,7 @@
                   Interpolate(v1.data[2], v2.data[2], weight[2]));
     return result;
   }
-
+  
   std::ostream& operator<< (std::ostream& os, const Vector& v);
   std::istream& operator>> (std::istream& is,       Vector& v);
 }

Modified: trunk/Core/Geometry/VectorT.h
==============================================================================
--- trunk/Core/Geometry/VectorT.h       (original)
+++ trunk/Core/Geometry/VectorT.h       Wed Dec  6 08:15:05 2006
@@ -137,69 +137,145 @@
     // object rather than a pointer to data.
     const T* getDataPtr() const { return data; }
 
+    // + operator
     VectorT<T, Dim> operator+(const VectorT<T, Dim>& v) const {
       VectorT<T, Dim> result;
       for(int i=0;i<Dim;i++)
         result.data[i] = data[i] + v.data[i];
       return result;
     }
+    VectorT<T, Dim>& operator+=(const VectorT<T, Dim>& v) {
+      for(int i=0;i<Dim;i++)
+        data[i] += v.data[i];
+      return *this;
+    }
     VectorT<T, Dim> operator+(T s) const {
       VectorT<T, Dim> result;
       for(int i=0;i<Dim;i++)
         result.data[i] = data[i] + s;
       return result;
     }
-    VectorT<T, Dim>& operator+=(const VectorT<T, Dim>& v) {
+    VectorT<T, Dim>& operator+=(T s) {
       for(int i=0;i<Dim;i++)
-        data[i] += v.data[i];
+        data[i] += s;
+      return *this;
+    }
+    template<typename S >
+    VectorT<T, Dim> operator+(S s) const
+    {
+      Real scalar = static_cast<T>(s);
+      VectorT<T, Dim> result;
+      for(int i=0;i<Dim;i++)
+        result.data[i] = data[i] + scalar;
+      return result;
+    }
+    template<typename S >
+    VectorT<T, Dim>& operator+=(S s)
+    {
+      Real scalar = static_cast<T>(s);
+      for(int i=0;i<Dim;i++)
+        data[i] += scalar;
       return *this;
     }
+
+    // Unary operator
+    VectorT<T, Dim> operator-() const {
+      VectorT<T, Dim> result;
+      for(int i=0;i<Dim;i++)
+        result.data[i] = -data[i];
+      return result;
+    }
+
+    // - operator
     VectorT<T, Dim> operator-(const VectorT<T, Dim>& v) const {
       VectorT<T, Dim> result;
       for(int i=0;i<Dim;i++)
         result.data[i] = data[i] - v.data[i];
       return result;
     }
+    VectorT<T, Dim>& operator-=(const VectorT<T, Dim>& v) {
+      for(int i=0;i<Dim;i++)
+        data[i] -= v.data[i];
+      return *this;
+    }
     VectorT<T, Dim> operator-(T s) const {
       VectorT<T, Dim> result;
       for(int i=0;i<Dim;i++)
         result.data[i] = data[i] - s;
       return result;
     }
-    VectorT<T, Dim>& operator-=(const VectorT<T, Dim>& v) {
+    VectorT<T, Dim> operator-=(T s) {
+      VectorT<T, Dim> result;
       for(int i=0;i<Dim;i++)
-        data[i] -= v.data[i];
+        data[i] -= s;
       return *this;
     }
-    VectorT<T, Dim> operator-() const {
+    template<typename S >
+    VectorT<T, Dim> operator-(S s) const
+    {
+      Real scalar = static_cast<T>(s);
       VectorT<T, Dim> result;
       for(int i=0;i<Dim;i++)
-        result.data[i] = -data[i];
+        result.data[i] = data[i] - scalar;
       return result;
     }
+    template<typename S >
+    VectorT<T, Dim>& operator-=(S s)
+    {
+      Real scalar = static_cast<T>(s);
+      for(int i=0;i<Dim;i++)
+        data[i] -= scalar;
+      return *this;
+    }
 
+    // * operator
     VectorT<T, Dim> operator*(const VectorT<T, Dim>& v) const {
       VectorT<T, Dim> result;
       for(int i=0;i<Dim;i++)
         result.data[i] = data[i] * v.data[i];
       return result;
     }
+    VectorT<T, Dim>& operator*=(const VectorT<T, Dim>& v) {
+      for(int i=0;i<Dim;i++)
+        data[i] *= v.data[i];
+      return *this;
+    }
     VectorT<T, Dim> operator*(T s) const {
       VectorT<T, Dim> result;
       for(int i=0;i<Dim;i++)
         result.data[i] = data[i] * s;
       return result;
     }
-    VectorT<T, Dim>& operator*=(const VectorT<T, Dim>& v) {
+    VectorT<T, Dim>& operator*=(T s) {
       for(int i=0;i<Dim;i++)
-        data[i] *= v.data[i];
+        data[i] *= s;
       return *this;
     }
-    VectorT<T, Dim>& operator*=(T s) {
+    template<typename S >
+    VectorT<T, Dim> operator*(S s) const
+    {
+      Real scalar = static_cast<T>(s);
+      VectorT<T, Dim> result;
       for(int i=0;i<Dim;i++)
-        data[i] *= s;
+        result.data[i] = data[i] * scalar;
+      return result;
+    }
+    template<typename S >
+    VectorT<T, Dim>& operator*=(S s)
+    {
+      Real scalar = static_cast<T>(s);
+      for(int i=0;i<Dim;i++)
+        data[i] *= scalar;
       return *this;
     }
+
+    // / operator
+    VectorT<T, Dim> operator/(const VectorT<T, Dim>& v) const {
+      VectorT<T, Dim> result;
+      for(int i=0;i<Dim;i++)
+        result.data[i] = data[i] / v.data[i];
+      return result;
+    }
     VectorT<T, Dim> operator/(T s) const {
       T inv_s = 1/s;
       VectorT<T, Dim> result;
@@ -213,12 +289,6 @@
         data[i] *= inv_s;
       return *this;
     }
-    VectorT<T, Dim> operator/(const VectorT<T, Dim>& v) const {
-      VectorT<T, Dim> result;
-      for(int i=0;i<Dim;i++)
-        result.data[i] = data[i] / v.data[i];
-      return result;
-    }
 
     bool operator==(const VectorT<T, Dim>& right) const {
       for (int i = 0; i < Dim; ++i)
@@ -343,12 +413,22 @@
   }
 
   template<typename T, int Dim, typename S >
-  inline VectorT<T, Dim> operator*(const VectorT<T, Dim>& v, S s)
+  inline VectorT<T, Dim> operator+(S s, const VectorT<T, Dim>& v)
+  {
+    T scalar = static_cast<T>(s);
+    VectorT<T, Dim> result;
+    for(int i=0;i<Dim;i++)
+      result[i] = scalar + v[i];
+    return result;
+  }
+
+  template<typename T, int Dim, typename S >
+  inline VectorT<T, Dim> operator-(S s, const VectorT<T, Dim>& v)
   {
     T scalar = static_cast<T>(s);
     VectorT<T, Dim> result;
     for(int i=0;i<Dim;i++)
-      result[i] = v[i] * scalar;
+      result[i] = scalar - v[i];
     return result;
   }
 

Modified: trunk/Interface/RayPacket.h
==============================================================================
--- trunk/Interface/RayPacket.h (original)
+++ trunk/Interface/RayPacket.h Wed Dec  6 08:15:05 2006
@@ -57,15 +57,15 @@
 
   class MANTA_ALIGN(16) RayPacketData {
   public:
-    enum {
+    enum RayPacketDataSizes {
       // Scratchpads - 8 values of 4 bytes, 4 values of 8 bytes,
       MaxScratchpad4 = 8,
       MaxScratchpad8 = 4,
       MaxScratchpadSize = SCRATCHPAD_MAXSIZE,
       MaxSize              = RAYPACKET_MAXSIZE,
-#ifdef MANTA_SSE      
+#ifdef MANTA_SSE
       SSE_MaxSize   = (RAYPACKET_MAXSIZE+3)/4,
-#endif      
+#endif
     };
     RayPacketData()
       {
@@ -118,13 +118,15 @@
 
   class RayPacket {
   public:
-    enum {
+    enum RayPacketSizes {
       MaxSize               = RayPacketData::MaxSize,
       
 #ifdef MANTA_SSE
       SSE_MaxSize           = RayPacketData::SSE_MaxSize,
 #endif
+    };
 
+    enum RayPacketFlags {
       // Flags.
       ConstantOrigin        = 0x0001,
       ConstantEye           = 0x0002,

Modified: trunk/Model/Groups/Build_OnLogn_cc.cc
==============================================================================
--- trunk/Model/Groups/Build_OnLogn_cc.cc       (original)
+++ trunk/Model/Groups/Build_OnLogn_cc.cc       Wed Dec  6 08:15:05 2006
@@ -199,7 +199,7 @@
     // Iterate over dimensions.
     for (int d=0;d<3;++d) {
 
-      const unsigned int axis_flag = AxisX+d;
+      const unsigned int axis_flag = static_cast<unsigned int>(AxisX)+d;
 
       // Check to see if the box is planar in this dimension.
       if (box[1][d] == box[0][d]) {

Modified: trunk/Model/Materials/Lambertian.cc
==============================================================================
--- trunk/Model/Materials/Lambertian.cc (original)
+++ trunk/Model/Materials/Lambertian.cc Wed Dec  6 08:15:05 2006
@@ -57,20 +57,20 @@
   // Shade a bunch of rays.  We know that they all have the same intersected
   // object and are all of the same material
 
-  // Compute normals
-  rays.computeFFNormals(context);
+  // We normalized directions for proper dot product computation.
+  rays.normalizeDirections();
 
   // Compute colors
   Packet<Color> diffuse;
   colortex->mapValues(diffuse, context, rays);
 
+  // Compute normals
+  rays.computeFFNormals(context);
+
   // Compute ambient contributions for all rays
   MANTA_ALIGN(16) ColorArray totalLight;
   activeLights->getAmbientLight()->computeAmbient(context, rays, totalLight);
 
-  // We normalized directions for proper dot product computation.
-  rays.normalizeDirections();
-
   ShadowAlgorithm::StateBuffer stateBuffer;
   bool firstTime = true;
   bool done;
@@ -123,25 +123,9 @@
       RayPacketData* shadowData = shadowRays.data;
       for(;i<e;i+=4){
 
-        // Compute a mask for the shadow rays that hit something.
-        // mask[i] is 0 if shadowRays[i] is in shadow.
-#ifdef __x86_64
-
-        // Check Phong.cc to see if the _mm_load_pd function is ever
-        // made to work.  For now this is the method that seems to not
-        // break in most compilers.
-        __m128 masklo = _mm_castpd_ps( _mm_cmpeq_pd( 
_mm_set_pd((double)(size_t)shadowData->hitMatl[i+0],
-                                                                
(double)(size_t)shadowData->hitMatl[i+1]),
-                                                     _mm_setzero_pd() ));
-        __m128 maskhi = _mm_castpd_ps( _mm_cmpeq_pd ( 
_mm_set_pd((double)(size_t)shadowData->hitMatl[i+2],
-                                                                 
(double)(size_t)shadowData->hitMatl[i+3] ),
-                                                      _mm_setzero_pd() ));
+        // We are interested in the rays that didn't hit anything
+        __m128 mask = shadowRays.wereNotHitSSE(i);
         
-        __m128 mask = _mm_shuffle_ps(masklo, maskhi, _MM_SHUFFLE(2, 0, 2, 
0));
-#else
-        __m128 mask = 
_mm_cmpeq_ps(_mm_load_ps((float*)&shadowData->hitMatl[i]), _mm_setzero_ps());
-#endif
-
         if(_mm_movemask_ps(mask) == 0)
           // All hit points are in shadow
           continue;
@@ -189,7 +173,7 @@
         }
       }
     }
-#else
+#else // ifdef MANTA_SSE
     for(int i=shadowRays.begin(); i < shadowRays.end(); i++){
       if(!shadowRays.wasHit(i)){
         // Not in shadow, so compute the direct lighting contributions.
@@ -201,7 +185,7 @@
           totalLight[k][i] += light[k]*cos_theta;
       }
     }
-#endif
+#endif // ifdef MANTA_SSE
     firstTime = false;
   } while(!done);
 

Modified: trunk/Model/Materials/Phong.cc
==============================================================================
--- trunk/Model/Materials/Phong.cc      (original)
+++ trunk/Model/Materials/Phong.cc      Wed Dec  6 08:15:05 2006
@@ -49,7 +49,7 @@
 
 using namespace Manta;
 
-#define USE_MASKEDSTORE 1
+#define USE_MASKEDSTORE 0
 #define USE_INTMASKEDSTORE 0
 
 #if 0
@@ -222,24 +222,34 @@
         __m128 mask = shadowRays.wereNotHitSSE(i);
         
         if(_mm_movemask_ps(mask) == 0)
+          // All hit points are in shadow
           continue;
+
         // Not in shadow, so compute the direct and specular contributions.
+
+        // Vector normal = rays.getNormal(i)
         __m128 normalx = _mm_load_ps(&data->ffnormal[0][i]);
         __m128 normaly = _mm_load_ps(&data->ffnormal[1][i]);
         __m128 normalz = _mm_load_ps(&data->ffnormal[2][i]);
+        // Vector shadowdir = shadowRays.getDirection(i);
         __m128 sdx = _mm_load_ps(&shadowData->direction[0][i]);
         __m128 sdy = _mm_load_ps(&shadowData->direction[1][i]);
         __m128 sdz = _mm_load_ps(&shadowData->direction[2][i]);
+        // ColorComponent cos_theta = Dot(shadowdir, normal);
         __m128 cos_theta = _mm_add_ps(_mm_add_ps(_mm_mul_ps(sdx, normalx), 
_mm_mul_ps(sdy, normaly)), _mm_mul_ps(sdz, normalz));
-
+        // Color light = shadowRays.getColor(i);
         __m128 lightr = _mm_load_ps(&shadowData->color[0][i]);
         __m128 lightg = _mm_load_ps(&shadowData->color[1][i]);
         __m128 lightb = _mm_load_ps(&shadowData->color[2][i]);
+        // for(int k = 0; k < Color::NumComponents;k++)
+        //   totalLight[k][i] += light[k]*cos_theta;
         if(_mm_movemask_ps(mask) == 0xf){
+          // All the rays are not in shadow
           _mm_store_ps(&ambientAndDiffuseLight[0][i], 
_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[0][i]), _mm_mul_ps(lightr, 
cos_theta)));
           _mm_store_ps(&ambientAndDiffuseLight[1][i], 
_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[1][i]), _mm_mul_ps(lightg, 
cos_theta)));
           _mm_store_ps(&ambientAndDiffuseLight[2][i], 
_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[2][i]), _mm_mul_ps(lightb, 
cos_theta)));
         } else {
+          // Some rays are in shadow so only copy over data for those that 
are.
 #if USE_MASKEDSTORE
 #if USE_INTMASKEDSTORE
           maskedStore_si128(_mm_castps_si128(mask),
@@ -325,6 +335,7 @@
 #endif // USE_MASKEDSTORE
         }
       }
+      // Pick up the trailing bits
       for(;i<rays.rayEnd;i++){
         if(!shadowRays.wasHit(i)){
           // Not in shadow, so compute the direct and specular contributions.

Modified: trunk/include/RayPacketParameters.h.CMakeTemplate
==============================================================================
--- trunk/include/RayPacketParameters.h.CMakeTemplate   (original)
+++ trunk/include/RayPacketParameters.h.CMakeTemplate   Wed Dec  6 08:15:05 
2006
@@ -31,7 +31,7 @@
 
 namespace Manta {
   // Parameters configured by CMake.
-  enum {
+  enum RayPacketParameters {
     RAYPACKET_MAXSIZE  = ${MANTA_RAYPACKET_MAXSIZE},
     SCRATCHPAD_MAXSIZE = ${MANTA_SCRATCHPAD_MAXSIZE}
   };

Modified: trunk/scenes/objviewer.cc
==============================================================================
--- trunk/scenes/objviewer.cc   (original)
+++ trunk/scenes/objviewer.cc   Wed Dec  6 08:15:05 2006
@@ -205,7 +205,7 @@
     
///////////////////////////////////////////////////////////////////////////
     // Center the model
     if (center_object) {
-        Vector translate = ((Vector(bmax) + Vector(bmin)) * 0.5);
+        Vectorf translate((Vector(bmax) + Vector(bmin)) * 0.5);
 
         std::cerr << "Min: " << bmin << " Max: " << bmax << " translate: " 
<< translate << std::endl;
 
@@ -213,7 +213,7 @@
         for (int i=1;i<=model->numvertices;++i) {
             vertex = (Vectorf *)&model->vertices[i*3];
 
-            (*vertex) = (*vertex) - translate;
+            vertex->operator-=(translate);
         }
     }
 




  • [MANTA] r1248 - in trunk: Core/Color Core/Geometry Interface Model/Groups Model/Materials include scenes, bigler, 12/06/2006

Archive powered by MHonArc 2.6.16.

Top of page