summaryrefslogtreecommitdiff
path: root/indra/llmath/v4color.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath/v4color.h')
-rw-r--r--indra/llmath/v4color.h29
1 files changed, 29 insertions, 0 deletions
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