From 8aa1b45a6b75409e5ccb8b10208ec4315e540f8a Mon Sep 17 00:00:00 2001 From: Chris Loer Date: Wed, 5 Sep 2018 12:07:58 -0700 Subject: [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. --- include/mbgl/style/expression/interpolator.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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& inputLevels, const double input) const { - return ub.solve(input / (inputLevels.max - inputLevels.min), 1e-6); + return ub.solve(util::interpolationFactor(1.0, + Range { + static_cast(inputLevels.min), + static_cast(inputLevels.max) + }, + input), + 1e-6); } bool operator==(const CubicBezierInterpolator& rhs) const { -- cgit v1.2.1