diff options
Diffstat (limited to 'indra/llmath')
-rw-r--r-- | indra/llmath/v2math.cpp | 35 | ||||
-rw-r--r-- | indra/llmath/v2math.h | 140 | ||||
-rw-r--r-- | indra/llmath/v3dmath.cpp | 24 | ||||
-rw-r--r-- | indra/llmath/v3dmath.h | 196 | ||||
-rw-r--r-- | indra/llmath/v3math.cpp | 106 | ||||
-rw-r--r-- | indra/llmath/v3math.h | 271 | ||||
-rw-r--r-- | indra/llmath/v4math.cpp | 18 | ||||
-rw-r--r-- | indra/llmath/v4math.h | 119 |
8 files changed, 458 insertions, 451 deletions
diff --git a/indra/llmath/v2math.cpp b/indra/llmath/v2math.cpp index 4649e13376..198fedcb03 100644 --- a/indra/llmath/v2math.cpp +++ b/indra/llmath/v2math.cpp @@ -26,7 +26,6 @@ #include "linden_common.h" -//#include "vmath.h" #include "v2math.h" #include "v3math.h" #include "v4math.h" @@ -47,8 +46,8 @@ bool LLVector2::abs() { bool ret{ false }; - if (mV[0] < 0.f) { mV[0] = -mV[0]; ret = true; } - if (mV[1] < 0.f) { mV[1] = -mV[1]; ret = true; } + if (mV[VX] < 0.f) { mV[VX] = -mV[VX]; ret = true; } + if (mV[VY] < 0.f) { mV[VY] = -mV[VY]; ret = true; } return ret; } @@ -67,7 +66,7 @@ F32 angle_between(const LLVector2& a, const LLVector2& b) return angle; } -bool are_parallel(const LLVector2 &a, const LLVector2 &b, float epsilon) +bool are_parallel(const LLVector2& a, const LLVector2& b, F32 epsilon) { LLVector2 an = a; LLVector2 bn = b; @@ -82,28 +81,28 @@ bool are_parallel(const LLVector2 &a, const LLVector2 &b, float epsilon) } -F32 dist_vec(const LLVector2 &a, const LLVector2 &b) +F32 dist_vec(const LLVector2& a, const LLVector2& b) { - F32 x = a.mV[0] - b.mV[0]; - F32 y = a.mV[1] - b.mV[1]; + F32 x = a.mV[VX] - b.mV[VX]; + F32 y = a.mV[VY] - b.mV[VY]; return (F32) sqrt( x*x + y*y ); } -F32 dist_vec_squared(const LLVector2 &a, const LLVector2 &b) +F32 dist_vec_squared(const LLVector2& a, const LLVector2& b) { - F32 x = a.mV[0] - b.mV[0]; - F32 y = a.mV[1] - b.mV[1]; + F32 x = a.mV[VX] - b.mV[VX]; + F32 y = a.mV[VY] - b.mV[VY]; return x*x + y*y; } -F32 dist_vec_squared2D(const LLVector2 &a, const LLVector2 &b) +F32 dist_vec_squared2D(const LLVector2& a, const LLVector2& b) { - F32 x = a.mV[0] - b.mV[0]; - F32 y = a.mV[1] - b.mV[1]; + F32 x = a.mV[VX] - b.mV[VX]; + F32 y = a.mV[VY] - b.mV[VY]; return x*x + y*y; } -LLVector2 lerp(const LLVector2 &a, const LLVector2 &b, F32 u) +LLVector2 lerp(const LLVector2& a, const LLVector2& b, F32 u) { return LLVector2( a.mV[VX] + (b.mV[VX] - a.mV[VX]) * u, @@ -113,14 +112,14 @@ LLVector2 lerp(const LLVector2 &a, const LLVector2 &b, F32 u) LLSD LLVector2::getValue() const { LLSD ret; - ret[0] = mV[0]; - ret[1] = mV[1]; + ret[0] = mV[VX]; + ret[1] = mV[VY]; return ret; } void LLVector2::setValue(const LLSD& sd) { - mV[0] = (F32) sd[0].asReal(); - mV[1] = (F32) sd[1].asReal(); + mV[VX] = (F32) sd[0].asReal(); + mV[VY] = (F32) sd[1].asReal(); } diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h index a61c946304..a0ba3ec505 100644 --- a/indra/llmath/v2math.h +++ b/indra/llmath/v2math.h @@ -36,7 +36,7 @@ class LLQuaternion; // Llvector2 = |x y z w| -static const U32 LENGTHOFVECTOR2 = 2; +static constexpr U32 LENGTHOFVECTOR2 = 2; class LLVector2 { @@ -82,7 +82,7 @@ class LLVector2 const LLVector2& scaleVec(const LLVector2& vec); // scales per component by vec - bool isNull(); // Returns true if vector has a _very_small_ length + bool isNull() const; // Returns true if vector has a _very_small_ length bool isExactlyZero() const { return !mV[VX] && !mV[VY]; } F32 operator[](int idx) const { return mV[idx]; } @@ -113,16 +113,16 @@ class LLVector2 // Non-member functions -F32 angle_between(const LLVector2 &a, const LLVector2 &b); // Returns angle (radians) between a and b -bool are_parallel(const LLVector2 &a, const LLVector2 &b, F32 epsilon=F_APPROXIMATELY_ZERO); // Returns true if a and b are very close to parallel -F32 dist_vec(const LLVector2 &a, const LLVector2 &b); // Returns distance between a and b -F32 dist_vec_squared(const LLVector2 &a, const LLVector2 &b);// Returns distance squared between a and b -F32 dist_vec_squared2D(const LLVector2 &a, const LLVector2 &b);// Returns distance squared between a and b ignoring Z component -LLVector2 lerp(const LLVector2 &a, const LLVector2 &b, F32 u); // Returns a vector that is a linear interpolation between a and b +F32 angle_between(const LLVector2& a, const LLVector2& b); // Returns angle (radians) between a and b +bool are_parallel(const LLVector2& a, const LLVector2& b, F32 epsilon = F_APPROXIMATELY_ZERO); // Returns true if a and b are very close to parallel +F32 dist_vec(const LLVector2& a, const LLVector2& b); // Returns distance between a and b +F32 dist_vec_squared(const LLVector2& a, const LLVector2& b);// Returns distance squared between a and b +F32 dist_vec_squared2D(const LLVector2& a, const LLVector2& b);// Returns distance squared between a and b ignoring Z component +LLVector2 lerp(const LLVector2& a, const LLVector2& b, F32 u); // Returns a vector that is a linear interpolation between a and b // Constructors -inline LLVector2::LLVector2(void) +inline LLVector2::LLVector2() { mV[VX] = 0.f; mV[VY] = 0.f; @@ -153,27 +153,27 @@ inline LLVector2::LLVector2(const LLSD &sd) // Clear and Assignment Functions -inline void LLVector2::clear(void) +inline void LLVector2::clear() { mV[VX] = 0.f; mV[VY] = 0.f; } -inline void LLVector2::setZero(void) +inline void LLVector2::setZero() { mV[VX] = 0.f; mV[VY] = 0.f; } // deprecated -inline void LLVector2::clearVec(void) +inline void LLVector2::clearVec() { mV[VX] = 0.f; mV[VY] = 0.f; } // deprecated -inline void LLVector2::zeroVec(void) +inline void LLVector2::zeroVec() { mV[VX] = 0.f; mV[VY] = 0.f; @@ -222,31 +222,31 @@ inline void LLVector2::setVec(const F32 *vec) // LLVector2 Magnitude and Normalization Functions -inline F32 LLVector2::length(void) const +inline F32 LLVector2::length() const { - return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]); + return sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY]); } -inline F32 LLVector2::lengthSquared(void) const +inline F32 LLVector2::lengthSquared() const { - return mV[0]*mV[0] + mV[1]*mV[1]; + return mV[VX]*mV[VX] + mV[VY]*mV[VY]; } -inline F32 LLVector2::normalize(void) +inline F32 LLVector2::normalize() { - F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]); + F32 mag = sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY]); F32 oomag; if (mag > FP_MAG_THRESHOLD) { oomag = 1.f/mag; - mV[0] *= oomag; - mV[1] *= oomag; + mV[VX] *= oomag; + mV[VY] *= oomag; } else { - mV[0] = 0.f; - mV[1] = 0.f; + mV[VX] = 0.f; + mV[VY] = 0.f; mag = 0; } return (mag); @@ -259,33 +259,33 @@ inline bool LLVector2::isFinite() const } // deprecated -inline F32 LLVector2::magVec(void) const +inline F32 LLVector2::magVec() const { - return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]); + return sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY]); } // deprecated -inline F32 LLVector2::magVecSquared(void) const +inline F32 LLVector2::magVecSquared() const { - return mV[0]*mV[0] + mV[1]*mV[1]; + return mV[VX]*mV[VX] + mV[VY]*mV[VY]; } // deprecated -inline F32 LLVector2::normVec(void) +inline F32 LLVector2::normVec() { - F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]); + F32 mag = sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY]); F32 oomag; if (mag > FP_MAG_THRESHOLD) { oomag = 1.f/mag; - mV[0] *= oomag; - mV[1] *= oomag; + mV[VX] *= oomag; + mV[VY] *= oomag; } else { - mV[0] = 0.f; - mV[1] = 0.f; + mV[VX] = 0.f; + mV[VY] = 0.f; mag = 0; } return (mag); @@ -299,7 +299,7 @@ inline const LLVector2& LLVector2::scaleVec(const LLVector2& vec) return *this; } -inline bool LLVector2::isNull() +inline bool LLVector2::isNull() const { if ( F_APPROXIMATELY_ZERO > mV[VX]*mV[VX] + mV[VY]*mV[VY] ) { @@ -312,7 +312,7 @@ inline bool LLVector2::isNull() // LLVector2 Operators // For sorting. By convention, x is "more significant" than y. -inline bool operator<(const LLVector2 &a, const LLVector2 &b) +inline bool operator<(const LLVector2& a, const LLVector2& b) { if( a.mV[VX] == b.mV[VX] ) { @@ -325,95 +325,95 @@ inline bool operator<(const LLVector2 &a, const LLVector2 &b) } -inline LLVector2 operator+(const LLVector2 &a, const LLVector2 &b) +inline LLVector2 operator+(const LLVector2& a, const LLVector2& b) { LLVector2 c(a); return c += b; } -inline LLVector2 operator-(const LLVector2 &a, const LLVector2 &b) +inline LLVector2 operator-(const LLVector2& a, const LLVector2& b) { LLVector2 c(a); return c -= b; } -inline F32 operator*(const LLVector2 &a, const LLVector2 &b) +inline F32 operator*(const LLVector2& a, const LLVector2& b) { - return (a.mV[0]*b.mV[0] + a.mV[1]*b.mV[1]); + return (a.mV[VX]*b.mV[VX] + a.mV[VY]*b.mV[VY]); } -inline LLVector2 operator%(const LLVector2 &a, const LLVector2 &b) +inline LLVector2 operator%(const LLVector2& a, const LLVector2& b) { - return LLVector2(a.mV[0]*b.mV[1] - b.mV[0]*a.mV[1], a.mV[1]*b.mV[0] - b.mV[1]*a.mV[0]); + return LLVector2(a.mV[VX]*b.mV[VY] - b.mV[VX]*a.mV[VY], a.mV[VY]*b.mV[VX] - b.mV[VY]*a.mV[VX]); } -inline LLVector2 operator/(const LLVector2 &a, F32 k) +inline LLVector2 operator/(const LLVector2& a, F32 k) { F32 t = 1.f / k; - return LLVector2( a.mV[0] * t, a.mV[1] * t ); + return LLVector2( a.mV[VX] * t, a.mV[VY] * t ); } -inline LLVector2 operator*(const LLVector2 &a, F32 k) +inline LLVector2 operator*(const LLVector2& a, F32 k) { - return LLVector2( a.mV[0] * k, a.mV[1] * k ); + return LLVector2( a.mV[VX] * k, a.mV[VY] * k ); } -inline LLVector2 operator*(F32 k, const LLVector2 &a) +inline LLVector2 operator*(F32 k, const LLVector2& a) { - return LLVector2( a.mV[0] * k, a.mV[1] * k ); + return LLVector2( a.mV[VX] * k, a.mV[VY] * k ); } -inline bool operator==(const LLVector2 &a, const LLVector2 &b) +inline bool operator==(const LLVector2& a, const LLVector2& b) { - return ( (a.mV[0] == b.mV[0]) - &&(a.mV[1] == b.mV[1])); + return ( (a.mV[VX] == b.mV[VX]) + &&(a.mV[VY] == b.mV[VY])); } -inline bool operator!=(const LLVector2 &a, const LLVector2 &b) +inline bool operator!=(const LLVector2& a, const LLVector2& b) { - return ( (a.mV[0] != b.mV[0]) - ||(a.mV[1] != b.mV[1])); + return ( (a.mV[VX] != b.mV[VX]) + ||(a.mV[VY] != b.mV[VY])); } -inline const LLVector2& operator+=(LLVector2 &a, const LLVector2 &b) +inline const LLVector2& operator+=(LLVector2& a, const LLVector2& b) { - a.mV[0] += b.mV[0]; - a.mV[1] += b.mV[1]; + a.mV[VX] += b.mV[VX]; + a.mV[VY] += b.mV[VY]; return a; } -inline const LLVector2& operator-=(LLVector2 &a, const LLVector2 &b) +inline const LLVector2& operator-=(LLVector2& a, const LLVector2& b) { - a.mV[0] -= b.mV[0]; - a.mV[1] -= b.mV[1]; + a.mV[VX] -= b.mV[VX]; + a.mV[VY] -= b.mV[VY]; return a; } -inline const LLVector2& operator%=(LLVector2 &a, const LLVector2 &b) +inline const LLVector2& operator%=(LLVector2& a, const LLVector2& b) { - LLVector2 ret(a.mV[0]*b.mV[1] - b.mV[0]*a.mV[1], a.mV[1]*b.mV[0] - b.mV[1]*a.mV[0]); + LLVector2 ret(a.mV[VX]*b.mV[VY] - b.mV[VX]*a.mV[VY], a.mV[VY]*b.mV[VX] - b.mV[VY]*a.mV[VX]); a = ret; return a; } -inline const LLVector2& operator*=(LLVector2 &a, F32 k) +inline const LLVector2& operator*=(LLVector2& a, F32 k) { - a.mV[0] *= k; - a.mV[1] *= k; + a.mV[VX] *= k; + a.mV[VY] *= k; return a; } -inline const LLVector2& operator/=(LLVector2 &a, F32 k) +inline const LLVector2& operator/=(LLVector2& a, F32 k) { F32 t = 1.f / k; - a.mV[0] *= t; - a.mV[1] *= t; + a.mV[VX] *= t; + a.mV[VY] *= t; return a; } -inline LLVector2 operator-(const LLVector2 &a) +inline LLVector2 operator-(const LLVector2& a) { - return LLVector2( -a.mV[0], -a.mV[1] ); + return LLVector2( -a.mV[VX], -a.mV[VY] ); } inline void update_min_max(LLVector2& min, LLVector2& max, const LLVector2& pos) @@ -431,7 +431,7 @@ inline void update_min_max(LLVector2& min, LLVector2& max, const LLVector2& pos) } } -inline std::ostream& operator<<(std::ostream& s, const LLVector2 &a) +inline std::ostream& operator<<(std::ostream& s, const LLVector2& a) { s << "{ " << a.mV[VX] << ", " << a.mV[VY] << " }"; return s; diff --git a/indra/llmath/v3dmath.cpp b/indra/llmath/v3dmath.cpp index bb55c812b5..bd6d838186 100644 --- a/indra/llmath/v3dmath.cpp +++ b/indra/llmath/v3dmath.cpp @@ -57,13 +57,13 @@ bool LLVector3d::clamp(F64 min, F64 max) { bool ret{ false }; - if (mdV[0] < min) { mdV[0] = min; ret = true; } - if (mdV[1] < min) { mdV[1] = min; ret = true; } - if (mdV[2] < min) { mdV[2] = min; ret = true; } + if (mdV[VX] < min) { mdV[VX] = min; ret = true; } + if (mdV[VY] < min) { mdV[VY] = min; ret = true; } + if (mdV[VZ] < min) { mdV[VZ] = min; ret = true; } - if (mdV[0] > max) { mdV[0] = max; ret = true; } - if (mdV[1] > max) { mdV[1] = max; ret = true; } - if (mdV[2] > max) { mdV[2] = max; ret = true; } + if (mdV[VX] > max) { mdV[VX] = max; ret = true; } + if (mdV[VY] > max) { mdV[VY] = max; ret = true; } + if (mdV[VZ] > max) { mdV[VZ] = max; ret = true; } return ret; } @@ -74,9 +74,9 @@ bool LLVector3d::abs() { bool ret{ false }; - if (mdV[0] < 0.0) { mdV[0] = -mdV[0]; ret = true; } - if (mdV[1] < 0.0) { mdV[1] = -mdV[1]; ret = true; } - if (mdV[2] < 0.0) { mdV[2] = -mdV[2]; ret = true; } + if (mdV[VX] < 0.0) { mdV[VX] = -mdV[VX]; ret = true; } + if (mdV[VY] < 0.0) { mdV[VY] = -mdV[VY]; ret = true; } + if (mdV[VZ] < 0.0) { mdV[VZ] = -mdV[VZ]; ret = true; } return ret; } @@ -89,9 +89,9 @@ std::ostream& operator<<(std::ostream& s, const LLVector3d &a) const LLVector3d& LLVector3d::operator=(const LLVector4 &a) { - mdV[0] = a.mV[0]; - mdV[1] = a.mV[1]; - mdV[2] = a.mV[2]; + mdV[VX] = a.mV[VX]; + mdV[VY] = a.mV[VY]; + mdV[VZ] = a.mV[VZ]; return *this; } diff --git a/indra/llmath/v3dmath.h b/indra/llmath/v3dmath.h index ece8c54ea4..7c94ebdf9b 100644 --- a/indra/llmath/v3dmath.h +++ b/indra/llmath/v3dmath.h @@ -54,17 +54,17 @@ class LLVector3d void setValue(const LLSD& sd) { - mdV[0] = sd[0].asReal(); - mdV[1] = sd[1].asReal(); - mdV[2] = sd[2].asReal(); + mdV[VX] = sd[0].asReal(); + mdV[VY] = sd[1].asReal(); + mdV[VZ] = sd[2].asReal(); } LLSD getValue() const { LLSD ret; - ret[0] = mdV[0]; - ret[1] = mdV[1]; - ret[2] = mdV[2]; + ret[0] = mdV[VX]; + ret[1] = mdV[VY]; + ret[2] = mdV[VZ]; return ret; } @@ -134,26 +134,26 @@ typedef LLVector3d LLGlobalVec; inline const LLVector3d &LLVector3d::set(const LLVector3 &vec) { - mdV[0] = vec.mV[0]; - mdV[1] = vec.mV[1]; - mdV[2] = vec.mV[2]; + mdV[VX] = vec.mV[VX]; + mdV[VY] = vec.mV[VY]; + mdV[VZ] = vec.mV[VZ]; return *this; } inline const LLVector3d &LLVector3d::setVec(const LLVector3 &vec) { - mdV[0] = vec.mV[0]; - mdV[1] = vec.mV[1]; - mdV[2] = vec.mV[2]; + mdV[VX] = vec.mV[VX]; + mdV[VY] = vec.mV[VY]; + mdV[VZ] = vec.mV[VZ]; return *this; } inline LLVector3d::LLVector3d(void) { - mdV[0] = 0.f; - mdV[1] = 0.f; - mdV[2] = 0.f; + mdV[VX] = 0.f; + mdV[VY] = 0.f; + mdV[VZ] = 0.f; } inline LLVector3d::LLVector3d(const F64 x, const F64 y, const F64 z) @@ -199,33 +199,33 @@ inline bool LLVector3d::isFinite() const inline const LLVector3d& LLVector3d::clear(void) { - mdV[0] = 0.f; - mdV[1] = 0.f; - mdV[2]= 0.f; + mdV[VX] = 0.f; + mdV[VY] = 0.f; + mdV[VZ] = 0.f; return (*this); } inline const LLVector3d& LLVector3d::clearVec(void) { - mdV[0] = 0.f; - mdV[1] = 0.f; - mdV[2]= 0.f; + mdV[VX] = 0.f; + mdV[VY] = 0.f; + mdV[VZ] = 0.f; return (*this); } inline const LLVector3d& LLVector3d::setZero(void) { - mdV[0] = 0.f; - mdV[1] = 0.f; - mdV[2] = 0.f; + mdV[VX] = 0.f; + mdV[VY] = 0.f; + mdV[VZ] = 0.f; return (*this); } inline const LLVector3d& LLVector3d::zeroVec(void) { - mdV[0] = 0.f; - mdV[1] = 0.f; - mdV[2] = 0.f; + mdV[VX] = 0.f; + mdV[VY] = 0.f; + mdV[VZ] = 0.f; return (*this); } @@ -239,17 +239,17 @@ inline const LLVector3d& LLVector3d::set(const F64 x, const F64 y, const F64 inline const LLVector3d& LLVector3d::set(const LLVector3d &vec) { - mdV[0] = vec.mdV[0]; - mdV[1] = vec.mdV[1]; - mdV[2] = vec.mdV[2]; + mdV[VX] = vec.mdV[VX]; + mdV[VY] = vec.mdV[VY]; + mdV[VZ] = vec.mdV[VZ]; return (*this); } inline const LLVector3d& LLVector3d::set(const F64 *vec) { - mdV[0] = vec[0]; - mdV[1] = vec[1]; - mdV[2] = vec[2]; + mdV[VX] = vec[0]; + mdV[VY] = vec[1]; + mdV[VZ] = vec[2]; return (*this); } @@ -261,61 +261,61 @@ inline const LLVector3d& LLVector3d::setVec(const F64 x, const F64 y, const F return (*this); } -inline const LLVector3d& LLVector3d::setVec(const LLVector3d &vec) +inline const LLVector3d& LLVector3d::setVec(const LLVector3d& vec) { - mdV[0] = vec.mdV[0]; - mdV[1] = vec.mdV[1]; - mdV[2] = vec.mdV[2]; + mdV[VX] = vec.mdV[VX]; + mdV[VY] = vec.mdV[VY]; + mdV[VZ] = vec.mdV[VZ]; return (*this); } -inline const LLVector3d& LLVector3d::setVec(const F64 *vec) +inline const LLVector3d& LLVector3d::setVec(const F64* vec) { - mdV[0] = vec[0]; - mdV[1] = vec[1]; - mdV[2] = vec[2]; + mdV[VX] = vec[VX]; + mdV[VY] = vec[VY]; + mdV[VZ] = vec[VZ]; return (*this); } -inline F64 LLVector3d::normVec(void) +inline F64 LLVector3d::normVec() { - F64 mag = (F32) sqrt(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]); + F64 mag = sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]); F64 oomag; if (mag > FP_MAG_THRESHOLD) { oomag = 1.f/mag; - mdV[0] *= oomag; - mdV[1] *= oomag; - mdV[2] *= oomag; + mdV[VX] *= oomag; + mdV[VY] *= oomag; + mdV[VZ] *= oomag; } else { - mdV[0] = 0.f; - mdV[1] = 0.f; - mdV[2] = 0.f; + mdV[VX] = 0.f; + mdV[VY] = 0.f; + mdV[VZ] = 0.f; mag = 0; } return (mag); } -inline F64 LLVector3d::normalize(void) +inline F64 LLVector3d::normalize() { - F64 mag = (F32) sqrt(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]); + F64 mag = sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]); F64 oomag; if (mag > FP_MAG_THRESHOLD) { oomag = 1.f/mag; - mdV[0] *= oomag; - mdV[1] *= oomag; - mdV[2] *= oomag; + mdV[VX] *= oomag; + mdV[VY] *= oomag; + mdV[VZ] *= oomag; } else { - mdV[0] = 0.f; - mdV[1] = 0.f; - mdV[2] = 0.f; + mdV[VX] = 0.f; + mdV[VY] = 0.f; + mdV[VZ] = 0.f; mag = 0; } return (mag); @@ -323,24 +323,24 @@ inline F64 LLVector3d::normalize(void) // LLVector3d Magnitude and Normalization Functions -inline F64 LLVector3d::magVec(void) const +inline F64 LLVector3d::magVec() const { - return (F32) sqrt(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]); + return sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]); } -inline F64 LLVector3d::magVecSquared(void) const +inline F64 LLVector3d::magVecSquared() const { - return mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]; + return mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]; } -inline F64 LLVector3d::length(void) const +inline F64 LLVector3d::length() const { - return (F32) sqrt(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]); + return sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]); } -inline F64 LLVector3d::lengthSquared(void) const +inline F64 LLVector3d::lengthSquared() const { - return mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]; + return mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]; } inline LLVector3d operator+(const LLVector3d& a, const LLVector3d& b) @@ -357,109 +357,109 @@ inline LLVector3d operator-(const LLVector3d& a, const LLVector3d& b) inline F64 operator*(const LLVector3d& a, const LLVector3d& b) { - return (a.mdV[0]*b.mdV[0] + a.mdV[1]*b.mdV[1] + a.mdV[2]*b.mdV[2]); + return (a.mdV[VX]*b.mdV[VX] + a.mdV[VY]*b.mdV[VY] + a.mdV[VZ]*b.mdV[VZ]); } inline LLVector3d operator%(const LLVector3d& a, const LLVector3d& b) { - return LLVector3d( a.mdV[1]*b.mdV[2] - b.mdV[1]*a.mdV[2], a.mdV[2]*b.mdV[0] - b.mdV[2]*a.mdV[0], a.mdV[0]*b.mdV[1] - b.mdV[0]*a.mdV[1] ); + return LLVector3d( a.mdV[VY]*b.mdV[VZ] - b.mdV[VY]*a.mdV[VZ], a.mdV[VZ]*b.mdV[VX] - b.mdV[VZ]*a.mdV[VX], a.mdV[VX]*b.mdV[VY] - b.mdV[VX]*a.mdV[VY] ); } inline LLVector3d operator/(const LLVector3d& a, const F64 k) { F64 t = 1.f / k; - return LLVector3d( a.mdV[0] * t, a.mdV[1] * t, a.mdV[2] * t ); + return LLVector3d( a.mdV[VX] * t, a.mdV[VY] * t, a.mdV[VZ] * t ); } inline LLVector3d operator*(const LLVector3d& a, const F64 k) { - return LLVector3d( a.mdV[0] * k, a.mdV[1] * k, a.mdV[2] * k ); + return LLVector3d( a.mdV[VX] * k, a.mdV[VY] * k, a.mdV[VZ] * k ); } inline LLVector3d operator*(F64 k, const LLVector3d& a) { - return LLVector3d( a.mdV[0] * k, a.mdV[1] * k, a.mdV[2] * k ); + return LLVector3d( a.mdV[VX] * k, a.mdV[VY] * k, a.mdV[VZ] * k ); } inline bool operator==(const LLVector3d& a, const LLVector3d& b) { - return ( (a.mdV[0] == b.mdV[0]) - &&(a.mdV[1] == b.mdV[1]) - &&(a.mdV[2] == b.mdV[2])); + return ( (a.mdV[VX] == b.mdV[VX]) + &&(a.mdV[VY] == b.mdV[VY]) + &&(a.mdV[VZ] == b.mdV[VZ])); } inline bool operator!=(const LLVector3d& a, const LLVector3d& b) { - return ( (a.mdV[0] != b.mdV[0]) - ||(a.mdV[1] != b.mdV[1]) - ||(a.mdV[2] != b.mdV[2])); + return ( (a.mdV[VX] != b.mdV[VX]) + ||(a.mdV[VY] != b.mdV[VY]) + ||(a.mdV[VZ] != b.mdV[VZ])); } inline const LLVector3d& operator+=(LLVector3d& a, const LLVector3d& b) { - a.mdV[0] += b.mdV[0]; - a.mdV[1] += b.mdV[1]; - a.mdV[2] += b.mdV[2]; + a.mdV[VX] += b.mdV[VX]; + a.mdV[VY] += b.mdV[VY]; + a.mdV[VZ] += b.mdV[VZ]; return a; } inline const LLVector3d& operator-=(LLVector3d& a, const LLVector3d& b) { - a.mdV[0] -= b.mdV[0]; - a.mdV[1] -= b.mdV[1]; - a.mdV[2] -= b.mdV[2]; + a.mdV[VX] -= b.mdV[VX]; + a.mdV[VY] -= b.mdV[VY]; + a.mdV[VZ] -= b.mdV[VZ]; return a; } inline const LLVector3d& operator%=(LLVector3d& a, const LLVector3d& b) { - LLVector3d ret( a.mdV[1]*b.mdV[2] - b.mdV[1]*a.mdV[2], a.mdV[2]*b.mdV[0] - b.mdV[2]*a.mdV[0], a.mdV[0]*b.mdV[1] - b.mdV[0]*a.mdV[1]); + LLVector3d ret( a.mdV[VY]*b.mdV[VZ] - b.mdV[VY]*a.mdV[VZ], a.mdV[VZ]*b.mdV[VX] - b.mdV[VZ]*a.mdV[VX], a.mdV[VX]*b.mdV[VY] - b.mdV[VX]*a.mdV[VY]); a = ret; return a; } inline const LLVector3d& operator*=(LLVector3d& a, const F64 k) { - a.mdV[0] *= k; - a.mdV[1] *= k; - a.mdV[2] *= k; + a.mdV[VX] *= k; + a.mdV[VY] *= k; + a.mdV[VZ] *= k; return a; } inline const LLVector3d& operator/=(LLVector3d& a, const F64 k) { F64 t = 1.f / k; - a.mdV[0] *= t; - a.mdV[1] *= t; - a.mdV[2] *= t; + a.mdV[VX] *= t; + a.mdV[VY] *= t; + a.mdV[VZ] *= t; return a; } inline LLVector3d operator-(const LLVector3d& a) { - return LLVector3d( -a.mdV[0], -a.mdV[1], -a.mdV[2] ); + return LLVector3d( -a.mdV[VX], -a.mdV[VY], -a.mdV[VZ] ); } inline F64 dist_vec(const LLVector3d& a, const LLVector3d& b) { - F64 x = a.mdV[0] - b.mdV[0]; - F64 y = a.mdV[1] - b.mdV[1]; - F64 z = a.mdV[2] - b.mdV[2]; + F64 x = a.mdV[VX] - b.mdV[VX]; + F64 y = a.mdV[VY] - b.mdV[VY]; + F64 z = a.mdV[VZ] - b.mdV[VZ]; return (F32) sqrt( x*x + y*y + z*z ); } inline F64 dist_vec_squared(const LLVector3d& a, const LLVector3d& b) { - F64 x = a.mdV[0] - b.mdV[0]; - F64 y = a.mdV[1] - b.mdV[1]; - F64 z = a.mdV[2] - b.mdV[2]; + F64 x = a.mdV[VX] - b.mdV[VX]; + F64 y = a.mdV[VY] - b.mdV[VY]; + F64 z = a.mdV[VZ] - b.mdV[VZ]; return x*x + y*y + z*z; } inline F64 dist_vec_squared2D(const LLVector3d& a, const LLVector3d& b) { - F64 x = a.mdV[0] - b.mdV[0]; - F64 y = a.mdV[1] - b.mdV[1]; + F64 x = a.mdV[VX] - b.mdV[VX]; + F64 y = a.mdV[VY] - b.mdV[VY]; return x*x + y*y; } diff --git a/indra/llmath/v3math.cpp b/indra/llmath/v3math.cpp index 73ad2a4ed6..941a122528 100644 --- a/indra/llmath/v3math.cpp +++ b/indra/llmath/v3math.cpp @@ -58,13 +58,13 @@ bool LLVector3::clamp(F32 min, F32 max) { bool ret{ false }; - if (mV[0] < min) { mV[0] = min; ret = true; } - if (mV[1] < min) { mV[1] = min; ret = true; } - if (mV[2] < min) { mV[2] = min; ret = true; } + if (mV[VX] < min) { mV[VX] = min; ret = true; } + if (mV[VY] < min) { mV[VY] = min; ret = true; } + if (mV[VZ] < min) { mV[VZ] = min; ret = true; } - if (mV[0] > max) { mV[0] = max; ret = true; } - if (mV[1] > max) { mV[1] = max; ret = true; } - if (mV[2] > max) { mV[2] = max; ret = true; } + if (mV[VX] > max) { mV[VX] = max; ret = true; } + if (mV[VY] > max) { mV[VY] = max; ret = true; } + if (mV[VZ] > max) { mV[VZ] = max; ret = true; } return ret; } @@ -85,9 +85,9 @@ bool LLVector3::clampLength( F32 length_limit ) { length_limit = 0.f; } - mV[0] *= length_limit; - mV[1] *= length_limit; - mV[2] *= length_limit; + mV[VX] *= length_limit; + mV[VY] *= length_limit; + mV[VZ] *= length_limit; changed = true; } } @@ -116,35 +116,35 @@ bool LLVector3::clampLength( F32 length_limit ) { // yes it can be salvaged --> // bring the components down before we normalize - mV[0] /= max_abs_component; - mV[1] /= max_abs_component; - mV[2] /= max_abs_component; + mV[VX] /= max_abs_component; + mV[VY] /= max_abs_component; + mV[VZ] /= max_abs_component; normalize(); if (length_limit < 0.f) { length_limit = 0.f; } - mV[0] *= length_limit; - mV[1] *= length_limit; - mV[2] *= length_limit; + mV[VX] *= length_limit; + mV[VY] *= length_limit; + mV[VZ] *= length_limit; } } return changed; } -bool LLVector3::clamp(const LLVector3 &min_vec, const LLVector3 &max_vec) +bool LLVector3::clamp(const LLVector3& min_vec, const LLVector3& max_vec) { bool ret{ false }; - if (mV[0] < min_vec[0]) { mV[0] = min_vec[0]; ret = true; } - if (mV[1] < min_vec[1]) { mV[1] = min_vec[1]; ret = true; } - if (mV[2] < min_vec[2]) { mV[2] = min_vec[2]; ret = true; } + if (mV[VX] < min_vec[0]) { mV[VX] = min_vec[0]; ret = true; } + if (mV[VY] < min_vec[1]) { mV[VY] = min_vec[1]; ret = true; } + if (mV[VZ] < min_vec[2]) { mV[VZ] = min_vec[2]; ret = true; } - if (mV[0] > max_vec[0]) { mV[0] = max_vec[0]; ret = true; } - if (mV[1] > max_vec[1]) { mV[1] = max_vec[1]; ret = true; } - if (mV[2] > max_vec[2]) { mV[2] = max_vec[2]; ret = true; } + if (mV[VX] > max_vec[0]) { mV[VX] = max_vec[0]; ret = true; } + if (mV[VY] > max_vec[1]) { mV[VY] = max_vec[1]; ret = true; } + if (mV[VZ] > max_vec[2]) { mV[VZ] = max_vec[2]; ret = true; } return ret; } @@ -156,9 +156,9 @@ bool LLVector3::abs() { bool ret{ false }; - if (mV[0] < 0.f) { mV[0] = -mV[0]; ret = true; } - if (mV[1] < 0.f) { mV[1] = -mV[1]; ret = true; } - if (mV[2] < 0.f) { mV[2] = -mV[2]; ret = true; } + if (mV[VX] < 0.f) { mV[VX] = -mV[VX]; ret = true; } + if (mV[VY] < 0.f) { mV[VY] = -mV[VY]; ret = true; } + if (mV[VZ] < 0.f) { mV[VZ] = -mV[VZ]; ret = true; } return ret; } @@ -194,13 +194,13 @@ void LLVector3::snap(S32 sig_digits) mV[VZ] = snap_to_sig_figs(mV[VZ], sig_digits); } -const LLVector3& LLVector3::rotVec(const LLMatrix3 &mat) +const LLVector3& LLVector3::rotVec(const LLMatrix3& mat) { *this = *this * mat; return *this; } -const LLVector3& LLVector3::rotVec(const LLQuaternion &q) +const LLVector3& LLVector3::rotVec(const LLQuaternion& q) { *this = *this * q; return *this; @@ -228,7 +228,7 @@ const LLVector3& LLVector3::transVec(const LLMatrix4& mat) } -const LLVector3& LLVector3::rotVec(F32 angle, const LLVector3 &vec) +const LLVector3& LLVector3::rotVec(F32 angle, const LLVector3& vec) { if ( !vec.isExactlyZero() && angle ) { @@ -263,35 +263,35 @@ LLVector3 LLVector3::scaledVec(const LLVector3& vec) const return ret; } -const LLVector3& LLVector3::set(const LLVector3d &vec) +const LLVector3& LLVector3::set(const LLVector3d& vec) { - mV[0] = (F32)vec.mdV[0]; - mV[1] = (F32)vec.mdV[1]; - mV[2] = (F32)vec.mdV[2]; + mV[VX] = (F32)vec.mdV[VX]; + mV[VY] = (F32)vec.mdV[VY]; + mV[VZ] = (F32)vec.mdV[VZ]; return (*this); } -const LLVector3& LLVector3::set(const LLVector4 &vec) +const LLVector3& LLVector3::set(const LLVector4& vec) { - mV[0] = vec.mV[0]; - mV[1] = vec.mV[1]; - mV[2] = vec.mV[2]; + mV[VX] = vec.mV[VX]; + mV[VY] = vec.mV[VY]; + mV[VZ] = vec.mV[VZ]; return (*this); } -const LLVector3& LLVector3::setVec(const LLVector3d &vec) +const LLVector3& LLVector3::setVec(const LLVector3d& vec) { - mV[0] = (F32)vec.mdV[0]; - mV[1] = (F32)vec.mdV[1]; - mV[2] = (F32)vec.mdV[2]; + mV[VX] = (F32)vec.mdV[0]; + mV[VY] = (F32)vec.mdV[1]; + mV[VZ] = (F32)vec.mdV[2]; return (*this); } -const LLVector3& LLVector3::setVec(const LLVector4 &vec) +const LLVector3& LLVector3::setVec(const LLVector4& vec) { - mV[0] = vec.mV[0]; - mV[1] = vec.mV[1]; - mV[2] = vec.mV[2]; + mV[VX] = vec.mV[VX]; + mV[VY] = vec.mV[VY]; + mV[VZ] = vec.mV[VZ]; return (*this); } @@ -302,14 +302,14 @@ LLVector3::LLVector3(const LLVector2 &vec) mV[VZ] = 0; } -LLVector3::LLVector3(const LLVector3d &vec) +LLVector3::LLVector3(const LLVector3d& vec) { mV[VX] = (F32)vec.mdV[VX]; mV[VY] = (F32)vec.mdV[VY]; mV[VZ] = (F32)vec.mdV[VZ]; } -LLVector3::LLVector3(const LLVector4 &vec) +LLVector3::LLVector3(const LLVector4& vec) { mV[VX] = (F32)vec.mV[VX]; mV[VY] = (F32)vec.mV[VY]; @@ -330,20 +330,20 @@ LLVector3::LLVector3(const LLSD& sd) LLSD LLVector3::getValue() const { LLSD ret; - ret[0] = mV[0]; - ret[1] = mV[1]; - ret[2] = mV[2]; + ret[0] = mV[VX]; + ret[1] = mV[VY]; + ret[2] = mV[VZ]; return ret; } void LLVector3::setValue(const LLSD& sd) { - mV[0] = (F32) sd[0].asReal(); - mV[1] = (F32) sd[1].asReal(); - mV[2] = (F32) sd[2].asReal(); + mV[VX] = (F32) sd[0].asReal(); + mV[VY] = (F32) sd[1].asReal(); + mV[VZ] = (F32) sd[2].asReal(); } -const LLVector3& operator*=(LLVector3 &a, const LLQuaternion &rot) +const LLVector3& operator*=(LLVector3& a, const LLQuaternion& rot) { const F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ]; const F32 rx = rot.mQ[VW] * a.mV[VX] + rot.mQ[VY] * a.mV[VZ] - rot.mQ[VZ] * a.mV[VY]; diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h index d063b15c74..53491533c2 100644 --- a/indra/llmath/v3math.h +++ b/indra/llmath/v3math.h @@ -41,7 +41,7 @@ class LLQuaternion; // LLvector3 = |x y z w| -static const U32 LENGTHOFVECTOR3 = 3; +static constexpr U32 LENGTHOFVECTOR3 = 3; class LLVector3 { @@ -169,11 +169,11 @@ LLVector3 lerp(const LLVector3 &a, const LLVector3 &b, F32 u); // Returns a vect LLVector3 point_to_box_offset(LLVector3& pos, const LLVector3* box); // Displacement from query point to nearest point on bounding box. bool box_valid_and_non_zero(const LLVector3* box); -inline LLVector3::LLVector3(void) +inline LLVector3::LLVector3() { - mV[0] = 0.f; - mV[1] = 0.f; - mV[2] = 0.f; + mV[VX] = 0.f; + mV[VY] = 0.f; + mV[VZ] = 0.f; } inline LLVector3::LLVector3(const F32 x, const F32 y, const F32 z) @@ -210,32 +210,32 @@ inline bool LLVector3::isFinite() const // Clear and Assignment Functions -inline void LLVector3::clear(void) +inline void LLVector3::clear() { - mV[0] = 0.f; - mV[1] = 0.f; - mV[2] = 0.f; + mV[VX] = 0.f; + mV[VY] = 0.f; + mV[VZ] = 0.f; } -inline void LLVector3::setZero(void) +inline void LLVector3::setZero() { - mV[0] = 0.f; - mV[1] = 0.f; - mV[2] = 0.f; + mV[VX] = 0.f; + mV[VY] = 0.f; + mV[VZ] = 0.f; } -inline void LLVector3::clearVec(void) +inline void LLVector3::clearVec() { - mV[0] = 0.f; - mV[1] = 0.f; - mV[2] = 0.f; + mV[VX] = 0.f; + mV[VY] = 0.f; + mV[VZ] = 0.f; } -inline void LLVector3::zeroVec(void) +inline void LLVector3::zeroVec() { - mV[0] = 0.f; - mV[1] = 0.f; - mV[2] = 0.f; + mV[VX] = 0.f; + mV[VY] = 0.f; + mV[VZ] = 0.f; } inline void LLVector3::set(F32 x, F32 y, F32 z) @@ -245,18 +245,18 @@ inline void LLVector3::set(F32 x, F32 y, F32 z) mV[VZ] = z; } -inline void LLVector3::set(const LLVector3 &vec) +inline void LLVector3::set(const LLVector3& vec) { - mV[0] = vec.mV[0]; - mV[1] = vec.mV[1]; - mV[2] = vec.mV[2]; + mV[VX] = vec.mV[VX]; + mV[VY] = vec.mV[VY]; + mV[VZ] = vec.mV[VZ]; } -inline void LLVector3::set(const F32 *vec) +inline void LLVector3::set(const F32* vec) { - mV[0] = vec[0]; - mV[1] = vec[1]; - mV[2] = vec[2]; + mV[VX] = vec[0]; + mV[VY] = vec[1]; + mV[VZ] = vec[2]; } // deprecated @@ -268,61 +268,61 @@ inline void LLVector3::setVec(F32 x, F32 y, F32 z) } // deprecated -inline void LLVector3::setVec(const LLVector3 &vec) +inline void LLVector3::setVec(const LLVector3& vec) { - mV[0] = vec.mV[0]; - mV[1] = vec.mV[1]; - mV[2] = vec.mV[2]; + mV[VX] = vec.mV[VX]; + mV[VY] = vec.mV[VY]; + mV[VZ] = vec.mV[VZ]; } // deprecated -inline void LLVector3::setVec(const F32 *vec) +inline void LLVector3::setVec(const F32* vec) { - mV[0] = vec[0]; - mV[1] = vec[1]; - mV[2] = vec[2]; + mV[VX] = vec[0]; + mV[VY] = vec[1]; + mV[VZ] = vec[2]; } -inline F32 LLVector3::normalize(void) +inline F32 LLVector3::normalize() { - F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); + F32 mag = (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); F32 oomag; if (mag > FP_MAG_THRESHOLD) { oomag = 1.f/mag; - mV[0] *= oomag; - mV[1] *= oomag; - mV[2] *= oomag; + mV[VX] *= oomag; + mV[VY] *= oomag; + mV[VZ] *= oomag; } else { - mV[0] = 0.f; - mV[1] = 0.f; - mV[2] = 0.f; + mV[VX] = 0.f; + mV[VY] = 0.f; + mV[VZ] = 0.f; mag = 0; } return (mag); } // deprecated -inline F32 LLVector3::normVec(void) +inline F32 LLVector3::normVec() { - F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); + F32 mag = sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); F32 oomag; if (mag > FP_MAG_THRESHOLD) { oomag = 1.f/mag; - mV[0] *= oomag; - mV[1] *= oomag; - mV[2] *= oomag; + mV[VX] *= oomag; + mV[VY] *= oomag; + mV[VZ] *= oomag; } else { - mV[0] = 0.f; - mV[1] = 0.f; - mV[2] = 0.f; + mV[VX] = 0.f; + mV[VY] = 0.f; + mV[VZ] = 0.f; mag = 0; } return (mag); @@ -330,171 +330,178 @@ inline F32 LLVector3::normVec(void) // LLVector3 Magnitude and Normalization Functions -inline F32 LLVector3::length(void) const +inline F32 LLVector3::length() const { - return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); + return sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); } -inline F32 LLVector3::lengthSquared(void) const +inline F32 LLVector3::lengthSquared() const { - return mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]; + return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]; } -inline F32 LLVector3::magVec(void) const +inline F32 LLVector3::magVec() const { - return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); + return sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); } -inline F32 LLVector3::magVecSquared(void) const +inline F32 LLVector3::magVecSquared() const { - return mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]; + return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]; } inline bool LLVector3::inRange( F32 min, F32 max ) const { - return mV[0] >= min && mV[0] <= max && - mV[1] >= min && mV[1] <= max && - mV[2] >= min && mV[2] <= max; + return mV[VX] >= min && mV[VX] <= max && + mV[VY] >= min && mV[VY] <= max && + mV[VZ] >= min && mV[VZ] <= max; } -inline LLVector3 operator+(const LLVector3 &a, const LLVector3 &b) +inline LLVector3 operator+(const LLVector3& a, const LLVector3& b) { LLVector3 c(a); return c += b; } -inline LLVector3 operator-(const LLVector3 &a, const LLVector3 &b) +inline LLVector3 operator-(const LLVector3& a, const LLVector3& b) { LLVector3 c(a); return c -= b; } -inline F32 operator*(const LLVector3 &a, const LLVector3 &b) +inline F32 operator*(const LLVector3& a, const LLVector3& b) { - return (a.mV[0]*b.mV[0] + a.mV[1]*b.mV[1] + a.mV[2]*b.mV[2]); + return (a.mV[VX]*b.mV[VX] + a.mV[VY]*b.mV[VY] + a.mV[VZ]*b.mV[VZ]); } -inline LLVector3 operator%(const LLVector3 &a, const LLVector3 &b) +inline LLVector3 operator%(const LLVector3& a, const LLVector3& b) { - return LLVector3( a.mV[1]*b.mV[2] - b.mV[1]*a.mV[2], a.mV[2]*b.mV[0] - b.mV[2]*a.mV[0], a.mV[0]*b.mV[1] - b.mV[0]*a.mV[1] ); + return LLVector3( a.mV[VY]*b.mV[VZ] - b.mV[VY]*a.mV[VZ], a.mV[VZ]*b.mV[VX] - b.mV[VZ]*a.mV[VX], a.mV[VX]*b.mV[VY] - b.mV[VX]*a.mV[VY] ); } -inline LLVector3 operator/(const LLVector3 &a, F32 k) +inline LLVector3 operator/(const LLVector3& a, F32 k) { F32 t = 1.f / k; - return LLVector3( a.mV[0] * t, a.mV[1] * t, a.mV[2] * t ); + return LLVector3( a.mV[VX] * t, a.mV[VY] * t, a.mV[VZ] * t ); } -inline LLVector3 operator*(const LLVector3 &a, F32 k) +inline LLVector3 operator*(const LLVector3& a, F32 k) { - return LLVector3( a.mV[0] * k, a.mV[1] * k, a.mV[2] * k ); + return LLVector3( a.mV[VX] * k, a.mV[VY] * k, a.mV[VZ] * k ); } -inline LLVector3 operator*(F32 k, const LLVector3 &a) +inline LLVector3 operator*(F32 k, const LLVector3& a) { - return LLVector3( a.mV[0] * k, a.mV[1] * k, a.mV[2] * k ); + return LLVector3( a.mV[VX] * k, a.mV[VY] * k, a.mV[VZ] * k ); } -inline bool operator==(const LLVector3 &a, const LLVector3 &b) +inline bool operator==(const LLVector3& a, const LLVector3& b) { - return ( (a.mV[0] == b.mV[0]) - &&(a.mV[1] == b.mV[1]) - &&(a.mV[2] == b.mV[2])); + return ( (a.mV[VX] == b.mV[VX]) + &&(a.mV[VY] == b.mV[VY]) + &&(a.mV[VZ] == b.mV[VZ])); } -inline bool operator!=(const LLVector3 &a, const LLVector3 &b) +inline bool operator!=(const LLVector3& a, const LLVector3& b) { - return ( (a.mV[0] != b.mV[0]) - ||(a.mV[1] != b.mV[1]) - ||(a.mV[2] != b.mV[2])); + return ( (a.mV[VX] != b.mV[VX]) + ||(a.mV[VY] != b.mV[VY]) + ||(a.mV[VZ] != b.mV[VZ])); } -inline bool operator<(const LLVector3 &a, const LLVector3 &b) +inline bool operator<(const LLVector3& a, const LLVector3& b) { - return (a.mV[0] < b.mV[0] - || (a.mV[0] == b.mV[0] - && (a.mV[1] < b.mV[1] - || ((a.mV[1] == b.mV[1]) - && a.mV[2] < b.mV[2])))); + return (a.mV[VX] < b.mV[VX] + || (a.mV[VX] == b.mV[VX] + && (a.mV[VY] < b.mV[VY] + || ((a.mV[VY] == b.mV[VY]) + && a.mV[VZ] < b.mV[VZ])))); } -inline const LLVector3& operator+=(LLVector3 &a, const LLVector3 &b) +inline const LLVector3& operator+=(LLVector3& a, const LLVector3& b) { - a.mV[0] += b.mV[0]; - a.mV[1] += b.mV[1]; - a.mV[2] += b.mV[2]; + a.mV[VX] += b.mV[VX]; + a.mV[VY] += b.mV[VY]; + a.mV[VZ] += b.mV[VZ]; return a; } -inline const LLVector3& operator-=(LLVector3 &a, const LLVector3 &b) +inline const LLVector3& operator-=(LLVector3& a, const LLVector3& b) { - a.mV[0] -= b.mV[0]; - a.mV[1] -= b.mV[1]; - a.mV[2] -= b.mV[2]; + a.mV[VX] -= b.mV[VX]; + a.mV[VY] -= b.mV[VY]; + a.mV[VZ] -= b.mV[VZ]; return a; } -inline const LLVector3& operator%=(LLVector3 &a, const LLVector3 &b) +inline const LLVector3& operator%=(LLVector3& a, const LLVector3& b) { - LLVector3 ret( a.mV[1]*b.mV[2] - b.mV[1]*a.mV[2], a.mV[2]*b.mV[0] - b.mV[2]*a.mV[0], a.mV[0]*b.mV[1] - b.mV[0]*a.mV[1]); + LLVector3 ret( a.mV[VY]*b.mV[VZ] - b.mV[VY]*a.mV[VZ], a.mV[VZ]*b.mV[VX] - b.mV[VZ]*a.mV[VX], a.mV[VX]*b.mV[VY] - b.mV[VX]*a.mV[VY]); a = ret; return a; } -inline const LLVector3& operator*=(LLVector3 &a, F32 k) +inline const LLVector3& operator*=(LLVector3& a, F32 k) { - a.mV[0] *= k; - a.mV[1] *= k; - a.mV[2] *= k; + a.mV[VX] *= k; + a.mV[VY] *= k; + a.mV[VZ] *= k; return a; } -inline const LLVector3& operator*=(LLVector3 &a, const LLVector3 &b) +inline const LLVector3& operator*=(LLVector3& a, const LLVector3& b) { - a.mV[0] *= b.mV[0]; - a.mV[1] *= b.mV[1]; - a.mV[2] *= b.mV[2]; + a.mV[VX] *= b.mV[VX]; + a.mV[VY] *= b.mV[VY]; + a.mV[VZ] *= b.mV[VZ]; return a; } -inline const LLVector3& operator/=(LLVector3 &a, F32 k) +inline const LLVector3& operator/=(LLVector3& a, F32 k) { - F32 t = 1.f / k; - a.mV[0] *= t; - a.mV[1] *= t; - a.mV[2] *= t; + a.mV[VX] /= k; + a.mV[VY] /= k; + a.mV[VZ] /= k; + return a; +} + +inline const LLVector3& operator/=(LLVector3& a, const LLVector3& b) +{ + a.mV[VX] /= b.mV[VX]; + a.mV[VY] /= b.mV[VY]; + a.mV[VZ] /= b.mV[VZ]; return a; } -inline LLVector3 operator-(const LLVector3 &a) +inline LLVector3 operator-(const LLVector3& a) { - return LLVector3( -a.mV[0], -a.mV[1], -a.mV[2] ); + return LLVector3( -a.mV[VX], -a.mV[VY], -a.mV[VZ] ); } -inline F32 dist_vec(const LLVector3 &a, const LLVector3 &b) +inline F32 dist_vec(const LLVector3& a, const LLVector3& b) { - F32 x = a.mV[0] - b.mV[0]; - F32 y = a.mV[1] - b.mV[1]; - F32 z = a.mV[2] - b.mV[2]; - return (F32) sqrt( x*x + y*y + z*z ); + F32 x = a.mV[VX] - b.mV[VX]; + F32 y = a.mV[VY] - b.mV[VY]; + F32 z = a.mV[VZ] - b.mV[VZ]; + return sqrt( x*x + y*y + z*z ); } -inline F32 dist_vec_squared(const LLVector3 &a, const LLVector3 &b) +inline F32 dist_vec_squared(const LLVector3& a, const LLVector3& b) { - F32 x = a.mV[0] - b.mV[0]; - F32 y = a.mV[1] - b.mV[1]; - F32 z = a.mV[2] - b.mV[2]; + F32 x = a.mV[VX] - b.mV[VX]; + F32 y = a.mV[VY] - b.mV[VY]; + F32 z = a.mV[VZ] - b.mV[VZ]; return x*x + y*y + z*z; } -inline F32 dist_vec_squared2D(const LLVector3 &a, const LLVector3 &b) +inline F32 dist_vec_squared2D(const LLVector3& a, const LLVector3& b) { - F32 x = a.mV[0] - b.mV[0]; - F32 y = a.mV[1] - b.mV[1]; + F32 x = a.mV[VX] - b.mV[VX]; + F32 y = a.mV[VY] - b.mV[VY]; return x*x + y*y; } -inline LLVector3 projected_vec(const LLVector3 &a, const LLVector3 &b) +inline LLVector3 projected_vec(const LLVector3& a, const LLVector3& b) { F32 bb = b * b; if (bb > FP_MAG_THRESHOLD * FP_MAG_THRESHOLD) @@ -519,18 +526,18 @@ inline LLVector3 inverse_projected_vec(const LLVector3& a, const LLVector3& b) return normalized_a * (b_length / dot_product); } -inline LLVector3 parallel_component(const LLVector3 &a, const LLVector3 &b) +inline LLVector3 parallel_component(const LLVector3& a, const LLVector3& b) { return projected_vec(a, b); } -inline LLVector3 orthogonal_component(const LLVector3 &a, const LLVector3 &b) +inline LLVector3 orthogonal_component(const LLVector3& a, const LLVector3& b) { return a - projected_vec(a, b); } -inline LLVector3 lerp(const LLVector3 &a, const LLVector3 &b, F32 u) +inline LLVector3 lerp(const LLVector3& a, const LLVector3& b, F32 u) { return LLVector3( a.mV[VX] + (b.mV[VX] - a.mV[VX]) * u, @@ -589,7 +596,7 @@ inline F32 angle_between(const LLVector3& a, const LLVector3& b) return atan2f(sqrtf(c * c), ab); // return the angle } -inline bool are_parallel(const LLVector3 &a, const LLVector3 &b, F32 epsilon) +inline bool are_parallel(const LLVector3& a, const LLVector3& b, F32 epsilon) { LLVector3 an = a; LLVector3 bn = b; diff --git a/indra/llmath/v4math.cpp b/indra/llmath/v4math.cpp index 0aa6eb09c3..e87bfc0013 100644 --- a/indra/llmath/v4math.cpp +++ b/indra/llmath/v4math.cpp @@ -36,13 +36,13 @@ // LLVector4 // Axis-Angle rotations -const LLVector4& LLVector4::rotVec(const LLMatrix4 &mat) +const LLVector4& LLVector4::rotVec(const LLMatrix4& mat) { *this = *this * mat; return *this; } -const LLVector4& LLVector4::rotVec(const LLQuaternion &q) +const LLVector4& LLVector4::rotVec(const LLQuaternion& q) { *this = *this * q; return *this; @@ -64,16 +64,16 @@ bool LLVector4::abs() { bool ret{ false }; - if (mV[0] < 0.f) { mV[0] = -mV[0]; ret = true; } - if (mV[1] < 0.f) { mV[1] = -mV[1]; ret = true; } - if (mV[2] < 0.f) { mV[2] = -mV[2]; ret = true; } - if (mV[3] < 0.f) { mV[3] = -mV[3]; ret = true; } + if (mV[VX] < 0.f) { mV[VX] = -mV[VX]; ret = true; } + if (mV[VY] < 0.f) { mV[VY] = -mV[VY]; ret = true; } + if (mV[VZ] < 0.f) { mV[VZ] = -mV[VZ]; ret = true; } + if (mV[VW] < 0.f) { mV[VW] = -mV[VW]; ret = true; } return ret; } -std::ostream& operator<<(std::ostream& s, const LLVector4 &a) +std::ostream& operator<<(std::ostream& s, const LLVector4& a) { s << "{ " << a.mV[VX] << ", " << a.mV[VY] << ", " << a.mV[VZ] << ", " << a.mV[VW] << " }"; return s; @@ -108,12 +108,12 @@ bool are_parallel(const LLVector4 &a, const LLVector4 &b, F32 epsilon) } -LLVector3 vec4to3(const LLVector4 &vec) +LLVector3 vec4to3(const LLVector4& vec) { return LLVector3( vec.mV[VX], vec.mV[VY], vec.mV[VZ] ); } -LLVector4 vec3to4(const LLVector3 &vec) +LLVector4 vec3to4(const LLVector3& vec) { return LLVector4(vec.mV[VX], vec.mV[VY], vec.mV[VZ]); } diff --git a/indra/llmath/v4math.h b/indra/llmath/v4math.h index a5b6f506d7..e2092d1277 100644 --- a/indra/llmath/v4math.h +++ b/indra/llmath/v4math.h @@ -38,7 +38,7 @@ class LLQuaternion; // LLVector4 = |x y z w| -static const U32 LENGTHOFVECTOR4 = 4; +static constexpr U32 LENGTHOFVECTOR4 = 4; class LLVector4 { @@ -58,19 +58,19 @@ class LLVector4 LLSD getValue() const { LLSD ret; - ret[0] = mV[0]; - ret[1] = mV[1]; - ret[2] = mV[2]; - ret[3] = mV[3]; + ret[0] = mV[VX]; + ret[1] = mV[VY]; + ret[2] = mV[VZ]; + ret[3] = mV[VW]; return ret; } void setValue(const LLSD& sd) { - mV[0] = (F32)sd[0].asReal(); - mV[1] = (F32)sd[1].asReal(); - mV[2] = (F32)sd[2].asReal(); - mV[3] = (F32)sd[3].asReal(); + mV[VX] = (F32)sd[0].asReal(); + mV[VY] = (F32)sd[1].asReal(); + mV[VZ] = (F32)sd[2].asReal(); + mV[VW] = (F32)sd[3].asReal(); } @@ -231,7 +231,7 @@ inline bool LLVector4::isFinite() const // Clear and Assignment Functions -inline void LLVector4::clear(void) +inline void LLVector4::clear() { mV[VX] = 0.f; mV[VY] = 0.f; @@ -240,7 +240,7 @@ inline void LLVector4::clear(void) } // deprecated -inline void LLVector4::clearVec(void) +inline void LLVector4::clearVec() { mV[VX] = 0.f; mV[VY] = 0.f; @@ -249,7 +249,7 @@ inline void LLVector4::clearVec(void) } // deprecated -inline void LLVector4::zeroVec(void) +inline void LLVector4::zeroVec() { mV[VX] = 0.f; mV[VY] = 0.f; @@ -273,7 +273,7 @@ inline void LLVector4::set(F32 x, F32 y, F32 z, F32 w) mV[VW] = w; } -inline void LLVector4::set(const LLVector4 &vec) +inline void LLVector4::set(const LLVector4& vec) { mV[VX] = vec.mV[VX]; mV[VY] = vec.mV[VY]; @@ -281,7 +281,7 @@ inline void LLVector4::set(const LLVector4 &vec) mV[VW] = vec.mV[VW]; } -inline void LLVector4::set(const LLVector3 &vec, F32 w) +inline void LLVector4::set(const LLVector3& vec, F32 w) { mV[VX] = vec.mV[VX]; mV[VY] = vec.mV[VY]; @@ -289,7 +289,7 @@ inline void LLVector4::set(const LLVector3 &vec, F32 w) mV[VW] = w; } -inline void LLVector4::set(const F32 *vec) +inline void LLVector4::set(const F32* vec) { mV[VX] = vec[VX]; mV[VY] = vec[VY]; @@ -317,7 +317,7 @@ inline void LLVector4::setVec(F32 x, F32 y, F32 z, F32 w) } // deprecated -inline void LLVector4::setVec(const LLVector4 &vec) +inline void LLVector4::setVec(const LLVector4& vec) { mV[VX] = vec.mV[VX]; mV[VY] = vec.mV[VY]; @@ -326,7 +326,7 @@ inline void LLVector4::setVec(const LLVector4 &vec) } // deprecated -inline void LLVector4::setVec(const LLVector3 &vec, F32 w) +inline void LLVector4::setVec(const LLVector3& vec, F32 w) { mV[VX] = vec.mV[VX]; mV[VY] = vec.mV[VY]; @@ -335,7 +335,7 @@ inline void LLVector4::setVec(const LLVector3 &vec, F32 w) } // deprecated -inline void LLVector4::setVec(const F32 *vec) +inline void LLVector4::setVec(const F32* vec) { mV[VX] = vec[VX]; mV[VY] = vec[VY]; @@ -345,75 +345,75 @@ inline void LLVector4::setVec(const F32 *vec) // LLVector4 Magnitude and Normalization Functions -inline F32 LLVector4::length(void) const +inline F32 LLVector4::length() const { - return (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); + return sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); } -inline F32 LLVector4::lengthSquared(void) const +inline F32 LLVector4::lengthSquared() const { return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]; } -inline F32 LLVector4::magVec(void) const +inline F32 LLVector4::magVec() const { - return (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); + return sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); } -inline F32 LLVector4::magVecSquared(void) const +inline F32 LLVector4::magVecSquared() const { return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]; } // LLVector4 Operators -inline LLVector4 operator+(const LLVector4 &a, const LLVector4 &b) +inline LLVector4 operator+(const LLVector4& a, const LLVector4& b) { LLVector4 c(a); return c += b; } -inline LLVector4 operator-(const LLVector4 &a, const LLVector4 &b) +inline LLVector4 operator-(const LLVector4& a, const LLVector4& b) { LLVector4 c(a); return c -= b; } -inline F32 operator*(const LLVector4 &a, const LLVector4 &b) +inline F32 operator*(const LLVector4& a, const LLVector4& b) { return (a.mV[VX]*b.mV[VX] + a.mV[VY]*b.mV[VY] + a.mV[VZ]*b.mV[VZ]); } -inline LLVector4 operator%(const LLVector4 &a, const LLVector4 &b) +inline LLVector4 operator%(const LLVector4& a, const LLVector4& b) { return LLVector4(a.mV[VY]*b.mV[VZ] - b.mV[VY]*a.mV[VZ], a.mV[VZ]*b.mV[VX] - b.mV[VZ]*a.mV[VX], a.mV[VX]*b.mV[VY] - b.mV[VX]*a.mV[VY]); } -inline LLVector4 operator/(const LLVector4 &a, F32 k) +inline LLVector4 operator/(const LLVector4& a, F32 k) { F32 t = 1.f / k; return LLVector4( a.mV[VX] * t, a.mV[VY] * t, a.mV[VZ] * t ); } -inline LLVector4 operator*(const LLVector4 &a, F32 k) +inline LLVector4 operator*(const LLVector4& a, F32 k) { return LLVector4( a.mV[VX] * k, a.mV[VY] * k, a.mV[VZ] * k ); } -inline LLVector4 operator*(F32 k, const LLVector4 &a) +inline LLVector4 operator*(F32 k, const LLVector4& a) { return LLVector4( a.mV[VX] * k, a.mV[VY] * k, a.mV[VZ] * k ); } -inline bool operator==(const LLVector4 &a, const LLVector4 &b) +inline bool operator==(const LLVector4& a, const LLVector4& b) { return ( (a.mV[VX] == b.mV[VX]) &&(a.mV[VY] == b.mV[VY]) &&(a.mV[VZ] == b.mV[VZ])); } -inline bool operator!=(const LLVector4 &a, const LLVector4 &b) +inline bool operator!=(const LLVector4& a, const LLVector4& b) { return ( (a.mV[VX] != b.mV[VX]) ||(a.mV[VY] != b.mV[VY]) @@ -421,7 +421,7 @@ inline bool operator!=(const LLVector4 &a, const LLVector4 &b) ||(a.mV[VW] != b.mV[VW]) ); } -inline const LLVector4& operator+=(LLVector4 &a, const LLVector4 &b) +inline const LLVector4& operator+=(LLVector4& a, const LLVector4& b) { a.mV[VX] += b.mV[VX]; a.mV[VY] += b.mV[VY]; @@ -429,7 +429,7 @@ inline const LLVector4& operator+=(LLVector4 &a, const LLVector4 &b) return a; } -inline const LLVector4& operator-=(LLVector4 &a, const LLVector4 &b) +inline const LLVector4& operator-=(LLVector4& a, const LLVector4& b) { a.mV[VX] -= b.mV[VX]; a.mV[VY] -= b.mV[VY]; @@ -437,14 +437,14 @@ inline const LLVector4& operator-=(LLVector4 &a, const LLVector4 &b) return a; } -inline const LLVector4& operator%=(LLVector4 &a, const LLVector4 &b) +inline const LLVector4& operator%=(LLVector4& a, const LLVector4& b) { LLVector4 ret(a.mV[VY]*b.mV[VZ] - b.mV[VY]*a.mV[VZ], a.mV[VZ]*b.mV[VX] - b.mV[VZ]*a.mV[VX], a.mV[VX]*b.mV[VY] - b.mV[VX]*a.mV[VY]); a = ret; return a; } -inline const LLVector4& operator*=(LLVector4 &a, F32 k) +inline const LLVector4& operator*=(LLVector4& a, F32 k) { a.mV[VX] *= k; a.mV[VY] *= k; @@ -452,7 +452,7 @@ inline const LLVector4& operator*=(LLVector4 &a, F32 k) return a; } -inline const LLVector4& operator/=(LLVector4 &a, F32 k) +inline const LLVector4& operator/=(LLVector4& a, F32 k) { F32 t = 1.f / k; a.mV[VX] *= t; @@ -461,24 +461,24 @@ inline const LLVector4& operator/=(LLVector4 &a, F32 k) return a; } -inline LLVector4 operator-(const LLVector4 &a) +inline LLVector4 operator-(const LLVector4& a) { return LLVector4( -a.mV[VX], -a.mV[VY], -a.mV[VZ] ); } -inline F32 dist_vec(const LLVector4 &a, const LLVector4 &b) +inline F32 dist_vec(const LLVector4& a, const LLVector4& b) { LLVector4 vec = a - b; return (vec.length()); } -inline F32 dist_vec_squared(const LLVector4 &a, const LLVector4 &b) +inline F32 dist_vec_squared(const LLVector4& a, const LLVector4& b) { LLVector4 vec = a - b; return (vec.lengthSquared()); } -inline LLVector4 lerp(const LLVector4 &a, const LLVector4 &b, F32 u) +inline LLVector4 lerp(const LLVector4& a, const LLVector4& b, F32 u) { return LLVector4( a.mV[VX] + (b.mV[VX] - a.mV[VX]) * u, @@ -487,9 +487,9 @@ inline LLVector4 lerp(const LLVector4 &a, const LLVector4 &b, F32 u) a.mV[VW] + (b.mV[VW] - a.mV[VW]) * u); } -inline F32 LLVector4::normalize(void) +inline F32 LLVector4::normalize() { - F32 mag = (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); + F32 mag = sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); F32 oomag; if (mag > FP_MAG_THRESHOLD) @@ -501,18 +501,18 @@ inline F32 LLVector4::normalize(void) } else { - mV[0] = 0.f; - mV[1] = 0.f; - mV[2] = 0.f; - mag = 0; + mV[VX] = 0.f; + mV[VY] = 0.f; + mV[VZ] = 0.f; + mag = 0.f; } return (mag); } // deprecated -inline F32 LLVector4::normVec(void) +inline F32 LLVector4::normVec() { - F32 mag = (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); + F32 mag = sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); F32 oomag; if (mag > FP_MAG_THRESHOLD) @@ -524,22 +524,23 @@ inline F32 LLVector4::normVec(void) } else { - mV[0] = 0.f; - mV[1] = 0.f; - mV[2] = 0.f; - mag = 0; + mV[VX] = 0.f; + mV[VY] = 0.f; + mV[VZ] = 0.f; + mag = 0.f; } return (mag); } // Because apparently some parts of the viewer use this for color info. -inline const LLVector4 srgbVector4(const LLVector4 &a) { +inline const LLVector4 srgbVector4(const LLVector4& a) +{ LLVector4 srgbColor; - srgbColor.mV[0] = linearTosRGB(a.mV[0]); - srgbColor.mV[1] = linearTosRGB(a.mV[1]); - srgbColor.mV[2] = linearTosRGB(a.mV[2]); - srgbColor.mV[3] = a.mV[3]; + srgbColor.mV[VX] = linearTosRGB(a.mV[VX]); + srgbColor.mV[VY] = linearTosRGB(a.mV[VY]); + srgbColor.mV[VZ] = linearTosRGB(a.mV[VZ]); + srgbColor.mV[VW] = a.mV[VW]; return srgbColor; } |