From 52b5f02ed38970621ee53e4da6a65c79835d52e9 Mon Sep 17 00:00:00 2001 From: Oliver Wipfli Date: Tue, 5 Jul 2022 11:44:36 +0200 Subject: [PATCH] Fix render tests (#351) * Fix render tests * Update src/mbgl/util/grid_index.cpp Co-authored-by: Tadej Novak * Update src/mbgl/util/grid_index.cpp Co-authored-by: Tadej Novak * Update src/mbgl/text/collision_index.cpp Co-authored-by: Tadej Novak * Add static casts * Remove unneeded static cast Co-authored-by: Tadej Novak --- src/mbgl/text/collision_index.cpp | 16 ++++++++-------- src/mbgl/util/grid_index.cpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mbgl/text/collision_index.cpp b/src/mbgl/text/collision_index.cpp index 4335d4f31..364887de2 100644 --- a/src/mbgl/text/collision_index.cpp +++ b/src/mbgl/text/collision_index.cpp @@ -122,22 +122,22 @@ IntersectStatus CollisionIndex::intersectsTileEdges(const CollisionBox& box, const float tileY2 = tileEdges[3]; // Check left border - float minSectionLength = std::min(tileX1 - x1, x2 - tileX1); + int minSectionLength = static_cast(std::min(tileX1 - x1, x2 - tileX1)); if (minSectionLength <= 0) { // Check right border - minSectionLength = std::min(tileX2 - x1, x2 - tileX2); + minSectionLength = static_cast(std::min(tileX2 - x1, x2 - tileX2)); } if (minSectionLength > 0) { result.flags |= IntersectStatus::VerticalBorders; - result.minSectionLength = static_cast(minSectionLength); + result.minSectionLength = minSectionLength; } // Check top border - minSectionLength = std::min(tileY1 - y1, y2 - tileY1); + minSectionLength = static_cast(std::min(tileY1 - y1, y2 - tileY1)); if (minSectionLength <= 0) { // Check bottom border - minSectionLength = std::min(tileY2 - y1, y2 - tileY2); + minSectionLength = static_cast(std::min(tileY2 - y1, y2 - tileY2)); } if (minSectionLength > 0) { result.flags |= IntersectStatus::HorizontalBorders; - result.minSectionLength = std::min(result.minSectionLength, static_cast(minSectionLength)); + result.minSectionLength = std::min(result.minSectionLength, minSectionLength); } return result; } @@ -415,8 +415,8 @@ std::pair,float> CollisionIndex::projectAndGetPerspectiveRatio(cons auto size = transformState.getSize(); return std::make_pair( Point( - static_cast(((p[0] / p[3] + 1) / 2) * size.width) + viewportPadding, - static_cast(((-p[1] / p[3] + 1) / 2) * size.height) + viewportPadding + static_cast(((p[0] / p[3] + 1) / 2) * size.width + viewportPadding), + static_cast(((-p[1] / p[3] + 1) / 2) * size.height + viewportPadding) ), // See perspective ratio comment in symbol_sdf.vertex // We're doing collision detection in viewport space so we need diff --git a/src/mbgl/util/grid_index.cpp b/src/mbgl/util/grid_index.cpp index 7653dc193..eeeda01a2 100644 --- a/src/mbgl/util/grid_index.cpp +++ b/src/mbgl/util/grid_index.cpp @@ -263,12 +263,12 @@ void GridIndex::query(const BCircle& queryBCircle, std::function std::size_t GridIndex::convertToXCellCoord(const float x) const { - return util::max(size_t(0), util::min(xCellCount - 1, static_cast(std::floor(x * xScale)))); + return static_cast(util::max(0.0, util::min(xCellCount - 1.0, std::floor(x * xScale)))); } template std::size_t GridIndex::convertToYCellCoord(const float y) const { - return util::max(size_t(0), util::min(yCellCount - 1, static_cast(std::floor(y * yScale)))); + return static_cast(util::max(0.0, util::min(yCellCount - 1.0, std::floor(y * yScale)))); } template