Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically adjust field of view for widescreen aspect ratios #1322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ namespace game
VAR(IDF_PERSIST, fullbrightfocus, 0, 0, 3); // bitwise: 0 = don't fullbright focus, 1 = fullbright non-player1, 2 = fullbright player1

VAR(IDF_PERSIST, thirdpersonmodel, 0, 1, 1);
VAR(IDF_PERSIST, thirdpersonfov, 90, 120, 150);
VAR(IDF_PERSIST, thirdpersonfov, 90, 90, 150);
FVAR(IDF_PERSIST, thirdpersonblend, 0, 1, 1);
VAR(IDF_PERSIST, thirdpersoninterp, 0, 100, VAR_MAX);
FVAR(IDF_PERSIST, thirdpersondist, FVAR_NONZERO, 14, 20);
Expand All @@ -197,7 +197,7 @@ namespace game

VAR(IDF_PERSIST, firstpersonmodel, 0, 3, 3);
VAR(IDF_PERSIST, firstpersoncamera, 0, 0, 1);
VAR(IDF_PERSIST, firstpersonfov, 90, 100, 150);
VAR(IDF_PERSIST, firstpersonfov, 90, 90, 150);
FVAR(IDF_PERSIST, firstpersondepth, 0, 0.25f, 1);
FVAR(IDF_PERSIST, firstpersonbodydepth, 0, 0.65f, 1);
FVAR(IDF_PERSIST, firstpersondepthfov, 0, 70, 150);
Expand Down Expand Up @@ -238,8 +238,8 @@ namespace game
VAR(IDF_PERSIST, firstpersonslidetime, 0, 200, VAR_MAX);
FVAR(IDF_PERSIST, firstpersonslideroll, -89.9f, -5.f, 89.9f);

VAR(IDF_PERSIST, editfov, 10, 100, 150);
VAR(IDF_PERSIST, specfov, 10, 100, 150);
VAR(IDF_PERSIST, editfov, 10, 90, 150);
VAR(IDF_PERSIST, specfov, 10, 90, 150);

VAR(IDF_PERSIST, specresetstyle, 0, 1, 1); // 0 = back to player1, 1 = stay at camera

Expand Down Expand Up @@ -680,12 +680,17 @@ namespace game
ICOMMAND(0, isthirdperson, "i", (int *viewonly), intret(thirdpersonview(*viewonly ? true : false) ? 1 : 0));
ICOMMAND(0, thirdpersonswitch, "", (), int *n = (focus != player1 ? &followthirdperson : &thirdperson); *n = !*n);

int fov()
float fov()
{
if(player1->state == CS_EDITING) return editfov;
if(focus == player1 && player1->state == CS_SPECTATOR) return specfov;
if(thirdpersonview(true)) return thirdpersonfov;
return firstpersonfov;
float resultfov = 90.0f;
if(player1->state == CS_EDITING) resultfov = editfov;
if(focus == player1 && player1->state == CS_SPECTATOR) resultfov = specfov;
if(thirdpersonview(true)) resultfov = thirdpersonfov;
else resultfov = firstpersonfov;

// automatic FOV adjustment for wide screens
// (horizontal FOV value is always specified for 4:3, but scaled for different aspect ratios)
return atan(tan(resultfov * M_PI / 360.0f) * 0.75f * aspect) * 360.0f / M_PI;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a change that drastically changes the expected behavior of the FOV math, this should be behind an additional variable that enables/disables this. Gate it behind "fovaltaspectcorrect" variable and I think it'll be good to merge.

}

void checkzoom()
Expand Down