Hi All,

What i have gone for is replacing the Vec *= Vec and Vec /= Vec
methods with inlined Vec componentMultiply(Vec,Vec) and Vec
componentDivide(Vec,Vec).  I've gone for the long winded name instead
of scale as this way both the multiple and divide versions follow the
same convention.

The changes are all of the form:

--- Vec4f       (revision 10817)
+++ Vec4f       (working copy)
@@ -147,16 +147,6 @@
             return *this;
         }

-        /** Unary multiply by vector. */
-        inline Vec4f& operator *= (const Vec4f& rhs)
-        {
-            _v[0]*=rhs[0];
-            _v[1]*=rhs[1];
-            _v[2]*=rhs[2];
-            _v[3]*=rhs[3];
-            return *this;
-        }
-
         /** Divide by scalar. */
         inline Vec4f operator / (value_type rhs) const
         {
@@ -173,16 +163,6 @@
             return *this;
         }

-        /** Unary divide by vector. */
-        inline Vec4f& operator /= (const Vec4f& rhs)
-        {
-            _v[0]/=rhs[0];
-            _v[1]/=rhs[1];
-            _v[2]/=rhs[2];
-            _v[3]/=rhs[3];
-            return *this;
-        }
-
         /** Binary vector add. */
         inline Vec4f operator + (const Vec4f& rhs) const
         {
@@ -256,8 +236,6 @@

 };    // end of class Vec4f

-
-
 /** Compute the dot product of a (Vec3,1.0) and a Vec4f. */
 inline Vec4f::value_type operator * (const Vec3f& lhs,const Vec4f& rhs)
 {
@@ -270,6 +248,18 @@
     return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+lhs[3];
 }

+/** multiply by vector components. */
+inline Vec4f componentMultiply(const Vec4f& lhs, const Vec4f& rhs)
+{
+    return Vec4f(lhs[0]*rhs[0], lhs[1]*rhs[1], lhs[2]*rhs[2], lhs[3]*rhs[3]);
+}
+
+/** divide rhs components by rhs vector components. */
+inline Vec4f componentDivide(const Vec4f& lhs, const Vec4f& rhs)
+{
+    return Vec4f(lhs[0]/rhs[0], lhs[1]/rhs[1], lhs[2]/rhs[2], lhs[3]/rhs[3]);
+}
+
 }    // end of namespace osg
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to