diff options
author | Dave Parks <davep@lindenlab.com> | 2022-10-14 17:35:48 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2022-10-14 17:35:48 -0500 |
commit | f6762c3de57434730a2cbf6d0241bf1db5c9346c (patch) | |
tree | 4a112b3ce07552bc19e1c8b4474b64c292572d1f /indra/llmath | |
parent | a2b09df2db69ba8a2e6b587d839d509fbe5abebb (diff) |
SL-18105 Add to/from json capability to LLGLTFMaterial
Diffstat (limited to 'indra/llmath')
-rw-r--r-- | indra/llmath/v3color.h | 32 | ||||
-rw-r--r-- | indra/llmath/v4color.h | 29 |
2 files changed, 61 insertions, 0 deletions
diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h index 0b3b4ea3e1..d925f56e97 100644 --- a/indra/llmath/v3color.h +++ b/indra/llmath/v3color.h @@ -88,6 +88,16 @@ public: 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 + + // set from a vector of unknown type and size + // may leave some data unmodified + template<typename T> + const LLColor3& set(const std::vector<T>& v); + + // write to a vector of unknown type and size + // maye leave some data unmodified + template<typename T> + void write(std::vector<T>& v) const; F32 magVec() const; // deprecated F32 magVecSquared() const; // deprecated @@ -504,4 +514,26 @@ inline const LLVector3 linearColor3v(const T& a) { return LLVector3(linearColor3p(a.mV).mV); } +template<typename T> +const LLColor3& LLColor3::set(const std::vector<T>& v) +{ + for (S32 i = 0; i < llmin((S32)v.size(), 3); ++i) + { + mV[i] = v[i]; + } + + return *this; +} + +// write to a vector of unknown type and size +// maye leave some data unmodified +template<typename T> +void LLColor3::write(std::vector<T>& v) const +{ + for (int i = 0; i < llmin((S32)v.size(), 3); ++i) + { + v[i] = mV[i]; + } +} + #endif diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index f2863be531..daa61594fb 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -91,6 +91,15 @@ class LLColor4 const LLColor4& set(const F64 *vec); // Sets LLColor4 to (double)vec const LLColor4& set(const LLColor4U& color4u); // Sets LLColor4 to color4u, rescaled. + // set from a vector of unknown type and size + // may leave some data unmodified + template<typename T> + const LLColor4& set(const std::vector<T>& v); + + // write to a vector of unknown type and size + // maye leave some data unmodified + template<typename T> + void write(std::vector<T>& v) const; const LLColor4& setAlpha(F32 a); @@ -690,5 +699,25 @@ inline const LLColor4 linearColor4(const LLColor4 &a) return linearColor; } +template<typename T> +const LLColor4& LLColor4::set(const std::vector<T>& v) +{ + for (S32 i = 0; i < llmin((S32)v.size(), 4); ++i) + { + mV[i] = v[i]; + } + + return *this; +} + +template<typename T> +void LLColor4::write(std::vector<T>& v) const +{ + for (int i = 0; i < llmin((S32)v.size(), 4); ++i) + { + v[i] = mV[i]; + } +} + #endif |