diff --git a/src/d_player.h b/src/d_player.h index 62383f53a..26f17a1a0 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -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 diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 36d206843..efbcf81d7 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -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); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 6348592af..0639bcffe 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -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; diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index d12aa1c3f..2aae72883 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -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)); diff --git a/src/p_user.c b/src/p_user.c index a5918f695..52cdc41e5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -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, diff --git a/src/r_main.c b/src/r_main.c index 94116f8fd..8ab86da29 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -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<> 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)<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)<>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); diff --git a/src/r_sky.c b/src/r_sky.c index edde4c218..1b2c43d12 100644 --- a/src/r_sky.c +++ b/src/r_sky.c @@ -75,6 +75,5 @@ void R_SetupSkyDraw(void) */ void R_SetSkyScale(void) { - fixed_t difference = vid.fdup-(vid.dup<