This commit is contained in:
Lactozilla 2024-01-17 20:02:50 -03:00
parent 3176abe2e4
commit 1d2ea9b046
8 changed files with 63 additions and 114 deletions

View file

@ -612,9 +612,7 @@ typedef struct player_s
tic_t jointime; // Timer when player joins game to change skin/color
tic_t quittime; // Time elapsed since user disconnected, zero if connected
tic_t lastinputtime; // the last tic the player has made any input
#ifdef HWRENDER
fixed_t fovadd; // adjust FOV for hw rendering
#endif
} player_t;
// Values for dashmode

View file

@ -5866,7 +5866,7 @@ static void HWR_DrawSkyBackground(player_t *player)
if (cv_glskydome.value)
{
FTransform dometransform;
const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd);
const float fpov = FixedToFloat(R_GetPlayerFov(player));
postimg_t *type;
if (splitscreen && player == &players[secondarydisplayplayer])
@ -6100,7 +6100,7 @@ static void HWR_SetShaderState(void)
// ==========================================================================
void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
{
const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd);
const float fpov = FixedToFloat(R_GetPlayerFov(player));
postimg_t *type;
if (splitscreen && player == &players[secondarydisplayplayer])
@ -6227,35 +6227,6 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
HWR_RenderBSPNode((INT32)numnodes-1);
#ifndef NEWCLIP
// Make a viewangle int so we can render things based on mouselook
if (player == &players[consoleplayer])
viewangle = localaiming;
else if (splitscreen && player == &players[secondarydisplayplayer])
viewangle = localaiming2;
// Handle stuff when you are looking farther up or down.
if ((gl_aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT))
{
dup_viewangle += ANGLE_90;
HWR_ClearClipSegs();
HWR_RenderBSPNode((INT32)numnodes-1); //left
dup_viewangle += ANGLE_90;
if (((INT32)gl_aimingangle > ANGLE_45 || (INT32)gl_aimingangle<-ANGLE_45))
{
HWR_ClearClipSegs();
HWR_RenderBSPNode((INT32)numnodes-1); //back
}
dup_viewangle += ANGLE_90;
HWR_ClearClipSegs();
HWR_RenderBSPNode((INT32)numnodes-1); //right
dup_viewangle += ANGLE_90;
}
#endif
if (cv_glbatching.value)
HWR_RenderBatches();
@ -6301,7 +6272,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
// ==========================================================================
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
{
const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd);
const float fpov = FixedToFloat(R_GetPlayerFov(player));
postimg_t *type;
const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on
@ -6453,35 +6424,6 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
HWR_RenderBSPNode((INT32)numnodes-1);
#ifndef NEWCLIP
// Make a viewangle int so we can render things based on mouselook
if (player == &players[consoleplayer])
viewangle = localaiming;
else if (splitscreen && player == &players[secondarydisplayplayer])
viewangle = localaiming2;
// Handle stuff when you are looking farther up or down.
if ((gl_aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT))
{
dup_viewangle += ANGLE_90;
HWR_ClearClipSegs();
HWR_RenderBSPNode((INT32)numnodes-1); //left
dup_viewangle += ANGLE_90;
if (((INT32)gl_aimingangle > ANGLE_45 || (INT32)gl_aimingangle<-ANGLE_45))
{
HWR_ClearClipSegs();
HWR_RenderBSPNode((INT32)numnodes-1); //back
}
dup_viewangle += ANGLE_90;
HWR_ClearClipSegs();
HWR_RenderBSPNode((INT32)numnodes-1); //right
dup_viewangle += ANGLE_90;
}
#endif
PS_STOP_TIMING(ps_bsptime);
if (cv_glbatching.value)
@ -6572,7 +6514,6 @@ CV_PossibleValue_t glanisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NU
consvar_t cv_glshaders = CVAR_INIT ("gr_shaders", "On", CV_SAVE, glshaders_cons_t, NULL);
consvar_t cv_glallowshaders = CVAR_INIT ("gr_allowclientshaders", "On", CV_NETVAR, CV_OnOff, NULL);
consvar_t cv_fovchange = CVAR_INIT ("gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL);
#ifdef ALAM_LIGHTING
consvar_t cv_gldynamiclighting = CVAR_INIT ("gr_dynamiclighting", "On", CV_SAVE, CV_OnOff, NULL);
@ -6615,8 +6556,6 @@ static void CV_glanisotropic_OnChange(void)
//added by Hurdler: console varibale that are saved
void HWR_AddCommands(void)
{
CV_RegisterVar(&cv_fovchange);
#ifdef ALAM_LIGHTING
CV_RegisterVar(&cv_glstaticlighting);
CV_RegisterVar(&cv_gldynamiclighting);

View file

@ -97,7 +97,6 @@ extern consvar_t cv_glmodelinterpolation;
extern consvar_t cv_glmodellighting;
extern consvar_t cv_glfiltermode;
extern consvar_t cv_glanisotropicmode;
extern consvar_t cv_fovchange;
extern consvar_t cv_glsolvetjoin;
extern consvar_t cv_glshearing;
extern consvar_t cv_glspritebillboarding;

View file

@ -225,9 +225,7 @@ enum player_e
player_quittime,
player_lastinputtime,
player_ping,
#ifdef HWRENDER
player_fovadd,
#endif
player_fovadd
};
static const char *const player_opt[] = {
@ -374,9 +372,7 @@ static const char *const player_opt[] = {
"quittime",
"lastinputtime",
"ping",
#ifdef HWRENDER
"fovadd",
#endif
NULL,
};
@ -834,11 +830,9 @@ static int player_get(lua_State *L)
case player_ping:
lua_pushinteger(L, playerpingtable[plr - players]);
break;
#ifdef HWRENDER
case player_fovadd:
lua_pushfixed(L, plr->fovadd);
break;
#endif
default:
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
I_Assert(lua_istable(L, -1));
@ -1357,11 +1351,9 @@ static int player_set(lua_State *L)
case player_lastinputtime:
plr->lastinputtime = (tic_t)luaL_checkinteger(L, 3);
break;
#ifdef HWRENDER
case player_fovadd:
plr->fovadd = luaL_checkfixed(L, 3);
break;
#endif
default:
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
I_Assert(lua_istable(L, -1));

View file

@ -8850,8 +8850,7 @@ void P_MovePlayer(player_t *player)
}
}
#ifdef HWRENDER
if (rendermode == render_opengl && cv_fovchange.value)
if (cv_fovchange.value)
{
fixed_t speed;
const fixed_t runnyspeed = 20*FRACUNIT;
@ -8871,7 +8870,6 @@ void P_MovePlayer(player_t *player)
}
else
player->fovadd = 0;
#endif
// Look for blocks to bust up
// Because of BT_TOUCH, we should look for blocks constantly,

