diff options
author | Loren Shih <seraph@lindenlab.com> | 2010-09-08 17:58:17 -0400 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2010-09-08 17:58:17 -0400 |
commit | eed7b7201188e01a452c7f4c511c0cb157dc7a5f (patch) | |
tree | e705e93230361aee2c1573f6c37d5d53abda42a0 /indra/llmath | |
parent | a2fb3fabc7926dd105393391f334baa78f232640 (diff) | |
parent | 45639aa0d1889a6cbd9223e987740d25d96ed8fd (diff) |
automated merge
Diffstat (limited to 'indra/llmath')
-rw-r--r-- | indra/llmath/v3math.cpp | 15 | ||||
-rw-r--r-- | indra/llmath/v3math.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/indra/llmath/v3math.cpp b/indra/llmath/v3math.cpp index fd08df02d8..18b15e08c4 100644 --- a/indra/llmath/v3math.cpp +++ b/indra/llmath/v3math.cpp @@ -134,6 +134,21 @@ BOOL LLVector3::clampLength( F32 length_limit ) return changed; } +BOOL LLVector3::clamp(const LLVector3 &min_vec, const LLVector3 &max_vec) +{ + BOOL ret = FALSE; + + if (mV[0] < min_vec[0]) { mV[0] = min_vec[0]; ret = TRUE; } + if (mV[1] < min_vec[1]) { mV[1] = min_vec[1]; ret = TRUE; } + if (mV[2] < min_vec[2]) { mV[2] = min_vec[2]; ret = TRUE; } + + if (mV[0] > max_vec[0]) { mV[0] = max_vec[0]; ret = TRUE; } + if (mV[1] > max_vec[1]) { mV[1] = max_vec[1]; ret = TRUE; } + if (mV[2] > max_vec[2]) { mV[2] = max_vec[2]; ret = TRUE; } + + return ret; +} + // Sets all values to absolute value of their original values // Returns TRUE if data changed diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h index dbd38c1c3f..d3fc6fcb2f 100644 --- a/indra/llmath/v3math.h +++ b/indra/llmath/v3math.h @@ -69,6 +69,7 @@ class LLVector3 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 clamp(const LLVector3 &min_vec, const LLVector3 &max_vec); // Scales vector by another vector BOOL clampLength( F32 length_limit ); // Scales vector to limit length to a value void quantize16(F32 lowerxy, F32 upperxy, F32 lowerz, F32 upperz); // changes the vector to reflect quatization |