From 381a876b43cc1c208bfc60dc093a946ee387a8ce Mon Sep 17 00:00:00 2001
From: DragonGeo2 <dragongeo2@users.sourceforge.net>
Date: Mon, 7 Jun 2010 19:03:06 +0100
Subject: [PATCH] Some math operators for TexCoord and Color4 (cherry-picked
 from aedra svn revision 48).

---
 change_log.txt     |  1 +
 include/nif_math.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/change_log.txt b/change_log.txt
index 13a849b0..ceae0eea 100644
--- a/change_log.txt
+++ b/change_log.txt
@@ -635,4 +635,5 @@
 ==Version 0.7.3==
 
  * AsQuaternion is now a const member function (contributed by Dragongeo2).
+ * Some math operators for TexCoord and Color4 (contributed by Dragongeo2).
 
diff --git a/include/nif_math.h b/include/nif_math.h
index 2a55a940..eec07e49 100644
--- a/include/nif_math.h
+++ b/include/nif_math.h
@@ -45,6 +45,33 @@ struct TexCoord {
 	/*! Default constructor	*/
 	NIFLIB_API TexCoord() : u(0.0f), v(0.0f) {}
 
+	NIFLIB_API TexCoord operator+(const TexCoord& rhs) const
+	{
+		TexCoord ret;
+		ret = *this;
+		ret.u += rhs.u;
+		ret.v += rhs.v;
+		return ret;
+	}
+
+	NIFLIB_API TexCoord operator-(const TexCoord& rhs) const
+	{
+		TexCoord ret;
+		ret = *this;
+		ret.u -= rhs.u;
+		ret.v -= rhs.v;
+		return ret;
+	}
+
+	NIFLIB_API TexCoord operator*(const float rhs) const
+	{
+		TexCoord ret;
+		ret = *this;
+		ret.u *= rhs;
+		ret.v *= rhs;
+		return ret;
+	}
+
 	/*! This constructor can be used to set all values in this structure during initialization
 	 * \param[in] u The value to set U to.
 	 * \param[in] v The value to set V to.
@@ -958,6 +985,28 @@ struct Color4 {
 	float b; /*!< The blue component of this color.  Should be between 0.0f and 1.0f. */ 
 	float a; /*!< The alpha translucency component of this color.  Should be between 0.0f and 1.0f. */ 
 
+	NIFLIB_API Color4 operator+(const Color4& rhs) const
+	{
+		Color4 ret;
+		ret = *this;
+		ret.r += rhs.r;
+		ret.g += rhs.g;
+		ret.b += rhs.b;
+		ret.a += rhs.a;
+		return ret;
+	}
+
+	NIFLIB_API Color4 operator*(const float rhs) const
+	{
+		Color4 ret;
+		ret = *this;
+		ret.r *= rhs;
+		ret.g *= rhs;
+		ret.b *= rhs;
+		ret.a *= rhs;
+		return ret;
+	}
+
 	/*! Default constructor */
 	NIFLIB_API Color4() : r(0.0f), g(0.0f), b(0.0f), a(0.0f) {}
 
-- 
GitLab