From 70485472b15a0247258d0bddf7c832445ada77ce Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 24 Sep 2022 00:47:41 +0200 Subject: [PATCH 1/3] Common/Matrix: Add equality operators to TVec2/3/4. --- Source/Core/Common/Matrix.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/Core/Common/Matrix.h b/Source/Core/Common/Matrix.h index 1c6c53787e..c2bd78d36c 100644 --- a/Source/Core/Common/Matrix.h +++ b/Source/Core/Common/Matrix.h @@ -24,6 +24,11 @@ union TVec3 { } + constexpr bool operator==(const TVec3& other) const + { + return x == other.x && y == other.y && z == other.z; + } + constexpr TVec3 Cross(const TVec3& rhs) const { return {(y * rhs.z) - (rhs.y * z), (z * rhs.x) - (rhs.z * x), (x * rhs.y) - (rhs.x * y)}; @@ -153,6 +158,11 @@ union TVec4 constexpr TVec4(TVec3 _vec, T _w) : TVec4{_vec.x, _vec.y, _vec.z, _w} {} constexpr TVec4(T _x, T _y, T _z, T _w) : data{_x, _y, _z, _w} {} + constexpr bool operator==(const TVec4& other) const + { + return x == other.x && y == other.y && z == other.z && w == other.w; + } + constexpr T Dot(const TVec4& other) const { return x * other.x + y * other.y + z * other.z + w * other.w; @@ -216,6 +226,8 @@ union TVec2 { } + constexpr bool operator==(const TVec2& other) const { return x == other.x && y == other.y; } + constexpr T Cross(const TVec2& rhs) const { return (x * rhs.y) - (y * rhs.x); } constexpr T Dot(const TVec2& rhs) const { return (x * rhs.x) + (y * rhs.y); } constexpr T LengthSquared() const { return Dot(*this); } From 24a1fe32f1a6c2b83afd9933af4f22e24380f1b7 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 24 Sep 2022 00:48:26 +0200 Subject: [PATCH 2/3] InputCommon: Make RawValue constructors constexpr. --- Source/Core/InputCommon/ControllerEmu/ControllerEmu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h index 32b755eb30..6b6329cc4f 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h +++ b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h @@ -103,8 +103,8 @@ struct ThreePointCalibration template struct RawValue { - RawValue() = default; - explicit RawValue(const T& value_) : value{value_} {} + constexpr RawValue() = default; + constexpr explicit RawValue(const T& value_) : value{value_} {} static constexpr size_t BITS_OF_PRECISION = Bits; From 02a967f78625ce226c0590948d49f29d6e35ebe1 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 24 Sep 2022 00:48:47 +0200 Subject: [PATCH 3/3] InputCommon: Add equality operators to RawValue. --- Source/Core/InputCommon/ControllerEmu/ControllerEmu.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h index 6b6329cc4f..2db991eb82 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h +++ b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h @@ -110,6 +110,8 @@ struct RawValue T value; + constexpr bool operator==(const RawValue& other) const = default; + template auto GetNormalizedValue(const TwoPointCalibration& calibration) const {