Skip to content

Commit

Permalink
Limiting zoom out and moving default zoom enforcement to proper place
Browse files Browse the repository at this point in the history
  • Loading branch information
Siile committed Sep 9, 2024
1 parent 9263f9a commit d74d2e2
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/game/client/components/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ void CCamera::ConZoomIn(IConsole::IResult *pResult, void *pUserData)
{
CCamera *pSelf = (CCamera *)pUserData;
if(pSelf->m_pClient && pSelf->m_pClient->m_Snap.m_pLocalInfo && pSelf->m_pClient->m_Snap.m_pLocalInfo->m_Team == TEAM_SPECTATORS)
pSelf->m_TargetZoom -= 0.05;
pSelf->m_TargetZoom = max(pSelf->m_TargetZoom-0.05f, 0.5f);
}

void CCamera::ConZoomOut(IConsole::IResult *pResult, void *pUserData)
{
CCamera *pSelf = (CCamera *)pUserData;
// removing zooming out due to visual issues with snapping & background layers
if(pSelf->m_pClient && pSelf->m_pClient->m_Snap.m_pLocalInfo && pSelf->m_pClient->m_Snap.m_pLocalInfo->m_Team == TEAM_SPECTATORS)
pSelf->m_TargetZoom += 0.05;
pSelf->m_TargetZoom = min(pSelf->m_TargetZoom+0.05f, 1.0f);
}

void CCamera::ConZoomDefault(IConsole::IResult *pResult, void *pUserData)
Expand All @@ -53,13 +54,6 @@ void CCamera::OnInit()

void CCamera::OnRender()
{
if(m_pClient && m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS)
{
m_TargetZoom = 1.f;
m_Zoom = 1.f;
}
//m_pClient->m_pControls->m_CameraZoom = int(m_Zoom*10);

// update camera center
if(m_pClient->m_Snap.m_SpecInfo.m_Active && !m_pClient->m_Snap.m_SpecInfo.m_UsePosition)
{
Expand Down Expand Up @@ -99,6 +93,9 @@ void CCamera::OnRender()
}
else
{
m_TargetZoom = 1.f;
m_Zoom = 1.f;

if(m_CamType != CAMTYPE_PLAYER)
{
m_pClient->m_pControls->ClampMousePos();
Expand Down

0 comments on commit d74d2e2

Please sign in to comment.