From 1719bbdfb79c9b15c5f6f4b03208fa8f152f4498 Mon Sep 17 00:00:00 2001 From: mrmbernardi Date: Tue, 1 Oct 2024 23:48:08 +1000 Subject: [PATCH] Fix deadzone when panning while zoomed in. (#22877) --- distribution/changelog.txt | 1 + src/openrct2-ui/input/MouseInput.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index d3a706b748..a594bc98e1 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -29,6 +29,7 @@ - Fix: [#22729] Invisibility settings persist after reloading OpenRCT2. - Fix: [#22734] Support clearance above steep Side-Friction track is too low. - Fix: [#22774] Fix entities leaving stale pixels on the screen when the framerate is uncapped. +- Fix: [#22805] Fix deadzone when panning the view in positive axis directions. - Fix: [#22857] Side-Friction Roller Coaster train clips through slopes. - Fix: [objects#346] Invalid refund price for Brick Base Block scenery item. diff --git a/src/openrct2-ui/input/MouseInput.cpp b/src/openrct2-ui/input/MouseInput.cpp index 355225f573..fbe7cfca02 100644 --- a/src/openrct2-ui/input/MouseInput.cpp +++ b/src/openrct2-ui/input/MouseInput.cpp @@ -586,8 +586,14 @@ static void InputViewportDragContinue() // As the user moved the mouse, don't interpret it as right click in any case. _ticksSinceDragStart = std::nullopt; - differentialCoords.x = (viewport->zoom + 1).ApplyTo(differentialCoords.x); - differentialCoords.y = (viewport->zoom + 1).ApplyTo(differentialCoords.y); + // applying the zoom only with negative values avoids a "deadzone" effect where small positive value round to zero. + const bool posX = differentialCoords.x > 0; + const bool posY = differentialCoords.y > 0; + differentialCoords.x = (viewport->zoom + 1).ApplyTo(-std::abs(differentialCoords.x)); + differentialCoords.y = (viewport->zoom + 1).ApplyTo(-std::abs(differentialCoords.y)); + differentialCoords.x = posX ? -differentialCoords.x : differentialCoords.x; + differentialCoords.y = posY ? -differentialCoords.y : differentialCoords.y; + if (Config::Get().general.InvertViewportDrag) { w->savedViewPos -= differentialCoords;