Skip to content

Commit

Permalink
Merge pull request #29 from SollyBunny/tater_improve_prec_not_always
Browse files Browse the repository at this point in the history
Don't always normalize position (<5 || >1000)
  • Loading branch information
sjrc6 authored Nov 24, 2024
2 parents 3a22a78 + 071d189 commit 7be7e89
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 20 deletions.
24 changes: 16 additions & 8 deletions src/game/client/components/controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,14 @@ int CControls::SnapInput(int *pData)
// set the target anyway though so that we can keep seeing our surroundings,
// even if chat or menu are activated
vec2 Pos = m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy];
if(g_Config.m_ClImproveMousePrecision)
Pos *= length(Pos) * 1000.0f / (float)(g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance);
if(!m_pClient->m_Snap.m_SpecInfo.m_Active && !g_Config.m_ClOldMouseZoom)
Pos *= m_pClient->m_Camera.m_Zoom;
const int MaxDistance = g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance;
if(MaxDistance > 5) // Only multiply mouse coords if not angle bind
{
if(g_Config.m_ClImproveMousePrecision && MaxDistance < 1000) // Don't scale if it would reduce precision
Pos *= length(Pos) * 1000.0f / (float)MaxDistance;
if(!m_pClient->m_Snap.m_SpecInfo.m_Active && !g_Config.m_ClOldMouseZoom)
Pos *= m_pClient->m_Camera.m_Zoom;
}
m_aInputData[g_Config.m_ClDummy].m_TargetX = (int)Pos.x;
m_aInputData[g_Config.m_ClDummy].m_TargetY = (int)Pos.y;

Expand All @@ -234,10 +238,14 @@ int CControls::SnapInput(int *pData)
Pos = m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy];
if(!m_pClient->m_Snap.m_SpecInfo.m_Active)
{
if(g_Config.m_ClImproveMousePrecision)
Pos *= length(Pos) * 1000.0f / (float)(g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance);
if(!g_Config.m_ClOldMouseZoom)
Pos *= m_pClient->m_Camera.m_Zoom;
const int MaxDistance = g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance;
if(MaxDistance > 5) // Only multiply mouse coords if not angle bind
{
if(g_Config.m_ClImproveMousePrecision && MaxDistance < 1000) // Don't scale if it would reduce precision
Pos *= length(Pos) * 1000.0f / (float)(g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance);
if(!g_Config.m_ClOldMouseZoom)
Pos *= m_pClient->m_Camera.m_Zoom;
}
}
m_aInputData[g_Config.m_ClDummy].m_TargetX = (int)Pos.x;
m_aInputData[g_Config.m_ClDummy].m_TargetY = (int)Pos.y;
Expand Down
36 changes: 24 additions & 12 deletions src/game/client/components/players.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,14 @@ void CPlayers::RenderHookCollLine(
{
// just use the direct input if it's the local player we are rendering
vec2 Pos = m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy];
if(g_Config.m_ClImproveMousePrecision)
Pos *= length(Pos) * 1000.0f / (float)(g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance);
if(!g_Config.m_ClOldMouseZoom)
Pos *= m_pClient->m_Camera.m_Zoom;
const int MaxDistance = g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance;
if(MaxDistance > 5) // Only multiply mouse coords if not angle bind
{
if(g_Config.m_ClImproveMousePrecision && MaxDistance < 1000) // Don't scale if it would reduce precision
Pos *= length(Pos) * 1000.0f / (float)MaxDistance;
if(!m_pClient->m_Snap.m_SpecInfo.m_Active && !g_Config.m_ClOldMouseZoom)
Pos *= m_pClient->m_Camera.m_Zoom;
}
Pos.x = (int)Pos.x;
Pos.y = (int)Pos.y;
Angle = angle(Pos);
Expand Down Expand Up @@ -473,10 +477,14 @@ void CPlayers::RenderPlayer(
{
// just use the direct input if it's the local player we are rendering
vec2 Pos = m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy];
if(g_Config.m_ClImproveMousePrecision)
Pos *= length(Pos) * 1000.0f / (float)(g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance);
if(!g_Config.m_ClOldMouseZoom)
Pos *= m_pClient->m_Camera.m_Zoom;
const int MaxDistance = g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance;
if(MaxDistance > 5) // Only multiply mouse coords if not angle bind
{
if(g_Config.m_ClImproveMousePrecision && MaxDistance < 1000) // Don't scale if it would reduce precision
Pos *= length(Pos) * 1000.0f / (float)MaxDistance;
if(!m_pClient->m_Snap.m_SpecInfo.m_Active && !g_Config.m_ClOldMouseZoom)
Pos *= m_pClient->m_Camera.m_Zoom;
}
Pos.x = (int)Pos.x;
Pos.y = (int)Pos.y;
Angle = angle(Pos);
Expand Down Expand Up @@ -908,10 +916,14 @@ void CPlayers::RenderPlayerGhost(
{
// just use the direct input if it's the local player we are rendering
vec2 Pos = m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy];
if(g_Config.m_ClImproveMousePrecision)
Pos *= length(Pos) * 1000.0f / (float)(g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance);
if(!g_Config.m_ClOldMouseZoom)
Pos *= m_pClient->m_Camera.m_Zoom;
const int MaxDistance = g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance;
if(MaxDistance > 5) // Only multiply mouse coords if not angle bind
{
if(g_Config.m_ClImproveMousePrecision && MaxDistance < 1000) // Don't scale if it would reduce precision
Pos *= length(Pos) * 1000.0f / (float)MaxDistance;
if(!m_pClient->m_Snap.m_SpecInfo.m_Active && !g_Config.m_ClOldMouseZoom)
Pos *= m_pClient->m_Camera.m_Zoom;
}
Pos.x = (int)Pos.x;
Pos.y = (int)Pos.y;
Angle = angle(Pos);
Expand Down

0 comments on commit 7be7e89

Please sign in to comment.