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.
This commit is contained in:
Robert Müller 2022-12-18 20:58:29 +01:00
parent 3e458f8c10
commit 32ce5be301
2 changed files with 11 additions and 0 deletions

View file

@ -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());
}

View file

@ -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)