mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Don't send zoom level while zooming (fixes #2470)
This commit is contained in:
parent
606e284bef
commit
2e8faac549
|
@ -20,7 +20,6 @@ class CCamera : public CComponent
|
|||
vec2 m_PrevCenter;
|
||||
|
||||
bool m_Zooming;
|
||||
float m_ZoomSmoothingTarget;
|
||||
CCubicBezier m_ZoomSmoothing;
|
||||
float m_ZoomSmoothingStart;
|
||||
float m_ZoomSmoothingEnd;
|
||||
|
@ -33,6 +32,7 @@ public:
|
|||
vec2 m_Center;
|
||||
bool m_ZoomSet;
|
||||
float m_Zoom;
|
||||
float m_ZoomSmoothingTarget;
|
||||
|
||||
CCamera();
|
||||
virtual void OnRender();
|
||||
|
|
|
@ -1552,13 +1552,17 @@ void CGameClient::OnNewSnapshot()
|
|||
|
||||
static float LastZoom = .0;
|
||||
static float LastScreenAspect = .0;
|
||||
if(m_pCamera->m_Zoom != LastZoom || Graphics()->ScreenAspect() != LastScreenAspect)
|
||||
float ZoomToSend = m_pCamera->m_ZoomSmoothingTarget == .0 ? m_pCamera->m_Zoom // Initial
|
||||
: m_pCamera->m_ZoomSmoothingTarget > m_pCamera->m_Zoom ? m_pCamera->m_ZoomSmoothingTarget // Zooming out
|
||||
: m_pCamera->m_ZoomSmoothingTarget < m_pCamera->m_Zoom ? LastZoom // Zooming in
|
||||
: m_pCamera->m_Zoom; // Not zooming
|
||||
if(ZoomToSend != LastZoom || Graphics()->ScreenAspect() != LastScreenAspect)
|
||||
{
|
||||
LastZoom = m_pCamera->m_Zoom;
|
||||
LastZoom = ZoomToSend;
|
||||
LastScreenAspect = Graphics()->ScreenAspect();
|
||||
CNetMsg_Cl_ShowDistance Msg;
|
||||
float x, y;
|
||||
RenderTools()->CalcScreenParams(Graphics()->ScreenAspect(), m_pCamera->m_Zoom, &x, &y);
|
||||
RenderTools()->CalcScreenParams(Graphics()->ScreenAspect(), ZoomToSend, &x, &y);
|
||||
Msg.m_X = x;
|
||||
Msg.m_Y = y;
|
||||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
|
||||
|
|
Loading…
Reference in a new issue