diff options
author | Chris Loer <chris.loer@gmail.com> | 2018-09-05 12:07:58 -0700 |
---|---|---|
committer | Chris Loer <chris.loer@gmail.com> | 2018-09-05 12:07:58 -0700 |
commit | 8aa1b45a6b75409e5ccb8b10208ec4315e540f8a (patch) | |
tree | 9634b0afac1185feeff114748e758e8daff5515d | |
parent | 5fb096a4d09dd41f281612a94f9468df755bccb4 (diff) | |
download | qtlocation-mapboxgl-upstream/fix-bezier.tar.gz |
[core] Fix cubic-bezier interpolation for zooms outside stop range.upstream/fix-bezier
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.
-rw-r--r-- | include/mbgl/style/expression/interpolator.hpp | 8 |
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 { |