diff --git a/BunnymodXT/cvars.hpp b/BunnymodXT/cvars.hpp index 5c30165b..dbcb85c7 100644 --- a/BunnymodXT/cvars.hpp +++ b/BunnymodXT/cvars.hpp @@ -53,6 +53,7 @@ X(bxt_viewmodel_semitransparent, "0") \ X(bxt_clear_color, "") \ X(bxt_force_fov, "0") \ + X(bxt_fix_widescreen_fov, "0") \ X(bxt_force_clear, "0") \ X(bxt_fix_mouse_horizontal_limit, "0") \ X(bxt_hud_game_color, "") \ diff --git a/BunnymodXT/modules/HwDLL.cpp b/BunnymodXT/modules/HwDLL.cpp index 2894609a..46940363 100644 --- a/BunnymodXT/modules/HwDLL.cpp +++ b/BunnymodXT/modules/HwDLL.cpp @@ -5133,7 +5133,10 @@ void HwDLL::RegisterCVarsAndCommandsIfNeeded() RegisterCVar(CVars::bxt_tas_ducktap_priority); if (ORIG_R_SetFrustum && scr_fov_value) + { RegisterCVar(CVars::bxt_force_fov); + RegisterCVar(CVars::bxt_fix_widescreen_fov); + } if (ORIG_R_DrawViewModel) RegisterCVar(CVars::bxt_viewmodel_fov); @@ -7451,6 +7454,22 @@ HOOK_DEF_0(HwDLL, void, __cdecl, R_SetFrustum) if (CVars::bxt_force_fov.GetFloat() >= 1.0) *scr_fov_value = CVars::bxt_force_fov.GetFloat(); + if (CVars::bxt_fix_widescreen_fov.GetBool()) + { + float ScreenWidth = static_cast(CustomHud::GetScreenInfo().iWidth); + float ScreenHeight = static_cast(CustomHud::GetScreenInfo().iHeight); + + float def_aspect_ratio = 3.0f / 4.0f; + float our_aspect_ratio = ScreenWidth / ScreenHeight; + + float fov = *scr_fov_value; + float calculated_fov = static_cast(std::atan(std::tan(fov*M_PI / 360.0f) * def_aspect_ratio * our_aspect_ratio) * 360.0f/M_PI); + + *scr_fov_value = std::clamp(calculated_fov, 10.0f, 150.0f); // Engine does the clamp of FOV if less 10 or higher than 150, let's do it too! + + // Although, it could be extended to 1 for min. value and 180 for max. value + } + ORIG_R_SetFrustum(); }