aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath/v4coloru.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmath/v4coloru.h')
-rw-r--r--linden/indra/llmath/v4coloru.h91
1 files changed, 71 insertions, 20 deletions
diff --git a/linden/indra/llmath/v4coloru.h b/linden/indra/llmath/v4coloru.h
index 910a081..f3f1c57 100644
--- a/linden/indra/llmath/v4coloru.h
+++ b/linden/indra/llmath/v4coloru.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -97,15 +97,23 @@ public:
97 const LLColor4U& setToBlack(); // zero LLColor4U to (0, 0, 0, 1) 97 const LLColor4U& setToBlack(); // zero LLColor4U to (0, 0, 0, 1)
98 const LLColor4U& setToWhite(); // zero LLColor4U to (0, 0, 0, 1) 98 const LLColor4U& setToWhite(); // zero LLColor4U to (0, 0, 0, 1)
99 99
100 const LLColor4U& setVec(U8 r, U8 g, U8 b, U8 a); // Sets LLColor4U to (r, g, b, a) 100 const LLColor4U& set(U8 r, U8 g, U8 b, U8 a);// Sets LLColor4U to (r, g, b, a)
101 const LLColor4U& setVec(U8 r, U8 g, U8 b); // Sets LLColor4U to (r, g, b) (no change in a) 101 const LLColor4U& set(U8 r, U8 g, U8 b); // Sets LLColor4U to (r, g, b) (no change in a)
102 const LLColor4U& setVec(const LLColor4U &vec); // Sets LLColor4U to vec 102 const LLColor4U& set(const LLColor4U &vec); // Sets LLColor4U to vec
103 const LLColor4U& setVec(const U8 *vec); // Sets LLColor4U to vec 103 const LLColor4U& set(const U8 *vec); // Sets LLColor4U to vec
104
105 const LLColor4U& setVec(U8 r, U8 g, U8 b, U8 a); // deprecated -- use set()
106 const LLColor4U& setVec(U8 r, U8 g, U8 b); // deprecated -- use set()
107 const LLColor4U& setVec(const LLColor4U &vec); // deprecated -- use set()
108 const LLColor4U& setVec(const U8 *vec); // deprecated -- use set()
104 109
105 const LLColor4U& setAlpha(U8 a); 110 const LLColor4U& setAlpha(U8 a);
106 111
107 F32 magVec() const; // Returns magnitude of LLColor4U 112 F32 magVec() const; // deprecated -- use length()
108 F32 magVecSquared() const; // Returns magnitude squared of LLColor4U 113 F32 magVecSquared() const; // deprecated -- use lengthSquared()
114
115 F32 length() const; // Returns magnitude squared of LLColor4U
116 F32 lengthSquared() const; // Returns magnitude squared of LLColor4U
109 117
110 friend std::ostream& operator<<(std::ostream& s, const LLColor4U &a); // Print a 118 friend std::ostream& operator<<(std::ostream& s, const LLColor4U &a); // Print a
111 friend LLColor4U operator+(const LLColor4U &a, const LLColor4U &b); // Return vector a + b 119 friend LLColor4U operator+(const LLColor4U &a, const LLColor4U &b); // Return vector a + b
@@ -199,7 +207,7 @@ inline const LLColor4U& LLColor4U::setToWhite(void)
199 return (*this); 207 return (*this);
200} 208}
201 209
202inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z) 210inline const LLColor4U& LLColor4U::set(const U8 x, const U8 y, const U8 z)
203{ 211{
204 mV[VX] = x; 212 mV[VX] = x;
205 mV[VY] = y; 213 mV[VY] = y;
@@ -211,7 +219,7 @@ inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z)
211 return (*this); 219 return (*this);
212} 220}
213 221
214inline const LLColor4U& LLColor4U::setVec(const U8 r, const U8 g, const U8 b, U8 a) 222inline const LLColor4U& LLColor4U::set(const U8 r, const U8 g, const U8 b, U8 a)
215{ 223{
216 mV[0] = r; 224 mV[0] = r;
217 mV[1] = g; 225 mV[1] = g;
@@ -220,7 +228,7 @@ inline const LLColor4U& LLColor4U::setVec(const U8 r, const U8 g, const U8 b, U8
220 return (*this); 228 return (*this);
221} 229}
222 230
223inline const LLColor4U& LLColor4U::setVec(const LLColor4U &vec) 231inline const LLColor4U& LLColor4U::set(const LLColor4U &vec)
224{ 232{
225 mV[VX] = vec.mV[VX]; 233 mV[VX] = vec.mV[VX];
226 mV[VY] = vec.mV[VY]; 234 mV[VY] = vec.mV[VY];
@@ -229,17 +237,49 @@ inline const LLColor4U& LLColor4U::setVec(const LLColor4U &vec)
229 return (*this); 237 return (*this);
230} 238}
231 239
232/* 240inline const LLColor4U& LLColor4U::set(const U8 *vec)
233inline const LLColor4U& LLColor4U::setVec(const LLColor4 &vec)
234{ 241{
235 mV[VX] = (U8) (llmin(1.f, vec.mV[VX]) * 255.f); 242 mV[VX] = vec[VX];
236 mV[VY] = (U8) (llmin(1.f, vec.mV[VY]) * 255.f); 243 mV[VY] = vec[VY];
237 mV[VZ] = (U8) (llmin(1.f, vec.mV[VZ]) * 255.f); 244 mV[VZ] = vec[VZ];
238 mV[VW] = (U8) (llmin(1.f, vec.mV[VW]) * 255.f); 245 mV[VW] = vec[VW];
239 return (*this); 246 return (*this);
240} 247}
241*/
242 248
249// deprecated
250inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z)
251{
252 mV[VX] = x;
253 mV[VY] = y;
254 mV[VZ] = z;
255
256// no change to alpha!
257// mV[VW] = 255;
258
259 return (*this);
260}
261
262// deprecated
263inline const LLColor4U& LLColor4U::setVec(const U8 r, const U8 g, const U8 b, U8 a)
264{
265 mV[0] = r;
266 mV[1] = g;
267 mV[2] = b;
268 mV[3] = a;
269 return (*this);
270}
271
272// deprecated
273inline const LLColor4U& LLColor4U::setVec(const LLColor4U &vec)
274{
275 mV[VX] = vec.mV[VX];
276 mV[VY] = vec.mV[VY];
277 mV[VZ] = vec.mV[VZ];
278 mV[VW] = vec.mV[VW];
279 return (*this);
280}
281
282// deprecated
243inline const LLColor4U& LLColor4U::setVec(const U8 *vec) 283inline const LLColor4U& LLColor4U::setVec(const U8 *vec)
244{ 284{
245 mV[VX] = vec[VX]; 285 mV[VX] = vec[VX];
@@ -256,13 +296,24 @@ inline const LLColor4U& LLColor4U::setAlpha(U8 a)
256} 296}
257 297
258// LLColor4U Magnitude and Normalization Functions 298// LLColor4U Magnitude and Normalization Functions
259// bookmark
260 299
300inline F32 LLColor4U::length(void) const
301{
302 return fsqrtf( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] );
303}
304
305inline F32 LLColor4U::lengthSquared(void) const
306{
307 return ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ];
308}
309
310// deprecated
261inline F32 LLColor4U::magVec(void) const 311inline F32 LLColor4U::magVec(void) const
262{ 312{
263 return fsqrtf( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] ); 313 return fsqrtf( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] );
264} 314}
265 315
316// deprecated
266inline F32 LLColor4U::magVecSquared(void) const 317inline F32 LLColor4U::magVecSquared(void) const
267{ 318{
268 return ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ]; 319 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)
407inline F32 distVec(const LLColor4U &a, const LLColor4U &b) 458inline F32 distVec(const LLColor4U &a, const LLColor4U &b)
408{ 459{
409 LLColor4U vec = a - b; 460 LLColor4U vec = a - b;
410 return (vec.magVec()); 461 return (vec.length());
411} 462}
412 463
413inline F32 distVec_squared(const LLColor4U &a, const LLColor4U &b) 464inline F32 distVec_squared(const LLColor4U &a, const LLColor4U &b)
414{ 465{
415 LLColor4U vec = a - b; 466 LLColor4U vec = a - b;
416 return (vec.magVecSquared()); 467 return (vec.lengthSquared());
417} 468}
418 469
419void LLColor4U::setVecScaleClamp(const LLColor4& color) 470void LLColor4U::setVecScaleClamp(const LLColor4& color)