From dbd877cb80bf36197defa2a5ac8ea6df6f04eb24 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Thu, 22 May 2014 16:47:17 -0700 Subject: [PATCH] disallow/undo rotation at low zooms --- src/map/transform.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/map/transform.cpp b/src/map/transform.cpp index e05bb38f3..4f13fdaf8 100644 --- a/src/map/transform.cpp +++ b/src/map/transform.cpp @@ -12,6 +12,7 @@ using namespace llmr; const double D2R = M_PI / 180.0; const double R2D = 180.0 / M_PI; const double M2PI = 2 * M_PI; +const double MIN_ROTATE_SCALE = 8; Transform::Transform() { setScale(current.scale); @@ -248,6 +249,9 @@ void Transform::_setScaleXY(const double new_scale, const double xn, const doubl constrain(final.scale, final.y); + // Undo rotation at low zooms. + if (final.scale < MIN_ROTATE_SCALE && current.angle) _setAngle(0, 500_milliseconds); + if (duration == 0) { current.scale = final.scale; current.x = final.x; @@ -349,6 +353,9 @@ void Transform::_setAngle(double new_angle, const time duration) { final.angle = new_angle; + // Prevent rotation at low zooms. + if (final.scale < MIN_ROTATE_SCALE) final.angle = 0; + if (duration == 0) { current.angle = final.angle; } else {