[core] Clamp pitch in easeTo(), flyTo()
Also factored out the maximum pitch into a constant.
This commit is contained in:
committed by
Minh Nguyễn
parent
2cb70eac3c
commit
a5230f3e11
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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().
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user