From 32ce5be30196d9881f913a14815bf47946d22a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 18 Dec 2022 20:58:29 +0100 Subject: [PATCH] Fix smooth zooming overshooting the target zoom level Ensure that the zoom level with smooth zooming does not exceed the target zoom level. Closes #3747. --- src/game/client/components/camera.cpp | 6 ++++++ src/game/editor/editor.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/game/client/components/camera.cpp b/src/game/client/components/camera.cpp index 91e6bd142..b9e083604 100644 --- a/src/game/client/components/camera.cpp +++ b/src/game/client/components/camera.cpp @@ -81,7 +81,13 @@ void CCamera::OnRender() } else { + const float OldLevel = m_Zoom; m_Zoom = m_ZoomSmoothing.Evaluate(ZoomProgress(Time)); + if((OldLevel < m_ZoomSmoothingTarget && m_Zoom > m_ZoomSmoothingTarget) || (OldLevel > m_ZoomSmoothingTarget && m_Zoom < m_ZoomSmoothingTarget)) + { + m_Zoom = m_ZoomSmoothingTarget; + m_Zooming = false; + } } m_Zoom = clamp(m_Zoom, MinZoomLevel(), MaxZoomLevel()); } diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 92032ac41..a84c4bbe7 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -6138,6 +6138,11 @@ void CEditor::UpdateZoom() else { m_Zoom = m_ZoomSmoothing.Evaluate(ZoomProgress(Time)); + if((OldLevel < m_ZoomSmoothingTarget && m_Zoom > m_ZoomSmoothingTarget) || (OldLevel > m_ZoomSmoothingTarget && m_Zoom < m_ZoomSmoothingTarget)) + { + m_Zoom = m_ZoomSmoothingTarget; + m_Zooming = false; + } } m_Zoom = clamp(m_Zoom, MinZoomLevel(), MaxZoomLevel()); if(g_Config.m_EdZoomTarget)