[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.
This commit is contained in:
Chris Loer
2017-05-19 13:30:17 -07:00
committed by Ansis Brammanis
parent 2ee59796fb
commit f8402e2042
3 changed files with 19 additions and 3 deletions

View File

@@ -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)...
};
}

View File

@@ -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
};
}

View File

@@ -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