From 31c4b9472a2968609b815b359c9eb5460a585eda Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sat, 15 Apr 2023 19:11:13 -0600 Subject: [PATCH] Add clang-tidy `bugprone-incorrect-roundings` check --- .clang-tidy | 1 - src/SFML/Graphics/RenderTarget.cpp | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 584d7ee1f..18200714d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -12,7 +12,6 @@ Checks: > -bugprone-easily-swappable-parameters, -bugprone-exception-escape, -bugprone-implicit-widening-of-multiplication-result, - -bugprone-incorrect-roundings, -bugprone-integer-division, -bugprone-misplaced-widening-cast, -bugprone-narrowing-conversions, diff --git a/src/SFML/Graphics/RenderTarget.cpp b/src/SFML/Graphics/RenderTarget.cpp index ab2ef6e56..3eb3130c0 100644 --- a/src/SFML/Graphics/RenderTarget.cpp +++ b/src/SFML/Graphics/RenderTarget.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -193,8 +194,8 @@ IntRect RenderTarget::getViewport(const View& view) const const auto [width, height] = Vector2f(getSize()); const FloatRect& viewport = view.getViewport(); - return IntRect({static_cast(0.5f + width * viewport.left), static_cast(0.5f + height * viewport.top)}, - {static_cast(0.5f + width * viewport.width), static_cast(0.5f + height * viewport.height)}); + return IntRect(Rect({std::lround(width * viewport.left), std::lround(height * viewport.top)}, + {std::lround(width * viewport.width), std::lround(height * viewport.height)})); }