From e4f440ca9a397146a8efbdd7f1173e4fb4393504 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Tue, 19 Jan 2021 21:50:14 +0100 Subject: [PATCH] Fixed a graphical glitch caused by inaccurate rounding. --- CHANGELOG.md | 1 + es-core/src/math/Transform4x4f.cpp | 6 +++--- es-core/src/math/Vector2f.cpp | 6 ++++-- es-core/src/math/Vector3f.cpp | 8 +++++--- es-core/src/math/Vector4f.cpp | 10 ++++++---- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5f25d4b6..633ab0a15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -117,6 +117,7 @@ Many bugs have been fixed, and numerous features that were only partially implem * Deleting a game from the metadata editor did not delete the game media files or its entry in the gamelist.xml file * Hidden files still showed up if they had a gamelist.xml entry * Fixed multiple instances of misaligned GUI elements on high-resolution displays due to the use of fixed-pixel constants +* Fixed a rounding issue which caused one pixel wide lines to sometimes be shown along the upper and left screen edges * The VRAM statistics overlay was somewhat broken and incorrectly displayed numbers in megabytes instead of mebibytes * Long game names would sometimes not scroll in the gamelist view * Game media was not rendered when moving between gamelists using the slide transition style diff --git a/es-core/src/math/Transform4x4f.cpp b/es-core/src/math/Transform4x4f.cpp index 3f27f6fdf..071bc9b25 100644 --- a/es-core/src/math/Transform4x4f.cpp +++ b/es-core/src/math/Transform4x4f.cpp @@ -315,9 +315,9 @@ Transform4x4f& Transform4x4f::round() { float* tm = reinterpret_cast(this); - tm[12] = static_cast(static_cast(tm[12] + 0.5f)); - tm[13] = static_cast(static_cast(tm[13] + 0.5f)); - tm[14] = static_cast(static_cast(tm[14] + 0.5f)); + tm[12] = std::round(tm[12]); + tm[13] = std::round(tm[13]); + tm[14] = std::round(tm[14]); return *this; } diff --git a/es-core/src/math/Vector2f.cpp b/es-core/src/math/Vector2f.cpp index 04209fad4..8d2a7cf1f 100644 --- a/es-core/src/math/Vector2f.cpp +++ b/es-core/src/math/Vector2f.cpp @@ -8,10 +8,12 @@ #include "math/Vector2f.h" +#include + Vector2f& Vector2f::round() { - mX = static_cast(static_cast(mX + 0.5f)); - mY = static_cast(static_cast(mY + 0.5f)); + mX = std::round(mX); + mY = std::round(mY); return *this; } diff --git a/es-core/src/math/Vector3f.cpp b/es-core/src/math/Vector3f.cpp index fa14ebbfd..a89f464d5 100644 --- a/es-core/src/math/Vector3f.cpp +++ b/es-core/src/math/Vector3f.cpp @@ -8,11 +8,13 @@ #include "math/Vector3f.h" +#include + Vector3f& Vector3f::round() { - mX = static_cast(static_cast(mX + 0.5f)); - mY = static_cast(static_cast(mY + 0.5f)); - mZ = static_cast(static_cast(mZ + 0.5f)); + mX = std::round(mX); + mY = std::round(mY); + mZ = std::round(mZ); return *this; } diff --git a/es-core/src/math/Vector4f.cpp b/es-core/src/math/Vector4f.cpp index 0766ed477..f3ab4cf15 100644 --- a/es-core/src/math/Vector4f.cpp +++ b/es-core/src/math/Vector4f.cpp @@ -8,12 +8,14 @@ #include "math/Vector4f.h" +#include + Vector4f& Vector4f::round() { - mX = static_cast(static_cast(mX + 0.5f)); - mY = static_cast(static_cast(mY + 0.5f)); - mZ = static_cast(static_cast(mZ + 0.5f)); - mW = static_cast(static_cast(mW + 0.5f)); + mX = std::round(mX); + mY = std::round(mY); + mZ = std::round(mZ); + mW = std::round(mW); return *this; }