Merge pull request #2907 from Subv/warnings3
Disable unary operator- on Math::Vec2/Vec3/Vec4 for unsigned types.
This commit is contained in:
commit
0d42706a7b
2 changed files with 9 additions and 5 deletions
|
@ -31,6 +31,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace Math {
|
namespace Math {
|
||||||
|
|
||||||
|
@ -90,7 +91,8 @@ public:
|
||||||
y -= other.y;
|
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);
|
return MakeVec(-x, -y);
|
||||||
}
|
}
|
||||||
Vec2<decltype(T{} * T{})> operator*(const Vec2& other) const {
|
Vec2<decltype(T{} * T{})> operator*(const Vec2& other) const {
|
||||||
|
@ -247,7 +249,8 @@ public:
|
||||||
z -= other.z;
|
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);
|
return MakeVec(-x, -y, -z);
|
||||||
}
|
}
|
||||||
Vec3<decltype(T{} * T{})> operator*(const Vec3& other) const {
|
Vec3<decltype(T{} * T{})> operator*(const Vec3& other) const {
|
||||||
|
@ -462,7 +465,8 @@ public:
|
||||||
w -= other.w;
|
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);
|
return MakeVec(-x, -y, -z, -w);
|
||||||
}
|
}
|
||||||
Vec4<decltype(T{} * T{})> operator*(const Vec4& other) const {
|
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]);
|
return MakeVec(x, yzw[0], yzw[1], yzw[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace Math
|
||||||
|
|
|
@ -98,7 +98,7 @@ void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const Outpu
|
||||||
|
|
||||||
auto FlipQuaternionIfOpposite = [](auto& a, const auto& b) {
|
auto FlipQuaternionIfOpposite = [](auto& a, const auto& b) {
|
||||||
if (Math::Dot(a, b) < float24::Zero())
|
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
|
// Flip the quaternions if they are opposite to prevent interpolating them over the wrong
|
||||||
|
|
Loading…
Reference in a new issue