summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/vector_math.h12
-rw-r--r--src/video_core/swrasterizer/clipper.cpp2
2 files changed, 9 insertions, 5 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
35namespace Math { 36namespace 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
diff --git a/src/video_core/swrasterizer/clipper.cpp b/src/video_core/swrasterizer/clipper.cpp
index a52129eb7..c1ed48398 100644
--- a/src/video_core/swrasterizer/clipper.cpp
+++ b/src/video_core/swrasterizer/clipper.cpp
@@ -98,7 +98,7 @@ void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const Outpu
98 98
99 auto FlipQuaternionIfOpposite = [](auto& a, const auto& b) { 99 auto FlipQuaternionIfOpposite = [](auto& a, const auto& b) {
100 if (Math::Dot(a, b) < float24::Zero()) 100 if (Math::Dot(a, b) < float24::Zero())
101 a = -a; 101 a = a * float24::FromFloat32(-1.0f);
102 }; 102 };
103 103
104 // Flip the quaternions if they are opposite to prevent interpolating them over the wrong 104 // Flip the quaternions if they are opposite to prevent interpolating them over the wrong