diff --git a/change_log.txt b/change_log.txt index 13a849b0c446ecb3ab74c8e9eab21decab7801b6..ceae0eea5ee3c401ca323b9d2909382dc7a6be52 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 2a55a94092265dbb2580ab4d84340830470f60c2..eec07e49717be334c165c01781a4ada8d3175e07 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) {}