Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix render tests #351

Merged
merged 6 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/mbgl/text/collision_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(std::min(tileX1 - x1, x2 - tileX1));
if (minSectionLength <= 0) { // Check right border
minSectionLength = std::min(tileX2 - x1, x2 - tileX2);
minSectionLength = static_cast<int>(std::min(tileX2 - x1, x2 - tileX2));
}
if (minSectionLength > 0) {
result.flags |= IntersectStatus::VerticalBorders;
result.minSectionLength = static_cast<int>(minSectionLength);
result.minSectionLength = minSectionLength;
}
// Check top border
minSectionLength = std::min(tileY1 - y1, y2 - tileY1);
minSectionLength = static_cast<int>(std::min(tileY1 - y1, y2 - tileY1));
if (minSectionLength <= 0) { // Check bottom border
minSectionLength = std::min(tileY2 - y1, y2 - tileY2);
minSectionLength = static_cast<int>(std::min(tileY2 - y1, y2 - tileY2));
}
if (minSectionLength > 0) {
result.flags |= IntersectStatus::HorizontalBorders;
result.minSectionLength = std::min(result.minSectionLength, static_cast<int>(minSectionLength));
result.minSectionLength = std::min(result.minSectionLength, minSectionLength);
}
return result;
}
Expand Down Expand Up @@ -415,8 +415,8 @@ std::pair<Point<float>,float> CollisionIndex::projectAndGetPerspectiveRatio(cons
auto size = transformState.getSize();
return std::make_pair(
Point<float>(
static_cast<float>(((p[0] / p[3] + 1) / 2) * size.width) + viewportPadding,
static_cast<float>(((-p[1] / p[3] + 1) / 2) * size.height) + viewportPadding
static_cast<float>(((p[0] / p[3] + 1) / 2) * size.width + viewportPadding),
static_cast<float>(((-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
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/util/grid_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ void GridIndex<T>::query(const BCircle& queryBCircle, std::function<bool (const

template <class T>
std::size_t GridIndex<T>::convertToXCellCoord(const float x) const {
return util::max(size_t(0), util::min(xCellCount - 1, static_cast<size_t>(std::floor(x * xScale))));
ntadej marked this conversation as resolved.
Show resolved Hide resolved
return static_cast<size_t>(util::max(0.0, util::min(xCellCount - 1.0, std::floor(x * xScale))));
}

template <class T>
std::size_t GridIndex<T>::convertToYCellCoord(const float y) const {
return util::max(size_t(0), util::min(yCellCount - 1, static_cast<size_t>(std::floor(y * yScale))));
return static_cast<size_t>(util::max(0.0, util::min(yCellCount - 1.0, std::floor(y * yScale))));
}

template <class T>
Expand Down