Skip to content

Commit

Permalink
tr2/viewport: fix fov cropping viewport
Browse files Browse the repository at this point in the history
Resolves #2002.
  • Loading branch information
rr- committed Dec 31, 2024
1 parent e44c550 commit c01dbf7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/tr2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- fixed flare sound effects not always playing when Lara is in shallow water (#1590)
- fixed looking forward too far causing an upside down camera frame (#1594)
- fixed music not playing if triggered while the game is muted, but the volume is then increased (#2170)
- fixed game FOV being interpreted as horizontal (#2002)
- fixed software renderer not applying underwater tint (#2066, regression from 0.7)
- fixed some enemies not looking at Lara (#2080, regression from 0.6)
- fixed the camera getting stuck at the start of Home Sweet Home (#2129, regression from 0.7)
Expand Down
11 changes: 4 additions & 7 deletions src/tr2/game/viewport.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,10 @@ static void M_ApplyGameVars(const VIEWPORT *vp);

static void M_AlterFov(VIEWPORT *const vp)
{
if (vp->view_angle == 0) {
return;
}

const int16_t view_angle = vp->view_angle;
vp->game_vars.persp = vp->game_vars.win_width / 2 * Math_Cos(view_angle / 2)
/ Math_Sin(view_angle / 2);
const int32_t view_angle = vp->view_angle;
const int32_t fov_width = vp->game_vars.win_height * 320 / 240;
vp->game_vars.persp =
fov_width / 2 * Math_Cos(view_angle / 2) / Math_Sin(view_angle / 2);

vp->game_vars.flt_persp = vp->game_vars.persp;
vp->game_vars.flt_rhw_o_persp = g_RhwFactor / vp->game_vars.flt_persp;
Expand Down

0 comments on commit c01dbf7

Please sign in to comment.