On 24/11/09 2:30 PM, Robert Osfield wrote:
- /** 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;
- }
-
- /** 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;
- }
-
+/** 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]);
+}
Are there any arguments against also having a unary version?
Like (and like-wise for componentDivide):
inline Vec4f& componentMultiply(const Vec4f& rhs) {
_v[0]*=rhs[0];
_v[1]*=rhs[1];
_v[2]*=rhs[2];
_v[3]*=rhs[3];
return *this;
}
Cheers,
/ulrich
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org