summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
authorAndrew Meadows <andrew@lindenlab.com>2008-09-05 22:03:35 +0000
committerAndrew Meadows <andrew@lindenlab.com>2008-09-05 22:03:35 +0000
commit222bca24c12e162669c1a810c3102811f21cfbe4 (patch)
tree8eee52c0ffd4e9b03d624fc78d6547b8312a5c85 /indra/llmath
parent1493a212629b02a4323bf0c1f5a6960bc7b5e271 (diff)
svn merge -r95288:95907 svn+ssh://svn.lindenlab.com/svn/linden/qa/maint-server/qar-841
this is a combined mergeback of the following branches as per QAR-841: maint-server/maint-server-1 (absorbed by maint-server-2) maint-server/maint-server-2 maint-server/maint-server-3 havok4/havok4-8 havok4/havok4-9 yes dataserver-is-deprecated
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/v3color.h77
-rw-r--r--indra/llmath/v4color.cpp166
-rw-r--r--indra/llmath/v4color.h109
-rw-r--r--indra/llmath/v4coloru.cpp2
-rw-r--r--indra/llmath/v4coloru.h89
5 files changed, 339 insertions, 104 deletions
diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h
index e2a8274839..05f6186893 100644
--- a/indra/llmath/v3color.h
+++ b/indra/llmath/v3color.h
@@ -82,13 +82,23 @@ public:
const LLColor3& setToBlack(); // Clears LLColor3 to (0, 0, 0)
const LLColor3& setToWhite(); // Zero LLColor3 to (0, 0, 0)
- const LLColor3& setVec(F32 x, F32 y, F32 z); // Sets LLColor3 to (x, y, z)
- const LLColor3& setVec(const LLColor3 &vec); // Sets LLColor3 to vec
- const LLColor3& setVec(const F32 *vec); // Sets LLColor3 to vec
+
+ const LLColor3& setVec(F32 x, F32 y, F32 z); // deprecated
+ const LLColor3& setVec(const LLColor3 &vec); // deprecated
+ const LLColor3& setVec(const F32 *vec); // deprecated
+
+ const LLColor3& set(F32 x, F32 y, F32 z); // Sets LLColor3 to (x, y, z)
+ const LLColor3& set(const LLColor3 &vec); // Sets LLColor3 to vec
+ const LLColor3& set(const F32 *vec); // Sets LLColor3 to vec
+
+ F32 magVec() const; // deprecated
+ F32 magVecSquared() const; // deprecated
+ F32 normVec(); // deprecated
+
+ F32 length() const; // Returns magnitude of LLColor3
+ F32 lengthSquared() const; // Returns magnitude squared of LLColor3
+ F32 normalize(); // Normalizes and returns the magnitude of LLColor3
- F32 magVec() const; // Returns magnitude of LLColor3
- F32 magVecSquared() const; // Returns magnitude squared of LLColor3
- F32 normVec(); // Normalizes and returns the magnitude of LLColor3
F32 brightness() const; // Returns brightness of LLColor3
const LLColor3& operator=(const LLColor4 &a);
@@ -214,6 +224,31 @@ inline const LLColor3& LLColor3::setToWhite(void)
return (*this);
}
+inline const LLColor3& LLColor3::set(F32 r, F32 g, F32 b)
+{
+ mV[0] = r;
+ mV[1] = g;
+ mV[2] = b;
+ return (*this);
+}
+
+inline const LLColor3& LLColor3::set(const LLColor3 &vec)
+{
+ mV[0] = vec.mV[0];
+ mV[1] = vec.mV[1];
+ mV[2] = vec.mV[2];
+ return (*this);
+}
+
+inline const LLColor3& LLColor3::set(const F32 *vec)
+{
+ mV[0] = vec[0];
+ mV[1] = vec[1];
+ mV[2] = vec[2];
+ return (*this);
+}
+
+// deprecated
inline const LLColor3& LLColor3::setVec(F32 r, F32 g, F32 b)
{
mV[0] = r;
@@ -222,6 +257,7 @@ inline const LLColor3& LLColor3::setVec(F32 r, F32 g, F32 b)
return (*this);
}
+// deprecated
inline const LLColor3& LLColor3::setVec(const LLColor3 &vec)
{
mV[0] = vec.mV[0];
@@ -230,6 +266,7 @@ inline const LLColor3& LLColor3::setVec(const LLColor3 &vec)
return (*this);
}
+// deprecated
inline const LLColor3& LLColor3::setVec(const F32 *vec)
{
mV[0] = vec[0];
@@ -243,16 +280,44 @@ inline F32 LLColor3::brightness(void) const
return (mV[0] + mV[1] + mV[2]) / 3.0f;
}
+inline F32 LLColor3::length(void) const
+{
+ return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+}
+
+inline F32 LLColor3::lengthSquared(void) const
+{
+ return mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2];
+}
+
+inline F32 LLColor3::normalize(void)
+{
+ F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+ F32 oomag;
+
+ if (mag)
+ {
+ oomag = 1.f/mag;
+ mV[0] *= oomag;
+ mV[1] *= oomag;
+ mV[2] *= oomag;
+ }
+ return (mag);
+}
+
+// deprecated
inline F32 LLColor3::magVec(void) const
{
return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
}
+// deprecated
inline F32 LLColor3::magVecSquared(void) const
{
return mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2];
}
+// deprecated
inline F32 LLColor3::normVec(void)
{
F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
diff --git a/indra/llmath/v4color.cpp b/indra/llmath/v4color.cpp
index 8ba329eaf2..c66fe66c92 100644
--- a/indra/llmath/v4color.cpp
+++ b/indra/llmath/v4color.cpp
@@ -161,6 +161,38 @@ LLColor4::LLColor4(const LLVector4& vector4)
mV[VW] = vector4.mV[VW];
}
+const LLColor4& LLColor4::set(const LLColor4U& color4u)
+{
+ const F32 SCALE = 1.f/255.f;
+ mV[VX] = color4u.mV[VX] * SCALE;
+ mV[VY] = color4u.mV[VY] * SCALE;
+ mV[VZ] = color4u.mV[VZ] * SCALE;
+ mV[VW] = color4u.mV[VW] * SCALE;
+ return (*this);
+}
+
+const LLColor4& LLColor4::set(const LLColor3 &vec)
+{
+ mV[VX] = vec.mV[VX];
+ mV[VY] = vec.mV[VY];
+ mV[VZ] = vec.mV[VZ];
+
+// no change to alpha!
+// mV[VW] = 1.f;
+
+ return (*this);
+}
+
+const LLColor4& LLColor4::set(const LLColor3 &vec, F32 a)
+{
+ mV[VX] = vec.mV[VX];
+ mV[VY] = vec.mV[VY];
+ mV[VZ] = vec.mV[VZ];
+ mV[VW] = a;
+ return (*this);
+}
+
+// deprecated -- use set()
const LLColor4& LLColor4::setVec(const LLColor4U& color4u)
{
const F32 SCALE = 1.f/255.f;
@@ -171,6 +203,7 @@ const LLColor4& LLColor4::setVec(const LLColor4U& color4u)
return (*this);
}
+// deprecated -- use set()
const LLColor4& LLColor4::setVec(const LLColor3 &vec)
{
mV[VX] = vec.mV[VX];
@@ -183,6 +216,7 @@ const LLColor4& LLColor4::setVec(const LLColor3 &vec)
return (*this);
}
+// deprecated -- use set()
const LLColor4& LLColor4::setVec(const LLColor3 &vec, F32 a)
{
mV[VX] = vec.mV[VX];
@@ -338,270 +372,270 @@ BOOL LLColor4::parseColor(const std::string& buf, LLColor4* color)
{
v = v * (1.f / 255.f);
}
- color->setVec( v );
+ color->set( v );
}
else // Single value. Read as a named color.
{
// We have a color name
if ( "red" == color_name )
{
- color->setVec(LLColor4::red);
+ color->set(LLColor4::red);
}
else if ( "red1" == color_name )
{
- color->setVec(LLColor4::red1);
+ color->set(LLColor4::red1);
}
else if ( "red2" == color_name )
{
- color->setVec(LLColor4::red2);
+ color->set(LLColor4::red2);
}
else if ( "red3" == color_name )
{
- color->setVec(LLColor4::red3);
+ color->set(LLColor4::red3);
}
else if ( "red4" == color_name )
{
- color->setVec(LLColor4::red4);
+ color->set(LLColor4::red4);
}
else if ( "red5" == color_name )
{
- color->setVec(LLColor4::red5);
+ color->set(LLColor4::red5);
}
else if( "green" == color_name )
{
- color->setVec(LLColor4::green);
+ color->set(LLColor4::green);
}
else if( "green1" == color_name )
{
- color->setVec(LLColor4::green1);
+ color->set(LLColor4::green1);
}
else if( "green2" == color_name )
{
- color->setVec(LLColor4::green2);
+ color->set(LLColor4::green2);
}
else if( "green3" == color_name )
{
- color->setVec(LLColor4::green3);
+ color->set(LLColor4::green3);
}
else if( "green4" == color_name )
{
- color->setVec(LLColor4::green4);
+ color->set(LLColor4::green4);
}
else if( "green5" == color_name )
{
- color->setVec(LLColor4::green5);
+ color->set(LLColor4::green5);
}
else if( "green6" == color_name )
{
- color->setVec(LLColor4::green6);
+ color->set(LLColor4::green6);
}
else if( "blue" == color_name )
{
- color->setVec(LLColor4::blue);
+ color->set(LLColor4::blue);
}
else if( "blue1" == color_name )
{
- color->setVec(LLColor4::blue1);
+ color->set(LLColor4::blue1);
}
else if( "blue2" == color_name )
{
- color->setVec(LLColor4::blue2);
+ color->set(LLColor4::blue2);
}
else if( "blue3" == color_name )
{
- color->setVec(LLColor4::blue3);
+ color->set(LLColor4::blue3);
}
else if( "blue4" == color_name )
{
- color->setVec(LLColor4::blue4);
+ color->set(LLColor4::blue4);
}
else if( "blue5" == color_name )
{
- color->setVec(LLColor4::blue5);
+ color->set(LLColor4::blue5);
}
else if( "blue6" == color_name )
{
- color->setVec(LLColor4::blue6);
+ color->set(LLColor4::blue6);
}
else if( "black" == color_name )
{
- color->setVec(LLColor4::black);
+ color->set(LLColor4::black);
}
else if( "white" == color_name )
{
- color->setVec(LLColor4::white);
+ color->set(LLColor4::white);
}
else if( "yellow" == color_name )
{
- color->setVec(LLColor4::yellow);
+ color->set(LLColor4::yellow);
}
else if( "yellow1" == color_name )
{
- color->setVec(LLColor4::yellow1);
+ color->set(LLColor4::yellow1);
}
else if( "yellow2" == color_name )
{
- color->setVec(LLColor4::yellow2);
+ color->set(LLColor4::yellow2);
}
else if( "yellow3" == color_name )
{
- color->setVec(LLColor4::yellow3);
+ color->set(LLColor4::yellow3);
}
else if( "yellow4" == color_name )
{
- color->setVec(LLColor4::yellow4);
+ color->set(LLColor4::yellow4);
}
else if( "yellow5" == color_name )
{
- color->setVec(LLColor4::yellow5);
+ color->set(LLColor4::yellow5);
}
else if( "yellow6" == color_name )
{
- color->setVec(LLColor4::yellow6);
+ color->set(LLColor4::yellow6);
}
else if( "magenta" == color_name )
{
- color->setVec(LLColor4::magenta);
+ color->set(LLColor4::magenta);
}
else if( "magenta1" == color_name )
{
- color->setVec(LLColor4::magenta1);
+ color->set(LLColor4::magenta1);
}
else if( "magenta2" == color_name )
{
- color->setVec(LLColor4::magenta2);
+ color->set(LLColor4::magenta2);
}
else if( "magenta3" == color_name )
{
- color->setVec(LLColor4::magenta3);
+ color->set(LLColor4::magenta3);
}
else if( "magenta4" == color_name )
{
- color->setVec(LLColor4::magenta4);
+ color->set(LLColor4::magenta4);
}
else if( "purple" == color_name )
{
- color->setVec(LLColor4::purple);
+ color->set(LLColor4::purple);
}
else if( "purple1" == color_name )
{
- color->setVec(LLColor4::purple1);
+ color->set(LLColor4::purple1);
}
else if( "purple2" == color_name )
{
- color->setVec(LLColor4::purple2);
+ color->set(LLColor4::purple2);
}
else if( "purple3" == color_name )
{
- color->setVec(LLColor4::purple3);
+ color->set(LLColor4::purple3);
}
else if( "purple4" == color_name )
{
- color->setVec(LLColor4::purple4);
+ color->set(LLColor4::purple4);
}
else if( "purple5" == color_name )
{
- color->setVec(LLColor4::purple5);
+ color->set(LLColor4::purple5);
}
else if( "purple6" == color_name )
{
- color->setVec(LLColor4::purple6);
+ color->set(LLColor4::purple6);
}
else if( "pink" == color_name )
{
- color->setVec(LLColor4::pink);
+ color->set(LLColor4::pink);
}
else if( "pink1" == color_name )
{
- color->setVec(LLColor4::pink1);
+ color->set(LLColor4::pink1);
}
else if( "pink2" == color_name )
{
- color->setVec(LLColor4::pink2);
+ color->set(LLColor4::pink2);
}
else if( "cyan" == color_name )
{
- color->setVec(LLColor4::cyan);
+ color->set(LLColor4::cyan);
}
else if( "cyan1" == color_name )
{
- color->setVec(LLColor4::cyan1);
+ color->set(LLColor4::cyan1);
}
else if( "cyan2" == color_name )
{
- color->setVec(LLColor4::cyan2);
+ color->set(LLColor4::cyan2);
}
else if( "cyan3" == color_name )
{
- color->setVec(LLColor4::cyan3);
+ color->set(LLColor4::cyan3);
}
else if( "cyan4" == color_name )
{
- color->setVec(LLColor4::cyan4);
+ color->set(LLColor4::cyan4);
}
else if( "cyan5" == color_name )
{
- color->setVec(LLColor4::cyan5);
+ color->set(LLColor4::cyan5);
}
else if( "cyan6" == color_name )
{
- color->setVec(LLColor4::cyan6);
+ color->set(LLColor4::cyan6);
}
else if( "smoke" == color_name )
{
- color->setVec(LLColor4::smoke);
+ color->set(LLColor4::smoke);
}
else if( "grey" == color_name )
{
- color->setVec(LLColor4::grey);
+ color->set(LLColor4::grey);
}
else if( "grey1" == color_name )
{
- color->setVec(LLColor4::grey1);
+ color->set(LLColor4::grey1);
}
else if( "grey2" == color_name )
{
- color->setVec(LLColor4::grey2);
+ color->set(LLColor4::grey2);
}
else if( "grey3" == color_name )
{
- color->setVec(LLColor4::grey3);
+ color->set(LLColor4::grey3);
}
else if( "grey4" == color_name )
{
- color->setVec(LLColor4::grey4);
+ color->set(LLColor4::grey4);
}
else if( "orange" == color_name )
{
- color->setVec(LLColor4::orange);
+ color->set(LLColor4::orange);
}
else if( "orange1" == color_name )
{
- color->setVec(LLColor4::orange1);
+ color->set(LLColor4::orange1);
}
else if( "orange2" == color_name )
{
- color->setVec(LLColor4::orange2);
+ color->set(LLColor4::orange2);
}
else if( "orange3" == color_name )
{
- color->setVec(LLColor4::orange3);
+ color->set(LLColor4::orange3);
}
else if( "orange4" == color_name )
{
- color->setVec(LLColor4::orange4);
+ color->set(LLColor4::orange4);
}
else if( "orange5" == color_name )
{
- color->setVec(LLColor4::orange5);
+ color->set(LLColor4::orange5);
}
else if( "orange6" == color_name )
{
- color->setVec(LLColor4::orange6);
+ color->set(LLColor4::orange6);
}
else if ( "clear" == color_name )
{
- color->setVec(0.f, 0.f, 0.f, 0.f);
+ color->set(0.f, 0.f, 0.f, 0.f);
}
else
{
diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h
index 62c0b663b8..98f04130d6 100644
--- a/indra/llmath/v4color.h
+++ b/indra/llmath/v4color.h
@@ -84,20 +84,33 @@ class LLColor4
const LLColor4& setToBlack(); // zero LLColor4 to (0, 0, 0, 1)
const LLColor4& setToWhite(); // zero LLColor4 to (0, 0, 0, 1)
- const LLColor4& setVec(F32 r, F32 g, F32 b, F32 a); // Sets LLColor4 to (r, g, b, a)
- const LLColor4& setVec(F32 r, F32 g, F32 b); // Sets LLColor4 to (r, g, b) (no change in a)
- const LLColor4& setVec(const LLColor4 &vec); // Sets LLColor4 to vec
- const LLColor4& setVec(const LLColor3 &vec); // Sets LLColor4 to LLColor3 vec (no change in alpha)
- const LLColor4& setVec(const LLColor3 &vec, F32 a); // Sets LLColor4 to LLColor3 vec, with alpha specified
- const LLColor4& setVec(const F32 *vec); // Sets LLColor4 to vec
- const LLColor4& setVec(const LLColor4U& color4u); // Sets LLColor4 to color4u, rescaled.
+ const LLColor4& setVec(F32 r, F32 g, F32 b, F32 a); // deprecated -- use set()
+ const LLColor4& setVec(F32 r, F32 g, F32 b); // deprecated -- use set()
+ const LLColor4& setVec(const LLColor4 &vec); // deprecated -- use set()
+ const LLColor4& setVec(const LLColor3 &vec); // deprecated -- use set()
+ const LLColor4& setVec(const LLColor3 &vec, F32 a); // deprecated -- use set()
+ const LLColor4& setVec(const F32 *vec); // deprecated -- use set()
+ const LLColor4& setVec(const LLColor4U& color4u); // deprecated -- use set()
+
+ const LLColor4& set(F32 r, F32 g, F32 b, F32 a); // Sets LLColor4 to (r, g, b, a)
+ const LLColor4& set(F32 r, F32 g, F32 b); // Sets LLColor4 to (r, g, b) (no change in a)
+ const LLColor4& set(const LLColor4 &vec); // Sets LLColor4 to vec
+ const LLColor4& set(const LLColor3 &vec); // Sets LLColor4 to LLColor3 vec (no change in alpha)
+ const LLColor4& set(const LLColor3 &vec, F32 a); // Sets LLColor4 to LLColor3 vec, with alpha specified
+ const LLColor4& set(const F32 *vec); // Sets LLColor4 to vec
+ const LLColor4& set(const LLColor4U& color4u); // Sets LLColor4 to color4u, rescaled.
const LLColor4& setAlpha(F32 a);
- F32 magVec() const; // Returns magnitude of LLColor4
- F32 magVecSquared() const; // Returns magnitude squared of LLColor4
- F32 normVec(); // Normalizes and returns the magnitude of LLColor4
+ F32 magVec() const; // deprecated -- use length()
+ F32 magVecSquared() const; // deprecated -- use lengthSquared()
+ F32 normVec(); // deprecated -- use normalize()
+
+ F32 length() const; // Returns magnitude of LLColor4
+ F32 lengthSquared() const; // Returns magnitude squared of LLColor4
+ F32 normalize(); // deprecated -- use normalize()
+
BOOL isOpaque() { return mV[VALPHA] == 1.f; }
F32 operator[](int idx) const { return mV[idx]; }
@@ -289,6 +302,47 @@ inline const LLColor4& LLColor4::setToWhite(void)
return (*this);
}
+inline const LLColor4& LLColor4::set(F32 x, F32 y, F32 z)
+{
+ mV[VX] = x;
+ mV[VY] = y;
+ mV[VZ] = z;
+
+// no change to alpha!
+// mV[VW] = 1.f;
+
+ return (*this);
+}
+
+inline const LLColor4& LLColor4::set(F32 x, F32 y, F32 z, F32 a)
+{
+ mV[VX] = x;
+ mV[VY] = y;
+ mV[VZ] = z;
+ mV[VW] = a;
+ return (*this);
+}
+
+inline const LLColor4& LLColor4::set(const LLColor4 &vec)
+{
+ mV[VX] = vec.mV[VX];
+ mV[VY] = vec.mV[VY];
+ mV[VZ] = vec.mV[VZ];
+ mV[VW] = vec.mV[VW];
+ return (*this);
+}
+
+
+inline const LLColor4& LLColor4::set(const F32 *vec)
+{
+ mV[VX] = vec[VX];
+ mV[VY] = vec[VY];
+ mV[VZ] = vec[VZ];
+ mV[VW] = vec[VW];
+ return (*this);
+}
+
+// deprecated
inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z)
{
mV[VX] = x;
@@ -301,6 +355,7 @@ inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z)
return (*this);
}
+// deprecated
inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z, F32 a)
{
mV[VX] = x;
@@ -310,6 +365,7 @@ inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z, F32 a)
return (*this);
}
+// deprecated
inline const LLColor4& LLColor4::setVec(const LLColor4 &vec)
{
mV[VX] = vec.mV[VX];
@@ -320,6 +376,7 @@ inline const LLColor4& LLColor4::setVec(const LLColor4 &vec)
}
+// deprecated
inline const LLColor4& LLColor4::setVec(const F32 *vec)
{
mV[VX] = vec[VX];
@@ -337,16 +394,44 @@ inline const LLColor4& LLColor4::setAlpha(F32 a)
// LLColor4 Magnitude and Normalization Functions
+inline F32 LLColor4::length(void) const
+{
+ return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+}
+
+inline F32 LLColor4::lengthSquared(void) const
+{
+ return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ];
+}
+
+inline F32 LLColor4::normalize(void)
+{
+ F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+ F32 oomag;
+
+ if (mag)
+ {
+ oomag = 1.f/mag;
+ mV[VX] *= oomag;
+ mV[VY] *= oomag;
+ mV[VZ] *= oomag;
+ }
+ return (mag);
+}
+
+// deprecated
inline F32 LLColor4::magVec(void) const
{
return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
}
+// deprecated
inline F32 LLColor4::magVecSquared(void) const
{
return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ];
}
+// deprecated
inline F32 LLColor4::normVec(void)
{
F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
@@ -497,13 +582,13 @@ inline const LLColor4& operator%=(LLColor4 &a, F32 k)
inline F32 distVec(const LLColor4 &a, const LLColor4 &b)
{
LLColor4 vec = a - b;
- return (vec.magVec());
+ return (vec.length());
}
inline F32 distVec_squared(const LLColor4 &a, const LLColor4 &b)
{
LLColor4 vec = a - b;
- return (vec.magVecSquared());
+ return (vec.lengthSquared());
}
inline LLColor4 lerp(const LLColor4 &a, const LLColor4 &b, F32 u)
diff --git a/indra/llmath/v4coloru.cpp b/indra/llmath/v4coloru.cpp
index 26f3804209..17a198b392 100644
--- a/indra/llmath/v4coloru.cpp
+++ b/indra/llmath/v4coloru.cpp
@@ -120,6 +120,6 @@ BOOL LLColor4U::parseColor4U(const std::string& buf, LLColor4U* value)
}
}
- value->setVec( U8(v[0]), U8(v[1]), U8(v[2]), U8(v[3]) );
+ value->set( U8(v[0]), U8(v[1]), U8(v[2]), U8(v[3]) );
return TRUE;
}
diff --git a/indra/llmath/v4coloru.h b/indra/llmath/v4coloru.h
index 1d3f31e968..aa830e0035 100644
--- a/indra/llmath/v4coloru.h
+++ b/indra/llmath/v4coloru.h
@@ -97,15 +97,23 @@ public:
const LLColor4U& setToBlack(); // zero LLColor4U to (0, 0, 0, 1)
const LLColor4U& setToWhite(); // zero LLColor4U to (0, 0, 0, 1)
- const LLColor4U& setVec(U8 r, U8 g, U8 b, U8 a); // Sets LLColor4U to (r, g, b, a)
- const LLColor4U& setVec(U8 r, U8 g, U8 b); // Sets LLColor4U to (r, g, b) (no change in a)
- const LLColor4U& setVec(const LLColor4U &vec); // Sets LLColor4U to vec
- const LLColor4U& setVec(const U8 *vec); // Sets LLColor4U to vec
+ const LLColor4U& set(U8 r, U8 g, U8 b, U8 a);// Sets LLColor4U to (r, g, b, a)
+ const LLColor4U& set(U8 r, U8 g, U8 b); // Sets LLColor4U to (r, g, b) (no change in a)
+ const LLColor4U& set(const LLColor4U &vec); // Sets LLColor4U to vec
+ const LLColor4U& set(const U8 *vec); // Sets LLColor4U to vec
+
+ const LLColor4U& setVec(U8 r, U8 g, U8 b, U8 a); // deprecated -- use set()
+ const LLColor4U& setVec(U8 r, U8 g, U8 b); // deprecated -- use set()
+ const LLColor4U& setVec(const LLColor4U &vec); // deprecated -- use set()
+ const LLColor4U& setVec(const U8 *vec); // deprecated -- use set()
const LLColor4U& setAlpha(U8 a);
- F32 magVec() const; // Returns magnitude of LLColor4U
- F32 magVecSquared() const; // Returns magnitude squared of LLColor4U
+ F32 magVec() const; // deprecated -- use length()
+ F32 magVecSquared() const; // deprecated -- use lengthSquared()
+
+ F32 length() const; // Returns magnitude squared of LLColor4U
+ F32 lengthSquared() const; // Returns magnitude squared of LLColor4U
friend std::ostream& operator<<(std::ostream& s, const LLColor4U &a); // Print a
friend LLColor4U operator+(const LLColor4U &a, const LLColor4U &b); // Return vector a + b
@@ -199,7 +207,7 @@ inline const LLColor4U& LLColor4U::setToWhite(void)
return (*this);
}
-inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z)
+inline const LLColor4U& LLColor4U::set(const U8 x, const U8 y, const U8 z)
{
mV[VX] = x;
mV[VY] = y;
@@ -211,7 +219,7 @@ inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z)
return (*this);
}
-inline const LLColor4U& LLColor4U::setVec(const U8 r, const U8 g, const U8 b, U8 a)
+inline const LLColor4U& LLColor4U::set(const U8 r, const U8 g, const U8 b, U8 a)
{
mV[0] = r;
mV[1] = g;
@@ -220,7 +228,7 @@ inline const LLColor4U& LLColor4U::setVec(const U8 r, const U8 g, const U8 b, U8
return (*this);
}
-inline const LLColor4U& LLColor4U::setVec(const LLColor4U &vec)
+inline const LLColor4U& LLColor4U::set(const LLColor4U &vec)
{
mV[VX] = vec.mV[VX];
mV[VY] = vec.mV[VY];
@@ -229,17 +237,49 @@ inline const LLColor4U& LLColor4U::setVec(const LLColor4U &vec)
return (*this);
}
-/*
-inline const LLColor4U& LLColor4U::setVec(const LLColor4 &vec)
+inline const LLColor4U& LLColor4U::set(const U8 *vec)
{
- mV[VX] = (U8) (llmin(1.f, vec.mV[VX]) * 255.f);
- mV[VY] = (U8) (llmin(1.f, vec.mV[VY]) * 255.f);
- mV[VZ] = (U8) (llmin(1.f, vec.mV[VZ]) * 255.f);
- mV[VW] = (U8) (llmin(1.f, vec.mV[VW]) * 255.f);
+ mV[VX] = vec[VX];
+ mV[VY] = vec[VY];
+ mV[VZ] = vec[VZ];
+ mV[VW] = vec[VW];
return (*this);
}
-*/
+// deprecated
+inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z)
+{
+ mV[VX] = x;
+ mV[VY] = y;
+ mV[VZ] = z;
+
+// no change to alpha!
+// mV[VW] = 255;
+
+ return (*this);
+}
+
+// deprecated
+inline const LLColor4U& LLColor4U::setVec(const U8 r, const U8 g, const U8 b, U8 a)
+{
+ mV[0] = r;
+ mV[1] = g;
+ mV[2] = b;
+ mV[3] = a;
+ return (*this);
+}
+
+// deprecated
+inline const LLColor4U& LLColor4U::setVec(const LLColor4U &vec)
+{
+ mV[VX] = vec.mV[VX];
+ mV[VY] = vec.mV[VY];
+ mV[VZ] = vec.mV[VZ];
+ mV[VW] = vec.mV[VW];
+ return (*this);
+}
+
+// deprecated
inline const LLColor4U& LLColor4U::setVec(const U8 *vec)
{
mV[VX] = vec[VX];
@@ -256,13 +296,24 @@ inline const LLColor4U& LLColor4U::setAlpha(U8 a)
}
// LLColor4U Magnitude and Normalization Functions
-// bookmark
+inline F32 LLColor4U::length(void) const
+{
+ return fsqrtf( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] );
+}
+
+inline F32 LLColor4U::lengthSquared(void) const
+{
+ return ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ];
+}
+
+// deprecated
inline F32 LLColor4U::magVec(void) const
{
return fsqrtf( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] );
}
+// deprecated
inline F32 LLColor4U::magVecSquared(void) const
{
return ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ];
@@ -407,13 +458,13 @@ inline const LLColor4U& operator%=(LLColor4U &a, U8 k)
inline F32 distVec(const LLColor4U &a, const LLColor4U &b)
{
LLColor4U vec = a - b;
- return (vec.magVec());
+ return (vec.length());
}
inline F32 distVec_squared(const LLColor4U &a, const LLColor4U &b)
{
LLColor4U vec = a - b;
- return (vec.magVecSquared());
+ return (vec.lengthSquared());
}
void LLColor4U::setVecScaleClamp(const LLColor4& color)