|
16 | 16 |
|
17 | 17 | namespace mbgl { |
18 | 18 |
|
| 19 | +namespace { |
19 | 20 | // When a symbol crosses the edge that causes it to be included in |
20 | 21 | // collision detection, it will cause changes in the symbols around |
21 | 22 | // it. This constant specifies how many pixels to pad the edge of |
22 | 23 | // the viewport for collision detection so that the bulk of the changes |
23 | 24 | // occur offscreen. Making this constant greater increases label |
24 | 25 | // stability, but it's expensive. |
25 | | -static const float viewportPaddingDefault = 100; |
| 26 | +const float viewportPaddingDefault = 100; |
26 | 27 | // 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 |
28 | 36 |
|
29 | 37 | CollisionIndex::CollisionIndex(const TransformState& transformState_, MapMode mapMode) |
30 | 38 | : transformState(transformState_), |
31 | | - viewportPadding(mapMode == MapMode::Tile ? viewportPaddingForStaticTiles : viewportPaddingDefault), |
| 39 | + viewportPadding(getViewportPadding(transformState_, mapMode)), |
32 | 40 | collisionGrid(transformState.getSize().width + 2 * viewportPadding, |
33 | 41 | transformState.getSize().height + 2 * viewportPadding, |
34 | 42 | 25), |
|
0 commit comments