View file

@ -126,11 +126,13 @@ static CV_PossibleValue_t drawdist_precip_cons_t[] = {
{1024, "1024"}, {1536, "1536"}, {2048, "2048"},
{0, "None"}, {0, NULL}};
static CV_PossibleValue_t fov_cons_t[] = {{60*FRACUNIT, "MIN"}, {179*FRACUNIT, "MAX"}, {0, NULL}};
static CV_PossibleValue_t fov_cons_t[] = {{MINFOV*FRACUNIT, "MIN"}, {MAXFOV*FRACUNIT, "MAX"}, {0, NULL}};
static CV_PossibleValue_t translucenthud_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}};
static CV_PossibleValue_t maxportals_cons_t[] = {{0, "MIN"}, {12, "MAX"}, {0, NULL}}; // lmao rendering 32 portals, you're a card
static CV_PossibleValue_t homremoval_cons_t[] = {{0, "No"}, {1, "Yes"}, {2, "Flash"}, {0, NULL}};
static void R_SetFov(fixed_t playerfov);
static void Fov_OnChange(void);
static void ChaseCam_OnChange(void);
static void ChaseCam2_OnChange(void);
@ -157,8 +159,8 @@ consvar_t cv_translucency = CVAR_INIT ("translucency", "On", CV_SAVE, CV_OnOff,
consvar_t cv_drawdist = CVAR_INIT ("drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL);
consvar_t cv_drawdist_nights = CVAR_INIT ("drawdist_nights", "2048", CV_SAVE, drawdist_cons_t, NULL);
consvar_t cv_drawdist_precip = CVAR_INIT ("drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL);
//consvar_t cv_precipdensity = CVAR_INIT ("precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL);
consvar_t cv_fov = CVAR_INIT ("fov", "90", CV_SAVE|CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange);
consvar_t cv_fovchange = CVAR_INIT ("fovchange", "Off", CV_SAVE, CV_OnOff, NULL);
// Okay, whoever said homremoval causes a performance hit should be shot.
consvar_t cv_homremoval = CVAR_INIT ("homremoval", "No", CV_SAVE, homremoval_cons_t, NULL);
@ -206,10 +208,6 @@ void SplitScreen_OnChange(void)
}
static void Fov_OnChange(void)
{
// Shouldn't be needed with render parity?
//if ((netgame || multiplayer) && !cv_debug && cv_fov.value != 90*FRACUNIT)
// CV_Set(&cv_fov, cv_fov.defaultvalue);
R_SetViewSize();
}
@ -900,12 +898,10 @@ void R_SetViewSize(void)
//
void R_ExecuteSetViewSize(void)
{
fixed_t dy;
INT32 i;
INT32 j;
INT32 level;
INT32 startmapl;
angle_t fov;
setsizeneeded = false;
@ -928,37 +924,14 @@ void R_ExecuteSetViewSize(void)
centerxfrac = centerx<<FRACBITS;
centeryfrac = centery<<FRACBITS;
fov = FixedAngle(cv_fov.value/2) + ANGLE_90;
fovtan = FixedMul(FINETANGENT(fov >> ANGLETOFINESHIFT), viewmorph.zoomneeded);
if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view
fovtan = 17*fovtan/10;
projection = projectiony = FixedDiv(centerxfrac, fovtan);
R_SetFov(cv_fov.value);
R_InitViewBuffer(scaledviewwidth, viewheight);
R_InitTextureMapping();
// thing clipping
for (i = 0; i < viewwidth; i++)
screenheightarray[i] = (INT16)viewheight;
// setup sky scaling
R_SetSkyScale();
// planes
if (rendermode == render_soft)
{
// this is only used for planes rendering in software mode
j = viewheight*16;
for (i = 0; i < j; i++)
{
dy = (i - viewheight*8)<<FRACBITS;
dy = FixedMul(abs(dy), fovtan);
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
}
}
memset(scalelight, 0xFF, sizeof(scalelight));
// Calculate the light levels to use for each level/scale combination.
@ -988,6 +961,36 @@ void R_ExecuteSetViewSize(void)
am_recalc = true;
}
fixed_t R_GetPlayerFov(player_t *player)
{
fixed_t fov = cv_fov.value + player->fovadd;
return max(MINFOV*FRACUNIT, min(fov, MAXFOV*FRACUNIT));
}
static void R_SetFov(fixed_t playerfov)
{
angle_t fov = FixedAngle(playerfov/2) + ANGLE_90;
fovtan = FixedMul(FINETANGENT(fov >> ANGLETOFINESHIFT), viewmorph.zoomneeded);
if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view
fovtan = 17*fovtan/10;
// this is only used for planes rendering in software mode
INT32 j = viewheight*16;
for (INT32 i = 0; i < j; i++)
{
fixed_t dy = (i - viewheight*8)<<FRACBITS;
dy = FixedMul(abs(dy), fovtan);
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
}
projection = projectiony = FixedDiv(centerxfrac, fovtan);
R_InitTextureMapping();
// setup sky scaling
R_SetSkyScale();
}
//
// R_Init
//
@ -1477,6 +1480,8 @@ static void Mask_Post (maskcount_t* m)
// I mean, there is a win16lock() or something that lasts all the rendering,
// so maybe we should release screen lock before each netupdate below..?
static fixed_t viewfov[2];
void R_RenderPlayerView(player_t *player)
{
INT32 nummasks = 1;
@ -1490,6 +1495,19 @@ void R_RenderPlayerView(player_t *player)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 32+(timeinmap&15));
}
fixed_t fov = R_GetPlayerFov(player);
if (player == &players[displayplayer] && viewfov[0] != fov)
{
viewfov[0] = fov;
R_SetFov(fov);
}
else if (player == &players[secondarydisplayplayer] && viewfov[1] != fov)
{
viewfov[1] = fov;
R_SetFov(fov);
}
R_SetupFrame(player);
framecount++;
validcount++;
@ -1626,6 +1644,7 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_drawdist);
CV_RegisterVar(&cv_drawdist_nights);
CV_RegisterVar(&cv_drawdist_precip);
CV_RegisterVar(&cv_fovchange);
CV_RegisterVar(&cv_fov);
CV_RegisterVar(&cv_chasecam);

