diff options
author | Ansis Brammanis <brammanis@gmail.com> | 2017-06-20 13:06:16 -0400 |
---|---|---|
committer | Ansis Brammanis <brammanis@gmail.com> | 2017-06-20 13:06:16 -0400 |
commit | d3ea1633ed16a852d9a959c99e8a2eb9ad73981c (patch) | |
tree | ed033c71f481d3ac47826b63d6e2e8187e3a9dd1 | |
parent | a200c8be04e6ea13f14a7d74dce1a66d9eea1506 (diff) | |
download | qtlocation-mapboxgl-d3ea1633ed16a852d9a959c99e8a2eb9ad73981c.tar.gz |
add and hide vertices
-rw-r--r-- | src/mbgl/layout/symbol_projection.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/mbgl/layout/symbol_projection.cpp b/src/mbgl/layout/symbol_projection.cpp index b740688e3d..8a7bc3cd71 100644 --- a/src/mbgl/layout/symbol_projection.cpp +++ b/src/mbgl/layout/symbol_projection.cpp @@ -60,10 +60,20 @@ namespace mbgl { return inPaddedViewport; } - void addDynamicAttributes(const Point<float>&, const float, const float) { + void addDynamicAttributes(const Point<float>& anchorPoint, const float angle, const float placementZoom, + gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex>& dynamicVertexArray) { + auto dynamicVertex = SymbolDynamicLayoutAttributes::vertex(anchorPoint, angle, placementZoom); + dynamicVertexArray.emplace_back(dynamicVertex); + dynamicVertexArray.emplace_back(dynamicVertex); + dynamicVertexArray.emplace_back(dynamicVertex); + dynamicVertexArray.emplace_back(dynamicVertex); } - void hideGlyphs(size_t) { + void hideGlyphs(size_t numGlyphs, gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex>& dynamicVertexArray) { + const Point<float> offscreenPoint = { -INFINITY, -INFINITY }; + for (size_t i = 0; i < numGlyphs; i++) { + addDynamicAttributes(offscreenPoint, 0, 25, dynamicVertexArray); + } } struct PlacedGlyph { @@ -125,7 +135,8 @@ namespace mbgl { return {{ p, segmentAngle }}; } - void placeGlyphsAlongLine(const PlacedSymbol& symbol, const float fontSize, const bool flip, const mat4& labelPlaneMatrix) { + void placeGlyphsAlongLine(const PlacedSymbol& symbol, const float fontSize, const bool flip, const mat4& labelPlaneMatrix, + gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex>& dynamicVertexArray) { const float fontScale = fontSize / 24.0; const float lineOffsetX = symbol.lineOffsetX * fontSize; const float lineOffsetY = symbol.lineOffsetY * fontSize; @@ -138,13 +149,13 @@ namespace mbgl { if (placedGlyph) { placedGlyphs.push_back(*placedGlyph); } else { - hideGlyphs(symbol.glyphOffsets.size()); + hideGlyphs(symbol.glyphOffsets.size(), dynamicVertexArray); return; } } for (auto& placedGlyph : placedGlyphs) { - addDynamicAttributes(placedGlyph.point, placedGlyph.angle, symbol.placementZoom); + addDynamicAttributes(placedGlyph.point, placedGlyph.angle, symbol.placementZoom, dynamicVertexArray); } } @@ -161,11 +172,10 @@ namespace mbgl { const mat4 labelPlaneMatrix = getLabelPlaneMatrix(posMatrix, values.pitchAlignment == style::AlignmentType::Map, values.rotationAlignment == style::AlignmentType::Map, state, pixelsToTileUnits); - // - // const dynamicLayoutVertexArray = isText ? - // bucket.buffers.glyph.dynamicLayoutVertexArray : - // bucket.buffers.icon.dynamicLayoutVertexArray; - // dynamicLayoutVertexArray.clear(); + gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex>& dynamicVertexArray = isText ? + bucket.text.dynamicVertices : + bucket.icon.dynamicVertices; + dynamicVertexArray.clear(); const std::vector<PlacedSymbol>& placedSymbols = isText ? bucket.text.placedSymbols : bucket.icon.placedSymbols; for (auto& placedSymbol : placedSymbols) { @@ -174,7 +184,7 @@ namespace mbgl { // Don't bother calculating the correct point for invisible labels. if (!isVisible(anchorPos, placedSymbol.placementZoom, clippingBuffer)) { - hideGlyphs(placedSymbol.glyphOffsets.size()); + hideGlyphs(placedSymbol.glyphOffsets.size(), dynamicVertexArray); continue; } @@ -197,8 +207,7 @@ namespace mbgl { fontSize * perspectiveRatio : fontSize / perspectiveRatio; - //placeGlyphsAlongLine(symbol, pitchScaledFontSize, flip, labelPlaneMatrix, bucket.glyphOffsetArray, lineVertexArray, dynamicLayoutVertexArray); - placeGlyphsAlongLine(placedSymbol, pitchScaledFontSize, flip, labelPlaneMatrix); + placeGlyphsAlongLine(placedSymbol, pitchScaledFontSize, flip, labelPlaneMatrix, dynamicVertexArray); } } } // end namespace mbgl |