Merge branch 'fov-gamestate' into 'master'

Force FOV to 90 during Podium and Title Screen

Closes #1214

See merge request KartKrew/Kart!2171
This commit is contained in:
Oni 2024-04-02 17:00:53 +00:00
commit 6791bc301e
6 changed files with 38 additions and 7 deletions

View file

@ -77,7 +77,7 @@
#include "../r_state.h" #include "../r_state.h"
#include "../tables.h" #include "../tables.h"
#include "r_opengl/r_opengl.h" #include "r_opengl/r_opengl.h"
#include "../r_main.h" // for cv_fov #include "../r_main.h" // for R_FOV
#ifdef HAVE_SPHEREFRUSTRUM #ifdef HAVE_SPHEREFRUSTRUM
static GLdouble viewMatrix[16]; static GLdouble viewMatrix[16];
@ -331,7 +331,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle)
// NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function // NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function
float render_fov = FIXED_TO_FLOAT(cv_fov[viewssnum].value); float render_fov = FIXED_TO_FLOAT(R_FOV(viewssnum));
float render_fovratio = (float)BASEVIDWIDTH / (float)BASEVIDHEIGHT; // SRB2CBTODO: NEWCLIPTODO: Is this right? float render_fovratio = (float)BASEVIDWIDTH / (float)BASEVIDHEIGHT; // SRB2CBTODO: NEWCLIPTODO: Is this right?
float render_multiplier = 64.0f / render_fovratio / RMUL; float render_multiplier = 64.0f / render_fovratio / RMUL;

View file

@ -5450,7 +5450,7 @@ static void HWR_DrawSkyBackground(player_t *player)
if (cv_glskydome.value) if (cv_glskydome.value)
{ {
FTransform dometransform; FTransform dometransform;
const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd); const float fpov = FIXED_TO_FLOAT(R_FOV(viewssnum)+player->fovadd);
postimg_t *type = &postimgtype[R_GetViewNumber()]; postimg_t *type = &postimgtype[R_GetViewNumber()];
memset(&dometransform, 0x00, sizeof(FTransform)); memset(&dometransform, 0x00, sizeof(FTransform));
@ -5700,7 +5700,7 @@ static void HWR_SetShaderState(void)
static void HWR_RenderViewpoint(player_t *player, boolean drawSkyTexture, boolean timing) static void HWR_RenderViewpoint(player_t *player, boolean drawSkyTexture, boolean timing)
{ {
const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd); const float fpov = FIXED_TO_FLOAT(R_FOV(viewssnum)+player->fovadd);
postimg_t *type = &postimgtype[viewssnum]; postimg_t *type = &postimgtype[viewssnum];
{ {

View file

@ -1134,7 +1134,7 @@ void K_ObjectTracking(trackingResult_t *result, const vector3_t *point, boolean
screenHalfH = (screenHeight >> 1) << FRACBITS; screenHalfH = (screenHeight >> 1) << FRACBITS;
// Calculate FOV adjustments. // Calculate FOV adjustments.
fovDiff = cv_fov[cameraNum].value - baseFov; fovDiff = R_FOV(cameraNum) - baseFov;
fov = ((baseFov - fovDiff) / 2) - (stplyr->fovadd / 2); fov = ((baseFov - fovDiff) / 2) - (stplyr->fovadd / 2);
fovTangent = NEWTAN(FixedAngle(fov)); fovTangent = NEWTAN(FixedAngle(fov));

View file

@ -8825,6 +8825,9 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
{ {
G_PreLevelTitleCard(); G_PreLevelTitleCard();
} }
// Apply FOV override.
R_CheckFOV();
} }
TracyCZoneEnd(__zone); TracyCZoneEnd(__zone);

View file

@ -69,6 +69,7 @@ fixed_t centerxfrac, centeryfrac;
fixed_t projection[MAXSPLITSCREENPLAYERS]; fixed_t projection[MAXSPLITSCREENPLAYERS];
fixed_t projectiony[MAXSPLITSCREENPLAYERS]; // aspect ratio fixed_t projectiony[MAXSPLITSCREENPLAYERS]; // aspect ratio
fixed_t fovtan[MAXSPLITSCREENPLAYERS]; // field of view fixed_t fovtan[MAXSPLITSCREENPLAYERS]; // field of view
fixed_t g_fovcache[MAXSPLITSCREENPLAYERS];
// just for profiling purposes // just for profiling purposes
size_t framecount; size_t framecount;
@ -188,7 +189,7 @@ void SplitScreen_OnChange(void)
extern "C" void Fov_OnChange(void); extern "C" void Fov_OnChange(void);
void Fov_OnChange(void) void Fov_OnChange(void)
{ {
R_SetViewSize(); R_CheckFOV();
} }
extern "C" void ChaseCam_OnChange(void); extern "C" void ChaseCam_OnChange(void);
@ -955,6 +956,18 @@ void R_SetViewSize(void)
setsizeneeded = true; setsizeneeded = true;
} }
void R_CheckFOV(void)
{
for (UINT8 s = 0; s <= r_splitscreen; ++s)
{
if (g_fovcache[s] != R_FOV(s))
{
R_SetViewSize();
break;
}
}
}
// //
// R_ExecuteSetViewSize // R_ExecuteSetViewSize
// //
@ -997,7 +1010,8 @@ void R_ExecuteSetViewSize(void)
for (s = 0; s <= r_splitscreen; ++s) for (s = 0; s <= r_splitscreen; ++s)
{ {
fov = FixedAngle(cv_fov[s].value/2) + ANGLE_90; g_fovcache[s] = R_FOV(s);
fov = FixedAngle(g_fovcache[s]/2) + ANGLE_90;
fovtan[s] = FixedMul(FINETANGENT(fov >> ANGLETOFINESHIFT), viewmorph[s].zoomneeded); fovtan[s] = FixedMul(FINETANGENT(fov >> ANGLETOFINESHIFT), viewmorph[s].zoomneeded);
if (r_splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view if (r_splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view
fovtan[s] = 17*fovtan[s]/10; fovtan[s] = 17*fovtan[s]/10;
@ -1071,6 +1085,16 @@ void R_ExecuteSetViewSize(void)
am_recalc = true; am_recalc = true;
} }
fixed_t R_FOV(int split)
{
if (gamestate == GS_TITLESCREEN || gamestate == GS_CEREMONY)
{
return 90*FRACUNIT; // standard setting
}
return cv_fov[split].value;
}
// //
// R_Init // R_Init
// //

View file

@ -34,6 +34,7 @@ extern fixed_t centeryfrac;
extern fixed_t projection[MAXSPLITSCREENPLAYERS]; extern fixed_t projection[MAXSPLITSCREENPLAYERS];
extern fixed_t projectiony[MAXSPLITSCREENPLAYERS]; extern fixed_t projectiony[MAXSPLITSCREENPLAYERS];
extern fixed_t fovtan[MAXSPLITSCREENPLAYERS]; extern fixed_t fovtan[MAXSPLITSCREENPLAYERS];
extern fixed_t g_fovcache[MAXSPLITSCREENPLAYERS];
extern size_t validcount, linecount, loopcount, framecount; extern size_t validcount, linecount, loopcount, framecount;
@ -178,6 +179,9 @@ void R_SetViewSize(void);
// do it (sometimes explicitly called) // do it (sometimes explicitly called)
void R_ExecuteSetViewSize(void); void R_ExecuteSetViewSize(void);
fixed_t R_FOV(int split);
void R_CheckFOV(void);
void R_SetupFrame(int split); void R_SetupFrame(int split);
void R_SkyboxFrame(int split); void R_SkyboxFrame(int split);