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

Commit

Permalink
[core] Collision index uses doubled padding with the tilted view
Browse files Browse the repository at this point in the history
  • Loading branch information
pozdnyakov committed Mar 10, 2020
1 parent 53bb808 commit f81592c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/mbgl/text/collision_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit f81592c

Please sign in to comment.