Skip to content

Commit

Permalink
Merge #6162
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bors[bot] and Robyt3 authored Dec 18, 2022
2 parents 3e458f8 + 32ce5be commit 293af0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/game/client/components/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
5 changes: 5 additions & 0 deletions src/game/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 293af0e

Please sign in to comment.