Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 0bf8fda

Browse files
committed
[core] Collision index uses doubled padding with the tilted view
1 parent 5781075 commit 0bf8fda

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed
22.5 KB
Loading
45.3 KB
Loading

src/mbgl/text/collision_index.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,27 @@
1616

1717
namespace mbgl {
1818

19+
namespace {
1920
// When a symbol crosses the edge that causes it to be included in
2021
// collision detection, it will cause changes in the symbols around
2122
// it. This constant specifies how many pixels to pad the edge of
2223
// the viewport for collision detection so that the bulk of the changes
2324
// occur offscreen. Making this constant greater increases label
2425
// stability, but it's expensive.
25-
static const float viewportPaddingDefault = 100;
26+
const float viewportPaddingDefault = 100;
2627
// Viewport padding must be much larger for static tiles to avoid clipped labels.
27-
static const float viewportPaddingForStaticTiles = 1024;
28+
const float viewportPaddingForStaticTiles = 1024;
29+
30+
inline float getViewportPadding(const TransformState& transformState, MapMode mapMode) {
31+
if (mapMode == MapMode::Tile) return viewportPaddingForStaticTiles;
32+
return (transformState.getPitch() != 0.0f) ? viewportPaddingDefault * 2 : viewportPaddingDefault;
33+
}
34+
35+
} // namespace
2836

2937
CollisionIndex::CollisionIndex(const TransformState& transformState_, MapMode mapMode)
3038
: transformState(transformState_),
31-
viewportPadding(mapMode == MapMode::Tile ? viewportPaddingForStaticTiles : viewportPaddingDefault),
39+
viewportPadding(getViewportPadding(transformState_, mapMode)),
3240
collisionGrid(transformState.getSize().width + 2 * viewportPadding,
3341
transformState.getSize().height + 2 * viewportPadding,
3442
25),

0 commit comments

Comments
 (0)