summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
authorBryan O'Sullivan <bos@lindenlab.com>2009-06-22 15:02:19 -0700
committerBryan O'Sullivan <bos@lindenlab.com>2009-06-22 15:02:19 -0700
commitbaa73fddd9287ddafd2d31551cb253b355ed910a (patch)
treee3f0986617fe6c0ee0a14df6aac13c6bb6f92507 /indra/llmath
parentdc3833f31b8a20220ddb1775e1625c016c397435 (diff)
parentfcaa1ad46fd1df4cfec9dee12caf6e7b5bf32136 (diff)
Merge with viewer-2.0.0-3 branch
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/CMakeLists.txt9
-rw-r--r--indra/llmath/llrect.h8
-rw-r--r--indra/llmath/llvolumemgr.h4
-rw-r--r--indra/llmath/v3color.cpp36
-rw-r--r--indra/llmath/v3color.h1
-rw-r--r--indra/llmath/v3dmath.h8
-rw-r--r--indra/llmath/v3math.cpp6
-rw-r--r--indra/llmath/v3math.h4
-rw-r--r--indra/llmath/v4color.cpp36
-rw-r--r--indra/llmath/v4color.h11
-rw-r--r--indra/llmath/v4coloru.h8
11 files changed, 90 insertions, 41 deletions
diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt
index f84cdf1563..c26749cd23 100644
--- a/indra/llmath/CMakeLists.txt
+++ b/indra/llmath/CMakeLists.txt
@@ -80,3 +80,12 @@ set_source_files_properties(${llmath_HEADER_FILES}
list(APPEND llmath_SOURCE_FILES ${llmath_HEADER_FILES})
add_library (llmath ${llmath_SOURCE_FILES})
+
+
+include(LLAddBuildTest)
+SET(llmath_TEST_SOURCE_FILES
+ # WARNING: Please don't write tests against LLCommon or LLMath until this issue is resolved: https://jira.lindenlab.com/jira/browse/DEV-29456
+ # llvolume.cpp
+ )
+LL_ADD_PROJECT_UNIT_TESTS(llmath "${llmath_TEST_SOURCE_FILES}")
+
diff --git a/indra/llmath/llrect.h b/indra/llmath/llrect.h
index 98aceb0597..16bfdde658 100644
--- a/indra/llmath/llrect.h
+++ b/indra/llmath/llrect.h
@@ -64,17 +64,11 @@ public:
mLeft(left), mTop(top), mRight(right), mBottom(bottom)
{}
- LLRectBase(const LLSD& sd)
+ explicit LLRectBase(const LLSD& sd)
{
setValue(sd);
}
- const LLRectBase& operator=(const LLSD& sd)
- {
- setValue(sd);
- return *this;
- }
-
void setValue(const LLSD& sd)
{
mLeft = sd[0].asInteger();
diff --git a/indra/llmath/llvolumemgr.h b/indra/llmath/llvolumemgr.h
index 57d789e73a..a78ea76a1a 100644
--- a/indra/llmath/llvolumemgr.h
+++ b/indra/llmath/llvolumemgr.h
@@ -92,8 +92,8 @@ public:
// whatever calls getVolume() never owns the LLVolume* and
// cannot keep references for long since it may be deleted
// later. For best results hold it in an LLPointer<LLVolume>.
- LLVolume *refVolume(const LLVolumeParams &volume_params, const S32 detail);
- void unrefVolume(LLVolume *volumep);
+ virtual LLVolume *refVolume(const LLVolumeParams &volume_params, const S32 detail);
+ virtual void unrefVolume(LLVolume *volumep);
void dump();
diff --git a/indra/llmath/v3color.cpp b/indra/llmath/v3color.cpp
index fa7b61cd75..e76607a91f 100644
--- a/indra/llmath/v3color.cpp
+++ b/indra/llmath/v3color.cpp
@@ -75,6 +75,42 @@ std::ostream& operator<<(std::ostream& s, const LLColor3 &a)
return s;
}
+static F32 hueToRgb ( F32 val1In, F32 val2In, F32 valHUeIn )
+{
+ if ( valHUeIn < 0.0f ) valHUeIn += 1.0f;
+ if ( valHUeIn > 1.0f ) valHUeIn -= 1.0f;
+ if ( ( 6.0f * valHUeIn ) < 1.0f ) return ( val1In + ( val2In - val1In ) * 6.0f * valHUeIn );
+ if ( ( 2.0f * valHUeIn ) < 1.0f ) return ( val2In );
+ if ( ( 3.0f * valHUeIn ) < 2.0f ) return ( val1In + ( val2In - val1In ) * ( ( 2.0f / 3.0f ) - valHUeIn ) * 6.0f );
+ return ( val1In );
+}
+
+void LLColor3::setHSL ( F32 hValIn, F32 sValIn, F32 lValIn)
+{
+ if ( sValIn < 0.00001f )
+ {
+ mV[VRED] = lValIn;
+ mV[VGREEN] = lValIn;
+ mV[VBLUE] = lValIn;
+ }
+ else
+ {
+ F32 interVal1;
+ F32 interVal2;
+
+ if ( lValIn < 0.5f )
+ interVal2 = lValIn * ( 1.0f + sValIn );
+ else
+ interVal2 = ( lValIn + sValIn ) - ( sValIn * lValIn );
+
+ interVal1 = 2.0f * lValIn - interVal2;
+
+ mV[VRED] = hueToRgb ( interVal1, interVal2, hValIn + ( 1.f / 3.f ) );
+ mV[VGREEN] = hueToRgb ( interVal1, interVal2, hValIn );
+ mV[VBLUE] = hueToRgb ( interVal1, interVal2, hValIn - ( 1.f / 3.f ) );
+ }
+}
+
void LLColor3::calcHSL(F32* hue, F32* saturation, F32* luminance) const
{
F32 var_R = mV[VRED];
diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h
index 179687a32e..1915d80502 100644
--- a/indra/llmath/v3color.h
+++ b/indra/llmath/v3color.h
@@ -79,6 +79,7 @@ public:
mV[2] = (F32) sd[2].asReal();;
}
+ void setHSL(F32 hue, F32 saturation, F32 luminance);
void calcHSL(F32* hue, F32* saturation, F32* luminance) const;
const LLColor3& setToBlack(); // Clears LLColor3 to (0, 0, 0)
diff --git a/indra/llmath/v3dmath.h b/indra/llmath/v3dmath.h
index a99bf5b4a6..6ab31e8a41 100644
--- a/indra/llmath/v3dmath.h
+++ b/indra/llmath/v3dmath.h
@@ -53,7 +53,7 @@ class LLVector3d
inline LLVector3d(const F64 x, const F64 y, const F64 z); // Initializes LLVector3d to (x. y, z)
inline explicit LLVector3d(const F64 *vec); // Initializes LLVector3d to (vec[0]. vec[1], vec[2])
inline explicit LLVector3d(const LLVector3 &vec);
- LLVector3d(const LLSD& sd)
+ explicit LLVector3d(const LLSD& sd)
{
setValue(sd);
}
@@ -65,12 +65,6 @@ class LLVector3d
mdV[2] = sd[2].asReal();
}
- const LLVector3d& operator=(const LLSD& sd)
- {
- setValue(sd);
- return *this;
- }
-
LLSD getValue() const
{
LLSD ret;
diff --git a/indra/llmath/v3math.cpp b/indra/llmath/v3math.cpp
index 101e9d075a..f392ac448b 100644
--- a/indra/llmath/v3math.cpp
+++ b/indra/llmath/v3math.cpp
@@ -314,12 +314,6 @@ void LLVector3::setValue(const LLSD& sd)
mV[2] = (F32) sd[2].asReal();
}
-const LLVector3& LLVector3::operator=(const LLSD& sd)
-{
- setValue(sd);
- return *this;
-}
-
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];
diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h
index 7f96800e21..805d7e6384 100644
--- a/indra/llmath/v3math.h
+++ b/indra/llmath/v3math.h
@@ -67,14 +67,12 @@ class LLVector3
explicit LLVector3(const LLVector2 &vec); // Initializes LLVector3 to (vec[0]. vec[1], 0)
explicit LLVector3(const LLVector3d &vec); // Initializes LLVector3 to (vec[0]. vec[1], vec[2])
explicit LLVector3(const LLVector4 &vec); // Initializes LLVector4 to (vec[0]. vec[1], vec[2])
- LLVector3(const LLSD& sd);
+ explicit LLVector3(const LLSD& sd);
LLSD getValue() const;
void setValue(const LLSD& sd);
- const LLVector3& operator=(const LLSD& sd);
-
inline BOOL isFinite() const; // checks to see if all values of LLVector3 are finite
BOOL clamp(F32 min, F32 max); // Clamps all values to (min,max), returns TRUE if data changed
BOOL clampLength( F32 length_limit ); // Scales vector to limit length to a value
diff --git a/indra/llmath/v4color.cpp b/indra/llmath/v4color.cpp
index 34337b3ac8..219b06ec74 100644
--- a/indra/llmath/v4color.cpp
+++ b/indra/llmath/v4color.cpp
@@ -305,6 +305,42 @@ LLColor4 vec3to4(const LLColor3 &vec)
return temp;
}
+static F32 hueToRgb ( F32 val1In, F32 val2In, F32 valHUeIn )
+{
+ if ( valHUeIn < 0.0f ) valHUeIn += 1.0f;
+ if ( valHUeIn > 1.0f ) valHUeIn -= 1.0f;
+ if ( ( 6.0f * valHUeIn ) < 1.0f ) return ( val1In + ( val2In - val1In ) * 6.0f * valHUeIn );
+ if ( ( 2.0f * valHUeIn ) < 1.0f ) return ( val2In );
+ if ( ( 3.0f * valHUeIn ) < 2.0f ) return ( val1In + ( val2In - val1In ) * ( ( 2.0f / 3.0f ) - valHUeIn ) * 6.0f );
+ return ( val1In );
+}
+
+void LLColor4::setHSL ( F32 hValIn, F32 sValIn, F32 lValIn)
+{
+ if ( sValIn < 0.00001f )
+ {
+ mV[VRED] = lValIn;
+ mV[VGREEN] = lValIn;
+ mV[VBLUE] = lValIn;
+ }
+ else
+ {
+ F32 interVal1;
+ F32 interVal2;
+
+ if ( lValIn < 0.5f )
+ interVal2 = lValIn * ( 1.0f + sValIn );
+ else
+ interVal2 = ( lValIn + sValIn ) - ( sValIn * lValIn );
+
+ interVal1 = 2.0f * lValIn - interVal2;
+
+ mV[VRED] = hueToRgb ( interVal1, interVal2, hValIn + ( 1.f / 3.f ) );
+ mV[VGREEN] = hueToRgb ( interVal1, interVal2, hValIn );
+ mV[VBLUE] = hueToRgb ( interVal1, interVal2, hValIn - ( 1.f / 3.f ) );
+ }
+}
+
void LLColor4::calcHSL(F32* hue, F32* saturation, F32* luminance) const
{
F32 var_R = mV[VRED];
diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h
index f2a5cd39ed..d6fbdec61e 100644
--- a/indra/llmath/v4color.h
+++ b/indra/llmath/v4color.h
@@ -58,7 +58,7 @@ class LLColor4
LLColor4(U32 clr); // Initializes LLColor4 to (r=clr>>24, etc))
LLColor4(const F32 *vec); // Initializes LLColor4 to (vec[0]. vec[1], vec[2], 1)
LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a)
- LLColor4(const LLSD& sd);
+ explicit LLColor4(const LLSD& sd);
explicit LLColor4(const LLColor4U& color4u); // "explicit" to avoid automatic conversion
explicit LLColor4(const LLVector4& vector4); // "explicit" to avoid automatic conversion
@@ -74,6 +74,7 @@ class LLColor4
void setValue(const LLSD& sd);
+ void setHSL(F32 hue, F32 saturation, F32 luminance);
void calcHSL(F32* hue, F32* saturation, F32* luminance) const;
const LLColor4& setToBlack(); // zero LLColor4 to (0, 0, 0, 1)
@@ -112,7 +113,6 @@ class LLColor4
F32 &operator[](int idx) { return mV[idx]; }
const LLColor4& operator=(const LLColor3 &a); // Assigns vec3 to vec4 and returns vec4
- const LLColor4& operator=(const LLSD& sd);
friend std::ostream& operator<<(std::ostream& s, const LLColor4 &a); // Print a
friend LLColor4 operator+(const LLColor4 &a, const LLColor4 &b); // Return vector a + b
@@ -633,12 +633,5 @@ void LLColor4::clamp()
}
}
-inline const LLColor4& LLColor4::operator=(const LLSD& sd)
-{
- setValue(sd);
-
- return *this;
-}
-
#endif
diff --git a/indra/llmath/v4coloru.h b/indra/llmath/v4coloru.h
index c0390fa0b2..4ec5a345eb 100644
--- a/indra/llmath/v4coloru.h
+++ b/indra/llmath/v4coloru.h
@@ -66,7 +66,7 @@ public:
LLColor4U(U8 r, U8 g, U8 b); // Initializes LLColor4U to (r, g, b, 1)
LLColor4U(U8 r, U8 g, U8 b, U8 a); // Initializes LLColor4U to (r. g, b, a)
LLColor4U(const U8 *vec); // Initializes LLColor4U to (vec[0]. vec[1], vec[2], 1)
- LLColor4U(const LLSD& sd)
+ explicit LLColor4U(const LLSD& sd)
{
setValue(sd);
}
@@ -79,12 +79,6 @@ public:
mV[3] = sd[3].asInteger();
}
- const LLColor4U& operator=(const LLSD& sd)
- {
- setValue(sd);
- return *this;
- }
-
LLSD getValue() const
{
LLSD ret;