From 90097b5d40258cf34c39467e01de5c8ee486457f Mon Sep 17 00:00:00 2001 From: AdamTadeusz Date: Sat, 17 Jan 2026 11:43:00 +0000 Subject: [PATCH 1/2] init --- src/game/client/hud_crosshair.cpp | 4 ++-- src/game/client/neo/ui/neo_hud_crosshair.cpp | 15 ++++++--------- src/game/client/neo/ui/neo_hud_crosshair.h | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/game/client/hud_crosshair.cpp b/src/game/client/hud_crosshair.cpp index 8fc071d93d..54540663c8 100644 --- a/src/game/client/hud_crosshair.cpp +++ b/src/game/client/hud_crosshair.cpp @@ -503,7 +503,7 @@ void CHudCrosshair::Paint( void ) { if (cl_neo_crosshair_scope_inaccuracy.GetBool()) { - const int size = pWeapon ? HalfInaccuracyConeInScreenPixels(pPlayer, pWeapon, m_iHalfScreenWidth) : 0; + const int size = pWeapon ? HalfInaccuracyConeInScreenPixels(pWeapon, m_iHalfScreenWidth) : 0; if (size) { surface()->DrawSetTexture(m_hCrosshairLight); @@ -546,7 +546,7 @@ void CHudCrosshair::Paint( void ) } else { - PaintCrosshair(*pCrosshairInfo, HalfInaccuracyConeInScreenPixels(pPlayer, pWeapon, m_iHalfScreenWidth), iX, iY); + PaintCrosshair(*pCrosshairInfo, HalfInaccuracyConeInScreenPixels(pWeapon, m_iHalfScreenWidth), iX, iY); } if (bIsScopedWep && pPlayer->m_bInAim) diff --git a/src/game/client/neo/ui/neo_hud_crosshair.cpp b/src/game/client/neo/ui/neo_hud_crosshair.cpp index d7ac22447d..13f4fb7644 100644 --- a/src/game/client/neo/ui/neo_hud_crosshair.cpp +++ b/src/game/client/neo/ui/neo_hud_crosshair.cpp @@ -305,14 +305,11 @@ void ExportCrosshair(const CrosshairInfo *crh, char (&szSequence)[NEO_XHAIR_SEQM crh->colorOutline.GetRawColor()); } -int HalfInaccuracyConeInScreenPixels(C_NEO_Player* pPlayer, C_NEOBaseCombatWeapon* pWeapon, int halfScreenWidth) +int HalfInaccuracyConeInScreenPixels(C_NEOBaseCombatWeapon* pWeapon, int halfScreenWidth) { - // Hor+ FOV, e.g at an aspect ratio of 16:9 and horizontal fov of 110, the actual horizontal fov is ~120 - const float scaledFov = ScaleFOVByWidthRatio(pPlayer->GetFOV(), engine->GetScreenAspectRatio() * 0.75f); // 4 / 3 - const float halfInaccuracy = pWeapon && pWeapon->GetNeoWepBits() & NEO_WEP_FIREARM ? RAD2DEG(asin(pWeapon->GetBulletSpread().x)) : 0; - // No clue, just found a value which works well (fired some shots at 15 fov, then increased fov to 120 and scaled the circle down until it worked) - // NEO TODO (Adam) I welcome any suggestions on how to improve this, I assume its something to do with how higher fields of view distort an image. - constexpr float MAGIC_FOV_DISTORTION_VALUE = 0.4f / 120.0f; - const int size = halfInaccuracy ? (halfScreenWidth / ((scaledFov * 0.5f) / halfInaccuracy)) * (1 - (scaledFov * MAGIC_FOV_DISTORTION_VALUE)) : 0; - return size; + float spread = pWeapon && pWeapon->GetNeoWepBits() & NEO_WEP_FIREARM ? pWeapon->GetBulletSpread().x : 0.f; + Vector pointInWorldSpaceOnSpreadCone = MainViewOrigin() + MainViewForward() + (MainViewRight() * spread); + Vector pointInScreenSpaceOnSpreadCone = vec3_origin; + ScreenTransform(pointInWorldSpaceOnSpreadCone, pointInScreenSpaceOnSpreadCone); + return pointInScreenSpaceOnSpreadCone.x * halfScreenWidth; }; diff --git a/src/game/client/neo/ui/neo_hud_crosshair.h b/src/game/client/neo/ui/neo_hud_crosshair.h index 5fb10ce070..ed46ae07f4 100644 --- a/src/game/client/neo/ui/neo_hud_crosshair.h +++ b/src/game/client/neo/ui/neo_hud_crosshair.h @@ -101,4 +101,4 @@ void PaintCrosshair(const CrosshairInfo &crh, int inaccuracy, const int x, const bool ImportCrosshair(CrosshairInfo *crh, const char *pszSequence); void ExportCrosshair(const CrosshairInfo *crh, char (&szSequence)[NEO_XHAIR_SEQMAX]); -int HalfInaccuracyConeInScreenPixels(C_NEO_Player *player, C_NEOBaseCombatWeapon *pWeapon, int halfScreenWidth); +int HalfInaccuracyConeInScreenPixels(C_NEOBaseCombatWeapon *pWeapon, int halfScreenWidth); From a59c77b4b685a92be711b46095c3c94aad07b6e6 Mon Sep 17 00:00:00 2001 From: AdamTadeusz Date: Sat, 17 Jan 2026 12:02:19 +0000 Subject: [PATCH 2/2] remove the blur from scopes when fully accurate at some view angles --- src/game/client/neo/ui/neo_hud_crosshair.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/game/client/neo/ui/neo_hud_crosshair.cpp b/src/game/client/neo/ui/neo_hud_crosshair.cpp index 13f4fb7644..aa316d2880 100644 --- a/src/game/client/neo/ui/neo_hud_crosshair.cpp +++ b/src/game/client/neo/ui/neo_hud_crosshair.cpp @@ -308,6 +308,10 @@ void ExportCrosshair(const CrosshairInfo *crh, char (&szSequence)[NEO_XHAIR_SEQM int HalfInaccuracyConeInScreenPixels(C_NEOBaseCombatWeapon* pWeapon, int halfScreenWidth) { float spread = pWeapon && pWeapon->GetNeoWepBits() & NEO_WEP_FIREARM ? pWeapon->GetBulletSpread().x : 0.f; + if (!spread) + { + return 0; + } Vector pointInWorldSpaceOnSpreadCone = MainViewOrigin() + MainViewForward() + (MainViewRight() * spread); Vector pointInScreenSpaceOnSpreadCone = vec3_origin; ScreenTransform(pointInWorldSpaceOnSpreadCone, pointInScreenSpaceOnSpreadCone);