- Added 'ScaleWeaponFOV' flag to MODELDEF. Affects weapon models only; will scale the model along with the user's FOV to reduce distortion.

- Additionally, a 'cl_scaleweaponfov' CVar has been added to allow users to further fine-tune the weapon model scale with higher FOVs
This commit is contained in:
nashmuhandes 2022-03-08 04:45:52 +08:00 committed by Christoph Oelckers
commit 1785788bdc
3 changed files with 18 additions and 1 deletions

View file

@ -193,8 +193,16 @@ void RenderHUDModel(FModelRenderer *renderer, DPSprite *psp, float ofsX, float o
// 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)
{
fovscale = tan(players[consoleplayer].DesiredFOV * (0.5f * M_PI / 180.f));
fovscale = 1.f + (fovscale - 1.f) * cl_scaleweaponfov;
}
// Scaling model (y scale for a sprite means height, i.e. z in the world!).
objectToWorldMatrix.scale(smf->xscale, smf->zscale, smf->yscale);
objectToWorldMatrix.scale(smf->xscale, smf->zscale, smf->yscale / fovscale);
// Aplying model offsets (model offsets do not depend on model scalings).
objectToWorldMatrix.translate(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale);
@ -528,6 +536,10 @@ static void ParseModelDefLump(int Lump)
{
smf.flags |= MDL_NOPERPIXELLIGHTING;
}
else if (sc.Compare("scaleweaponfov"))
{
smf.flags |= MDL_SCALEWEAPONFOV;
}
else if (sc.Compare("rotating"))
{
smf.flags |= MDL_ROTATING;