Skip to content

Commit abf3d6c

Browse files
authored
Added bxt_fix_widescreen_fov (thank to Muty for the idea) (#448)
* Added bxt_fix_widescreen_fov (thank to Muty for the idea) * Allow to work 'bxt_fix_widescreen_fov' in combination with 'bxt_force_fov'
1 parent e3c4e3c commit abf3d6c

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

BunnymodXT/cvars.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
X(bxt_viewmodel_semitransparent, "0") \
5454
X(bxt_clear_color, "") \
5555
X(bxt_force_fov, "0") \
56+
X(bxt_fix_widescreen_fov, "0") \
5657
X(bxt_force_clear, "0") \
5758
X(bxt_fix_mouse_horizontal_limit, "0") \
5859
X(bxt_hud_game_color, "") \

BunnymodXT/modules/HwDLL.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5133,7 +5133,10 @@ void HwDLL::RegisterCVarsAndCommandsIfNeeded()
51335133
RegisterCVar(CVars::bxt_tas_ducktap_priority);
51345134

51355135
if (ORIG_R_SetFrustum && scr_fov_value)
5136+
{
51365137
RegisterCVar(CVars::bxt_force_fov);
5138+
RegisterCVar(CVars::bxt_fix_widescreen_fov);
5139+
}
51375140

51385141
if (ORIG_R_DrawViewModel)
51395142
RegisterCVar(CVars::bxt_viewmodel_fov);
@@ -7451,6 +7454,22 @@ HOOK_DEF_0(HwDLL, void, __cdecl, R_SetFrustum)
74517454
if (CVars::bxt_force_fov.GetFloat() >= 1.0)
74527455
*scr_fov_value = CVars::bxt_force_fov.GetFloat();
74537456

7457+
if (CVars::bxt_fix_widescreen_fov.GetBool())
7458+
{
7459+
float ScreenWidth = static_cast<float>(CustomHud::GetScreenInfo().iWidth);
7460+
float ScreenHeight = static_cast<float>(CustomHud::GetScreenInfo().iHeight);
7461+
7462+
float def_aspect_ratio = 3.0f / 4.0f;
7463+
float our_aspect_ratio = ScreenWidth / ScreenHeight;
7464+
7465+
float fov = *scr_fov_value;
7466+
float calculated_fov = static_cast<float>(std::atan(std::tan(fov*M_PI / 360.0f) * def_aspect_ratio * our_aspect_ratio) * 360.0f/M_PI);
7467+
7468+
*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!
7469+
7470+
// Although, it could be extended to 1 for min. value and 180 for max. value
7471+
}
7472+
74547473
ORIG_R_SetFrustum();
74557474
}
74567475

0 commit comments

Comments
 (0)