Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/game/client/hud_crosshair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 10 additions & 9 deletions src/game/client/neo/ui/neo_hud_crosshair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
2 changes: 1 addition & 1 deletion src/game/client/neo/ui/neo_hud_crosshair.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);