summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-10 23:05:47 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-12 23:35:55 +0200
commit0bf8fdae9c4055ded52a641ed87f400067f89055 (patch)
treec776ab20f97824fe05cd9379b2ee86c3ddd7b253
parent57810759ef7f82b8af6b3d47ded47b7ecd3cd846 (diff)
downloadqtlocation-mapboxgl-0bf8fdae9c4055ded52a641ed87f400067f89055.tar.gz
[core] Collision index uses doubled padding with the tilted view
-rw-r--r--metrics/expectations/platform-all/render-tests/text-pitch-alignment/viewport-overzoomed/expected.pngbin0 -> 23021 bytes
-rw-r--r--metrics/expectations/platform-all/render-tests/text-pitch-scaling/line-half/expected.pngbin0 -> 46378 bytes
-rw-r--r--src/mbgl/text/collision_index.cpp14
3 files changed, 11 insertions, 3 deletions
diff --git a/metrics/expectations/platform-all/render-tests/text-pitch-alignment/viewport-overzoomed/expected.png b/metrics/expectations/platform-all/render-tests/text-pitch-alignment/viewport-overzoomed/expected.png
new file mode 100644
index 0000000000..b996d264c4
--- /dev/null
+++ b/metrics/expectations/platform-all/render-tests/text-pitch-alignment/viewport-overzoomed/expected.png
Binary files differ
diff --git a/metrics/expectations/platform-all/render-tests/text-pitch-scaling/line-half/expected.png b/metrics/expectations/platform-all/render-tests/text-pitch-scaling/line-half/expected.png
new file mode 100644
index 0000000000..dbb104ee0f
--- /dev/null
+++ b/metrics/expectations/platform-all/render-tests/text-pitch-scaling/line-half/expected.png
Binary files differ
diff --git a/src/mbgl/text/collision_index.cpp b/src/mbgl/text/collision_index.cpp
index e749db3ffa..0447886166 100644
--- a/src/mbgl/text/collision_index.cpp
+++ b/src/mbgl/text/collision_index.cpp
@@ -16,19 +16,27 @@
namespace mbgl {
+namespace {
// When a symbol crosses the edge that causes it to be included in
// collision detection, it will cause changes in the symbols around
// it. This constant specifies how many pixels to pad the edge of
// the viewport for collision detection so that the bulk of the changes
// occur offscreen. Making this constant greater increases label
// stability, but it's expensive.
-static const float viewportPaddingDefault = 100;
+const float viewportPaddingDefault = 100;
// Viewport padding must be much larger for static tiles to avoid clipped labels.
-static const float viewportPaddingForStaticTiles = 1024;
+const float viewportPaddingForStaticTiles = 1024;
+
+inline float getViewportPadding(const TransformState& transformState, MapMode mapMode) {
+ if (mapMode == MapMode::Tile) return viewportPaddingForStaticTiles;
+ return (transformState.getPitch() != 0.0f) ? viewportPaddingDefault * 2 : viewportPaddingDefault;
+}
+
+} // namespace
CollisionIndex::CollisionIndex(const TransformState& transformState_, MapMode mapMode)
: transformState(transformState_),
- viewportPadding(mapMode == MapMode::Tile ? viewportPaddingForStaticTiles : viewportPaddingDefault),
+ viewportPadding(getViewportPadding(transformState_, mapMode)),
collisionGrid(transformState.getSize().width + 2 * viewportPadding,
transformState.getSize().height + 2 * viewportPadding,
25),