diff options
author | Kelly Washington <kelly@lindenlab.com> | 2008-04-03 22:50:22 +0000 |
---|---|---|
committer | Kelly Washington <kelly@lindenlab.com> | 2008-04-03 22:50:22 +0000 |
commit | dc48f1c7417f0f49ad1bd32330845ce17a29eece (patch) | |
tree | 8772aff5f32c1702228b7ca7e324fbd077269854 /indra/llmath/v2math.h | |
parent | b5936a4b1d8780b5b8cd425998eacd2c64ffa693 (diff) |
svn merge -r83872:83893 linden/branches/Branch_1-20-0-Server to linden/release
HAVOK4 IN TEH HOUSE!!11!!ONE!!
If it is broken blame Joel for not fixing the loginassetdatabaseinventorygroupIM server instead of working on this.
QAR-448
Diffstat (limited to 'indra/llmath/v2math.h')
-rw-r--r-- | indra/llmath/v2math.h | 95 |
1 files changed, 86 insertions, 9 deletions
diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h index f2450b1fd3..5f46655a07 100644 --- a/indra/llmath/v2math.h +++ b/indra/llmath/v2math.h @@ -54,18 +54,26 @@ class LLVector2 LLVector2(const F32 *vec); // Initializes LLVector2 to (vec[0]. vec[1]) // Clears LLVector2 to (0, 0). DEPRECATED - prefer zeroVec. - void clearVec(); + void clear(); + void setZero(); + void clearVec(); // deprecated + void zeroVec(); // deprecated - // Zero LLVector2 to (0, 0) - void zeroVec(); + void set(F32 x, F32 y); // Sets LLVector2 to (x, y) + void set(const LLVector2 &vec); // Sets LLVector2 to vec + void set(const F32 *vec); // Sets LLVector2 to vec - void setVec(F32 x, F32 y); // Sets LLVector2 to (x, y) - void setVec(const LLVector2 &vec); // Sets LLVector2 to vec - void setVec(const F32 *vec); // Sets LLVector2 to vec + void setVec(F32 x, F32 y); // deprecated + void setVec(const LLVector2 &vec); // deprecated + void setVec(const F32 *vec); // deprecated - F32 magVec() const; // Returns magnitude of LLVector2 - F32 magVecSquared() const; // Returns magnitude squared of LLVector2 - F32 normVec(); // Normalizes and returns the magnitude of LLVector2 + F32 length() const; // Returns magnitude of LLVector2 + F32 lengthSquared() const; // Returns magnitude squared of LLVector2 + F32 normalize(); // Normalizes and returns the magnitude of LLVector2 + + F32 magVec() const; // deprecated + F32 magVecSquared() const; // deprecated + F32 normVec(); // deprecated BOOL abs(); // sets all values to absolute value of original value (first octant), returns TRUE if changed @@ -132,30 +140,66 @@ inline LLVector2::LLVector2(const F32 *vec) // Clear and Assignment Functions +inline void LLVector2::clear(void) +{ + mV[VX] = 0.f; + mV[VY] = 0.f; +} + +inline void LLVector2::setZero(void) +{ + mV[VX] = 0.f; + mV[VY] = 0.f; +} + +// deprecated inline void LLVector2::clearVec(void) { mV[VX] = 0.f; mV[VY] = 0.f; } +// deprecated inline void LLVector2::zeroVec(void) { mV[VX] = 0.f; mV[VY] = 0.f; } +inline void LLVector2::set(F32 x, F32 y) +{ + mV[VX] = x; + mV[VY] = y; +} + +inline void LLVector2::set(const LLVector2 &vec) +{ + mV[VX] = vec.mV[VX]; + mV[VY] = vec.mV[VY]; +} + +inline void LLVector2::set(const F32 *vec) +{ + mV[VX] = vec[VX]; + mV[VY] = vec[VY]; +} + + +// deprecated inline void LLVector2::setVec(F32 x, F32 y) { mV[VX] = x; mV[VY] = y; } +// deprecated inline void LLVector2::setVec(const LLVector2 &vec) { mV[VX] = vec.mV[VX]; mV[VY] = vec.mV[VY]; } +// deprecated inline void LLVector2::setVec(const F32 *vec) { mV[VX] = vec[VX]; @@ -164,16 +208,49 @@ inline void LLVector2::setVec(const F32 *vec) // LLVector2 Magnitude and Normalization Functions +inline F32 LLVector2::length(void) const +{ + return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]); +} + +inline F32 LLVector2::lengthSquared(void) const +{ + return mV[0]*mV[0] + mV[1]*mV[1]; +} + +inline F32 LLVector2::normalize(void) +{ + F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]); + F32 oomag; + + if (mag > FP_MAG_THRESHOLD) + { + oomag = 1.f/mag; + mV[0] *= oomag; + mV[1] *= oomag; + } + else + { + mV[0] = 0.f; + mV[1] = 0.f; + mag = 0; + } + return (mag); +} + +// deprecated inline F32 LLVector2::magVec(void) const { return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]); } +// deprecated inline F32 LLVector2::magVecSquared(void) const { return mV[0]*mV[0] + mV[1]*mV[1]; } +// deprecated inline F32 LLVector2::normVec(void) { F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]); |