diff options
Diffstat (limited to 'src/common/vector_math.h')
| -rw-r--r-- | src/common/vector_math.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/common/vector_math.h b/src/common/vector_math.h index 6e2a5ad60..2b05f66ee 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #pragma once | 31 | #pragma once |
| 32 | 32 | ||
| 33 | #include <cmath> | 33 | #include <cmath> |
| 34 | #include <type_traits> | ||
| 34 | 35 | ||
| 35 | namespace Math { | 36 | namespace Math { |
| 36 | 37 | ||
| @@ -90,7 +91,8 @@ public: | |||
| 90 | y -= other.y; | 91 | y -= other.y; |
| 91 | } | 92 | } |
| 92 | 93 | ||
| 93 | Vec2<decltype(-T{})> operator-() const { | 94 | template <typename U = T> |
| 95 | Vec2<std::enable_if_t<std::is_signed<U>::value, U>> operator-() const { | ||
| 94 | return MakeVec(-x, -y); | 96 | return MakeVec(-x, -y); |
| 95 | } | 97 | } |
| 96 | Vec2<decltype(T{} * T{})> operator*(const Vec2& other) const { | 98 | Vec2<decltype(T{} * T{})> operator*(const Vec2& other) const { |
| @@ -247,7 +249,8 @@ public: | |||
| 247 | z -= other.z; | 249 | z -= other.z; |
| 248 | } | 250 | } |
| 249 | 251 | ||
| 250 | Vec3<decltype(-T{})> operator-() const { | 252 | template <typename U = T> |
| 253 | Vec3<std::enable_if_t<std::is_signed<U>::value, U>> operator-() const { | ||
| 251 | return MakeVec(-x, -y, -z); | 254 | return MakeVec(-x, -y, -z); |
| 252 | } | 255 | } |
| 253 | Vec3<decltype(T{} * T{})> operator*(const Vec3& other) const { | 256 | Vec3<decltype(T{} * T{})> operator*(const Vec3& other) const { |
| @@ -462,7 +465,8 @@ public: | |||
| 462 | w -= other.w; | 465 | w -= other.w; |
| 463 | } | 466 | } |
| 464 | 467 | ||
| 465 | Vec4<decltype(-T{})> operator-() const { | 468 | template <typename U = T> |
| 469 | Vec4<std::enable_if_t<std::is_signed<U>::value, U>> operator-() const { | ||
| 466 | return MakeVec(-x, -y, -z, -w); | 470 | return MakeVec(-x, -y, -z, -w); |
| 467 | } | 471 | } |
| 468 | Vec4<decltype(T{} * T{})> operator*(const Vec4& other) const { | 472 | Vec4<decltype(T{} * T{})> operator*(const Vec4& other) const { |
| @@ -720,4 +724,4 @@ static inline Vec4<T> MakeVec(const T& x, const Vec3<T>& yzw) { | |||
| 720 | return MakeVec(x, yzw[0], yzw[1], yzw[2]); | 724 | return MakeVec(x, yzw[0], yzw[1], yzw[2]); |
| 721 | } | 725 | } |
| 722 | 726 | ||
| 723 | } // namespace | 727 | } // namespace Math |