Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Fix cubic-bezier interpolation for zooms outside stop range.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ChrisLoer committed Sep 6, 2018
1 parent 3e23cae commit dbcbac4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion include/mbgl/style/expression/interpolator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ class CubicBezierInterpolator {
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 {
Expand Down

0 comments on commit dbcbac4

Please sign in to comment.