View file

@ -33,6 +33,9 @@ extern fixed_t fovtan;
// WARNING: a should be unsigned but to add with 2048, it isn't!
#define AIMINGTODY(a) FixedDiv((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160), fovtan)
#define MINFOV 60
#define MAXFOV 179
extern size_t validcount, linecount, loopcount, framecount;
// The fraction of a tic being drawn (for interpolation between two tics)
@ -118,7 +121,7 @@ extern consvar_t cv_shadow;
extern consvar_t cv_ffloorclip, cv_spriteclip;
extern consvar_t cv_translucency;
extern consvar_t cv_drawdist, cv_drawdist_nights, cv_drawdist_precip;
extern consvar_t cv_fov;
extern consvar_t cv_fov, cv_fovchange;
extern consvar_t cv_skybox;
extern consvar_t cv_tailspickup;
@ -135,6 +138,8 @@ void R_SetViewSize(void);
// do it (sometimes explicitly called)
void R_ExecuteSetViewSize(void);
fixed_t R_GetPlayerFov(player_t *player);
void R_SetupFrame(player_t *player);
void R_SkyboxFrame(player_t *player);

View file

@ -75,6 +75,5 @@ void R_SetupSkyDraw(void)
*/
void R_SetSkyScale(void)
{
fixed_t difference = vid.fdup-(vid.dup<<FRACBITS);
skyscale = FixedDiv(fovtan, vid.fdup+difference);
skyscale = FixedDiv(fovtan, FixedDiv(vid.width*FRACUNIT, BASEVIDWIDTH*FRACUNIT));
}