Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Move rotation constraining to view
Browse files Browse the repository at this point in the history
Fixes #458
  • Loading branch information
jfirebaugh committed Oct 30, 2014
1 parent acb65f8 commit aee42d7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 20 deletions.
1 change: 0 additions & 1 deletion include/mbgl/map/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class Map : private util::noncopyable {
void resetNorth();
void startRotating();
void stopRotating();
bool canRotate();

// Debug
void setDebug(bool value);
Expand Down
1 change: 0 additions & 1 deletion include/mbgl/map/transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class Transform : private util::noncopyable {
double getAngle() const;
void startRotating();
void stopRotating();
bool canRotate();

// Transitions
bool needsTransition() const;
Expand Down
7 changes: 5 additions & 2 deletions platform/default/glfw_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ void GLFWView::swap() {
glfwSetWindowTitle(window, title.c_str());
}

void GLFWView::notify_map_change(mbgl::MapChange /*change*/, mbgl::timestamp /*delay*/) {
// no-op
void GLFWView::notify_map_change(mbgl::MapChange change, mbgl::timestamp /*delay*/) {
if ((change == mbgl::MapChange::MapChangeRegionDidChange || change == mbgl::MapChange::MapChangeRegionDidChangeAnimated)
&& map->getZoom() <= 3 && map->getBearing() != 0) {
map->setBearing(0, 0.2);
}
}

void GLFWView::fps() {
Expand Down
4 changes: 0 additions & 4 deletions src/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,6 @@ void Map::stopRotating() {
update();
}

bool Map::canRotate() {
return transform.canRotate();
}


#pragma mark - Toggles

Expand Down
12 changes: 0 additions & 12 deletions src/map/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ using namespace mbgl;

const double D2R = M_PI / 180.0;
const double M2PI = 2 * M_PI;
const double MIN_ROTATE_SCALE = 8;

Transform::Transform(View &view_)
: view(view_)
Expand All @@ -37,7 +36,6 @@ bool Transform::resize(const uint16_t w, const uint16_t h, const float ratio,
current.pixelRatio = final.pixelRatio = ratio;
current.framebuffer[0] = final.framebuffer[0] = fb_w;
current.framebuffer[1] = final.framebuffer[1] = fb_h;
if (!canRotate() && current.angle) _setAngle(0);
constrain(current.scale, current.y);

view.notify_map_change(MapChangeRegionDidChange);
Expand Down Expand Up @@ -286,9 +284,6 @@ void Transform::_setScaleXY(const double new_scale, const double xn, const doubl

constrain(final.scale, final.y);

// Undo rotation at low zooms.
if (!canRotate() && current.angle) _setAngle(0);

if (duration == 0) {
current.scale = final.scale;
current.x = final.x;
Expand Down Expand Up @@ -398,9 +393,6 @@ void Transform::_setAngle(double new_angle, const timestamp duration) {

final.angle = new_angle;

// Prevent rotation at low zooms.
if (!canRotate()) final.angle = 0;

if (duration == 0) {
current.angle = final.angle;
} else {
Expand Down Expand Up @@ -449,10 +441,6 @@ void Transform::_clearRotating() {
}
}

bool Transform::canRotate() {
return (current.scale > MIN_ROTATE_SCALE);
}

#pragma mark - Transition

bool Transform::needsTransition() const {
Expand Down

0 comments on commit aee42d7

Please sign in to comment.