Merge lp:~gunchleoc/widelands/bug-1818494-ingame-zoom-freezes into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 9024
Proposed branch: lp:~gunchleoc/widelands/bug-1818494-ingame-zoom-freezes
Merge into: lp:widelands
Diff against target: 61 lines (+20/-0)
2 files modified
src/wui/mapview.cc (+16/-0)
src/wui/mapview.h (+4/-0)
To merge this branch: bzr merge lp:~gunchleoc/widelands/bug-1818494-ingame-zoom-freezes
Reviewer Review Type Date Requested Status
Benedikt Straub Approve
Review via email: mp+364304@code.launchpad.net

Commit message

Skip calculating changes to the map view's viewport when nothing would change. This prevents the map view from being busy when the user leans on the CTRL+/- keys.

Description of the change

I think this should go into Build 20, because it can make the player think that Widelands has crashed, while it's just the mapview being busy.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4610. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/508054518.
Appveyor build 4397. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_gunchleoc_widelands_bug_1818494_ingame_zoom_freezes-4397.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Just bumping this review. I'd like this branch in Build 20 to avoid getting bug reports when Widelands seems to freeze.

Revision history for this message
Benedikt Straub (nordfriese) wrote :

Code LGTM, works as expected.
Thanks for fixing this nasty bug :)

review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for the review :)

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/wui/mapview.cc'
--- src/wui/mapview.cc 2019-02-23 11:00:49 +0000
+++ src/wui/mapview.cc 2019-03-20 12:59:24 +0000
@@ -387,6 +387,10 @@
387 const Transition transition = animate_map_panning_ ? passed_transition : Transition::Jump;387 const Transition transition = animate_map_panning_ ? passed_transition : Transition::Jump;
388 switch (transition) {388 switch (transition) {
389 case Transition::Jump: {389 case Transition::Jump: {
390 if (view_ == target_view) {
391 // We're already there
392 return;
393 }
390 view_ = target_view;394 view_ = target_view;
391 MapviewPixelFunctions::normalize_pix(map_, &view_.viewpoint);395 MapviewPixelFunctions::normalize_pix(map_, &view_.viewpoint);
392 changeview();396 changeview();
@@ -394,6 +398,10 @@
394 }398 }
395399
396 case Transition::Smooth: {400 case Transition::Smooth: {
401 if (!view_plans_.empty() && view_plans_.back().back().view == target_view) {
402 // We're already there
403 return;
404 }
397 const TimestampedView current = animation_target_view();405 const TimestampedView current = animation_target_view();
398 const auto plan =406 const auto plan =
399 plan_map_transition(current.t, map_, current.view, target_view, get_w(), get_h());407 plan_map_transition(current.t, map_, current.view, target_view, get_w(), get_h());
@@ -509,6 +517,10 @@
509 const TimestampedView current = animation_target_view();517 const TimestampedView current = animation_target_view();
510 switch (transition) {518 switch (transition) {
511 case Transition::Jump: {519 case Transition::Jump: {
520 if (view_.zoom == new_zoom) {
521 // We're already there
522 return;
523 }
512 // Zoom around the current mouse position. See524 // Zoom around the current mouse position. See
513 // http://stackoverflow.com/questions/2916081/zoom-in-on-a-point-using-scale-and-translate525 // http://stackoverflow.com/questions/2916081/zoom-in-on-a-point-using-scale-and-translate
514 // for a good explanation of this math.526 // for a good explanation of this math.
@@ -518,6 +530,10 @@
518 }530 }
519531
520 case Transition::Smooth: {532 case Transition::Smooth: {
533 if (!view_plans_.empty() && view_plans_.back().back().view.zoom == new_zoom) {
534 // We're already there
535 return;
536 }
521 const int w = get_w();537 const int w = get_w();
522 const int h = get_h();538 const int h = get_h();
523 const auto plan = plan_zoom_transition(539 const auto plan = plan_zoom_transition(
524540
=== modified file 'src/wui/mapview.h'
--- src/wui/mapview.h 2019-02-23 11:00:49 +0000
+++ src/wui/mapview.h 2019-03-20 12:59:24 +0000
@@ -75,6 +75,10 @@
75 View() : View(Vector2f::zero(), 1.0f) {75 View() : View(Vector2f::zero(), 1.0f) {
76 }76 }
7777
78 bool operator==(const View& other) const {
79 return (zoom == other.zoom) && (viewpoint == other.viewpoint);
80 }
81
78 // Mappixel of top-left pixel of this MapView.82 // Mappixel of top-left pixel of this MapView.
79 Vector2f viewpoint;83 Vector2f viewpoint;
8084

Subscribers

People subscribed via source and target branches

to status/vote changes: