summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSebastian Valle <subv2112@gmail.com>2017-09-27 22:45:38 +0200
committerGitHub <noreply@github.com>2017-09-27 22:45:38 +0200
commit0d42706a7b50f0d2444d56932297480e4a4a3ae6 (patch)
treeac52819463dec69d83a82783e202da8148be3ba7 /src
parentMerge pull request #2954 from Subv/cache_unmapped_mem (diff)
parentDisable unary operator- on Math::Vec2/Vec3/Vec4 for unsigned types. (diff)
downloadyuzu-0d42706a7b50f0d2444d56932297480e4a4a3ae6.tar
yuzu-0d42706a7b50f0d2444d56932297480e4a4a3ae6.tar.gz
yuzu-0d42706a7b50f0d2444d56932297480e4a4a3ae6.tar.bz2
yuzu-0d42706a7b50f0d2444d56932297480e4a4a3ae6.tar.lz
yuzu-0d42706a7b50f0d2444d56932297480e4a4a3ae6.tar.xz
yuzu-0d42706a7b50f0d2444d56932297480e4a4a3ae6.tar.zst
yuzu-0d42706a7b50f0d2444d56932297480e4a4a3ae6.zip
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 @@
#pragma once
#include <cmath>
+#include <type_traits>
namespace Math {
@@ -90,7 +91,8 @@ public:
y -= other.y;
}
- Vec2<decltype(-T{})> operator-() const {
+ template <typename U = T>
+ Vec2<std::enable_if_t<std::is_signed<U>::value, U>> operator-() const {
return MakeVec(-x, -y);
}
Vec2<decltype(T{} * T{})> operator*(const Vec2& other) const {
@@ -247,7 +249,8 @@ public:
z -= other.z;
}
- Vec3<decltype(-T{})> operator-() const {
+ template <typename U = T>
+ Vec3<std::enable_if_t<std::is_signed<U>::value, U>> operator-() const {
return MakeVec(-x, -y, -z);
}
Vec3<decltype(T{} * T{})> operator*(const Vec3& other) const {
@@ -462,7 +465,8 @@ public:
w -= other.w;
}
- Vec4<decltype(-T{})> operator-() const {
+ template <typename U = T>
+ Vec4<std::enable_if_t<std::is_signed<U>::value, U>> operator-() const {
return MakeVec(-x, -y, -z, -w);
}
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) {
return MakeVec(x, yzw[0], yzw[1], yzw[2]);
}
-} // namespace
+} // 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
auto FlipQuaternionIfOpposite = [](auto& a, const auto& b) {
if (Math::Dot(a, b) < float24::Zero())
- a = -a;
+ a = a * float24::FromFloat32(-1.0f);
};
// Flip the quaternions if they are opposite to prevent interpolating them over the wrong