diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-20 15:28:28 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-20 16:11:57 -0700 |
commit | 3c23faf65ade59b62d41b68891bfac238acfc9ea (patch) | |
tree | f1251ef31ea888afcf8e521f6d089cacf813ea77 | |
parent | c6be40b71b2f81f07e24c14f0b9624b0fcf85798 (diff) | |
download | qtlocation-mapboxgl-3c23faf65ade59b62d41b68891bfac238acfc9ea.tar.gz |
[core] More complete fix for composite function interpolation edge case
b5b4549 / #8613 handled the edge case for layout properties, but not paint properties. Move the check for a degenerate range to interpolationFactor in order to handle both correctly.
-rw-r--r-- | include/mbgl/style/function/composite_function.hpp | 3 | ||||
m--------- | mapbox-gl-js | 0 | ||||
-rw-r--r-- | src/mbgl/util/interpolate.cpp | 4 |
3 files changed, 3 insertions, 4 deletions
diff --git a/include/mbgl/style/function/composite_function.hpp b/include/mbgl/style/function/composite_function.hpp index 2b4ae504ca..9275ccdf8f 100644 --- a/include/mbgl/style/function/composite_function.hpp +++ b/include/mbgl/style/function/composite_function.hpp @@ -100,9 +100,6 @@ public: T evaluate(float zoom, const GeometryTileFeature& feature, T finalDefaultValue) const { std::tuple<Range<float>, Range<InnerStops>> ranges = coveringRanges(zoom); Range<T> resultRange = evaluate(std::get<1>(ranges), feature, finalDefaultValue); - // If the covering stop range is constant, just return the output value directly. - if (resultRange.min == resultRange.max) return resultRange.min; - // Otherwise, interpolate between the two stops. return util::interpolate( resultRange.min, resultRange.max, diff --git a/mapbox-gl-js b/mapbox-gl-js -Subproject fbea8565244ad254eb9678798b4a21c88916dd8 +Subproject dff6bf91eca37071bb25356295f53f7e2aa4230 diff --git a/src/mbgl/util/interpolate.cpp b/src/mbgl/util/interpolate.cpp index 306a5c6630..066fa9c462 100644 --- a/src/mbgl/util/interpolate.cpp +++ b/src/mbgl/util/interpolate.cpp @@ -8,7 +8,9 @@ namespace util { float interpolationFactor(float base, Range<float> range, float z) { const float zoomDiff = range.max - range.min; const float zoomProgress = z - range.min; - if (base == 1.0f) { + if (zoomDiff == 0) { + return 0; + } else if (base == 1.0f) { return zoomProgress / zoomDiff; } else { return (std::pow(base, zoomProgress) - 1) / (std::pow(base, zoomDiff) - 1); |