From 7b30a7293976ac094f0ae9d3db95c29d09daec42 Mon Sep 17 00:00:00 2001 From: Michael Kuc Date: Sat, 11 Apr 2020 10:59:30 +0100 Subject: [PATCH] Added equality comparison to matrices and vectors. --- include/raylib/Matrix.hpp | 19 +++++++++++++++++++ include/raylib/Vector2.hpp | 5 +++++ include/raylib/Vector3.hpp | 6 ++++++ include/raylib/Vector4.hpp | 7 +++++++ 4 files changed, 37 insertions(+) diff --git a/include/raylib/Matrix.hpp b/include/raylib/Matrix.hpp index 4e160a4..42078de 100644 --- a/include/raylib/Matrix.hpp +++ b/include/raylib/Matrix.hpp @@ -89,6 +89,25 @@ namespace raylib { return *this; } + bool operator==(const Matrix& other) { + return m0 == other.m0 + && m1 == other.m1 + && m2 == other.m2 + && m3 == other.m3 + && m4 == other.m4 + && m5 == other.m5 + && m6 == other.m6 + && m7 == other.m7 + && m8 == other.m8 + && m9 == other.m9 + && m10 == other.m10 + && m11 == other.m11 + && m12 == other.m12 + && m13 == other.m13 + && m14 == other.m14 + && m15 == other.m15; + } + inline Matrix& SetProjection() { ::SetMatrixProjection(*this); return *this; diff --git a/include/raylib/Vector2.hpp b/include/raylib/Vector2.hpp index 6e2ea09..76a8a14 100644 --- a/include/raylib/Vector2.hpp +++ b/include/raylib/Vector2.hpp @@ -45,6 +45,11 @@ namespace raylib { return *this; } + bool operator==(const Vector2& other) { + return x == other.x + && y == other.y; + } + #ifndef RAYLIB_CPP_NO_MATH Vector2 Add(const Vector2& vector2) { return Vector2Add(*this, vector2); diff --git a/include/raylib/Vector3.hpp b/include/raylib/Vector3.hpp index 9f29bad..e0ff1a7 100644 --- a/include/raylib/Vector3.hpp +++ b/include/raylib/Vector3.hpp @@ -52,6 +52,12 @@ namespace raylib { return *this; } + bool operator==(const Vector3& other) { + return x == other.x + && y == other.y + && z == other.z; + } + #ifndef RAYLIB_CPP_NO_MATH Vector3 Add(const Vector3& vector3) { return Vector3Add(*this, vector3); diff --git a/include/raylib/Vector4.hpp b/include/raylib/Vector4.hpp index a1ce4a6..3cdf341 100644 --- a/include/raylib/Vector4.hpp +++ b/include/raylib/Vector4.hpp @@ -57,6 +57,13 @@ namespace raylib { return *this; } + bool operator==(const Vector4& other) { + return x == other.x + && y == other.y + && z == other.z + && w == other.w; + } + #ifndef RAYLIB_CPP_NO_MATH Vector4 Multiply(const Vector4& vector4) { return QuaternionMultiply(*this, vector4);