summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/symbol_bucket.cpp
diff options
context:
space:
mode:
authorYoung Hahn <young@mapbox.com>2016-06-10 23:05:15 -0400
committerGitHub <noreply@github.com>2016-06-10 23:05:15 -0400
commitecd4aa14397ed081a521d8412557724e52f277f3 (patch)
treea04bca00190eba8f3f3947689ab6b7ff537e8946 /src/mbgl/renderer/symbol_bucket.cpp
parenta8df0feb5414af2c16bfdae27431d779e4545dbe (diff)
downloadqtlocation-mapboxgl-ecd4aa14397ed081a521d8412557724e52f277f3.tar.gz
text-pitch-alignment (#5288)
* First pass at port of https://github.com/mapbox/mapbox-gl-js/pull/2668 * RotationAlignmentType => AlignmentType * Handle undefined default value for text-pitch-alignment and implement inheritance for this value from text-rotation-alignment * Update dependencies * Move handling fo undefined default value out of camelize functions
Diffstat (limited to 'src/mbgl/renderer/symbol_bucket.cpp')
-rw-r--r--src/mbgl/renderer/symbol_bucket.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp
index f4e55432c1..fb312661a7 100644
--- a/src/mbgl/renderer/symbol_bucket.cpp
+++ b/src/mbgl/renderer/symbol_bucket.cpp
@@ -314,10 +314,10 @@ void SymbolBucket::addFeature(const GeometryCollection &lines,
const float iconPadding = layout.iconPadding * tilePixelRatio;
const float textMaxAngle = layout.textMaxAngle * util::DEG2RAD;
const bool textAlongLine =
- layout.textRotationAlignment == RotationAlignmentType::Map &&
+ layout.textRotationAlignment == AlignmentType::Map &&
layout.symbolPlacement == SymbolPlacementType::Line;
const bool iconAlongLine =
- layout.iconRotationAlignment == RotationAlignmentType::Map &&
+ layout.iconRotationAlignment == AlignmentType::Map &&
layout.symbolPlacement == SymbolPlacementType::Line;
const bool mayOverlap = layout.textAllowOverlap || layout.iconAllowOverlap ||
layout.textIgnorePlacement || layout.iconIgnorePlacement;
@@ -394,10 +394,10 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile) {
// create the bufers used for rendering.
const bool textAlongLine =
- layout.textRotationAlignment == RotationAlignmentType::Map &&
+ layout.textRotationAlignment == AlignmentType::Map &&
layout.symbolPlacement == SymbolPlacementType::Line;
const bool iconAlongLine =
- layout.iconRotationAlignment == RotationAlignmentType::Map &&
+ layout.iconRotationAlignment == AlignmentType::Map &&
layout.symbolPlacement == SymbolPlacementType::Line;
const bool mayOverlap = layout.textAllowOverlap || layout.iconAllowOverlap ||
@@ -495,7 +495,7 @@ void SymbolBucket::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float
const auto &anchorPoint = symbol.anchorPoint;
// drop upside down versions of glyphs
- const float a = std::fmod(symbol.angle + placementAngle + M_PI, M_PI * 2);
+ const float a = std::fmod(symbol.anchorAngle + placementAngle + M_PI, M_PI * 2);
if (keepUpright && alongLine && (a <= M_PI / 2 || a > M_PI * 3 / 2)) continue;
@@ -521,15 +521,18 @@ void SymbolBucket::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float
auto &triangleGroup = *buffer.groups.back();
GLsizei triangleIndex = triangleGroup.vertex_length;
+ // Encode angle of glyph
+ uint8_t glyphAngle = std::round((symbol.glyphAngle / (M_PI * 2)) * 256);
+
// coordinates (2 triangles)
buffer.vertices.add(anchorPoint.x, anchorPoint.y, tl.x, tl.y, tex.x, tex.y, minZoom,
- maxZoom, placementZoom);
+ maxZoom, placementZoom, glyphAngle);
buffer.vertices.add(anchorPoint.x, anchorPoint.y, tr.x, tr.y, tex.x + tex.w, tex.y,
- minZoom, maxZoom, placementZoom);
+ minZoom, maxZoom, placementZoom, glyphAngle);
buffer.vertices.add(anchorPoint.x, anchorPoint.y, bl.x, bl.y, tex.x, tex.y + tex.h,
- minZoom, maxZoom, placementZoom);
+ minZoom, maxZoom, placementZoom, glyphAngle);
buffer.vertices.add(anchorPoint.x, anchorPoint.y, br.x, br.y, tex.x + tex.w, tex.y + tex.h,
- minZoom, maxZoom, placementZoom);
+ minZoom, maxZoom, placementZoom, glyphAngle);
// add the two triangles, referencing the four coordinates we just inserted.
buffer.triangles.add(triangleIndex + 0, triangleIndex + 1, triangleIndex + 2);