[core] Clamp pitch in easeTo(), flyTo()

Also factored out the maximum pitch into a constant.
This commit is contained in:
Minh Nguyễn
2015-12-19 23:14:01 -08:00
committed by Minh Nguyễn
parent 2cb70eac3c
commit a5230f3e11
4 changed files with 7 additions and 2 deletions

View File

@@ -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().