From dbcbac4c4fd2c82163535c4d6a08faf19a6c1993 Mon Sep 17 00:00:00 2001 From: Chris Loer Date: Wed, 5 Sep 2018 12:07:58 -0700 Subject: [PATCH 1/2] [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 f37fb2c9cda..62b48c1752b 100644 --- a/include/mbgl/style/expression/interpolator.hpp +++ b/include/mbgl/style/expression/interpolator.hpp @@ -33,7 +33,13 @@ class CubicBezierInterpolator { 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 { From 51b9532e21a7b06ae3389b9e570c325ee99a6a30 Mon Sep 17 00:00:00 2001 From: Chris Loer Date: Thu, 6 Sep 2018 11:37:15 -0700 Subject: [PATCH 2/2] [docs] Changelog entries for cubic-bezier interpolation fix. --- platform/android/CHANGELOG.md | 2 ++ platform/ios/CHANGELOG.md | 1 + platform/macos/CHANGELOG.md | 1 + platform/node/CHANGELOG.md | 1 + 4 files changed, 5 insertions(+) diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index 13162c0b48f..ab7cec335f2 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -4,6 +4,8 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to ## master +- Fixed a cubic-bezier interpolation bug. ([#12812] (https://github.com/mapbox/mapbox-gl-native/issues/12812)) + ## 6.5.0-beta.1 - September 5, 2018 - Retain shared thread pool reference [#12811](https://github.com/mapbox/mapbox-gl-native/pull/12811) - MapStrictMode configuration [#12817](https://github.com/mapbox/mapbox-gl-native/pull/12817) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index e7c061aff1c..49039ed4b81 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -29,6 +29,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Fixed a sporadic crash with location updates. ([#12584](https://github.com/mapbox/mapbox-gl-native/pull/12584)) * Fixed a crash that occurred during power state changes. ([#12584](https://github.com/mapbox/mapbox-gl-native/pull/12584)) * Fixed a crash related to telemetry upload. ([#12584](https://github.com/mapbox/mapbox-gl-native/pull/12584)) +* Fixed a cubic-bezier interpolation bug. ([#12812] (https://github.com/mapbox/mapbox-gl-native/issues/12812)) ## 4.3.0 - August 15, 2018 diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index c1083ba1191..b37fb711bbf 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -21,6 +21,7 @@ * The `-[MGLMapView annotationAtPoint:]` method can now return annotations near tile boundaries at high zoom levels. ([#12570](https://github.com/mapbox/mapbox-gl-native/pull/12570)) * Added an `-[MGLMapViewDelegate mapView:shapeAnnotationIsEnabled:]` method to specify whether an annotation is selectable. ([#12352](https://github.com/mapbox/mapbox-gl-native/pull/12352)) * Fixed inconsistencies in exception naming. ([#12583](https://github.com/mapbox/mapbox-gl-native/issues/12583)) +* Fixed a cubic-bezier interpolation bug. ([#12812] (https://github.com/mapbox/mapbox-gl-native/issues/12812)) # 0.10.0 - August 15, 2018 diff --git a/platform/node/CHANGELOG.md b/platform/node/CHANGELOG.md index db33ab52dbc..5e5e75651d5 100644 --- a/platform/node/CHANGELOG.md +++ b/platform/node/CHANGELOG.md @@ -5,6 +5,7 @@ - Remove unnecessary memory use when collision debug mode is not enabled ([#12294](https://github.com/mapbox/mapbox-gl-native/issues/12294)) - Added support for rendering `symbol-placement: line-center` ([#12337](https://github.com/mapbox/mapbox-gl-native/pull/12337)) - Add support for feature expressions in `line-pattern`, `fill-pattern`, and `fill-extrusion-pattern` properties. [#12284](https://github.com/mapbox/mapbox-gl-native/pull/12284) +- Fixed a cubic-bezier interpolation bug. ([#12812] (https://github.com/mapbox/mapbox-gl-native/issues/12812)) # 3.5.8 - October 19, 2017 - Fixes an issue that causes memory leaks when not deleting the frontend object