Skip to content

Commit ba3c1cd

Browse files
committed
Automatically adjust field of view for widescreen aspect ratios
The FOV value is now always interpreted as being a 4:3 horizontal FOV value. It will be automatically scaled for different aspect ratios (which results in a horizontal FOV of ~106.26 degrees on 16:9, for example). This provides a better out of the box experience for most players, since 16:9 is the norm for gaming nowadays (or even wider on mobile). Default FOV values were changed to be less extreme at wider aspect ratios.
1 parent c526c08 commit ba3c1cd

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/game/game.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ namespace game
182182
VAR(IDF_PERSIST, fullbrightfocus, 0, 0, 3); // bitwise: 0 = don't fullbright focus, 1 = fullbright non-player1, 2 = fullbright player1
183183

184184
VAR(IDF_PERSIST, thirdpersonmodel, 0, 1, 1);
185-
VAR(IDF_PERSIST, thirdpersonfov, 90, 120, 150);
185+
VAR(IDF_PERSIST, thirdpersonfov, 90, 90, 150);
186186
FVAR(IDF_PERSIST, thirdpersonblend, 0, 1, 1);
187187
VAR(IDF_PERSIST, thirdpersoninterp, 0, 100, VAR_MAX);
188188
FVAR(IDF_PERSIST, thirdpersondist, FVAR_NONZERO, 14, 20);
@@ -197,7 +197,7 @@ namespace game
197197

198198
VAR(IDF_PERSIST, firstpersonmodel, 0, 3, 3);
199199
VAR(IDF_PERSIST, firstpersoncamera, 0, 0, 1);
200-
VAR(IDF_PERSIST, firstpersonfov, 90, 100, 150);
200+
VAR(IDF_PERSIST, firstpersonfov, 90, 90, 150);
201201
FVAR(IDF_PERSIST, firstpersondepth, 0, 0.25f, 1);
202202
FVAR(IDF_PERSIST, firstpersonbodydepth, 0, 0.65f, 1);
203203
FVAR(IDF_PERSIST, firstpersondepthfov, 0, 70, 150);
@@ -238,8 +238,8 @@ namespace game
238238
VAR(IDF_PERSIST, firstpersonslidetime, 0, 200, VAR_MAX);
239239
FVAR(IDF_PERSIST, firstpersonslideroll, -89.9f, -5.f, 89.9f);
240240

241-
VAR(IDF_PERSIST, editfov, 10, 100, 150);
242-
VAR(IDF_PERSIST, specfov, 10, 100, 150);
241+
VAR(IDF_PERSIST, editfov, 10, 90, 150);
242+
VAR(IDF_PERSIST, specfov, 10, 90, 150);
243243

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

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

683-
int fov()
683+
float fov()
684684
{
685-
if(player1->state == CS_EDITING) return editfov;
686-
if(focus == player1 && player1->state == CS_SPECTATOR) return specfov;
687-
if(thirdpersonview(true)) return thirdpersonfov;
688-
return firstpersonfov;
685+
float resultfov = 90.0f;
686+
if(player1->state == CS_EDITING) resultfov = editfov;
687+
if(focus == player1 && player1->state == CS_SPECTATOR) resultfov = specfov;
688+
if(thirdpersonview(true)) resultfov = thirdpersonfov;
689+
else resultfov = firstpersonfov;
690+
691+
// automatic FOV adjustment for wide screens
692+
// (horizontal FOV value is always specified for 4:3, but scaled for different aspect ratios)
693+
return atan(tan(resultfov * M_PI / 360.0f) * 0.75f * aspect) * 360.0f / M_PI;
689694
}
690695

691696
void checkzoom()

0 commit comments

Comments
 (0)