diff --git a/src/common/models/model.h b/src/common/models/model.h index 3fa293073..c2b379d2f 100644 --- a/src/common/models/model.h +++ b/src/common/models/model.h @@ -47,6 +47,7 @@ struct FSpriteModelFrame float xrotate, yrotate, zrotate; float rotationCenterX, rotationCenterY, rotationCenterZ; float rotationSpeed; + float viewModelFOV; private: unsigned int flags; public: diff --git a/src/r_data/models.cpp b/src/r_data/models.cpp index 166387cd9..8a469cf2b 100644 --- a/src/r_data/models.cpp +++ b/src/r_data/models.cpp @@ -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(smf.viewModelFOV, 175.0f); + } else if (sc.Compare("rotating")) { smf.flags |= MDL_ROTATING;