From 43be58a1ea64aa10d2ac9b94c7b8111defa33ddd Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 19 Jul 2019 18:41:16 -0600 Subject: [PATCH] Fix bug in occulted centering logic. --- common/view/view.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/common/view/view.cpp b/common/view/view.cpp index fe581b3a96..97532988e2 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -633,9 +633,7 @@ void VIEW::SetCenter( VECTOR2D aCenter, const BOX2D& occultingScreenRect ) return; } - BOX2D occultedRect = screenRect.Intersect( occultingScreenRect ); - VECTOR2D offset( occultedRect.GetWidth() / 2, occultedRect.GetHeight() / 2 ); - + BOX2D occultedRect = screenRect.Intersect( occultingScreenRect ); double topExposed = occultedRect.GetTop() - screenRect.GetTop(); double bottomExposed = screenRect.GetBottom() - occultedRect.GetBottom(); double leftExposed = occultedRect.GetLeft() - screenRect.GetLeft(); @@ -644,16 +642,16 @@ void VIEW::SetCenter( VECTOR2D aCenter, const BOX2D& occultingScreenRect ) if( std::max( topExposed, bottomExposed ) > std::max( leftExposed, rightExposed ) ) { if( topExposed > bottomExposed ) - aCenter.y += ToWorld( occultedRect.GetHeight() / 2 ); + aCenter.y += ToWorld( screenRect.GetHeight() / 2 - topExposed / 2 ); else - aCenter.y -= ToWorld( occultedRect.GetHeight() / 2 ); + aCenter.y -= ToWorld( screenRect.GetHeight() / 2 - bottomExposed / 2 ); } else { if( leftExposed > rightExposed ) - aCenter.x += ToWorld( occultedRect.GetWidth() / 2 ); + aCenter.x += ToWorld( screenRect.GetWidth() / 2 - leftExposed / 2 ); else - aCenter.x -= ToWorld( occultedRect.GetWidth() / 2 ); + aCenter.x -= ToWorld( screenRect.GetWidth() / 2 - rightExposed / 2 ); } SetCenter( aCenter );