From 26c9eff60ab58e94e8a86fd84159f0047efb2839 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Fri, 27 Oct 2017 13:13:07 -0400 Subject: fix collisions in overscaled tiles [skip ci] --- src/mbgl/text/placement.cpp | 8 +++++--- src/mbgl/text/placement.hpp | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index d67da53643..3f9ea07d58 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -51,6 +51,8 @@ void Placement::placeLayer(RenderSymbolLayer& symbolLayer, const mat4& projMatri const float scale = std::pow(2, state.getZoom() - renderTile.id.canonical.z); + const float pixelRatio = util::EXTENT / (util::tileSize * renderTile.tile.id.overscaleFactor()); + // TODO perf: do this only once for each tile, not once per layer state.matrixFor(renderTile.matrix, renderTile.id); matrix::multiply(renderTile.matrix, projMatrix, renderTile.matrix); @@ -67,7 +69,7 @@ void Placement::placeLayer(RenderSymbolLayer& symbolLayer, const mat4& projMatri state, pixelsToTileUnits); - placeLayerBucket(symbolBucket, renderTile.matrix, textLabelPlaneMatrix, iconLabelPlaneMatrix, scale, showCollisionBoxes); + placeLayerBucket(symbolBucket, renderTile.matrix, textLabelPlaneMatrix, iconLabelPlaneMatrix, scale, pixelRatio, showCollisionBoxes); } } @@ -77,6 +79,7 @@ void Placement::placeLayerBucket( const mat4& textLabelPlaneMatrix, const mat4& iconLabelPlaneMatrix, const float scale, + const float pixelRatio, const bool showCollisionBoxes) { // TODO collision debug array clearing @@ -86,7 +89,6 @@ void Placement::placeLayerBucket( const bool iconWithoutText = !bucket.hasTextData() || bucket.layout.get(); const bool textWithoutIcon = !bucket.hasIconData() || bucket.layout.get(); - float pixelRatio = util::EXTENT / util::tileSize; for (auto& symbolInstance : bucket.symbolInstances) { @@ -108,7 +110,7 @@ void Placement::placeLayerBucket( placeText = collisionIndex.placeFeature(symbolInstance.textCollisionFeature, posMatrix, textLabelPlaneMatrix, pixelRatio, - placedSymbol,scale, fontSize, + placedSymbol, scale, fontSize, bucket.layout.get(), bucket.layout.get() == style::AlignmentType::Map, showCollisionBoxes); diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp index c694e8ef98..9802ad546b 100644 --- a/src/mbgl/text/placement.hpp +++ b/src/mbgl/text/placement.hpp @@ -54,6 +54,7 @@ namespace mbgl { const mat4& textLabelPlaneMatrix, const mat4& iconLabelPlaneMatrix, const float scale, + const float pixelRatio, const bool showCollisionBoxes); void updateBucketOpacities(SymbolBucket&); -- cgit v1.2.1