diff --git a/include/assimp/color4.h b/include/assimp/color4.h index 4fb8941ee..bd8ff6fb4 100644 --- a/include/assimp/color4.h +++ b/include/assimp/color4.h @@ -74,6 +74,7 @@ public: // comparison bool operator == (const aiColor4t& other) const; bool operator != (const aiColor4t& other) const; + bool operator < (const aiColor4t& other) const; // color tuple access, rgba order inline TReal operator[](unsigned int i) const; diff --git a/include/assimp/color4.inl b/include/assimp/color4.inl index f4f9126de..1b9d173ab 100644 --- a/include/assimp/color4.inl +++ b/include/assimp/color4.inl @@ -94,6 +94,17 @@ AI_FORCE_INLINE bool aiColor4t::operator!= (const aiColor4t& other } // ------------------------------------------------------------------------------------------------ template +AI_FORCE_INLINE bool aiColor4t::operator< (const aiColor4t& other) const { + return r < other.r || ( + r == other.r && (g < other.g || + g == other.g && (b < other.b || + b == other.b && a < other.a + ) + ) + ); +} +// ------------------------------------------------------------------------------------------------ +template AI_FORCE_INLINE aiColor4t operator + (const aiColor4t& v1, const aiColor4t& v2) { return aiColor4t( v1.r + v2.r, v1.g + v2.g, v1.b + v2.b, v1.a + v2.a); } diff --git a/include/assimp/types.h b/include/assimp/types.h index 22ca7abdc..070c5d224 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -172,6 +172,16 @@ struct aiColor3D bool operator != (const aiColor3D& other) const {return r != other.r || g != other.g || b != other.b;} + /** Component-wise comparison */ + // TODO: add epsilon? + bool operator < (const aiColor3D& other) const { + return r < other.r || ( + r == other.r && (g < other.g || + g == other.g && b < other.b + ) + ); + } + /** Component-wise addition */ aiColor3D operator+(const aiColor3D& c) const { return aiColor3D(r+c.r,g+c.g,b+c.b);