Skip to content

Commit

Permalink
Misc FOV changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlaux committed May 7, 2023
1 parent cb4db3b commit 5beba51
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,20 @@ int extra_level_brightness; // level brightness feature

// [Nugget] FOV from Doom Retro

int fovfx[NUMFOVFX]; // FOV effects (recoil, teleport)
int fovfx[NUMFOVFX]; // FOV effects (recoil, teleport)
static int zoomed = 0; // Current zoom state

boolean fovchange = true;
static int bfov = ORIGFOV; // Base FOV
static int rfov = ORIGFOV; // Rendered (currently applied) FOV, with effects added to it
static int bfov; // Base FOV
static int rfov; // Rendered (currently applied) FOV, with effects added to it
static float fovdiff; // Used for some corrections

static fixed_t fovscale;
static int WIDEFOVDELTA;

static int lookdirmin;
static int lookdirmax;


void (*colfunc)(void) = R_DrawColumn; // current column draw function

Expand Down Expand Up @@ -462,7 +466,7 @@ void R_SetZoom(int state)

if (zoomed != state) { fovchange = true; }

if (!strictmode && (zoom_fov - bfov))
if (STRICTMODE(zoom_fov - bfov))
{ zoomed = state; }
else
{ zoomed = ZOOM_OFF; }
Expand Down Expand Up @@ -574,6 +578,9 @@ void R_ExecuteSetViewSize (void)
{ fx += fovfx[i]; }

rfov = bfov + fx;
fovdiff = (float) ORIGFOV / rfov;
lookdirmin = LOOKDIRMIN * fovdiff;
lookdirmax = LOOKDIRMAX * fovdiff;
}

// [Nugget] FOV from Doom Retro
Expand Down Expand Up @@ -610,11 +617,11 @@ void R_ExecuteSetViewSize (void)
{
// [crispy] re-generate lookup-table for yslope[] whenever "viewheight" or "hires" change
// [Nugget] Mitigate PLAYER_SLOPE() and 'lookdir' misalignment
fixed_t dy = abs(((i-viewheight/2-(j-(LOOKDIRMIN * ORIGFOV/rfov))*viewblocks/10)<<FRACBITS)+FRACUNIT/2);
fixed_t dy = abs(((i-viewheight/2-(j-lookdirmin)*viewblocks/10)<<FRACBITS)+FRACUNIT/2);
yslopes[j][i] = FixedDiv(num, dy);
}
}
yslope = yslopes[(LOOKDIRMIN * ORIGFOV/rfov)]; // [Nugget] Mitigate PLAYER_SLOPE() and 'lookdir' misalignment
yslope = yslopes[lookdirmin]; // [Nugget] Mitigate PLAYER_SLOPE() and 'lookdir' misalignment

for (i=0 ; i<viewwidth ; i++)
{
Expand Down Expand Up @@ -757,9 +764,9 @@ void R_SetupFrame (player_t *player)
// [crispy] pitch is actual lookdir and weapon pitch
pitch = player->lookdir / MLOOKUNIT + player->recoilpitch;
}

// [Nugget] Mitigate PLAYER_SLOPE() and 'lookdir' misalignment
// by reducing the rendered pitch
pitch = pitch * ORIGFOV/rfov;
pitch *= fovdiff;

// [Nugget]: [crispy] A11Y
if (NOTSTRICTMODE(a11y_weapon_flash))
Expand All @@ -770,18 +777,18 @@ void R_SetupFrame (player_t *player)
extralight += STRICTMODE(LIGHTBRIGHT * extra_level_brightness); // level brightness feature

// [Nugget] Mitigate PLAYER_SLOPE() and 'lookdir' misalignment
if (pitch > (LOOKDIRMAX * ORIGFOV/rfov))
{ pitch = LOOKDIRMAX * ORIGFOV/rfov; }
else if (pitch < (-LOOKDIRMIN * ORIGFOV/rfov))
{ pitch = -LOOKDIRMIN * ORIGFOV/rfov; }
if (pitch > lookdirmax)
{ pitch = lookdirmax; }
else if (pitch < -lookdirmin)
{ pitch = -lookdirmin; }

// apply new yslope[] whenever "lookdir", "viewheight" or "hires" change
tempCentery = viewheight/2 + pitch * viewblocks / 10;
if (centery != tempCentery)
{
centery = tempCentery;
centeryfrac = centery << FRACBITS;
yslope = yslopes[(LOOKDIRMIN * ORIGFOV/rfov) + pitch]; // [Nugget] Mitigate PLAYER_SLOPE() and 'lookdir' misalignment
yslope = yslopes[lookdirmin + pitch]; // [Nugget] Mitigate PLAYER_SLOPE() and 'lookdir' misalignment
}

viewsin = finesine[viewangle>>ANGLETOFINESHIFT];
Expand Down

0 comments on commit 5beba51

Please sign in to comment.