From f2d4d5c2191275bd91f2f42b880f3edf3bccfd63 Mon Sep 17 00:00:00 2001 From: Subv Date: Fri, 9 Jun 2017 17:33:25 -0500 Subject: SwRasterizer: Corrected the light LUT lookups. --- src/common/quaternion.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/common') diff --git a/src/common/quaternion.h b/src/common/quaternion.h index 84ac82ed3..77f626bcb 100644 --- a/src/common/quaternion.h +++ b/src/common/quaternion.h @@ -30,6 +30,11 @@ public: return {xyz * other.w + other.xyz * w + Cross(xyz, other.xyz), w * other.w - Dot(xyz, other.xyz)}; } + + Quaternion Normalized() const { + T length = std::sqrt(xyz.Length2() + w * w); + return {xyz / length, w / length}; + } }; template -- cgit v1.2.3 From 73566ff7a990cdfe8d8f023997b57942dc785fc4 Mon Sep 17 00:00:00 2001 From: Subv Date: Sun, 11 Jun 2017 11:55:35 -0500 Subject: SwRasterizer: Flip the vertex quaternions before clipping (if necessary). --- src/common/vector_math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/vector_math.h b/src/common/vector_math.h index c7a461a1e..d0fe0e405 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h @@ -462,7 +462,7 @@ public: z -= other.z; w -= other.w; } - template ::value>::type> + template Vec4 operator-() const { return MakeVec(-x, -y, -z, -w); } -- cgit v1.2.3 From f3660ba9dd13f342c591aaa9901e94b6caee8d9a Mon Sep 17 00:00:00 2001 From: wwylele Date: Tue, 11 Jul 2017 19:51:29 +0300 Subject: vector_math: remove broken SFINAE stuff this was originally added to eliminate warnings on MSVC, but it doesn't work for custom types. --- src/common/vector_math.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/vector_math.h b/src/common/vector_math.h index d0fe0e405..49ae87f6d 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h @@ -31,7 +31,6 @@ #pragma once #include -#include namespace Math { @@ -90,7 +89,7 @@ public: x -= other.x; y -= other.y; } - template ::value>::type> + Vec2 operator-() const { return MakeVec(-x, -y); } @@ -247,7 +246,7 @@ public: y -= other.y; z -= other.z; } - template ::value>::type> + Vec3 operator-() const { return MakeVec(-x, -y, -z); } -- cgit v1.2.3 From fe44e843fe1e300491d3bcd9072948407a86e7e1 Mon Sep 17 00:00:00 2001 From: wwylele Date: Tue, 11 Jul 2017 20:08:56 +0300 Subject: vector_math: remove dead template parameter --- src/common/vector_math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/vector_math.h b/src/common/vector_math.h index 49ae87f6d..6e2a5ad60 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h @@ -461,7 +461,7 @@ public: z -= other.z; w -= other.w; } - template + Vec4 operator-() const { return MakeVec(-x, -y, -z, -w); } -- cgit v1.2.3 From f44a1e0291ab64ea9f34a9263432f30d18f3e98d Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 1 Aug 2017 19:54:24 -0400 Subject: common: Add build timestamp to scm_rev. --- src/common/scm_rev.cpp.in | 2 ++ src/common/scm_rev.h | 1 + 2 files changed, 3 insertions(+) (limited to 'src/common') diff --git a/src/common/scm_rev.cpp.in b/src/common/scm_rev.cpp.in index 0080db5d5..4083095d5 100644 --- a/src/common/scm_rev.cpp.in +++ b/src/common/scm_rev.cpp.in @@ -8,6 +8,7 @@ #define GIT_BRANCH "@GIT_BRANCH@" #define GIT_DESC "@GIT_DESC@" #define BUILD_NAME "@REPO_NAME@" +#define BUILD_DATE "@BUILD_DATE@" namespace Common { @@ -15,6 +16,7 @@ const char g_scm_rev[] = GIT_REV; const char g_scm_branch[] = GIT_BRANCH; const char g_scm_desc[] = GIT_DESC; const char g_build_name[] = BUILD_NAME; +const char g_build_date[] = BUILD_DATE; } // namespace diff --git a/src/common/scm_rev.h b/src/common/scm_rev.h index e22389803..18aaa1735 100644 --- a/src/common/scm_rev.h +++ b/src/common/scm_rev.h @@ -10,5 +10,6 @@ extern const char g_scm_rev[]; extern const char g_scm_branch[]; extern const char g_scm_desc[]; extern const char g_build_name[]; +extern const char g_build_date[]; } // namespace -- cgit v1.2.3 From a321bce37834c1f3034bd87df14fc71c13e6b84a Mon Sep 17 00:00:00 2001 From: Subv Date: Tue, 29 Aug 2017 12:59:54 -0500 Subject: Disable unary operator- on Math::Vec2/Vec3/Vec4 for unsigned types. It is unlikely we will ever use this without first doing a Cast to a signed type. Fixes 9 "unary minus operator applied to unsigned type, result still unsigned" warnings on MSVC2017.3 --- src/common/vector_math.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/common') 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 +#include namespace Math { @@ -90,7 +91,8 @@ public: y -= other.y; } - Vec2 operator-() const { + template + Vec2::value, U>> operator-() const { return MakeVec(-x, -y); } Vec2 operator*(const Vec2& other) const { @@ -247,7 +249,8 @@ public: z -= other.z; } - Vec3 operator-() const { + template + Vec3::value, U>> operator-() const { return MakeVec(-x, -y, -z); } Vec3 operator*(const Vec3& other) const { @@ -462,7 +465,8 @@ public: w -= other.w; } - Vec4 operator-() const { + template + Vec4::value, U>> operator-() const { return MakeVec(-x, -y, -z, -w); } Vec4 operator*(const Vec4& other) const { @@ -720,4 +724,4 @@ static inline Vec4 MakeVec(const T& x, const Vec3& yzw) { return MakeVec(x, yzw[0], yzw[1], yzw[2]); } -} // namespace +} // namespace Math -- cgit v1.2.3 From a13ab958cbba75bc9abd1ca50f3030a10a75784e Mon Sep 17 00:00:00 2001 From: Huw Pascoe Date: Wed, 27 Sep 2017 00:26:09 +0100 Subject: Fixed type conversion ambiguity --- src/common/string_util.cpp | 2 +- src/common/string_util.h | 2 +- src/common/vector_math.h | 12 +++--------- 3 files changed, 5 insertions(+), 11 deletions(-) (limited to 'src/common') diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index bad311793..6959915fa 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -117,7 +117,7 @@ std::string StringFromFormat(const char* format, ...) { } // For Debugging. Read out an u8 array. -std::string ArrayToString(const u8* data, u32 size, int line_len, bool spaces) { +std::string ArrayToString(const u8* data, size_t size, int line_len, bool spaces) { std::ostringstream oss; oss << std::setfill('0') << std::hex; diff --git a/src/common/string_util.h b/src/common/string_util.h index 075bf4ecb..259360aec 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -33,7 +33,7 @@ inline void CharArrayFromFormat(char (&out)[Count], const char* format, ...) { } // Good -std::string ArrayToString(const u8* data, u32 size, int line_len = 20, bool spaces = true); +std::string ArrayToString(const u8* data, size_t size, int line_len = 20, bool spaces = true); std::string StripSpaces(const std::string& s); std::string StripQuotes(const std::string& s); diff --git a/src/common/vector_math.h b/src/common/vector_math.h index 2b05f66ee..3f0057d9e 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h @@ -104,8 +104,7 @@ public: } template void operator*=(const V& f) { - x *= f; - y *= f; + *this = *this * f; } template Vec2 operator/(const V& f) const { @@ -262,9 +261,7 @@ public: } template void operator*=(const V& f) { - x *= f; - y *= f; - z *= f; + *this = *this * f; } template Vec3 operator/(const V& f) const { @@ -478,10 +475,7 @@ public: } template void operator*=(const V& f) { - x *= f; - y *= f; - z *= f; - w *= f; + *this = *this * f; } template Vec4 operator/(const V& f) const { -- cgit v1.2.3