diff options
author | Chris Loer <chris.loer@gmail.com> | 2018-09-05 12:07:58 -0700 |
---|---|---|
committer | Chris Loer <chris.loer@mapbox.com> | 2018-09-06 12:12:45 -0700 |
commit | b2fb62e0038adcd796ceab309e22ab050e811d0b (patch) | |
tree | cbc906a24babb6670c5418ebee31939580c8db22 | |
parent | 3e23cae601fe85a4ed4931dfb0ba9c3e3a4564aa (diff) | |
download | qtlocation-mapboxgl-b2fb62e0038adcd796ceab309e22ab050e811d0b.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.
-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 { |