summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2017-05-19 13:30:17 -0700
committerAnsis Brammanis <brammanis@gmail.com>2017-07-11 09:10:23 -0700
commitf8402e20425cee6cbad2a28809bce17ac46c1379 (patch)
tree9ad5ed11fb445f5d5268dfc5da89eb08ecc6dc71 /src
parent2ee59796fb47c3152b2bdcfa5cde4be5a92316b4 (diff)
downloadqtlocation-mapboxgl-f8402e20425cee6cbad2a28809bce17ac46c1379.tar.gz
[core] Set "max_camera_distance" to 1.5 for viewport-aligned road labels.
Viewport-aligned curved labels start to look very strange in the distance. Until we have a better system for projecting them, just prevent them from showing.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/programs/symbol_program.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.cpp18
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.hpp2
3 files changed, 19 insertions, 3 deletions
diff --git a/src/mbgl/programs/symbol_program.cpp b/src/mbgl/programs/symbol_program.cpp
index 1b5a7d9bff..bd43237b8f 100644
--- a/src/mbgl/programs/symbol_program.cpp
+++ b/src/mbgl/programs/symbol_program.cpp
@@ -61,7 +61,7 @@ Values makeValues(const bool isText,
uniforms::u_collision_y_stretch::Value{ tile.tile.yStretch() },
uniforms::u_camera_to_center_distance::Value{ state.getCameraToCenterDistance() },
uniforms::u_pitch::Value{ state.getPitch() },
- uniforms::u_max_camera_distance::Value{ 10.0f },
+ uniforms::u_max_camera_distance::Value{ values.maxCameraDistance },
std::forward<Args>(args)...
};
}
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp
index 6540fc9612..573e9db72e 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.cpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp
@@ -88,11 +88,24 @@ style::SymbolPropertyValues RenderSymbolLayer::iconPropertyValues(const style::S
evaluated.get<style::IconTranslateAnchor>(),
evaluated.get<style::IconHaloColor>().constantOr(Color::black()).a > 0 &&
evaluated.get<style::IconHaloWidth>().constantOr(1),
- evaluated.get<style::IconColor>().constantOr(Color::black()).a > 0
+ evaluated.get<style::IconColor>().constantOr(Color::black()).a > 0,
+ 10.0f
};
}
style::SymbolPropertyValues RenderSymbolLayer::textPropertyValues(const style::SymbolLayoutProperties::PossiblyEvaluated& layout_) const {
+ // We hide line labels with viewport alignment as they move into the distance
+ // because the approximations we use for drawing their glyphs get progressively worse
+ // The "1.5" here means we start hiding them when the distance from the label
+ // to the camera is 50% greater than the distance from the center of the map
+ // to the camera. Depending on viewport properties, you might expect this to filter
+ // the top third of the screen at pitch 60, and do almost nothing at pitch 45
+ // "10" is effectively infinite at any pitch we support
+ const bool limitMaxDistance =
+ layout_.get<style::SymbolPlacement>() == style::SymbolPlacementType::Line
+ && layout_.get<style::TextRotationAlignment>() == style::AlignmentType::Map
+ && layout_.get<style::TextPitchAlignment>() == style::AlignmentType::Viewport;
+
return style::SymbolPropertyValues {
layout_.get<style::TextPitchAlignment>(),
layout_.get<style::TextRotationAlignment>(),
@@ -100,7 +113,8 @@ style::SymbolPropertyValues RenderSymbolLayer::textPropertyValues(const style::S
evaluated.get<style::TextTranslateAnchor>(),
evaluated.get<style::TextHaloColor>().constantOr(Color::black()).a > 0 &&
evaluated.get<style::TextHaloWidth>().constantOr(1),
- evaluated.get<style::TextColor>().constantOr(Color::black()).a > 0
+ evaluated.get<style::TextColor>().constantOr(Color::black()).a > 0,
+ limitMaxDistance ? 1.5f : 10.0f
};
}
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.hpp b/src/mbgl/renderer/layers/render_symbol_layer.hpp
index 2199103de2..e788336cbd 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.hpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.hpp
@@ -47,6 +47,8 @@ public:
bool hasHalo;
bool hasFill;
+
+ float maxCameraDistance; // 1.5 for road labels, or 10 (essentially infinite) for everything else
};
} // namespace style