aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath/v4color.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmath/v4color.h')
-rw-r--r--linden/indra/llmath/v4color.h111
1 files changed, 98 insertions, 13 deletions
diff --git a/linden/indra/llmath/v4color.h b/linden/indra/llmath/v4color.h
index 53e4407..57055c5 100644
--- a/linden/indra/llmath/v4color.h
+++ b/linden/indra/llmath/v4color.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
@@ -84,20 +84,33 @@ class LLColor4
84 const LLColor4& setToBlack(); // zero LLColor4 to (0, 0, 0, 1) 84 const LLColor4& setToBlack(); // zero LLColor4 to (0, 0, 0, 1)
85 const LLColor4& setToWhite(); // zero LLColor4 to (0, 0, 0, 1) 85 const LLColor4& setToWhite(); // zero LLColor4 to (0, 0, 0, 1)
86 86
87 const LLColor4& setVec(F32 r, F32 g, F32 b, F32 a); // Sets LLColor4 to (r, g, b, a) 87 const LLColor4& setVec(F32 r, F32 g, F32 b, F32 a); // deprecated -- use set()
88 const LLColor4& setVec(F32 r, F32 g, F32 b); // Sets LLColor4 to (r, g, b) (no change in a) 88 const LLColor4& setVec(F32 r, F32 g, F32 b); // deprecated -- use set()
89 const LLColor4& setVec(const LLColor4 &vec); // Sets LLColor4 to vec 89 const LLColor4& setVec(const LLColor4 &vec); // deprecated -- use set()
90 const LLColor4& setVec(const LLColor3 &vec); // Sets LLColor4 to LLColor3 vec (no change in alpha) 90 const LLColor4& setVec(const LLColor3 &vec); // deprecated -- use set()
91 const LLColor4& setVec(const LLColor3 &vec, F32 a); // Sets LLColor4 to LLColor3 vec, with alpha specified 91 const LLColor4& setVec(const LLColor3 &vec, F32 a); // deprecated -- use set()
92 const LLColor4& setVec(const F32 *vec); // Sets LLColor4 to vec 92 const LLColor4& setVec(const F32 *vec); // deprecated -- use set()
93 const LLColor4& setVec(const LLColor4U& color4u); // Sets LLColor4 to color4u, rescaled. 93 const LLColor4& setVec(const LLColor4U& color4u); // deprecated -- use set()
94
95 const LLColor4& set(F32 r, F32 g, F32 b, F32 a); // Sets LLColor4 to (r, g, b, a)
96 const LLColor4& set(F32 r, F32 g, F32 b); // Sets LLColor4 to (r, g, b) (no change in a)
97 const LLColor4& set(const LLColor4 &vec); // Sets LLColor4 to vec
98 const LLColor4& set(const LLColor3 &vec); // Sets LLColor4 to LLColor3 vec (no change in alpha)
99 const LLColor4& set(const LLColor3 &vec, F32 a); // Sets LLColor4 to LLColor3 vec, with alpha specified
100 const LLColor4& set(const F32 *vec); // Sets LLColor4 to vec
101 const LLColor4& set(const LLColor4U& color4u); // Sets LLColor4 to color4u, rescaled.
94 102
95 103
96 const LLColor4& setAlpha(F32 a); 104 const LLColor4& setAlpha(F32 a);
97 105
98 F32 magVec() const; // Returns magnitude of LLColor4 106 F32 magVec() const; // deprecated -- use length()
99 F32 magVecSquared() const; // Returns magnitude squared of LLColor4 107 F32 magVecSquared() const; // deprecated -- use lengthSquared()
100 F32 normVec(); // Normalizes and returns the magnitude of LLColor4 108 F32 normVec(); // deprecated -- use normalize()
109
110 F32 length() const; // Returns magnitude of LLColor4
111 F32 lengthSquared() const; // Returns magnitude squared of LLColor4
112 F32 normalize(); // deprecated -- use normalize()
113
101 BOOL isOpaque() { return mV[VALPHA] == 1.f; } 114 BOOL isOpaque() { return mV[VALPHA] == 1.f; }
102 115
103 F32 operator[](int idx) const { return mV[idx]; } 116 F32 operator[](int idx) const { return mV[idx]; }
@@ -289,6 +302,47 @@ inline const LLColor4& LLColor4::setToWhite(void)
289 return (*this); 302 return (*this);
290} 303}
291 304
305inline const LLColor4& LLColor4::set(F32 x, F32 y, F32 z)
306{
307 mV[VX] = x;
308 mV[VY] = y;
309 mV[VZ] = z;
310
311// no change to alpha!
312// mV[VW] = 1.f;
313
314 return (*this);
315}
316
317inline const LLColor4& LLColor4::set(F32 x, F32 y, F32 z, F32 a)
318{
319 mV[VX] = x;
320 mV[VY] = y;
321 mV[VZ] = z;
322 mV[VW] = a;
323 return (*this);
324}
325
326inline const LLColor4& LLColor4::set(const LLColor4 &vec)
327{
328 mV[VX] = vec.mV[VX];
329 mV[VY] = vec.mV[VY];
330 mV[VZ] = vec.mV[VZ];
331 mV[VW] = vec.mV[VW];
332 return (*this);
333}
334
335
336inline const LLColor4& LLColor4::set(const F32 *vec)
337{
338 mV[VX] = vec[VX];
339 mV[VY] = vec[VY];
340 mV[VZ] = vec[VZ];
341 mV[VW] = vec[VW];
342 return (*this);
343}
344
345// deprecated
292inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z) 346inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z)
293{ 347{
294 mV[VX] = x; 348 mV[VX] = x;
@@ -301,6 +355,7 @@ inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z)
301 return (*this); 355 return (*this);
302} 356}
303 357
358// deprecated
304inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z, F32 a) 359inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z, F32 a)
305{ 360{
306 mV[VX] = x; 361 mV[VX] = x;
@@ -310,6 +365,7 @@ inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z, F32 a)
310 return (*this); 365 return (*this);
311} 366}
312 367
368// deprecated
313inline const LLColor4& LLColor4::setVec(const LLColor4 &vec) 369inline const LLColor4& LLColor4::setVec(const LLColor4 &vec)
314{ 370{
315 mV[VX] = vec.mV[VX]; 371 mV[VX] = vec.mV[VX];
@@ -320,6 +376,7 @@ inline const LLColor4& LLColor4::setVec(const LLColor4 &vec)
320} 376}
321 377
322 378
379// deprecated
323inline const LLColor4& LLColor4::setVec(const F32 *vec) 380inline const LLColor4& LLColor4::setVec(const F32 *vec)
324{ 381{
325 mV[VX] = vec[VX]; 382 mV[VX] = vec[VX];
@@ -337,16 +394,44 @@ inline const LLColor4& LLColor4::setAlpha(F32 a)
337 394
338// LLColor4 Magnitude and Normalization Functions 395// LLColor4 Magnitude and Normalization Functions
339 396
397inline F32 LLColor4::length(void) const
398{
399 return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
400}
401
402inline F32 LLColor4::lengthSquared(void) const
403{
404 return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ];
405}
406
407inline F32 LLColor4::normalize(void)
408{
409 F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
410 F32 oomag;
411
412 if (mag)
413 {
414 oomag = 1.f/mag;
415 mV[VX] *= oomag;
416 mV[VY] *= oomag;
417 mV[VZ] *= oomag;
418 }
419 return (mag);
420}
421
422// deprecated
340inline F32 LLColor4::magVec(void) const 423inline F32 LLColor4::magVec(void) const
341{ 424{
342 return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); 425 return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
343} 426}
344 427
428// deprecated
345inline F32 LLColor4::magVecSquared(void) const 429inline F32 LLColor4::magVecSquared(void) const
346{ 430{
347 return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]; 431 return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ];
348} 432}
349 433
434// deprecated
350inline F32 LLColor4::normVec(void) 435inline F32 LLColor4::normVec(void)
351{ 436{
352 F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); 437 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)
497inline F32 distVec(const LLColor4 &a, const LLColor4 &b) 582inline F32 distVec(const LLColor4 &a, const LLColor4 &b)
498{ 583{
499 LLColor4 vec = a - b; 584 LLColor4 vec = a - b;
500 return (vec.magVec()); 585 return (vec.length());
501} 586}
502 587
503inline F32 distVec_squared(const LLColor4 &a, const LLColor4 &b) 588inline F32 distVec_squared(const LLColor4 &a, const LLColor4 &b)
504{ 589{
505 LLColor4 vec = a - b; 590 LLColor4 vec = a - b;
506 return (vec.magVecSquared()); 591 return (vec.lengthSquared());
507} 592}
508 593
509inline LLColor4 lerp(const LLColor4 &a, const LLColor4 &b, F32 u) 594inline LLColor4 lerp(const LLColor4 &a, const LLColor4 &b, F32 u)