Added ViewModelFOV field for models

Allows manually setting FOV for models instead of scaling from 90 degrees. Positive values are exact FOVs while negative FOVs are scalars from 90. SCALEWEAPONFOV does not work with exact values since it automatically scales based on FOV.
This commit is contained in:
Boondorl 2025-06-07 22:42:48 -04:00 committed by Ricardo Luís Vaz Silva
commit c6825a9881
2 changed files with 23 additions and 4 deletions

View file

@ -250,12 +250,23 @@ void RenderHUDModel(FModelRenderer *renderer, DPSprite *psp, FVector3 translatio
// but we need to position it correctly in the world for light to work properly.
VSMatrix objectToWorldMatrix = renderer->GetViewToWorldMatrix();
// [Nash] Optional scale weapon FOV
float fovscale = 1.0f;
if (smf_flags & MDL_SCALEWEAPONFOV)
if (smf->viewModelFOV <= 0.0f)
{
fovscale = tan(players[consoleplayer].DesiredFOV * (0.5f * M_PI / 180.f));
fovscale = 1.f + (fovscale - 1.f) * cl_scaleweaponfov;
if (smf->viewModelFOV < 0.0f)
fovscale = 1.0f / fabs(smf->viewModelFOV);
// [Nash] Optional scale weapon FOV
if (smf_flags & MDL_SCALEWEAPONFOV)
{
float newScale = tan(players[consoleplayer].DesiredFOV * (0.5f * M_PI / 180.f));
newScale = 1.f + (newScale - 1.f) * cl_scaleweaponfov;
fovscale *= newScale;
}
}
else if (players[consoleplayer].DesiredFOV != smf->viewModelFOV)
{
fovscale = tan(players[consoleplayer].DesiredFOV * (0.5f * M_PI / 180.f)) / tan(smf->viewModelFOV * (0.5f * M_PI / 180.f));
}
// Scaling model (y scale for a sprite means height, i.e. z in the world!).
@ -935,6 +946,13 @@ void ParseModelDefLump(int Lump)
{
smf.flags |= MDL_MODELSAREATTACHMENTS;
}
else if (sc.Compare("viewmodelfov"))
{
sc.MustGetFloat();
smf.viewModelFOV = sc.Float;
if (smf.viewModelFOV > 0.0f)
smf.viewModelFOV = min<float>(smf.viewModelFOV, 175.0f);
}
else if (sc.Compare("rotating"))
{
smf.flags |= MDL_ROTATING;