Add clang-tidy bugprone-incorrect-roundings check

This commit is contained in:
Chris Thrasher 2023-04-15 19:11:13 -06:00
parent 26b300f923
commit 31c4b9472a
2 changed files with 3 additions and 3 deletions

View File

@ -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,

View File

@ -37,6 +37,7 @@
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <mutex>
#include <ostream>
@ -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<int>(0.5f + width * viewport.left), static_cast<int>(0.5f + height * viewport.top)},
{static_cast<int>(0.5f + width * viewport.width), static_cast<int>(0.5f + height * viewport.height)});
return IntRect(Rect<long>({std::lround(width * viewport.left), std::lround(height * viewport.top)},
{std::lround(width * viewport.width), std::lround(height * viewport.height)}));
}