From 421d1da2053c7bb1ba74707bf5d0220c27605072 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 25 Jan 2020 19:02:52 -0800 Subject: [PATCH 01/30] Squashed commit of the following: commit ec89015662e12dada02877feb9309b565a07b2a4 Author: fickleheart Date: Sat Jan 18 11:19:59 2020 -0600 Fix loss of aimingtody precision at high FOV commit f6efe19fca206f972ebe567051648b3b11f900c2 Author: fickleheart Date: Sat Jan 18 11:15:36 2020 -0600 Use generally higher zooms and fix fuzzy edges commit 5757f24342f9dfdebe7bedc226f237bd0aea5cca Author: fickleheart Date: Sat Jan 18 10:53:45 2020 -0600 Reduce the number of distinct roll angles commit 8679606ebb56975a93b7140184b45170b82bc3fe Author: fickleheart Date: Sat Jan 18 10:53:23 2020 -0600 Remove a couple adds from each pixel of morph mapping commit af4479924ad616ddf50daee4d1886a59f159607a Author: fickleheart Date: Sat Jan 18 10:53:00 2020 -0600 Fully clip drawing to roll-used screen bounds commit 8868fc4d8abce1b6393303155e758921f7ef9e4f Author: fickleheart Date: Sat Jan 18 00:16:18 2020 -0600 Fix lighting discrepancies between different FOVs commit 1d221a453a183d3933b9176436e91efca9632011 Author: fickleheart Date: Fri Jan 17 23:21:11 2020 -0600 Avoid rendering unused left/right edges of screen while rolling commit 21ccefe4eb96e3b3f3216025f40d6271faaac206 Author: fickleheart Date: Fri Jan 17 22:03:16 2020 -0600 Fix sky texture scaling wrong with fov changes commit 7bd9344dd01cf541d86d3e7965e7037fb85ca494 Author: fickleheart Date: Fri Jan 17 21:55:16 2020 -0600 I think this fixes the compile errors commit 64c4a4c02c6a59264446e9a43593e7397b774baa Author: fickleheart Date: Fri Jan 17 20:39:38 2020 -0600 Fisheye lens experiments commit 2b7d75126e8e8641a4b413c74b3c65da87e0d309 Author: fickleheart Date: Fri Jan 17 20:39:15 2020 -0600 Add DBG_VIEWMORPH to view pre-transformed view commit 84329fcd2677a42860f986e06b901434bc44966e Author: fickleheart Date: Fri Jan 17 19:01:45 2020 -0600 OGL can have little a viewroll commit 7cf563eadd0c2a4e1977c7024ef40975159e5aff Author: fickleheart Date: Fri Jan 17 18:32:13 2020 -0600 Un/archive viewrollangle in netsaves commit d63aa1031e4c26d0fe6f077e15764aa27c55005b Merge: e23f632cd 9a1cb0e30 Author: fickleheart Date: Fri Jan 17 18:27:15 2020 -0600 Merge remote-tracking branch 'upstream/next' into viewroll commit e23f632cdbc687039ec25297ae0105142135e1a1 Author: fickleheart Date: Tue Jan 14 23:44:21 2020 -0600 Clean up fisheye and fix crashes commit cdbea0be26067a5774778ba51a18df7aa661ce80 Author: fickleheart Date: Tue Jan 14 23:30:39 2020 -0600 Revert "LMAO fisheye" This reverts commit cd957d84f7332fc71ebd1924aaa2b533684cc07d. commit cd957d84f7332fc71ebd1924aaa2b533684cc07d Author: fickleheart Date: Tue Jan 14 23:30:19 2020 -0600 LMAO fisheye commit c25e9696760afa898f24acab9ff43378e4156499 Author: fickleheart Date: Tue Jan 14 23:29:56 2020 -0600 wip viewroll stuff --- src/d_main.c | 6 + src/d_player.h | 2 + src/doomdef.h | 3 +- src/hardware/hw_main.c | 16 +- src/hardware/r_opengl/r_opengl.c | 3 +- src/p_user.c | 2 + src/r_draw8.c | 146 +++++++++++++- src/r_main.c | 318 ++++++++++++++++++++++++++++++- src/r_main.h | 6 + src/r_segs.c | 14 +- src/r_sky.c | 5 +- src/r_things.c | 4 +- 12 files changed, 501 insertions(+), 24 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 2c02565dc..3ee3e94c9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -287,6 +287,9 @@ static void D_Display(void) if (vid.recalc) SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc() + if (rendermode == render_soft && !splitscreen) + R_CheckViewMorph(); + // change the view size if needed if (setsizeneeded) { @@ -496,6 +499,9 @@ static void D_Display(void) if (rendermode == render_soft) { + if (!splitscreen) + R_ApplyViewMorph(); + for (i = 0; i <= splitscreen; i++) { if (postimgtype[i]) diff --git a/src/d_player.h b/src/d_player.h index 114674ff5..90370c796 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -369,6 +369,8 @@ typedef struct player_s // bounded/scaled total momentum. //fixed_t bob; + angle_t viewrollangle; + // Mouse aiming, where the guy is looking at! // It is updated with cmd->aiming. angle_t aiming; diff --git a/src/doomdef.h b/src/doomdef.h index 79ab2e13a..d9627709e 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -518,6 +518,7 @@ extern INT32 cv_debug; #define DBG_MEMORY 0x0200 #define DBG_SETUP 0x0400 #define DBG_LUA 0x0800 +#define DBG_VIEWMORPH 0x2000 // ======================= // Misc stuff for later... @@ -528,7 +529,7 @@ extern UINT8 shiftdown, ctrldown, altdown; extern boolean capslock; // WARNING: a should be unsigned but to add with 2048, it isn't! -#define AIMINGTODY(a) (FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160) +#define AIMINGTODY(a) FixedDiv((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160), fovtan) // if we ever make our alloc stuff... #define ZZ_Alloc(x) Z_Malloc(x, PU_STATIC, NULL) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9b7b31e49..26ca13819 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4471,7 +4471,7 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) static boolean drewsky = false; -void HWR_DrawSkyBackground(float fpov) +void HWR_DrawSkyBackground(player_t *player, float fpov) { FTransform dometransform; @@ -4496,6 +4496,12 @@ void HWR_DrawSkyBackground(float fpov) dometransform.scalez = 1; dometransform.fovxangle = fpov; // Tails dometransform.fovyangle = fpov; // Tails + if (player->viewrollangle != 0) + { + fixed_t rol = AngleFixed(player->viewrollangle); + atransform.rollangle = FIXED_TO_FLOAT(rol); + atransform.roll = true; + } dometransform.splitscreen = splitscreen; HWR_GetTexture(texturetranslation[skytexture]); @@ -4617,6 +4623,12 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails + if (player->viewrollangle != 0) + { + fixed_t rol = AngleFixed(player->viewrollangle); + atransform.rollangle = FIXED_TO_FLOAT(rol); + atransform.roll = true; + } atransform.splitscreen = splitscreen; for (i = 0; i <= splitscreen; i++) @@ -4640,7 +4652,7 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) ST_doPaletteStuff(); // Draw the sky background. - HWR_DrawSkyBackground(fpov); + HWR_DrawSkyBackground(player, fpov); if (skybox) drewsky = true; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index eef723e51..73cb50732 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3095,7 +3095,8 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) else pglScalef(stransform->scalex, stransform->scaley, -stransform->scalez); - pglMatrixMode(GL_MODELVIEW); + if (stransform->roll) + pglRotatef(stransform->rollangle, 0.0f, 0.0f, 1.0f); pglRotatef(stransform->anglex, 1.0f, 0.0f, 0.0f); pglRotatef(stransform->angley+270.0f, 0.0f, 1.0f, 0.0f); pglTranslatef(-stransform->x, -stransform->z, -stransform->y); diff --git a/src/p_user.c b/src/p_user.c index cb6b7bd62..fdb9a457a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5165,6 +5165,8 @@ static void P_NiGHTSMovement(player_t *player) else // AngleFixed(R_PointToAngle2()) results in slight inaccuracy! Don't use it unless movement is on both axises. newangle = (INT16)FixedInt(AngleFixed(R_PointToAngle2(0,0, cmd->sidemove*FRACUNIT, cmd->forwardmove*FRACUNIT))); + newangle -= player->viewrollangle / ANG1; + if (newangle < 0 && moved) newangle = (INT16)(360+newangle); } diff --git a/src/r_draw8.c b/src/r_draw8.c index 37d93d162..b2aabe3e5 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -643,6 +643,7 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) } } +#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) /** \brief The R_DrawTiltedSpan_8 function Draw slopes! Holy sheit! @@ -668,7 +669,7 @@ void R_DrawTiltedSpan_8(void) // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; lightend = (iz + ds_sz.x*width) * planelightfloat; @@ -804,7 +805,7 @@ void R_DrawTiltedTranslucentSpan_8(void) // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; lightend = (iz + ds_sz.x*width) * planelightfloat; @@ -915,6 +916,145 @@ void R_DrawTiltedTranslucentSpan_8(void) #endif } +#ifndef NOWATER +/** \brief The R_DrawTiltedTranslucentWaterSpan_8 function + Like DrawTiltedTranslucentSpan, but for water +*/ +void R_DrawTiltedTranslucentWaterSpan_8(void) +{ + // x1, x2 = ds_x1, ds_x2 + int width = ds_x2 - ds_x1; + double iz, uz, vz; + UINT32 u, v; + int i; + + UINT8 *source; + UINT8 *colormap; + UINT8 *dest; + UINT8 *dsrc; + + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); + + // Lighting is simple. It's just linear interpolation from start to end + { + float planelightfloat = PLANELIGHTFLOAT; + float lightstart, lightend; + + lightend = (iz + ds_szp->x*width) * planelightfloat; + lightstart = iz * planelightfloat; + + R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); + //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); + } + + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); + + dest = ylookup[ds_y] + columnofs[ds_x1]; + dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; + source = ds_source; + //colormap = ds_colormap; + +#if 0 // The "perfect" reference version of this routine. Pretty slow. + // Use it only to see how things are supposed to look. + i = 0; + do + { + double z = 1.f/iz; + u = (INT64)(uz*z) + viewx; + v = (INT64)(vz*z) + viewy; + + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + dest++; + iz += ds_szp->x; + uz += ds_sup->x; + vz += ds_svp->x; + } while (--width >= 0); +#else +#define SPANSIZE 16 +#define INVSPAN 0.0625f + + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; + + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; + //x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (i = SPANSIZE-1; i >= 0; i--) + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + dest++; + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = (INT64)(startu); + v = (INT64)(startv); + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + } + else + { + double left = width; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + left = 1.f/left; + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (; width != 0; width--) + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + dest++; + u += stepu; + v += stepv; + } + } + } +#endif +} +#endif // NOWATER + void R_DrawTiltedSplat_8(void) { // x1, x2 = ds_x1, ds_x2 @@ -938,7 +1078,7 @@ void R_DrawTiltedSplat_8(void) // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; lightend = (iz + ds_sz.x*width) * planelightfloat; diff --git a/src/r_main.c b/src/r_main.c index 5f3639ded..fce485812 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -622,6 +622,303 @@ static inline void R_InitLightTables(void) } } +//#define WOUGHMP_WOUGHMP // I got a fish-eye lens - I'll make a rap video with a couple of friends +// it's kinda laggy sometimes + +static struct { + angle_t rollangle; // pre-shifted by fineshift +#ifdef WOUGHMP_WOUGHMP + fixed_t fisheye; +#endif + + fixed_t zoomneeded; + INT32 *scrmap; + INT32 scrmapsize; + + INT32 x1; // clip rendering horizontally for efficiency + INT16 ceilingclip[MAXVIDWIDTH], floorclip[MAXVIDWIDTH]; + + boolean use; +} viewmorph = { + 0, +#ifdef WOUGHMP_WOUGHMP + 0, +#endif + + FRACUNIT, + NULL, + 0, + + 0, + {}, {}, + + false +}; + +void R_CheckViewMorph(void) +{ + float zoomfactor, rollcos, rollsin; + float x1, y1, x2, y2; + fixed_t temp; + INT32 end, vx, vy, pos, usedpos; + INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2; +#ifdef WOUGHMP_WOUGHMP + float fisheyemap[MAXVIDWIDTH/2 + 1]; +#endif + + angle_t rollangle = players[displayplayer].viewrollangle; +#ifdef WOUGHMP_WOUGHMP + fixed_t fisheye = cv_cam2_turnmultiplier.value; // temporary test value +#endif + + rollangle >>= ANGLETOFINESHIFT; + rollangle = ((rollangle+2) & ~3) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. + +#ifdef WOUGHMP_WOUGHMP + fisheye &= ~0x7FF; // Same +#endif + + if (rollangle == viewmorph.rollangle && +#ifdef WOUGHMP_WOUGHMP + fisheye == viewmorph.fisheye && +#endif + viewmorph.scrmapsize == vid.width*vid.height) + return; // No change + + viewmorph.rollangle = rollangle; +#ifdef WOUGHMP_WOUGHMP + viewmorph.fisheye = fisheye; +#endif + + if (viewmorph.rollangle == 0 +#ifdef WOUGHMP_WOUGHMP + && viewmorph.fisheye == 0 +#endif + ) + { + viewmorph.use = false; + viewmorph.x1 = 0; + if (viewmorph.zoomneeded != FRACUNIT) + R_SetViewSize(); + viewmorph.zoomneeded = FRACUNIT; + + return; + } + + if (viewmorph.scrmapsize != vid.width*vid.height) + { + if (viewmorph.scrmap) + free(viewmorph.scrmap); + viewmorph.scrmap = malloc(vid.width*vid.height * sizeof(INT32)); + viewmorph.scrmapsize = vid.width*vid.height; + } + + temp = FINECOSINE(rollangle); + rollcos = FIXED_TO_FLOAT(temp); + temp = FINESINE(rollangle); + rollsin = FIXED_TO_FLOAT(temp); + + // Calculate maximum zoom needed + x1 = (vid.width*fabsf(rollcos) + vid.height*fabsf(rollsin)) / vid.width; + y1 = (vid.height*fabsf(rollcos) + vid.width*fabsf(rollsin)) / vid.height; + +#ifdef WOUGHMP_WOUGHMP + if (fisheye) + { + float f = FIXED_TO_FLOAT(fisheye); + for (vx = 0; vx <= halfwidth; vx++) + fisheyemap[vx] = 1.0f / cos(atan(vx * f / halfwidth)); + + f = cos(atan(f)); + if (f < 1.0f) + { + x1 /= f; + y1 /= f; + } + } +#endif + + temp = max(x1, y1)*FRACUNIT; + if (temp < FRACUNIT) + temp = FRACUNIT; + else + temp |= 0x3FFF; // Limit how many times the viewport needs to be recalculated + + //CONS_Printf("Setting zoom to %f\n", FIXED_TO_FLOAT(temp)); + + if (temp != viewmorph.zoomneeded) + { + viewmorph.zoomneeded = temp; + R_SetViewSize(); + } + + zoomfactor = FIXED_TO_FLOAT(viewmorph.zoomneeded); + + end = vid.width * vid.height - 1; + + pos = 0; + + // Pre-multiply rollcos and rollsin to use for positional stuff + rollcos /= zoomfactor; + rollsin /= zoomfactor; + + x1 = -(halfwidth * rollcos - halfheight * rollsin); + y1 = -(halfheight * rollcos + halfwidth * rollsin); + +#ifdef WOUGHMP_WOUGHMP + if (fisheye) + viewmorph.x1 = (INT32)(halfwidth - (halfwidth * fabsf(rollcos) + halfheight * fabsf(rollsin)) * fisheyemap[halfwidth]); + else +#endif + viewmorph.x1 = (INT32)(halfwidth - (halfwidth * fabsf(rollcos) + halfheight * fabsf(rollsin))); + //CONS_Printf("saving %d cols\n", viewmorph.x1); + + // Set ceilingclip and floorclip + for (vx = 0; vx < vid.width; vx++) + { + viewmorph.ceilingclip[vx] = vid.height; + viewmorph.floorclip[vx] = -1; + } + x2 = x1; + y2 = y1; + for (vx = 0; vx < vid.width; vx++) + { + INT16 xa, ya, xb, yb; + xa = x2+halfwidth; + ya = y2+halfheight-1; + xb = vid.width-1-xa; + yb = vid.height-1-ya; + + viewmorph.ceilingclip[xa] = min(viewmorph.ceilingclip[xa], ya); + viewmorph.floorclip[xa] = max(viewmorph.floorclip[xa], ya); + viewmorph.ceilingclip[xb] = min(viewmorph.ceilingclip[xb], yb); + viewmorph.floorclip[xb] = max(viewmorph.floorclip[xb], yb); + x2 += rollcos; + y2 += rollsin; + } + x2 = x1; + y2 = y1; + for (vy = 0; vy < vid.height; vy++) + { + INT16 xa, ya, xb, yb; + xa = x2+halfwidth; + ya = y2+halfheight; + xb = vid.width-1-xa; + yb = vid.height-1-ya; + + viewmorph.ceilingclip[xa] = min(viewmorph.ceilingclip[xa], ya); + viewmorph.floorclip[xa] = max(viewmorph.floorclip[xa], ya); + viewmorph.ceilingclip[xb] = min(viewmorph.ceilingclip[xb], yb); + viewmorph.floorclip[xb] = max(viewmorph.floorclip[xb], yb); + x2 -= rollsin; + y2 += rollcos; + } + + //CONS_Printf("Top left corner is %f %f\n", x1, y1); + +#ifdef WOUGHMP_WOUGHMP + if (fisheye) + { + for (vy = 0; vy < halfheight; vy++) + { + x2 = x1; + y2 = y1; + x1 -= rollsin; + y1 += rollcos; + + for (vx = 0; vx < vid.width; vx++) + { + usedx = halfwidth + x2*fisheyemap[(int) floorf(fabsf(y2*zoomfactor))]; + usedy = halfheight + y2*fisheyemap[(int) floorf(fabsf(x2*zoomfactor))]; + + usedpos = usedx + usedy*vid.width; + + viewmorph.scrmap[pos] = usedpos; + viewmorph.scrmap[end-pos] = end-usedpos; + + x2 += rollcos; + y2 += rollsin; + pos++; + } + } + } + else + { +#endif + x1 += halfwidth; + y1 += halfheight; + + for (vy = 0; vy < halfheight; vy++) + { + x2 = x1; + y2 = y1; + x1 -= rollsin; + y1 += rollcos; + + for (vx = 0; vx < vid.width; vx++) + { + usedx = x2; + usedy = y2; + + usedpos = usedx + usedy*vid.width; + + viewmorph.scrmap[pos] = usedpos; + viewmorph.scrmap[end-pos] = end-usedpos; + + x2 += rollcos; + y2 += rollsin; + pos++; + } + } +#ifdef WOUGHMP_WOUGHMP + } +#endif + + viewmorph.use = true; +} + +void R_ApplyViewMorph(void) +{ + UINT8 *tmpscr = screens[4]; + UINT8 *srcscr = screens[0]; + INT32 p, end = vid.width * vid.height; + + if (!viewmorph.use) + return; + + if (cv_debug & DBG_VIEWMORPH) + { + UINT8 border = 32; + UINT8 grid = 160; + INT32 ws = vid.width / 4; + INT32 hs = vid.width * (vid.height / 4); + + memcpy(tmpscr, srcscr, vid.width*vid.height); + for (p = 0; p < vid.width; p++) + { + tmpscr[viewmorph.scrmap[p]] = border; + tmpscr[viewmorph.scrmap[p + hs]] = grid; + tmpscr[viewmorph.scrmap[p + hs*2]] = grid; + tmpscr[viewmorph.scrmap[p + hs*3]] = grid; + tmpscr[viewmorph.scrmap[end - 1 - p]] = border; + } + for (p = vid.width; p < end; p += vid.width) + { + tmpscr[viewmorph.scrmap[p]] = border; + tmpscr[viewmorph.scrmap[p + ws]] = grid; + tmpscr[viewmorph.scrmap[p + ws*2]] = grid; + tmpscr[viewmorph.scrmap[p + ws*3]] = grid; + tmpscr[viewmorph.scrmap[end - 1 - p]] = border; + } + } + else + for (p = 0; p < end; p++) + tmpscr[p] = srcscr[viewmorph.scrmap[p]]; + + VID_BlitLinearScreen(tmpscr, screens[0], + vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.width); +} + // // R_SetViewSize @@ -676,7 +973,7 @@ void R_ExecuteSetViewSize(void) centeryfrac = centery<> ANGLETOFINESHIFT); + fovtan = FixedMul(FINETANGENT(fov >> ANGLETOFINESHIFT), viewmorph.zoomneeded); if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view fovtan = 17*fovtan/10; @@ -833,7 +1130,7 @@ static void R_SetupFreelook(void) if (rendermode == render_soft) { - dy = (AIMINGTODY(aimingangle)/fovtan) * viewwidth/BASEVIDWIDTH; + dy = (AIMINGTODY(aimingangle)>>FRACBITS) * viewwidth/BASEVIDWIDTH; yslope = &yslopetab[viewheight*8 - (viewheight/2 + dy)]; } centery = (viewheight/2) + dy; @@ -1389,9 +1686,22 @@ void R_RenderPlayerView(player_t *player) validcount++; // Clear buffers. - R_ClearClipSegs(); - R_ClearDrawSegs(); R_ClearPlanes(); + if (viewmorph.use) + { + portalclipstart = viewmorph.x1; + portalclipend = viewwidth-viewmorph.x1-1; + R_PortalClearClipSegs(portalclipstart, portalclipend); + memcpy(ceilingclip, viewmorph.ceilingclip, sizeof(INT16)*vid.width); + memcpy(floorclip, viewmorph.floorclip, sizeof(INT16)*vid.width); + } + else + { + portalclipstart = 0; + portalclipend = viewwidth-1; + R_ClearClipSegs(); + } + R_ClearDrawSegs(); R_ClearSprites(); #ifdef FLOORSPLATS R_ClearVisibleFloorSplats(); diff --git a/src/r_main.h b/src/r_main.h index 38a589682..f26fe14fb 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -26,6 +26,7 @@ extern INT32 centerx, centery; extern fixed_t centerxfrac, centeryfrac; extern fixed_t projection, projectiony; +extern fixed_t fovtan; // field of view extern size_t validcount, linecount, loopcount, framecount; @@ -45,6 +46,8 @@ extern size_t validcount, linecount, loopcount, framecount; #define MAXLIGHTZ 128 #define LIGHTZSHIFT 20 +#define LIGHTRESOLUTIONFIX (640*fovtan/vid.width) + extern lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; extern lighttable_t *scalelightfixed[MAXLIGHTSCALE]; extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; @@ -86,6 +89,9 @@ extern consvar_t cv_tailspickup; // Called by startup code. void R_Init(void); +void R_CheckViewMorph(void); +void R_ApplyViewMorph(void); + // just sets setsizeneeded true extern boolean setsizeneeded; void R_SetViewSize(void); diff --git a/src/r_segs.c b/src/r_segs.c index c531be52d..8d99a4947 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -194,7 +194,7 @@ static void R_DrawWallSplats(void) // draw the columns for (dc_x = x1; dc_x <= x2; dc_x++, spryscale += rw_scalestep) { - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; dc_colormap = walllights[pindex]; @@ -547,7 +547,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) else xwalllights = scalelight[rlight->lightnum]; - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; @@ -596,7 +596,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } // calculate lighting - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; @@ -1080,7 +1080,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else xwalllights = scalelight[lightnum]; - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; @@ -1181,7 +1181,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) } // calculate lighting - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; @@ -1374,7 +1374,7 @@ static void R_RenderSegLoop (void) if (segtextured) { // calculate lighting - pindex = FixedMul(rw_scale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; @@ -1411,7 +1411,7 @@ static void R_RenderSegLoop (void) else xwalllights = scalelight[lightnum]; - pindex = FixedMul(rw_scale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; diff --git a/src/r_sky.c b/src/r_sky.c index fe1630e90..f42907a54 100644 --- a/src/r_sky.c +++ b/src/r_sky.c @@ -80,8 +80,5 @@ void R_SetupSkyDraw(void) void R_SetSkyScale(void) { fixed_t difference = vid.fdupx-(vid.dupx< 1) - scr *= 2; - skyscale = FixedDiv(scr, vid.fdupx+difference); + skyscale = FixedDiv(fovtan, vid.fdupx+difference); } diff --git a/src/r_things.c b/src/r_things.c index 9cb35e191..9e63cd7ed 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1112,7 +1112,7 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) { - lindex = FixedMul(sprite->xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT); + lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); if (lindex >= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; @@ -1495,7 +1495,7 @@ static void R_ProjectSprite(mobj_t *thing) else { // diminished light - lindex = FixedMul(xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT); + lindex = FixedMul(xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); if (lindex >= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; From cfa8485eeea006cfcff24be32de6d22d6e21f3e5 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 25 Jan 2020 19:20:20 -0800 Subject: [PATCH 02/30] lmao 2.2 --- src/hardware/hw_defs.h | 2 ++ src/r_draw.h | 2 ++ src/r_draw8.c | 26 +++++++++++++------------- src/r_main.c | 2 +- src/r_plane.c | 18 +++++++++--------- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index af545191a..cebdc91f6 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -154,6 +154,8 @@ typedef struct FLOAT fovxangle, fovyangle; UINT8 splitscreen; boolean flip; // screenflip + boolean roll; + FLOAT rollangle; #ifdef USE_FTRANSFORM_MIRROR boolean mirror; // SRB2Kart: Encore Mode #endif diff --git a/src/r_draw.h b/src/r_draw.h index a9921028c..18ee9f06a 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -62,6 +62,8 @@ extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; extern UINT8 *ds_source; // start of a 64*64 tile image extern UINT8 *ds_transmap; +extern INT32 ds_bgofs; + typedef struct { float x, y, z; } floatv3_t; diff --git a/src/r_draw8.c b/src/r_draw8.c index b2aabe3e5..6badc16fb 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -938,22 +938,22 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) double endz, endu, endv; UINT32 stepu, stepv; - iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); + iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx); // Lighting is simple. It's just linear interpolation from start to end { float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; - lightend = (iz + ds_szp->x*width) * planelightfloat; + lightend = (iz + ds_sz.x*width) * planelightfloat; lightstart = iz * planelightfloat; R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); } - uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); - vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); + uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx); + vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx); dest = ylookup[ds_y] + columnofs[ds_x1]; dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; @@ -972,9 +972,9 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); dest++; - iz += ds_szp->x; - uz += ds_sup->x; - vz += ds_svp->x; + iz += ds_sz.x; + uz += ds_su.x; + vz += ds_sv.x; } while (--width >= 0); #else #define SPANSIZE 16 @@ -984,9 +984,9 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) startu = uz*startz; startv = vz*startz; - izstep = ds_szp->x * SPANSIZE; - uzstep = ds_sup->x * SPANSIZE; - vzstep = ds_svp->x * SPANSIZE; + izstep = ds_sz.x * SPANSIZE; + uzstep = ds_su.x * SPANSIZE; + vzstep = ds_sv.x * SPANSIZE; //x1 = 0; width++; @@ -1028,9 +1028,9 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) else { double left = width; - iz += ds_szp->x * left; - uz += ds_sup->x * left; - vz += ds_svp->x * left; + iz += ds_sz.x * left; + uz += ds_su.x * left; + vz += ds_sv.x * left; endz = 1.f/iz; endu = uz*endz; diff --git a/src/r_main.c b/src/r_main.c index fce485812..a5c1b6e65 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -666,7 +666,7 @@ void R_CheckViewMorph(void) float fisheyemap[MAXVIDWIDTH/2 + 1]; #endif - angle_t rollangle = players[displayplayer].viewrollangle; + angle_t rollangle = players[displayplayers[0]].viewrollangle; #ifdef WOUGHMP_WOUGHMP fixed_t fisheye = cv_cam2_turnmultiplier.value; // temporary test value #endif diff --git a/src/r_plane.c b/src/r_plane.c index d00274262..f1c662fed 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -173,7 +173,7 @@ void R_PortalRestoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor // viewheight #ifndef NOWATER -static INT32 bgofs; +INT32 ds_bgofs; static INT32 wtofs=0; static INT32 waterofs; static boolean itswater; @@ -206,7 +206,7 @@ static void R_DrawTranslucentWaterSpan_8(void) source = ds_source; colormap = ds_colormap; dest = ylookup[ds_y] + columnofs[ds_x1]; - dsrc = screens[1] + (ds_y+bgofs)*vid.width + ds_x1; + dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; count = ds_x2 - ds_x1 + 1; while (count >= 8) @@ -304,17 +304,17 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) { const INT32 yay = (wtofs + (distance>>9) ) & 8191; // ripples da water texture - bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS; + ds_bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS; angle = (currentplane->viewangle + currentplane->plangle + xtoviewangle[x1])>>ANGLETOFINESHIFT; angle = (angle + 2048) & 8191; // 90 degrees - ds_xfrac += FixedMul(FINECOSINE(angle), (bgofs<=viewheight) - bgofs = viewheight-y-1; - if (y+bgofs<0) - bgofs = -y; + if (y+ds_bgofs>=viewheight) + ds_bgofs = viewheight-y-1; + if (y+ds_bgofs<0) + ds_bgofs = -y; } #endif From e11eb792eae4349e70aa95d8475c90404f5d127a Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 25 Jan 2020 21:43:39 -0800 Subject: [PATCH 03/30] GONNAHURL HARDCODE --- src/p_local.h | 2 ++ src/p_user.c | 31 +++++++++++++++++++++++++++++++ src/r_main.c | 2 ++ 3 files changed, 35 insertions(+) diff --git a/src/p_local.h b/src/p_local.h index 26035817d..d4ee7643f 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -136,6 +136,8 @@ extern consvar_t cv_cam3_speed, cv_cam3_rotate, cv_cam3_rotspeed; extern consvar_t cv_cam4_dist, cv_cam4_still, cv_cam4_height; extern consvar_t cv_cam4_speed, cv_cam4_rotate, cv_cam4_rotspeed; +extern consvar_t cv_inverseslope; + extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate; extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate; extern fixed_t t_cam3_dist, t_cam3_height, t_cam3_rotate; diff --git a/src/p_user.c b/src/p_user.c index fdb9a457a..4a9d4c745 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7108,6 +7108,8 @@ consvar_t cv_cam4_speed = {"cam4_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, N consvar_t cv_cam4_rotate = {"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam4_rotspeed = {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_inverseslope = {"inverseslope", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + fixed_t t_cam_dist = -42; fixed_t t_cam_height = -42; fixed_t t_cam_rotate = -42; @@ -8217,6 +8219,33 @@ void P_DoTimeOver(player_t *player) exitcountdown = 5*TICRATE; } + /* gaysed script from me, based on Golden's sprite slope roll */ + +static void +DoABarrelRoll (player_t *player) +{ + angle_t slope; + angle_t delta; + + if (player->mo->standingslope) + { + delta = ( player->mo->angle - player->mo->standingslope->xydirection ); + slope = FixedMul(FINESINE (delta>>ANGLETOFINESHIFT), + player->mo->standingslope->zangle); + if (cv_inverseslope.value) + slope = -slope; + } + else + slope = 0; + + delta = (INT32)( slope - player->viewrollangle )/ 16; + + if (delta) + player->viewrollangle += delta; + else + player->viewrollangle = slope; +} + // // P_PlayerThink // @@ -8801,6 +8830,8 @@ void P_PlayerThink(player_t *player) I_Error("I'm done!\n"); }*/ + + DoABarrelRoll(player); } // diff --git a/src/r_main.c b/src/r_main.c index a5c1b6e65..c9722d581 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1843,6 +1843,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam4_rotate); CV_RegisterVar(&cv_cam4_rotspeed); + CV_RegisterVar(&cv_inverseslope); + CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); From e1a2c1464f777372944d7303cdc80161888fa8c3 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 25 Jan 2020 23:36:24 -0800 Subject: [PATCH 04/30] QUAAAAAAAAKE --- src/p_local.h | 1 + src/p_user.c | 36 ++++++++++++++++++++++++++++++++++++ src/r_main.c | 1 + 3 files changed, 38 insertions(+) diff --git a/src/p_local.h b/src/p_local.h index d4ee7643f..56df91585 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -137,6 +137,7 @@ extern consvar_t cv_cam4_dist, cv_cam4_still, cv_cam4_height; extern consvar_t cv_cam4_speed, cv_cam4_rotate, cv_cam4_rotspeed; extern consvar_t cv_inverseslope; +extern consvar_t cv_quaketilt; extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate; extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate; diff --git a/src/p_user.c b/src/p_user.c index 4a9d4c745..4c5a85eda 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7109,6 +7109,7 @@ consvar_t cv_cam4_rotate = {"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, consvar_t cv_cam4_rotspeed = {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_inverseslope = {"inverseslope", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_quaketilt = {"quaketilt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; fixed_t t_cam_dist = -42; fixed_t t_cam_height = -42; @@ -8221,6 +8222,38 @@ void P_DoTimeOver(player_t *player) /* gaysed script from me, based on Golden's sprite slope roll */ +// holy SHIT +static INT32 +Quaketilt (player_t *player) +{ + angle_t tilt; + fixed_t lowb; // this threshold for speed + angle_t moma = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); + angle_t delta = (INT32)( player->mo->angle - moma ); + fixed_t speed; + // Hi! I'm "not a math guy"! + if (abs(delta) > ANGLE_90) + delta = (INT32)(( moma + ANGLE_180 ) - player->mo->angle ); + if (P_IsObjectOnGround(player->mo)) + { + tilt = ANGLE_11hh; + lowb = 15*FRACUNIT; + } + else + { + tilt = ANGLE_45; + lowb = 10*FRACUNIT; + } + moma = FixedMul(FixedDiv(delta, ANGLE_90), tilt); + speed = abs( player->mo->momx + player->mo->momy ); + if (speed < lowb) + { + // ease out tilt as we slow... + moma = FixedMul(moma, FixedDiv(speed, lowb)); + } + return moma; +} + static void DoABarrelRoll (player_t *player) { @@ -8238,6 +8271,9 @@ DoABarrelRoll (player_t *player) else slope = 0; + if (cv_quaketilt.value) + slope += Quaketilt(player); + delta = (INT32)( slope - player->viewrollangle )/ 16; if (delta) diff --git a/src/r_main.c b/src/r_main.c index c9722d581..ee071c06f 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1844,6 +1844,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam4_rotspeed); CV_RegisterVar(&cv_inverseslope); + CV_RegisterVar(&cv_quaketilt); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); From 3b5057067ccfd4763b9e3e93a6b8461bc20c18ce Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 26 Jan 2020 00:02:34 -0800 Subject: [PATCH 05/30] One last adjustment --- src/p_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 4c5a85eda..f29c3a21a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8236,12 +8236,12 @@ Quaketilt (player_t *player) delta = (INT32)(( moma + ANGLE_180 ) - player->mo->angle ); if (P_IsObjectOnGround(player->mo)) { - tilt = ANGLE_11hh; + tilt = 4*ANGLE_11hh/5; lowb = 15*FRACUNIT; } else { - tilt = ANGLE_45; + tilt = ANGLE_22h; lowb = 10*FRACUNIT; } moma = FixedMul(FixedDiv(delta, ANGLE_90), tilt); From 39ecdd1591cc6b95a7f52504ef30428f947bab10 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 26 Jan 2020 15:57:28 -0800 Subject: [PATCH 06/30] Rumble rumble --- src/doomstat.h | 1 + src/p_tick.c | 9 ++++++++- src/r_main.c | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 232a5af8e..32a5b02f6 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -190,6 +190,7 @@ extern struct quake { // camera offsets and duration fixed_t x,y,z; + angle_t roll; UINT16 time; // location, radius, and intensity... diff --git a/src/p_tick.c b/src/p_tick.c index 4cc6c9ba4..deb8b5cc9 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -744,10 +744,17 @@ void P_Ticker(boolean run) quake.x = M_RandomRange(-ir,ir); quake.y = M_RandomRange(-ir,ir); quake.z = M_RandomRange(-ir,ir); + ir >>= 2; + ir = M_RandomRange(-ir,ir); + if (ir < 0) + ir = ANGLE_MAX - FixedAngle(-ir); + else + ir = FixedAngle(ir); + quake.roll = ir; --quake.time; } else - quake.x = quake.y = quake.z = 0; + quake.x = quake.y = quake.z = quake.roll = 0; if (metalplayback) G_ReadMetalTic(metalplayback); diff --git a/src/r_main.c b/src/r_main.c index ee071c06f..96f21e51f 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -666,7 +666,7 @@ void R_CheckViewMorph(void) float fisheyemap[MAXVIDWIDTH/2 + 1]; #endif - angle_t rollangle = players[displayplayers[0]].viewrollangle; + angle_t rollangle = players[displayplayers[0]].viewrollangle + quake.roll; #ifdef WOUGHMP_WOUGHMP fixed_t fisheye = cv_cam2_turnmultiplier.value; // temporary test value #endif From b1d2db56f8ba84484171d76d01cd87de9418b355 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 26 Jan 2020 21:07:04 -0800 Subject: [PATCH 07/30] Revise cvars, inverseslope is now the default --- src/p_local.h | 2 +- src/p_user.c | 15 ++++++++++++--- src/r_main.c | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 56df91585..4c2789a46 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -136,7 +136,7 @@ extern consvar_t cv_cam3_speed, cv_cam3_rotate, cv_cam3_rotspeed; extern consvar_t cv_cam4_dist, cv_cam4_still, cv_cam4_height; extern consvar_t cv_cam4_speed, cv_cam4_rotate, cv_cam4_rotspeed; -extern consvar_t cv_inverseslope; +extern consvar_t cv_slopeview; extern consvar_t cv_quaketilt; extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate; diff --git a/src/p_user.c b/src/p_user.c index f29c3a21a..3733f7e49 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7108,7 +7108,15 @@ consvar_t cv_cam4_speed = {"cam4_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, N consvar_t cv_cam4_rotate = {"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam4_rotspeed = {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_inverseslope = {"inverseslope", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t slopeview_cons_t[] = +{ + { 0, "Off" }, + { 1, "On" }, + { 2, "Inverse" }, + + {0} +}; +consvar_t cv_slopeview = {"slopeview", "Off", CV_SAVE, slopeview_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_quaketilt = {"quaketilt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; fixed_t t_cam_dist = -42; @@ -8260,12 +8268,13 @@ DoABarrelRoll (player_t *player) angle_t slope; angle_t delta; - if (player->mo->standingslope) + if (cv_slopeview.value && player->mo->standingslope) { delta = ( player->mo->angle - player->mo->standingslope->xydirection ); slope = FixedMul(FINESINE (delta>>ANGLETOFINESHIFT), player->mo->standingslope->zangle); - if (cv_inverseslope.value) + /* invert the screen tilt as if tilting the view instead */ + if (cv_slopeview.value != 2)/* :james: mode */ slope = -slope; } else diff --git a/src/r_main.c b/src/r_main.c index 96f21e51f..fca595a28 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1843,7 +1843,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam4_rotate); CV_RegisterVar(&cv_cam4_rotspeed); - CV_RegisterVar(&cv_inverseslope); + CV_RegisterVar(&cv_slopeview); CV_RegisterVar(&cv_quaketilt); CV_RegisterVar(&cv_showhud); From 319cef25dababa7d70774e8dd82bab733b5252ec Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 26 Jan 2020 21:10:24 -0800 Subject: [PATCH 08/30] Make rolling quake optional --- src/p_local.h | 1 + src/p_user.c | 1 + src/r_main.c | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/p_local.h b/src/p_local.h index 4c2789a46..ee5c7ea95 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -138,6 +138,7 @@ extern consvar_t cv_cam4_speed, cv_cam4_rotate, cv_cam4_rotspeed; extern consvar_t cv_slopeview; extern consvar_t cv_quaketilt; +extern consvar_t cv_actionmovie; extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate; extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate; diff --git a/src/p_user.c b/src/p_user.c index 3733f7e49..e9c8dc928 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7118,6 +7118,7 @@ static CV_PossibleValue_t slopeview_cons_t[] = }; consvar_t cv_slopeview = {"slopeview", "Off", CV_SAVE, slopeview_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_quaketilt = {"quaketilt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_actionmovie = {"actionmovie", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; fixed_t t_cam_dist = -42; fixed_t t_cam_height = -42; diff --git a/src/r_main.c b/src/r_main.c index fca595a28..1e664a408 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -666,11 +666,14 @@ void R_CheckViewMorph(void) float fisheyemap[MAXVIDWIDTH/2 + 1]; #endif - angle_t rollangle = players[displayplayers[0]].viewrollangle + quake.roll; + angle_t rollangle = players[displayplayers[0]].viewrollangle; #ifdef WOUGHMP_WOUGHMP fixed_t fisheye = cv_cam2_turnmultiplier.value; // temporary test value #endif + if (cv_actionmovie.value) + rollangle += quake.roll; + rollangle >>= ANGLETOFINESHIFT; rollangle = ((rollangle+2) & ~3) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. @@ -1845,6 +1848,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_slopeview); CV_RegisterVar(&cv_quaketilt); + CV_RegisterVar(&cv_actionmovie); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); From e8e10497b8884370e8ec93e885b6ad51673192d4 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 26 Jan 2020 21:10:48 -0800 Subject: [PATCH 09/30] Please turn it on --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index e9c8dc928..c2d89a3a6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7116,7 +7116,7 @@ static CV_PossibleValue_t slopeview_cons_t[] = {0} }; -consvar_t cv_slopeview = {"slopeview", "Off", CV_SAVE, slopeview_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_slopeview = {"slopeview", "On", CV_SAVE, slopeview_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_quaketilt = {"quaketilt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_actionmovie = {"actionmovie", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; From 56b7a15403de2d23500888700d289bd6c0605992 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 28 Jan 2020 21:28:26 -0800 Subject: [PATCH 10/30] You have entered the comedy area --- src/d_main.c | 2 ++ src/doomstat.h | 2 ++ src/i_system.h | 2 ++ src/p_tick.c | 1 + src/sdl/i_system.c | 6 ++++++ src/sdl/i_video.c | 3 +++ 6 files changed, 16 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index 3ee3e94c9..f3e3fd940 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -108,6 +108,8 @@ int snprintf(char *str, size_t n, const char *fmt, ...); // platform independant focus loss UINT8 window_notinfocus = false; +INT32 window_x; +INT32 window_y; // // DEMO LOOP diff --git a/src/doomstat.h b/src/doomstat.h index 32a5b02f6..aea051495 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -107,6 +107,8 @@ extern boolean digital_disabled; extern boolean menuactive; // Menu overlaid? extern UINT8 paused; // Game paused? extern UINT8 window_notinfocus; // are we in focus? (backend independant -- handles auto pausing and display of "focus lost" message) +extern INT32 window_x; +extern INT32 window_y; extern boolean nodrawers; extern boolean noblit; diff --git a/src/i_system.h b/src/i_system.h index 3e589c69a..66f90112d 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -352,4 +352,6 @@ const char *I_ClipboardPaste(void); void I_RegisterSysCommands(void); +void I_CursedWindowMovement(int xd, int yd); + #endif diff --git a/src/p_tick.c b/src/p_tick.c index deb8b5cc9..6e4dbbd68 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -744,6 +744,7 @@ void P_Ticker(boolean run) quake.x = M_RandomRange(-ir,ir); quake.y = M_RandomRange(-ir,ir); quake.z = M_RandomRange(-ir,ir); + I_CursedWindowMovement(FixedInt(quake.x), FixedInt(quake.y)); ir >>= 2; ir = M_RandomRange(-ir,ir); if (ir < 0) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 51f708d0f..7b952146d 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -852,6 +852,12 @@ INT32 I_GetKey (void) return rc; } +void +I_CursedWindowMovement (int xd, int yd) +{ + SDL_SetWindowPosition(window, window_x + xd, window_y + yd); +} + // // I_JoyScale // diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 37eedf147..8e4ce4129 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -617,6 +617,9 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) break; case SDL_WINDOWEVENT_MAXIMIZED: break; + case SDL_WINDOWEVENT_MOVED: + window_x = evt.data1; + window_y = evt.data2; } if (mousefocus && kbfocus) From a2913ffba6aa692540ff9c9ac29c23e37b6eeb65 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 28 Jan 2020 21:29:51 -0800 Subject: [PATCH 11/30] Slower roll --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index c2d89a3a6..aeec718d2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8284,7 +8284,7 @@ DoABarrelRoll (player_t *player) if (cv_quaketilt.value) slope += Quaketilt(player); - delta = (INT32)( slope - player->viewrollangle )/ 16; + delta = (INT32)( slope - player->viewrollangle )/ 32; if (delta) player->viewrollangle += delta; From b65ecd6ecfe902b44704bc36ec5688f442f74695 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 28 Jan 2020 21:32:30 -0800 Subject: [PATCH 12/30] bruhhhhh --- src/p_tick.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_tick.c b/src/p_tick.c index 6e4dbbd68..c451599ea 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -23,6 +23,7 @@ #include "lua_script.h" #include "lua_hook.h" #include "k_kart.h" +#include "i_system.h" // Object place #include "m_cheat.h" From 99de2b6b665f79c775e9dbee60f2019d048cbbae Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 29 Jan 2020 20:40:24 -0800 Subject: [PATCH 13/30] Make fucking with the window optional --- src/p_local.h | 1 + src/p_tick.c | 3 ++- src/p_user.c | 1 + src/r_main.c | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/p_local.h b/src/p_local.h index ee5c7ea95..5a6c95f4c 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -139,6 +139,7 @@ extern consvar_t cv_cam4_speed, cv_cam4_rotate, cv_cam4_rotspeed; extern consvar_t cv_slopeview; extern consvar_t cv_quaketilt; extern consvar_t cv_actionmovie; +extern consvar_t cv_windowquake; extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate; extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate; diff --git a/src/p_tick.c b/src/p_tick.c index c451599ea..e9ab8145e 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -745,7 +745,8 @@ void P_Ticker(boolean run) quake.x = M_RandomRange(-ir,ir); quake.y = M_RandomRange(-ir,ir); quake.z = M_RandomRange(-ir,ir); - I_CursedWindowMovement(FixedInt(quake.x), FixedInt(quake.y)); + if (cv_windowquake.value) + I_CursedWindowMovement(FixedInt(quake.x), FixedInt(quake.y)); ir >>= 2; ir = M_RandomRange(-ir,ir); if (ir < 0) diff --git a/src/p_user.c b/src/p_user.c index aeec718d2..e3bbd9bc1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7119,6 +7119,7 @@ static CV_PossibleValue_t slopeview_cons_t[] = consvar_t cv_slopeview = {"slopeview", "On", CV_SAVE, slopeview_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_quaketilt = {"quaketilt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_actionmovie = {"actionmovie", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_windowquake = {"windowquake", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; fixed_t t_cam_dist = -42; fixed_t t_cam_height = -42; diff --git a/src/r_main.c b/src/r_main.c index 1e664a408..e654544a2 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1849,6 +1849,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_slopeview); CV_RegisterVar(&cv_quaketilt); CV_RegisterVar(&cv_actionmovie); + CV_RegisterVar(&cv_windowquake); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); From ab0d7f91a1233ee28360ec4213a57ddcb283bef0 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 23 Sep 2020 18:03:26 -0700 Subject: [PATCH 14/30] angle_t -> INT32 (cherry picked from commit a413e4f701577252f8bc5c401583e84711455ca5) --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index e3bbd9bc1..57920c2aa 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8239,7 +8239,7 @@ Quaketilt (player_t *player) angle_t tilt; fixed_t lowb; // this threshold for speed angle_t moma = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); - angle_t delta = (INT32)( player->mo->angle - moma ); + INT32 delta = (INT32)( player->mo->angle - moma ); fixed_t speed; // Hi! I'm "not a math guy"! if (abs(delta) > ANGLE_90) From 536589902d8652067203509953fad7d2caa9aee1 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 23 Sep 2020 18:15:22 -0700 Subject: [PATCH 15/30] Reduce quake tilting (cherry picked from commit 079fb7c7a4c4a9f9b9a3c2228551c56071e47414) --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 57920c2aa..e97e19fc5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8246,7 +8246,7 @@ Quaketilt (player_t *player) delta = (INT32)(( moma + ANGLE_180 ) - player->mo->angle ); if (P_IsObjectOnGround(player->mo)) { - tilt = 4*ANGLE_11hh/5; + tilt = ANGLE_11hh/2; lowb = 15*FRACUNIT; } else From 5070123d1120966f5b0c2d3c4a583dd3eb3bb55c Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 24 Sep 2020 19:54:30 -0700 Subject: [PATCH 16/30] Remove inverse slope option, merge quaketilt and slopeview into tilting cvar (cherry picked from commit 3e9e51cf18f31d02c1e4330d9d49c16145da4da6) --- src/p_local.h | 4 ++-- src/p_user.c | 33 ++++++++++++++------------------- src/r_main.c | 3 +-- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 5a6c95f4c..d4ea16a51 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -136,8 +136,8 @@ extern consvar_t cv_cam3_speed, cv_cam3_rotate, cv_cam3_rotspeed; extern consvar_t cv_cam4_dist, cv_cam4_still, cv_cam4_height; extern consvar_t cv_cam4_speed, cv_cam4_rotate, cv_cam4_rotspeed; -extern consvar_t cv_slopeview; -extern consvar_t cv_quaketilt; +extern consvar_t cv_tilting; + extern consvar_t cv_actionmovie; extern consvar_t cv_windowquake; diff --git a/src/p_user.c b/src/p_user.c index e97e19fc5..be81cf2d0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7108,16 +7108,8 @@ consvar_t cv_cam4_speed = {"cam4_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, N consvar_t cv_cam4_rotate = {"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam4_rotspeed = {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t slopeview_cons_t[] = -{ - { 0, "Off" }, - { 1, "On" }, - { 2, "Inverse" }, +consvar_t cv_tilting = {"tilting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - {0} -}; -consvar_t cv_slopeview = {"slopeview", "On", CV_SAVE, slopeview_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_quaketilt = {"quaketilt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_actionmovie = {"actionmovie", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_windowquake = {"windowquake", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -8270,20 +8262,16 @@ DoABarrelRoll (player_t *player) angle_t slope; angle_t delta; - if (cv_slopeview.value && player->mo->standingslope) + if (player->mo->standingslope) { delta = ( player->mo->angle - player->mo->standingslope->xydirection ); - slope = FixedMul(FINESINE (delta>>ANGLETOFINESHIFT), - player->mo->standingslope->zangle); - /* invert the screen tilt as if tilting the view instead */ - if (cv_slopeview.value != 2)/* :james: mode */ - slope = -slope; + slope = -(FixedMul(FINESINE (delta>>ANGLETOFINESHIFT), + player->mo->standingslope->zangle)); } else slope = 0; - if (cv_quaketilt.value) - slope += Quaketilt(player); + slope += Quaketilt(player); delta = (INT32)( slope - player->viewrollangle )/ 32; @@ -8842,6 +8830,15 @@ void P_PlayerThink(player_t *player) K_KartPlayerThink(player, cmd); // SRB2kart + if (cv_tilting.value) + { + DoABarrelRoll(player); + } + else + { + player->viewrollangle = 0; + } + /* // Colormap verification { @@ -8877,8 +8874,6 @@ void P_PlayerThink(player_t *player) I_Error("I'm done!\n"); }*/ - - DoABarrelRoll(player); } // diff --git a/src/r_main.c b/src/r_main.c index e654544a2..c764d5d43 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1846,8 +1846,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam4_rotate); CV_RegisterVar(&cv_cam4_rotspeed); - CV_RegisterVar(&cv_slopeview); - CV_RegisterVar(&cv_quaketilt); + CV_RegisterVar(&cv_tilting); CV_RegisterVar(&cv_actionmovie); CV_RegisterVar(&cv_windowquake); From dcb6b475ea0127785d63d5ad4ae1bf50b292a1e9 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 24 Sep 2020 19:55:58 -0700 Subject: [PATCH 17/30] Quake tilt in correct direction (cherry picked from commit 5f0cae44e20201cd32b895fe4dba2ce1a43b9137) --- src/p_user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index be81cf2d0..a88728eef 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8233,6 +8233,7 @@ Quaketilt (player_t *player) angle_t moma = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); INT32 delta = (INT32)( player->mo->angle - moma ); fixed_t speed; + // Hi! I'm "not a math guy"! if (abs(delta) > ANGLE_90) delta = (INT32)(( moma + ANGLE_180 ) - player->mo->angle ); @@ -8271,7 +8272,7 @@ DoABarrelRoll (player_t *player) else slope = 0; - slope += Quaketilt(player); + slope -= Quaketilt(player); delta = (INT32)( slope - player->viewrollangle )/ 32; From 2c5e7e8f9a30b8fda1d0b29397d5a420b07065ca Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 24 Sep 2020 19:59:24 -0700 Subject: [PATCH 18/30] Require slope angle > 11.25 to tilt camera (cherry picked from commit d4c2b81897752240cb0d0b63f4a3de4cd45edf90) --- src/p_user.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index a88728eef..c96252595 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8265,12 +8265,22 @@ DoABarrelRoll (player_t *player) if (player->mo->standingslope) { - delta = ( player->mo->angle - player->mo->standingslope->xydirection ); - slope = -(FixedMul(FINESINE (delta>>ANGLETOFINESHIFT), - player->mo->standingslope->zangle)); + slope = player->mo->standingslope->zangle; } else + { slope = 0; + } + + if (abs((INT32)slope) > ANGLE_11hh) + { + delta = ( player->mo->angle - player->mo->standingslope->xydirection ); + slope = -(FixedMul(FINESINE (delta>>ANGLETOFINESHIFT), slope)); + } + else + { + slope = 0; + } slope -= Quaketilt(player); From 554dfb6ce7fb4f51fab2f4ad8012da7f7e79df63 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 24 Sep 2020 20:00:19 -0700 Subject: [PATCH 19/30] Big Large tilt while sliptiding (cherry picked from commit e560ad4b78a74c2210a47c380ff1b45100a8e4a6) --- src/p_user.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index c96252595..fa53fe0f5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8234,13 +8234,27 @@ Quaketilt (player_t *player) INT32 delta = (INT32)( player->mo->angle - moma ); fixed_t speed; + boolean sliptiding = + ( + player->kartstuff[k_aizdriftstrat] != 0 && + player->kartstuff[k_drift] == 0 + ); + // Hi! I'm "not a math guy"! if (abs(delta) > ANGLE_90) delta = (INT32)(( moma + ANGLE_180 ) - player->mo->angle ); if (P_IsObjectOnGround(player->mo)) { - tilt = ANGLE_11hh/2; - lowb = 15*FRACUNIT; + if (sliptiding) + { + tilt = ANGLE_45; + lowb = 5*FRACUNIT; + } + else + { + tilt = ANGLE_11hh/2; + lowb = 15*FRACUNIT; + } } else { From 83ebf475888593390a6240b869530f121421c34b Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 24 Sep 2020 20:01:56 -0700 Subject: [PATCH 20/30] Don't quake tilt if just going backward THIS IS A HACK FOR WHEN ANGLE IS 90 DEGREES (cherry picked from commit a6a7c8d661ee019d9dc2030ba3b76a4e7486cd09) --- src/p_user.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index fa53fe0f5..94c5e5cd5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8240,6 +8240,11 @@ Quaketilt (player_t *player) player->kartstuff[k_drift] == 0 ); + if (delta == (INT32)ANGLE_180)/* FUCK YOU HAVE A HACK */ + { + return 0; + } + // Hi! I'm "not a math guy"! if (abs(delta) > ANGLE_90) delta = (INT32)(( moma + ANGLE_180 ) - player->mo->angle ); From 7877f8ae0e8808f814e36820891076468ca3dceb Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 27 Sep 2020 17:30:36 -0700 Subject: [PATCH 21/30] Fix some merge fuckups --- src/hardware/hw_main.h | 2 +- src/r_draw8.c | 139 ----------------------------------------- 2 files changed, 1 insertion(+), 140 deletions(-) diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index bc4a74e5f..eefcb8651 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -102,7 +102,7 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor); void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf); -void HWR_DrawSkyBackground(float fpov); +void HWR_DrawSkyBackground(player_t *player, float fpov); #ifdef POLYOBJECTS void HWR_AddPolyObjectSegs(void); diff --git a/src/r_draw8.c b/src/r_draw8.c index 6badc16fb..e6116863e 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -916,145 +916,6 @@ void R_DrawTiltedTranslucentSpan_8(void) #endif } -#ifndef NOWATER -/** \brief The R_DrawTiltedTranslucentWaterSpan_8 function - Like DrawTiltedTranslucentSpan, but for water -*/ -void R_DrawTiltedTranslucentWaterSpan_8(void) -{ - // x1, x2 = ds_x1, ds_x2 - int width = ds_x2 - ds_x1; - double iz, uz, vz; - UINT32 u, v; - int i; - - UINT8 *source; - UINT8 *colormap; - UINT8 *dest; - UINT8 *dsrc; - - double startz, startu, startv; - double izstep, uzstep, vzstep; - double endz, endu, endv; - UINT32 stepu, stepv; - - iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx); - - // Lighting is simple. It's just linear interpolation from start to end - { - float planelightfloat = PLANELIGHTFLOAT; - float lightstart, lightend; - - lightend = (iz + ds_sz.x*width) * planelightfloat; - lightstart = iz * planelightfloat; - - R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); - //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); - } - - uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx); - vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx); - - dest = ylookup[ds_y] + columnofs[ds_x1]; - dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; - source = ds_source; - //colormap = ds_colormap; - -#if 0 // The "perfect" reference version of this routine. Pretty slow. - // Use it only to see how things are supposed to look. - i = 0; - do - { - double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; - - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); - dest++; - iz += ds_sz.x; - uz += ds_su.x; - vz += ds_sv.x; - } while (--width >= 0); -#else -#define SPANSIZE 16 -#define INVSPAN 0.0625f - - startz = 1.f/iz; - startu = uz*startz; - startv = vz*startz; - - izstep = ds_sz.x * SPANSIZE; - uzstep = ds_su.x * SPANSIZE; - vzstep = ds_sv.x * SPANSIZE; - //x1 = 0; - width++; - - while (width >= SPANSIZE) - { - iz += izstep; - uz += uzstep; - vz += vzstep; - - endz = 1.f/iz; - endu = uz*endz; - endv = vz*endz; - stepu = (INT64)((endu - startu) * INVSPAN); - stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; - - for (i = SPANSIZE-1; i >= 0; i--) - { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); - dest++; - u += stepu; - v += stepv; - } - startu = endu; - startv = endv; - width -= SPANSIZE; - } - if (width > 0) - { - if (width == 1) - { - u = (INT64)(startu); - v = (INT64)(startv); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); - } - else - { - double left = width; - iz += ds_sz.x * left; - uz += ds_su.x * left; - vz += ds_sv.x * left; - - endz = 1.f/iz; - endu = uz*endz; - endv = vz*endz; - left = 1.f/left; - stepu = (INT64)((endu - startu) * left); - stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; - - for (; width != 0; width--) - { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); - dest++; - u += stepu; - v += stepv; - } - } - } -#endif -} -#endif // NOWATER - void R_DrawTiltedSplat_8(void) { // x1, x2 = ds_x1, ds_x2 From aab1af5926dffd94dcc353ff3551cc10c7be2680 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 30 Mar 2020 19:58:46 +0100 Subject: [PATCH 22/30] Turn the fixed-float convert macros into inline functions, like those in GZDoom. The old macros get to be just the same as calling these inline functions. (cherry picked from commit 2e27b3ea87cdc870774a1cbe068494d9a1df233d) --- src/m_fixed.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/m_fixed.h b/src/m_fixed.h index 8145a6917..3079cdb66 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -43,8 +43,20 @@ typedef INT32 fixed_t; /*! \brief convert fixed_t into floating number */ -#define FIXED_TO_FLOAT(x) (((float)(x)) / ((float)FRACUNIT)) -#define FLOAT_TO_FIXED(f) (fixed_t)((f) * ((float)FRACUNIT)) + +FUNCMATH FUNCINLINE static inline float FixedToFloat(fixed_t x) +{ + return x / (float)FRACUNIT; +} + +FUNCMATH FUNCINLINE static inline fixed_t FloatToFixed(float f) +{ + return (fixed_t)(f * FRACUNIT); +} + +// for backwards compat +#define FIXED_TO_FLOAT(x) FixedToFloat(x) // (((float)(x)) / ((float)FRACUNIT)) +#define FLOAT_TO_FIXED(f) FloatToFixed(f) // (fixed_t)((f) * ((float)FRACUNIT)) #if defined (__WATCOMC__) && FRACBITS == 16 From 997966351e94eb6335de089b145d817acb3b3b3d Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 30 Mar 2020 20:25:56 +0100 Subject: [PATCH 23/30] use ATTRINLINE rather than inline to match some of the other functions in this file, though I'm told modern compilers ignore inlining info as they actually decide themselves now (though I could pretend we still support the older ones lol) (cherry picked from commit befae492fe996ddedd4e9c6e0feaaa74a3b889bd) --- src/m_fixed.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_fixed.h b/src/m_fixed.h index 3079cdb66..49f14f8f4 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -44,12 +44,12 @@ typedef INT32 fixed_t; \brief convert fixed_t into floating number */ -FUNCMATH FUNCINLINE static inline float FixedToFloat(fixed_t x) +FUNCMATH FUNCINLINE static ATTRINLINE float FixedToFloat(fixed_t x) { return x / (float)FRACUNIT; } -FUNCMATH FUNCINLINE static inline fixed_t FloatToFixed(float f) +FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FloatToFixed(float f) { return (fixed_t)(f * FRACUNIT); } From 57f8acfd3c5f537b7e774f87d58df21fe912f4c9 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 24 Jul 2020 02:58:05 -0700 Subject: [PATCH 24/30] Compiler error :V (cherry picked from commit e47fbe7dd9c460b0ca8d88334f6a22e329cd10b3) --- src/hardware/hw_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 26ca13819..54607fe11 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2220,8 +2220,11 @@ void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t } // reference point for flat texture coord for each vertex around the polygon - flatxref = (float)(((fixed_t)FIXED_TO_FLOAT(polysector->origVerts[0].x) & (~flatflag)) / fflatsize); - flatyref = (float)(((fixed_t)FIXED_TO_FLOAT(polysector->origVerts[0].y) & (~flatflag)) / fflatsize); + flatxref = FIXED_TO_FLOAT(polysector->origVerts[0].x); + flatyref = FIXED_TO_FLOAT(polysector->origVerts[0].y); + + flatxref = (float)(((fixed_t)flatxref & (~flatflag)) / fflatsize); + flatyref = (float)(((fixed_t)flatyref & (~flatflag)) / fflatsize); // transform v3d = planeVerts; From d5cb7312a0a68482a29885d60e6f327f65c57fbe Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 27 Sep 2020 17:49:32 -0700 Subject: [PATCH 25/30] Extern fovtan hack omegalul --- src/hardware/r_opengl/r_opengl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 73cb50732..26bced3b6 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -28,6 +28,8 @@ #include "../../p_tick.h" // for leveltime (NOTE: THIS IS BAD, FIGURE OUT HOW TO PROPERLY IMPLEMENT gl_leveltime) +extern fixed_t fovtan; // also extremely bad, I'm just too lazy!!! + #if defined (HWRENDER) && !defined (NOROPENGL) struct GLRGBAFloat From 9ccf2490fc11022234a87e2efa8950f3b824baf8 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 7 Dec 2019 23:55:28 -0300 Subject: [PATCH 26/30] Just in case? (cherry picked from commit 40b862967d3a4aef3cca63a10f6399ce1c7af47c) --- src/hardware/hw_main.c | 2 ++ src/hardware/hw_md2.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 54607fe11..4c3ed0d6f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4598,6 +4598,8 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) gr_viewsin = FIXED_TO_FLOAT(viewsin); gr_viewcos = FIXED_TO_FLOAT(viewcos); + memset(&atransform, 0x00, sizeof(FTransform)); + // Set T&L transform atransform.x = gr_viewx; atransform.y = gr_viewy; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 7d97bd065..fcab76286 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1082,6 +1082,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr) if (spr->precip) return; + memset(&p, 0x00, sizeof(FTransform)); + // MD2 colormap fix // colormap test if (spr->mobj->subsector) From b69162e92d972b58c59b73a19eed2ea234e464f3 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 27 Sep 2020 23:02:04 -0700 Subject: [PATCH 27/30] Apply quake rolling to opengl too, cv_actionmovie depends on cv_tilting --- src/d_player.h | 1 + src/p_user.c | 29 ++++++++++++++++++----------- src/r_main.c | 3 --- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 90370c796..7b542d7ab 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -370,6 +370,7 @@ typedef struct player_s //fixed_t bob; angle_t viewrollangle; + angle_t tilt; // Mouse aiming, where the guy is looking at! // It is updated with cmd->aiming. diff --git a/src/p_user.c b/src/p_user.c index 94c5e5cd5..c222fed7f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8303,12 +8303,26 @@ DoABarrelRoll (player_t *player) slope -= Quaketilt(player); - delta = (INT32)( slope - player->viewrollangle )/ 32; + delta = (INT32)( slope - player->tilt )/ 32; if (delta) - player->viewrollangle += delta; + player->tilt += delta; else - player->viewrollangle = slope; + player->tilt = slope; + + if (cv_tilting.value) + { + player->viewrollangle = player->tilt; + + if (cv_actionmovie.value) + { + player->viewrollangle += quake.roll; + } + } + else + { + player->viewrollangle = 0; + } } // @@ -8860,14 +8874,7 @@ void P_PlayerThink(player_t *player) K_KartPlayerThink(player, cmd); // SRB2kart - if (cv_tilting.value) - { - DoABarrelRoll(player); - } - else - { - player->viewrollangle = 0; - } + DoABarrelRoll(player); /* // Colormap verification diff --git a/src/r_main.c b/src/r_main.c index c764d5d43..eee1be27f 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -671,9 +671,6 @@ void R_CheckViewMorph(void) fixed_t fisheye = cv_cam2_turnmultiplier.value; // temporary test value #endif - if (cv_actionmovie.value) - rollangle += quake.roll; - rollangle >>= ANGLETOFINESHIFT; rollangle = ((rollangle+2) & ~3) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. From 5d12696a7030f2ed0c3e8ea52accb6470de0a722 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 27 Sep 2020 23:08:43 -0700 Subject: [PATCH 28/30] Fix opengl sky dome rotation I was setting atransform by mistake, but I noticed I do a small refactor too. --- src/hardware/hw_main.c | 12 ++++-------- src/hardware/hw_main.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4c3ed0d6f..229ce0879 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4474,7 +4474,7 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) static boolean drewsky = false; -void HWR_DrawSkyBackground(player_t *player, float fpov) +void HWR_DrawSkyBackground(float fpov) { FTransform dometransform; @@ -4499,12 +4499,8 @@ void HWR_DrawSkyBackground(player_t *player, float fpov) dometransform.scalez = 1; dometransform.fovxangle = fpov; // Tails dometransform.fovyangle = fpov; // Tails - if (player->viewrollangle != 0) - { - fixed_t rol = AngleFixed(player->viewrollangle); - atransform.rollangle = FIXED_TO_FLOAT(rol); - atransform.roll = true; - } + dometransform.rollangle = atransform.rollangle; + dometransform.roll = atransform.roll; dometransform.splitscreen = splitscreen; HWR_GetTexture(texturetranslation[skytexture]); @@ -4657,7 +4653,7 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) ST_doPaletteStuff(); // Draw the sky background. - HWR_DrawSkyBackground(player, fpov); + HWR_DrawSkyBackground(fpov); if (skybox) drewsky = true; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index eefcb8651..bc4a74e5f 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -102,7 +102,7 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor); void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf); -void HWR_DrawSkyBackground(player_t *player, float fpov); +void HWR_DrawSkyBackground(float fpov); #ifdef POLYOBJECTS void HWR_AddPolyObjectSegs(void); From ae77792df39ff0c8911dfe73ba9b9de29c7f0181 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 28 Sep 2020 13:39:24 -0700 Subject: [PATCH 29/30] Bring back cv_quaketilt, add cv_tiltsmoothing to adjust the smoothening --- src/p_local.h | 2 ++ src/p_user.c | 9 +++++++-- src/r_main.c | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index d4ea16a51..33e085a09 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -137,6 +137,8 @@ extern consvar_t cv_cam4_dist, cv_cam4_still, cv_cam4_height; extern consvar_t cv_cam4_speed, cv_cam4_rotate, cv_cam4_rotspeed; extern consvar_t cv_tilting; +extern consvar_t cv_quaketilt; +extern consvar_t cv_tiltsmoothing; extern consvar_t cv_actionmovie; extern consvar_t cv_windowquake; diff --git a/src/p_user.c b/src/p_user.c index c222fed7f..e10c88cfd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7109,6 +7109,8 @@ consvar_t cv_cam4_rotate = {"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, consvar_t cv_cam4_rotspeed = {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_tilting = {"tilting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_quaketilt = {"quaketilt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_tiltsmoothing = {"tiltsmoothing", "32", CV_SAVE, CV_Natural, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_actionmovie = {"actionmovie", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_windowquake = {"windowquake", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -8301,9 +8303,12 @@ DoABarrelRoll (player_t *player) slope = 0; } - slope -= Quaketilt(player); + if (cv_quaketilt.value) + { + slope -= Quaketilt(player); + } - delta = (INT32)( slope - player->tilt )/ 32; + delta = (INT32)( slope - player->tilt )/ cv_tiltsmoothing.value; if (delta) player->tilt += delta; diff --git a/src/r_main.c b/src/r_main.c index eee1be27f..43ad0a546 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1844,6 +1844,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam4_rotspeed); CV_RegisterVar(&cv_tilting); + CV_RegisterVar(&cv_quaketilt); + CV_RegisterVar(&cv_tiltsmoothing); CV_RegisterVar(&cv_actionmovie); CV_RegisterVar(&cv_windowquake); From 766c8b3f0cadb136314b90ed3bfb8825f72e1d9e Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 28 Sep 2020 14:20:11 -0700 Subject: [PATCH 30/30] Make tilting work even on no physics slopes --- src/lua_maplib.c | 3 +++ src/p_slopes.c | 41 ++++++++++++++++++++++++++++++----------- src/p_user.c | 4 ++-- src/r_defs.h | 4 ++++ 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 41875ea98..75c0842b9 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1341,6 +1341,7 @@ static int slope_set(lua_State *L) case slope_zdelta: { // zdelta, this is temp until i figure out wtf to do slope->zdelta = luaL_checkfixed(L, 3); slope->zangle = R_PointToAngle2(0, 0, FRACUNIT, -slope->zdelta); + slope->real_zangle = slope->zangle; P_CalculateSlopeNormal(slope); break; } @@ -1349,12 +1350,14 @@ static int slope_set(lua_State *L) if (zangle == ANGLE_90 || zangle == ANGLE_270) return luaL_error(L, "invalid zangle for slope!"); slope->zangle = zangle; + slope->real_zangle = slope->zangle; slope->zdelta = -FINETANGENT(((slope->zangle+ANGLE_90)>>ANGLETOFINESHIFT) & 4095); P_CalculateSlopeNormal(slope); break; } case slope_xydirection: // xydirection slope->xydirection = luaL_checkangle(L, 3); + slope->real_xydirection = slope->xydirection; slope->d.x = -FINECOSINE((slope->xydirection>>ANGLETOFINESHIFT) & FINEMASK); slope->d.y = -FINESINE((slope->xydirection>>ANGLETOFINESHIFT) & FINEMASK); P_CalculateSlopeNormal(slope); diff --git a/src/p_slopes.c b/src/p_slopes.c index 60c852f53..984f423cd 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -39,6 +39,8 @@ static void P_ReconfigureVertexSlope(pslope_t *slope) { vector3_t vec1, vec2; + fixed_t extent; + // Set slope normal vec1.x = (slope->vertices[1]->x - slope->vertices[0]->x) << FRACBITS; vec1.y = (slope->vertices[1]->y - slope->vertices[0]->y) << FRACBITS; @@ -75,21 +77,25 @@ static void P_ReconfigureVertexSlope(pslope_t *slope) slope->o.y = slope->vertices[0]->y << FRACBITS; slope->o.z = slope->vertices[0]->z << FRACBITS; + // Get direction vector + extent = R_PointToDist2(0, 0, slope->normal.x, slope->normal.y); + slope->d.x = -FixedDiv(slope->normal.x, extent); + slope->d.y = -FixedDiv(slope->normal.y, extent); + + // Z delta + slope->zdelta = FixedDiv(extent, slope->normal.z); + + // Get angles + slope->real_xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180; + slope->real_zangle = InvAngle(R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta)); + if (slope->normal.x == 0 && slope->normal.y == 0) { // Set some defaults for a non-sloped "slope" slope->zangle = slope->xydirection = 0; slope->zdelta = slope->d.x = slope->d.y = 0; } else { - // Get direction vector - slope->extent = R_PointToDist2(0, 0, slope->normal.x, slope->normal.y); - slope->d.x = -FixedDiv(slope->normal.x, slope->extent); - slope->d.y = -FixedDiv(slope->normal.y, slope->extent); - - // Z delta - slope->zdelta = FixedDiv(slope->extent, slope->normal.z); - - // Get angles - slope->xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180; - slope->zangle = InvAngle(R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta)); + slope->extent = extent; + slope->xydirection = slope->real_xydirection; + slope->zangle = slope->real_zangle; } } @@ -147,6 +153,7 @@ void P_RunDynamicSlopes(void) { if (slope->zdelta != FixedDiv(zdelta, slope->extent)) { slope->zdelta = FixedDiv(zdelta, slope->extent); slope->zangle = R_PointToAngle2(0, 0, slope->extent, -zdelta); + slope->real_zangle = slope->zangle; P_CalculateSlopeNormal(slope); } } @@ -357,6 +364,9 @@ void P_SpawnSlope_Line(int linenum) fslope->zangle = R_PointToAngle2(0, origin.z, extent, point.z); fslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y); + fslope->real_zangle = fslope->zangle; + fslope->real_xydirection = fslope->xydirection; + P_CalculateSlopeNormal(fslope); } if(frontceil) @@ -400,6 +410,9 @@ void P_SpawnSlope_Line(int linenum) cslope->zangle = R_PointToAngle2(0, origin.z, extent, point.z); cslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y); + cslope->real_zangle = cslope->zangle; + cslope->real_xydirection = cslope->xydirection; + P_CalculateSlopeNormal(cslope); } } @@ -466,6 +479,9 @@ void P_SpawnSlope_Line(int linenum) fslope->zangle = R_PointToAngle2(0, origin.z, extent, point.z); fslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y); + fslope->real_zangle = fslope->zangle; + fslope->real_xydirection = fslope->xydirection; + P_CalculateSlopeNormal(fslope); } if(backceil) @@ -509,6 +525,9 @@ void P_SpawnSlope_Line(int linenum) cslope->zangle = R_PointToAngle2(0, origin.z, extent, point.z); cslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y); + cslope->real_zangle = cslope->zangle; + cslope->real_xydirection = cslope->xydirection; + P_CalculateSlopeNormal(cslope); } } diff --git a/src/p_user.c b/src/p_user.c index e10c88cfd..db362da23 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8286,7 +8286,7 @@ DoABarrelRoll (player_t *player) if (player->mo->standingslope) { - slope = player->mo->standingslope->zangle; + slope = player->mo->standingslope->real_zangle; } else { @@ -8295,7 +8295,7 @@ DoABarrelRoll (player_t *player) if (abs((INT32)slope) > ANGLE_11hh) { - delta = ( player->mo->angle - player->mo->standingslope->xydirection ); + delta = ( player->mo->angle - player->mo->standingslope->real_xydirection ); slope = -(FixedMul(FINESINE (delta>>ANGLETOFINESHIFT), slope)); } else diff --git a/src/r_defs.h b/src/r_defs.h index 6635e2afc..11bef611f 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -253,6 +253,10 @@ typedef struct pslope_s angle_t zangle; // Angle of the plane going up from the ground (not mesured in degrees) angle_t xydirection; // The direction the slope is facing (north, west, south, etc.) + // Applies even if the slope has no physics, for tilting + angle_t real_zangle; + angle_t real_xydirection; + struct line_s *sourceline; // The line that generated the slope fixed_t extent; // Distance value used for recalculating zdelta UINT8 refpos; // 1=front floor 2=front ceiling 3=back floor 4=back ceiling (used for dynamic sloping)