diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-12-19 23:14:01 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2015-12-19 23:14:01 -0800 |
commit | a5230f3e110c4c286721a45add063db2380b5c80 (patch) | |
tree | 8e4ef72cdcc6f24c9c8c31c732890d1f8e682ecb | |
parent | 2cb70eac3ce7350ba2c0b5e93a7184a30e07c5cc (diff) | |
download | qtlocation-mapboxgl-a5230f3e110c4c286721a45add063db2380b5c80.tar.gz |
[core] Clamp pitch in easeTo(), flyTo()
Also factored out the maximum pitch into a constant.
-rw-r--r-- | include/mbgl/util/constants.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/map/map.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/map/transform.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/util/constants.cpp | 1 |
4 files changed, 7 insertions, 2 deletions
diff --git a/include/mbgl/util/constants.hpp b/include/mbgl/util/constants.hpp index 113a368128..22a460c9b0 100644 --- a/include/mbgl/util/constants.hpp +++ b/include/mbgl/util/constants.hpp @@ -16,6 +16,7 @@ extern const double RAD2DEG; extern const double M2PI; extern const double EARTH_RADIUS_M; extern const double LATITUDE_MAX; +extern const double PITCH_MAX; } // namespace util diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index ff4b2f5c06..8fe73458fc 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -334,7 +334,7 @@ void Map::resetNorth(const Duration& duration) { #pragma mark - Pitch void Map::setPitch(double pitch, const Duration& duration) { - transform->setPitch(util::clamp(pitch, 0., 60.) * M_PI / 180, duration); + transform->setPitch(pitch * M_PI / 180, duration); update(Update::Repaint); } diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 3da31d64b5..86d204f58e 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -256,6 +256,7 @@ void Transform::_easeTo(const CameraOptions& options, double new_scale, double n double angle = _normalizeAngle(new_angle, state.angle); state.angle = _normalizeAngle(state.angle, angle); double pitch = easeOptions.pitch ? *easeOptions.pitch : state.pitch; + pitch = util::clamp(pitch, 0., util::PITCH_MAX); if (!easeOptions.duration) { easeOptions.duration = Duration::zero(); @@ -367,6 +368,8 @@ void Transform::flyTo(const CameraOptions &options) { double normalizedAngle = _normalizeAngle(angle, state.angle); state.angle = _normalizeAngle(state.angle, normalizedAngle); + pitch = util::clamp(pitch, 0., util::PITCH_MAX); + const double startZoom = state.scaleZoom(state.scale); const double startAngle = state.angle; const double startPitch = state.pitch; @@ -492,7 +495,7 @@ void Transform::flyTo(const CameraOptions &options) { state.angle = util::wrap(util::interpolate(startAngle, normalizedAngle, k), -M_PI, M_PI); } if (pitch != startPitch) { - state.pitch = util::clamp(util::interpolate(startPitch, pitch, k), 0., 60.); + state.pitch = util::interpolate(startPitch, pitch, k); } // At k = 1.0, a DidChangeAnimated notification should be sent from finish(). diff --git a/src/mbgl/util/constants.cpp b/src/mbgl/util/constants.cpp index ccdbeba23a..9a5282d5e0 100644 --- a/src/mbgl/util/constants.cpp +++ b/src/mbgl/util/constants.cpp @@ -7,6 +7,7 @@ const double mbgl::util::RAD2DEG = 180.0 / M_PI; const double mbgl::util::M2PI = 2 * M_PI; const double mbgl::util::EARTH_RADIUS_M = 6378137; const double mbgl::util::LATITUDE_MAX = 85.05112878; +const double mbgl::util::PITCH_MAX = M_PI / 3; #if defined(DEBUG) const bool mbgl::debug::tileParseWarnings = false; |