summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-09-05 12:07:58 -0700
committerChris Loer <chris.loer@mapbox.com>2018-09-06 11:10:10 -0700
commit50f9381ad3538045a84a0cf6d51dc9f2252d1c2d (patch)
tree28910ae91ec5a440b3ff05fac4b24a6a2c7693c5 /include
parent5d8abb65e126abce2a4d21e24808216910ad663c (diff)
downloadqtlocation-mapboxgl-50f9381ad3538045a84a0cf6d51dc9f2252d1c2d.tar.gz
[core] Fix cubic-bezier interpolation for zooms outside stop range.
Fixes issue #12812. Using `util::interpolationFactor` handles the case where inputLevels.min == inputLevels.max, so it returns an interpolation factor of "0" instead of dividing by 0.
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/style/expression/interpolator.hpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/mbgl/style/expression/interpolator.hpp b/include/mbgl/style/expression/interpolator.hpp
index f37fb2c9cd..62b48c1752 100644
--- a/include/mbgl/style/expression/interpolator.hpp
+++ b/include/mbgl/style/expression/interpolator.hpp
@@ -33,7 +33,13 @@ public:
CubicBezierInterpolator(double x1_, double y1_, double x2_, double y2_) : ub(x1_, y1_, x2_, y2_) {}
double interpolationFactor(const Range<double>& inputLevels, const double input) const {
- return ub.solve(input / (inputLevels.max - inputLevels.min), 1e-6);
+ return ub.solve(util::interpolationFactor(1.0,
+ Range<float> {
+ static_cast<float>(inputLevels.min),
+ static_cast<float>(inputLevels.max)
+ },
+ input),
+ 1e-6);
}
bool operator==(const CubicBezierInterpolator& rhs) const {