@@ -24,7 +24,8 @@ void Painter::renderSDF(SymbolBucket &bucket,
24
24
void (SymbolBucket::*drawSDF)(SDFShader&, gl::ObjectStore&),
25
25
26
26
// Layout
27
- RotationAlignmentType rotationAlignment,
27
+ AlignmentType rotationAlignment,
28
+ AlignmentType pitchAlignment,
28
29
float layoutSize,
29
30
30
31
// Paint
@@ -45,10 +46,11 @@ void Painter::renderSDF(SymbolBucket &bucket,
45
46
46
47
float scale = fontScale;
47
48
std::array<float , 2 > exScale = extrudeScale;
48
- bool alignedWithMap = rotationAlignment == RotationAlignmentType::Map;
49
+ bool rotateWithMap = rotationAlignment == AlignmentType::Map;
50
+ bool pitchWithMap = pitchAlignment == AlignmentType::Map;
49
51
float gammaScale = 1 .0f ;
50
52
51
- if (alignedWithMap ) {
53
+ if (pitchWithMap ) {
52
54
scale *= tileID.pixelsToTileUnits (1 , state.getZoom ());
53
55
exScale.fill (scale);
54
56
gammaScale /= std::cos (state.getPitch ());
@@ -60,8 +62,12 @@ void Painter::renderSDF(SymbolBucket &bucket,
60
62
sdfShader.u_matrix = vtxMatrix;
61
63
sdfShader.u_extrude_scale = exScale;
62
64
sdfShader.u_texsize = texsize;
63
- sdfShader.u_skewed = alignedWithMap;
65
+ sdfShader.u_rotate_with_map = rotateWithMap;
66
+ sdfShader.u_pitch_with_map = pitchWithMap;
64
67
sdfShader.u_texture = 0 ;
68
+ sdfShader.u_pitch = state.getPitch () * util::DEG2RAD;
69
+ sdfShader.u_bearing = -1 .0f * state.getAngle ();
70
+ sdfShader.u_aspect_ratio = (state.getWidth () * 1 .0f ) / (state.getHeight () * 1 .0f );
65
71
66
72
// adjust min/max zooms for variable font sies
67
73
float zoomAdjust = std::log (fontSize / layoutSize) / std::log (2 );
@@ -135,7 +141,7 @@ void Painter::renderSymbol(SymbolBucket& bucket,
135
141
}
136
142
137
143
if (bucket.hasIconData ()) {
138
- if (layout.iconRotationAlignment == RotationAlignmentType ::Map) {
144
+ if (layout.iconRotationAlignment == AlignmentType ::Map) {
139
145
config.depthFunc .reset ();
140
146
config.depthTest = GL_TRUE;
141
147
} else {
@@ -145,7 +151,7 @@ void Painter::renderSymbol(SymbolBucket& bucket,
145
151
bool sdf = bucket.sdfIcons ;
146
152
147
153
const float angleOffset =
148
- layout.iconRotationAlignment == RotationAlignmentType ::Map
154
+ layout.iconRotationAlignment == AlignmentType ::Map
149
155
? state.getAngle ()
150
156
: 0 ;
151
157
@@ -154,7 +160,7 @@ void Painter::renderSymbol(SymbolBucket& bucket,
154
160
155
161
SpriteAtlas* activeSpriteAtlas = layer.impl ->spriteAtlas ;
156
162
const bool iconScaled = fontScale != 1 || frame.pixelRatio != activeSpriteAtlas->getPixelRatio () || bucket.iconsNeedLinear ;
157
- const bool iconTransformed = layout.iconRotationAlignment == RotationAlignmentType ::Map || angleOffset != 0 || state.getPitch () != 0 ;
163
+ const bool iconTransformed = layout.iconRotationAlignment == AlignmentType ::Map || angleOffset != 0 || state.getPitch () != 0 ;
158
164
config.activeTexture = GL_TEXTURE0;
159
165
activeSpriteAtlas->bind (sdf || state.isChanging () || iconScaled || iconTransformed, store);
160
166
@@ -167,6 +173,9 @@ void Painter::renderSymbol(SymbolBucket& bucket,
167
173
*sdfIconShader,
168
174
&SymbolBucket::drawIcons,
169
175
layout.iconRotationAlignment ,
176
+ // icon-pitch-alignment is not yet implemented
177
+ // and we simply inherit the rotation alignment
178
+ layout.iconRotationAlignment ,
170
179
layout.iconSize ,
171
180
paint.iconOpacity ,
172
181
paint.iconColor ,
@@ -182,7 +191,7 @@ void Painter::renderSymbol(SymbolBucket& bucket,
182
191
183
192
float scale = fontScale;
184
193
std::array<float , 2 > exScale = extrudeScale;
185
- const bool alignedWithMap = layout.iconRotationAlignment == RotationAlignmentType ::Map;
194
+ const bool alignedWithMap = layout.iconRotationAlignment == AlignmentType ::Map;
186
195
if (alignedWithMap) {
187
196
scale *= tileID.pixelsToTileUnits (1 , state.getZoom ());
188
197
exScale.fill (scale);
@@ -194,7 +203,7 @@ void Painter::renderSymbol(SymbolBucket& bucket,
194
203
iconShader->u_matrix = vtxMatrix;
195
204
iconShader->u_extrude_scale = exScale;
196
205
iconShader->u_texsize = {{ float (activeSpriteAtlas->getWidth ()) / 4 .0f , float (activeSpriteAtlas->getHeight ()) / 4 .0f }};
197
- iconShader->u_skewed = alignedWithMap;
206
+ iconShader->u_rotate_with_map = alignedWithMap;
198
207
iconShader->u_texture = 0 ;
199
208
200
209
// adjust min/max zooms for variable font sies
@@ -212,7 +221,7 @@ void Painter::renderSymbol(SymbolBucket& bucket,
212
221
}
213
222
214
223
if (bucket.hasTextData ()) {
215
- if (layout.textRotationAlignment == RotationAlignmentType ::Map) {
224
+ if (layout.textRotationAlignment == AlignmentType ::Map) {
216
225
config.depthFunc .reset ();
217
226
config.depthTest = GL_TRUE;
218
227
} else {
@@ -230,6 +239,7 @@ void Painter::renderSymbol(SymbolBucket& bucket,
230
239
*sdfGlyphShader,
231
240
&SymbolBucket::drawGlyphs,
232
241
layout.textRotationAlignment ,
242
+ layout.textPitchAlignment ,
233
243
layout.textSize ,
234
244
paint.textOpacity ,
235
245
paint.textColor ,
0 commit comments