Skip to content

Commit 293af0e

Browse files
bors[bot]Robyt3
andauthored
Merge #6162
6162: Fix smooth zooming overshooting the target zoom level r=Chairn a=Robyt3 Ensure that the zoom level with smooth zooming does not exceed the target zoom level. Closes #3747. ## Checklist - [X] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <[email protected]>
2 parents 3e458f8 + 32ce5be commit 293af0e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/game/client/components/camera.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ void CCamera::OnRender()
8181
}
8282
else
8383
{
84+
const float OldLevel = m_Zoom;
8485
m_Zoom = m_ZoomSmoothing.Evaluate(ZoomProgress(Time));
86+
if((OldLevel < m_ZoomSmoothingTarget && m_Zoom > m_ZoomSmoothingTarget) || (OldLevel > m_ZoomSmoothingTarget && m_Zoom < m_ZoomSmoothingTarget))
87+
{
88+
m_Zoom = m_ZoomSmoothingTarget;
89+
m_Zooming = false;
90+
}
8591
}
8692
m_Zoom = clamp(m_Zoom, MinZoomLevel(), MaxZoomLevel());
8793
}

src/game/editor/editor.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -6138,6 +6138,11 @@ void CEditor::UpdateZoom()
61386138
else
61396139
{
61406140
m_Zoom = m_ZoomSmoothing.Evaluate(ZoomProgress(Time));
6141+
if((OldLevel < m_ZoomSmoothingTarget && m_Zoom > m_ZoomSmoothingTarget) || (OldLevel > m_ZoomSmoothingTarget && m_Zoom < m_ZoomSmoothingTarget))
6142+
{
6143+
m_Zoom = m_ZoomSmoothingTarget;
6144+
m_Zooming = false;
6145+
}
61416146
}
61426147
m_Zoom = clamp(m_Zoom, MinZoomLevel(), MaxZoomLevel());
61436148
if(g_Config.m_EdZoomTarget)

0 commit comments

Comments
 (0)