diff --git a/src/game/client/hud_crosshair.cpp b/src/game/client/hud_crosshair.cpp index 8fc071d93..54540663c 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 d7ac22447..aa316d288 100644 --- a/src/game/client/neo/ui/neo_hud_crosshair.cpp +++ b/src/game/client/neo/ui/neo_hud_crosshair.cpp @@ -305,14 +305,15 @@ 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; + if (!spread) + { + return 0; + } + 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 5fb10ce07..ed46ae07f 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);