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

Commit

Permalink
Backport GL-JS fix 'Hide glyphs behind the camera'(mapbox/mapbox-gl-j…
Browse files Browse the repository at this point in the history
  • Loading branch information
zmiao committed Feb 10, 2020
1 parent 7dd1483 commit 401e841
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/mbgl/layout/symbol_projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,16 @@ namespace mbgl {
const float pitchScaledFontSize = pitchWithMap ?
fontSize * perspectiveRatio :
fontSize / perspectiveRatio;

const auto transformedTileAnchor = project(placedSymbol.anchorPoint, labelPlaneMatrix);

const Point<float> anchorPoint = project(placedSymbol.anchorPoint, labelPlaneMatrix).first;
// Skip labels behind the camera
if (transformedTileAnchor.second <= 0.0) {
hideGlyphs(placedSymbol.glyphOffsets.size(), dynamicVertexArray);
continue;
}

const Point<float> anchorPoint = transformedTileAnchor.first;

PlacementResult placeUnflipped = placeGlyphsAlongLine(placedSymbol, pitchScaledFontSize, false /*unflipped*/, keepUpright, posMatrix, labelPlaneMatrix, glCoordMatrix, dynamicVertexArray, anchorPoint, state.getSize().aspectRatio());

Expand Down

0 comments on commit 401e841

Please sign in to comment.