From 4143c31176a39643e25883e075afe76fe32b49c2 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 23 Feb 2019 10:31:37 -0600 Subject: [PATCH] Add field-of-view support in software mode --- src/p_user.c | 15 +-------------- src/r_main.c | 17 +++++++++++------ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 76f57a9b..e26acdfd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8295,9 +8295,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (mo->eflags & MFE_VERTICALFLIP) camheight += thiscam->height; - if (splitscreen == 1) - camspeed = (3*camspeed)/4; - if (camspeed > FRACUNIT) camspeed = FRACUNIT; @@ -8351,13 +8348,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall height -= FixedMul(height, player->kartstuff[k_boostcam]); } - // in splitscreen modes, mess with the camera distances to make it feel proportional to how it feels normally - if (splitscreen == 1) // widescreen splits should get x1.5 distance - { - dist = FixedMul(dist, 3*FRACUNIT/2); - height = FixedMul(height, 3*FRACUNIT/2); - } - x = mo->x - FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); y = mo->y - FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); @@ -8623,10 +8613,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { thiscam->momx = x - thiscam->x; thiscam->momy = y - thiscam->y; - if (splitscreen == 1) // Wide-screen needs to follow faster, due to a smaller vertical:horizontal ratio of screen space - thiscam->momz = FixedMul(z - thiscam->z, (3*camspeed)/4); - else - thiscam->momz = FixedMul(z - thiscam->z, camspeed/2); + thiscam->momz = FixedMul(z - thiscam->z, camspeed/2); } thiscam->pan = pan; diff --git a/src/r_main.c b/src/r_main.c index ee613076..29f8c77e 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -56,6 +56,7 @@ INT32 centerx, centery; fixed_t centerxfrac, centeryfrac; fixed_t projection; fixed_t projectiony; // aspect ratio +fixed_t fovtan; // field of view // just for profiling purposes size_t framecount; @@ -529,7 +530,7 @@ static void R_InitTextureMapping(void) // // Calc focallength // so FIELDOFVIEW angles covers SCREENWIDTH. - focallength = FixedDiv(centerxfrac, + focallength = FixedDiv(projection, FINETANGENT(FINEANGLES/4+/*cv_fov.value*/ FIELDOFVIEW/2)); #ifdef ESLOPE @@ -644,6 +645,7 @@ void R_ExecuteSetViewSize(void) INT32 j; INT32 level; INT32 startmapl; + angle_t fov; setsizeneeded = false; @@ -672,9 +674,12 @@ void R_ExecuteSetViewSize(void) centerxfrac = centerx<> ANGLETOFINESHIFT); + if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view + fovtan *= 2; + + projection = projectiony = FixedDiv(centerxfrac, fovtan); R_InitViewBuffer(scaledviewwidth, viewheight); @@ -700,7 +705,7 @@ void R_ExecuteSetViewSize(void) for (i = 0; i < j; i++) { dy = ((i - viewheight*8)<>ANGLETOFINESHIFT)) & FINEMASK)*160)>>FRACBITS) +#define AIMINGTODY(a) FixedDiv((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)>>FRACBITS, fovtan) // recalc necessary stuff for mouseaiming // slopes are already calculated for the full possible view (which is 4*viewheight).