diff --git a/src/d_player.h b/src/d_player.h index 6ddca1622..b18fea1eb 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -549,9 +549,8 @@ typedef struct player_s UINT8 hitemvictim; UINT8 splitscreenindex; -#ifdef HWRENDER + fixed_t fovadd; // adjust FOV for hw rendering -#endif } player_t; #endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d401f8b67..d1566c6f7 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -228,8 +228,6 @@ consvar_t cv_glrenderdistance = {"gr_renderdistance", "Max", CV_SAVE, glrenderdi consvar_t cv_glhorizonlines = {"gr_horizonlines", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glportals = {"gr_portals", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_glpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_glpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -5409,7 +5407,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl // ========================================================================== static void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) { - const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd); + const float fpov = FixedToFloat(R_GetPlayerFov(player)); // set window position gl_viewwindowx = gl_baseviewwindowx; @@ -5639,8 +5637,6 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_glhorizonlines); CV_RegisterVar(&cv_glportals); - CV_RegisterVar(&cv_glfovchange); - CV_RegisterVar(&cv_glpaletterendering); CV_RegisterVar(&cv_glpalettedepth); CV_RegisterVar(&cv_glflashpal); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index cb5b0609f..63be2b1da 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -186,8 +186,6 @@ extern consvar_t cv_glrenderdistance; extern consvar_t cv_glhorizonlines; extern consvar_t cv_glportals; -extern consvar_t cv_glfovchange; - extern consvar_t cv_glpaletterendering; extern consvar_t cv_glpalettedepth; extern consvar_t cv_glflashpal; diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index dd4cf7b03..32b4abfe7 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -157,9 +157,8 @@ static const udata_field_t player_fields[] = { FIELD(player_t, grieftime, udatalib_getter_tic, udatalib_setter_tic), FIELD(player_t, griefstrikes, udatalib_getter_uint8, udatalib_setter_uint8), FIELD(player_t, splitscreenindex, udatalib_getter_uint8, player_splitscreenindex_noset), -#ifdef HWRENDER FIELD(player_t, fovadd, udatalib_getter_fixed, udatalib_setter_fixed), // Mmm yeah thats definitely synch safe -#endif + // Same as player.name { "sliproll", 0, player_sliproll_getter, player_sliproll_noset }, { "viewrollangle", 0, player_viewrollangle_getter, player_viewrollangle_noset }, @@ -882,4 +881,4 @@ int LUA_PlayerLib(lua_State *L) lua_setglobal(L, "displayplayers"); return 0; -} \ No newline at end of file +} diff --git a/src/p_user.c b/src/p_user.c index 3251f6bec..d93b719f4 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2495,8 +2495,7 @@ static void P_MovePlayer(player_t *player) return; } -#ifdef HWRENDER - if (rendermode == render_opengl && cv_glfovchange.value) + if (cv_fovchange.value) { fixed_t speed; const fixed_t runnyspeed = 20*FRACUNIT; @@ -2516,7 +2515,6 @@ static void P_MovePlayer(player_t *player) } else player->fovadd = 0; -#endif #ifdef FLOORSPLATS if (cv_shadow.value && rendermode == render_soft) diff --git a/src/r_main.c b/src/r_main.c index 15a50b314..78d6c2d31 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -143,12 +143,14 @@ static CV_PossibleValue_t maxinterpdist_cons_t[] = { {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; -static CV_PossibleValue_t fov_cons_t[] = {{5*FRACUNIT, "MIN"}, {178*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 FlipCam_OnChange(void); static void FlipCam2_OnChange(void); @@ -202,6 +204,7 @@ consvar_t cv_ripplewater = {"waterripples", "On", CV_SAVE, CV_OnOff, NULL, 0, NU // cap fov, fov too high tears software apart. consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL|CV_SAVE, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fovchange = {"fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // Okay, whoever said homremoval causes a performance hit should be shot. consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -921,12 +924,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; @@ -955,17 +956,10 @@ 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(); - // why did we calc all the software crap? #ifdef HWRENDER if (rendermode == render_opengl) @@ -980,19 +974,6 @@ void R_ExecuteSetViewSize(void) for (i = 0; i < viewwidth; i++) screenheightarray[i] = (INT16)viewheight; - // setup sky scaling - R_SetSkyScale(); - - // planes - // 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)<