From eb8d9cedbd506b7cd9a85053fbde2348e398333f Mon Sep 17 00:00:00 2001 From: craftablescience Date: Thu, 13 Jun 2024 19:11:45 -0400 Subject: [PATCH] feat(sourcepp): add vector equality operators --- include/sourcepp/math/Vector.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/sourcepp/math/Vector.h b/include/sourcepp/math/Vector.h index 246a7875b..289441e5e 100644 --- a/include/sourcepp/math/Vector.h +++ b/include/sourcepp/math/Vector.h @@ -17,6 +17,10 @@ struct Vec2 { return {this->x - other.x, this->y - other.y}; } + [[nodiscard]] bool operator==(const Vec2& other) const { + return this->x == other.x && this->y == other.y; + } + [[nodiscard]] static constexpr Vec2 zero() { return {{}, {}}; } @@ -52,6 +56,10 @@ struct Vec3 { return {this->x - other.x, this->y - other.y, this->z - other.z}; } + [[nodiscard]] bool operator==(const Vec3& other) const { + return this->x == other.x && this->y == other.y && this->z == other.z; + } + [[nodiscard]] static constexpr Vec3 zero() { return {{}, {}, {}}; } @@ -88,6 +96,10 @@ struct Vec4 { return {this->x - other.x, this->y - other.y, this->z - other.z, this->w - other.w}; } + [[nodiscard]] bool operator==(const Vec4& other) const { + return this->x == other.x && this->y == other.y && this->z == other.z && this->w == other.w; + } + [[nodiscard]] static constexpr Vec4 zero() { return {{}, {}, {}, {}}; }