From 48c1ce3ac3c0869a9272d3685da9ddaa3c1b014b Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 27 Dec 2019 15:31:20 -0600 Subject: [PATCH 01/22] Add render-based drop shadows to some objects Uses a hardcoded list for now. I was experiencing some crashes with this, but the shadowyscale check seems to have suppressed them. --- src/r_things.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 132 insertions(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index c9fe795fb..558ea280e 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1094,6 +1094,124 @@ static void R_SplitSprite(vissprite_t *sprite) } } +static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fixed_t tz) +{ + vissprite_t *shadow; + patch_t *patch; + fixed_t xscale, yscale, shadowxscale, shadowyscale, x1, x2; + INT32 light = 0; + fixed_t scalemul; UINT8 trans; + fixed_t floordiff; + fixed_t floorz; + + // Get floorz as the first floor below the object that's visible + floorz = (vis->heightsec != -1) ? sectors[vis->heightsec].floorheight : thing->floorz; + if (vis->sector->ffloors) + { + ffloor_t *rover = vis->sector->ffloors; + fixed_t z; + + for (; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || (rover->alpha < 90 && !(rover->flags & FF_SWIMMABLE))) + continue; + + z = *rover->t_slope ? P_GetZAt(*rover->t_slope, thing->x, thing->y) : *rover->topheight; + if (z < thing->z+thing->height/3 && z > floorz) + floorz = z; + } + } + + floordiff = abs(thing->z - floorz); + + trans = floordiff / (100*FRACUNIT) + 3; + if (trans >= 9) return; + + scalemul = FRACUNIT - floordiff/640; + + patch = W_CachePatchNum(sprites[SPR_THOK].spriteframes[0].lumppat[0], PU_CACHE); + xscale = FixedDiv(projection, tz); + yscale = FixedDiv(projectiony, tz); + shadowxscale = FixedMul(thing->radius*2, scalemul) / patch->width; + shadowyscale = FixedMul(FixedMul(thing->radius*2 / patch->height, scalemul), FixedDiv(abs(floorz - viewz), tz)); + + tx -= patch->width * shadowxscale/2; + x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + if (x1 >= viewwidth) return; + + tx += patch->width * shadowxscale; + x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; + if (x2 < 0 || x2 <= x1) return; + + if (shadowyscale < FRACUNIT/patch->height) return; // fix some crashes? + + shadow = R_NewVisSprite(); + shadow->patch = patch; + shadow->heightsec = vis->heightsec; + + shadow->thingheight = FRACUNIT; + shadow->pz = floorz; + shadow->pzt = shadow->pz + shadow->thingheight; + + shadow->mobjflags = 0; + shadow->sortscale = vis->sortscale; + shadow->dispoffset = vis->dispoffset - 5; + shadow->gx = thing->x; + shadow->gy = thing->y; + shadow->gzt = shadow->pz + shadow->patch->height * shadowyscale / 2; + shadow->gz = shadow->gzt - shadow->patch->height * shadowyscale; + shadow->texturemid = FixedDiv(shadow->gzt - viewz, shadowyscale); + shadow->scalestep = 0; + + shadow->mobj = thing; // Easy access! Tails 06-07-2002 + + shadow->x1 = x1 < 0 ? 0 : x1; + shadow->x2 = x2 >= viewwidth ? viewwidth-1 : x2; + + shadow->xscale = FixedMul(xscale, shadowxscale); //SoM: 4/17/2000 + shadow->scale = FixedMul(yscale, shadowyscale); + shadow->sector = vis->sector; + shadow->szt = (INT16)((centeryfrac - FixedMul(shadow->gzt - viewz, yscale))>>FRACBITS); + shadow->sz = (INT16)((centeryfrac - FixedMul(shadow->gz - viewz, yscale))>>FRACBITS); + shadow->cut = SC_ISSCALED; //check this + + + shadow->startfrac = 0; + shadow->xiscale = 0x7fffff00 / (shadow->xscale/2); + + if (shadow->x1 > x1) + shadow->startfrac += shadow->xiscale*(vis->x1-x1); + + if (thing->subsector->sector->numlights) + { + INT32 lightnum; +#ifdef ESLOPE // R_GetPlaneLight won't work on sloped lights! + light = thing->subsector->sector->numlights - 1; + + for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { + fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, thing->x, thing->y) + : thing->subsector->sector->lightlist[lightnum].height; + if (h <= shadow->gzt) { + light = lightnum - 1; + break; + } + } +#else + light = R_GetPlaneLight(thing->subsector->sector, shadow->gzt, false); +#endif + } + + if (thing->subsector->sector->numlights) + shadow->extra_colormap = *thing->subsector->sector->lightlist[light].extra_colormap; + else + shadow->extra_colormap = thing->subsector->sector->extra_colormap; + + shadow->transmap = transtables + (trans<colormap = scalelight[0][0]; // full dark! + + objectsdrawn++; +} + // // R_ProjectSprite // Generates a vissprite for a thing @@ -1131,6 +1249,8 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t scalestep; fixed_t offset, offset2; + fixed_t basetx; // drop shadows + boolean papersprite = !!(thing->frame & FF_PAPERSPRITE); fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0; @@ -1166,7 +1286,7 @@ static void R_ProjectSprite(mobj_t *thing) gxt = -FixedMul(tr_x, viewsin); gyt = FixedMul(tr_y, viewcos); - tx = -(gyt + gxt); + basetx = tx = -(gyt + gxt); // too far off the side? if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later @@ -1623,6 +1743,17 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->subsector->sector->numlights) R_SplitSprite(vis); + // temporary: whitelist. eventually: MF/2/E flag? + if (( + oldthing->type == MT_PLAYER || + (oldthing->state - states) == S_RING || + oldthing->type == MT_ROLLOUTROCK || + oldthing->flags & MF_ENEMY || + oldthing->type == MT_EGGMOBILE4_MACE || + (oldthing->type >= MT_SMALLMACE && oldthing->type <= MT_REDSPRINGBALL) // .W. + ) && !papersprite) + R_ProjectDropShadow(oldthing, vis, basetx, tz); + // Debug ++objectsdrawn; } From c46c92d605efa401fbb24193eef170b64ecb99ca Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 29 Dec 2019 18:30:29 -0600 Subject: [PATCH 02/22] Prevent linkdraw sprites from connecting to shadows --- src/r_things.c | 11 ++++++++++- src/r_things.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 558ea280e..953952c56 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1122,6 +1122,8 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix } } + if (abs(floorz-viewz)/tz > 4) return; // Prevent stretchy shadows and possible crashes + floordiff = abs(thing->z - floorz); trans = floordiff / (100*FRACUNIT) + 3; @@ -1173,7 +1175,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix shadow->sector = vis->sector; shadow->szt = (INT16)((centeryfrac - FixedMul(shadow->gzt - viewz, yscale))>>FRACBITS); shadow->sz = (INT16)((centeryfrac - FixedMul(shadow->gz - viewz, yscale))>>FRACBITS); - shadow->cut = SC_ISSCALED; //check this + shadow->cut = SC_ISSCALED|SC_SHADOW; //check this shadow->startfrac = 0; @@ -2069,6 +2071,9 @@ static void R_SortVisSprites(vissprite_t* vsprsortedhead, UINT32 start, UINT32 e if (!(ds->cut & SC_LINKDRAW)) continue; + if (ds->cut & SC_SHADOW) + continue; + // reuse dsfirst... for (dsfirst = unsorted.prev; dsfirst != &unsorted; dsfirst = dsfirst->prev) { @@ -2076,6 +2081,10 @@ static void R_SortVisSprites(vissprite_t* vsprsortedhead, UINT32 start, UINT32 e if (dsfirst->cut & SC_LINKDRAW) continue; + // don't connect to your shadow! + if (dsfirst->cut & SC_SHADOW) + continue; + // don't connect if it's not the tracer if (dsfirst->mobj != ds->mobj) continue; diff --git a/src/r_things.h b/src/r_things.h index 1b74dd74e..a6ef92802 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -153,7 +153,8 @@ typedef enum SC_LINKDRAW = 1<<3, SC_FULLBRIGHT = 1<<4, SC_VFLIP = 1<<5, - SC_ISSCALED = 1>>6, + SC_ISSCALED = 1<<6, + SC_SHADOW = 1<<7, // masks SC_CUTMASK = SC_TOP|SC_BOTTOM, SC_FLAGMASK = ~SC_CUTMASK From 5929b4797e33f3869131be37b2ff52daf30d469e Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 29 Dec 2019 19:19:26 -0600 Subject: [PATCH 03/22] This acursed crash-inducing typo spat in my face and called me a bitch --- src/r_things.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 953952c56..174ada10a 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1177,12 +1177,11 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix shadow->sz = (INT16)((centeryfrac - FixedMul(shadow->gz - viewz, yscale))>>FRACBITS); shadow->cut = SC_ISSCALED|SC_SHADOW; //check this - shadow->startfrac = 0; - shadow->xiscale = 0x7fffff00 / (shadow->xscale/2); + shadow->xiscale = 0x7ffffff0 / (shadow->xscale/2); if (shadow->x1 > x1) - shadow->startfrac += shadow->xiscale*(vis->x1-x1); + shadow->startfrac += shadow->xiscale*(shadow->x1-x1); if (thing->subsector->sector->numlights) { From 9c49e020c3abd7d748ea93e37c1b2eb67a4f90ea Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 29 Dec 2019 20:19:27 -0600 Subject: [PATCH 04/22] FUCK IT, SLOPED SHADOWS NOW --- src/r_things.c | 76 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 174ada10a..628239957 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -876,6 +876,7 @@ static void R_DrawVisSprite(vissprite_t *vis) if (!(vis->scalestep)) { sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); + sprtopscreen += vis->paperdistance * vis->paperoffset; dc_iscale = FixedDiv(FRACUNIT, vis->scale); } @@ -921,7 +922,7 @@ static void R_DrawVisSprite(vissprite_t *vis) else { // Non-paper drawing loop - for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) + for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, sprtopscreen += vis->paperdistance) { #ifdef RANGECHECK texturecolumn = frac>>FRACBITS; @@ -1098,30 +1099,59 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix { vissprite_t *shadow; patch_t *patch; - fixed_t xscale, yscale, shadowxscale, shadowyscale, x1, x2; + fixed_t xscale, yscale, shadowxscale, shadowyscale, shadowskew, x1, x2; INT32 light = 0; fixed_t scalemul; UINT8 trans; fixed_t floordiff; fixed_t floorz; + pslope_t *floorslope; // Get floorz as the first floor below the object that's visible floorz = (vis->heightsec != -1) ? sectors[vis->heightsec].floorheight : thing->floorz; - if (vis->sector->ffloors) + floorslope = (vis->heightsec != -1) ? NULL : thing->standingslope; + { - ffloor_t *rover = vis->sector->ffloors; + boolean original = true; fixed_t z; - for (; rover; rover = rover->next) + if (vis->sector->ffloors) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || (rover->alpha < 90 && !(rover->flags & FF_SWIMMABLE))) - continue; + ffloor_t *rover = vis->sector->ffloors; - z = *rover->t_slope ? P_GetZAt(*rover->t_slope, thing->x, thing->y) : *rover->topheight; - if (z < thing->z+thing->height/3 && z > floorz) + for (; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || (rover->alpha < 90 && !(rover->flags & FF_SWIMMABLE))) + continue; + + z = *rover->t_slope ? P_GetZAt(*rover->t_slope, thing->x, thing->y) : *rover->topheight; + if (z < thing->z+thing->height/3 && z > floorz) + { + floorz = z; + floorslope = *rover->t_slope; + original = false; + } + else if (original && (*rover->t_slope) && z < thing->z+thing->height/3 && z > floorz - FixedMul(abs((*rover->t_slope)->zdelta), thing->radius*2)) + { + // Guesstimated to be a usable floor. This is here to handle floorslope of non-grounded things, I guess. + floorz = z; + floorslope = *rover->t_slope; + original = false; + } + } + } + + if (original && vis->sector->f_slope) + { + z = P_GetZAt(vis->sector->f_slope, thing->x, thing->y); + if (z < thing->z+thing->height/3 && z > floorz - FixedMul(abs(vis->sector->f_slope->zdelta), thing->radius*2)) + { floorz = z; + floorslope = vis->sector->f_slope; + } } } + if (abs(floorz-viewz)/tz > 4) return; // Prevent stretchy shadows and possible crashes floordiff = abs(thing->z - floorz); @@ -1136,6 +1166,28 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix yscale = FixedDiv(projectiony, tz); shadowxscale = FixedMul(thing->radius*2, scalemul) / patch->width; shadowyscale = FixedMul(FixedMul(thing->radius*2 / patch->height, scalemul), FixedDiv(abs(floorz - viewz), tz)); + shadowskew = 0; + + if (floorslope) + { + // haha let's try some dumb stuff + fixed_t xslope, zslope; + angle_t sloperelang = (R_PointToAngle(thing->x, thing->y) - floorslope->xydirection) >> ANGLETOFINESHIFT; + + xslope = FixedMul(FINESINE(sloperelang), floorslope->zdelta); + zslope = FixedMul(FINECOSINE(sloperelang), floorslope->zdelta); + + //CONS_Printf("Shadow is sloped by %d %d\n", xslope, zslope); + + if (viewz < floorz) + shadowyscale += FixedMul(FixedMul(thing->radius*2 / patch->height, scalemul), zslope); + else + shadowyscale -= FixedMul(FixedMul(thing->radius*2 / patch->height, scalemul), zslope); + + shadowyscale = abs(shadowyscale); + + shadowskew = xslope; + } tx -= patch->width * shadowxscale/2; x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; @@ -1164,6 +1216,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix shadow->gz = shadow->gzt - shadow->patch->height * shadowyscale; shadow->texturemid = FixedDiv(shadow->gzt - viewz, shadowyscale); shadow->scalestep = 0; + shadow->paperdistance = shadowskew; // repurposed variable shadow->mobj = thing; // Easy access! Tails 06-07-2002 @@ -1183,6 +1236,10 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix if (shadow->x1 > x1) shadow->startfrac += shadow->xiscale*(shadow->x1-x1); + // reusing x1 variable + x1 += (x2-x1)/2; + shadow->paperoffset = (vis->x1-x1)/2; + if (thing->subsector->sector->numlights) { INT32 lightnum; @@ -1878,6 +1935,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->pzt = vis->pz + vis->thingheight; vis->texturemid = vis->gzt - viewz; vis->scalestep = 0; + vis->paperdistance = 0; vis->x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; From c078ab630d83b5bc18d4e0ba4c5db3571be8706a Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 29 Dec 2019 20:45:07 -0600 Subject: [PATCH 05/22] Fix more shadow crashes and save my sanity --- src/r_things.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 628239957..4db6cae58 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1231,7 +1231,8 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix shadow->cut = SC_ISSCALED|SC_SHADOW; //check this shadow->startfrac = 0; - shadow->xiscale = 0x7ffffff0 / (shadow->xscale/2); + //shadow->xiscale = 0x7ffffff0 / (shadow->xscale/2); + shadow->xiscale = (patch->width<x1 > x1) shadow->startfrac += shadow->xiscale*(shadow->x1-x1); From 8757194d7347ba15fa7b25a7c66a509e123e19d0 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 29 Dec 2019 20:53:28 -0600 Subject: [PATCH 06/22] Make ring shadows smaller and fix scale bug --- src/r_things.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 4db6cae58..e6d0d53e6 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1161,6 +1161,10 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix scalemul = FRACUNIT - floordiff/640; + //@TODO make this configurable instead of hardcoding to the ring + if (thing->type == MT_RING) + scalemul = scalemul*2/3; + patch = W_CachePatchNum(sprites[SPR_THOK].spriteframes[0].lumppat[0], PU_CACHE); xscale = FixedDiv(projection, tz); yscale = FixedDiv(projectiony, tz); @@ -1214,7 +1218,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix shadow->gy = thing->y; shadow->gzt = shadow->pz + shadow->patch->height * shadowyscale / 2; shadow->gz = shadow->gzt - shadow->patch->height * shadowyscale; - shadow->texturemid = FixedDiv(shadow->gzt - viewz, shadowyscale); + shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale)); shadow->scalestep = 0; shadow->paperdistance = shadowskew; // repurposed variable From ef4974ab4dfd1d6551079cb6d157cbe4fdfd301f Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 29 Dec 2019 22:15:01 -0600 Subject: [PATCH 07/22] Apply portal clipping to drop shadows too --- src/r_things.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/r_things.c b/src/r_things.c index e6d0d53e6..1f48bcb52 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1227,6 +1227,15 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix shadow->x1 = x1 < 0 ? 0 : x1; shadow->x2 = x2 >= viewwidth ? viewwidth-1 : x2; + // PORTAL SEMI-CLIPPING + if (portalrender) + { + if (shadow->x1 < portalclipstart) + shadow->x1 = portalclipstart; + if (shadow->x2 >= portalclipend) + shadow->x2 = portalclipend-1; + } + shadow->xscale = FixedMul(xscale, shadowxscale); //SoM: 4/17/2000 shadow->scale = FixedMul(yscale, shadowyscale); shadow->sector = vis->sector; From a7edf51cb9fbfaa36bd6208dfbc2b5783a5c120b Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 8 Jan 2020 21:52:10 -0600 Subject: [PATCH 08/22] Stop misusing papersprite vars for sprite skew --- src/r_things.c | 12 ++++++++---- src/r_things.h | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 1f48bcb52..ca3993322 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -876,7 +876,7 @@ static void R_DrawVisSprite(vissprite_t *vis) if (!(vis->scalestep)) { sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); - sprtopscreen += vis->paperdistance * vis->paperoffset; + sprtopscreen += vis->shear.tan * vis->shear.offset; dc_iscale = FixedDiv(FRACUNIT, vis->scale); } @@ -922,7 +922,7 @@ static void R_DrawVisSprite(vissprite_t *vis) else { // Non-paper drawing loop - for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, sprtopscreen += vis->paperdistance) + for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, sprtopscreen += vis->shear.tan) { #ifdef RANGECHECK texturecolumn = frac>>FRACBITS; @@ -1220,7 +1220,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix shadow->gz = shadow->gzt - shadow->patch->height * shadowyscale; shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale)); shadow->scalestep = 0; - shadow->paperdistance = shadowskew; // repurposed variable + shadow->shear.tan = shadowskew; // repurposed variable shadow->mobj = thing; // Easy access! Tails 06-07-2002 @@ -1252,7 +1252,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix // reusing x1 variable x1 += (x2-x1)/2; - shadow->paperoffset = (vis->x1-x1)/2; + shadow->shear.offset = (vis->x1-x1)/2; if (thing->subsector->sector->numlights) { @@ -1723,6 +1723,8 @@ static void R_ProjectSprite(mobj_t *thing) vis->paperoffset = paperoffset; vis->paperdistance = paperdistance; vis->centerangle = centerangle; + vis->shear.tan = 0; + vis->shear.offset = 0; vis->mobj = thing; // Easy access! Tails 06-07-2002 @@ -1950,6 +1952,8 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->texturemid = vis->gzt - viewz; vis->scalestep = 0; vis->paperdistance = 0; + vis->shear.tan = 0; + vis->shear.offset = 0; vis->x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; diff --git a/src/r_things.h b/src/r_things.h index a6ef92802..12f0008eb 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -187,6 +187,11 @@ typedef struct vissprite_s angle_t centerangle; // for paper sprites + struct { + fixed_t tan; // The amount to shear the sprite vertically per row + INT32 offset; // The center of the shearing location offset from x1 + } shear; + fixed_t texturemid; patch_t *patch; From fa4b49d52cb75abd06cee204a1ac0678c919afc8 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 8 Jan 2020 23:19:52 -0600 Subject: [PATCH 09/22] Refactor shadow floor finding code a bit I tried to fix ring shadows on polyobjects and got this in return: https://media.discordapp.net/attachments/629477786943356938/664695818913185822/srb20156.png --- src/r_things.c | 160 +++++++++++++++++++++++++++++++++++-------------- src/r_things.h | 2 + 2 files changed, 117 insertions(+), 45 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index ca3993322..018f5d37f 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1095,6 +1095,120 @@ static void R_SplitSprite(vissprite_t *sprite) } } +// +// R_GetShadowZ(thing, shadowslope) +// Get the first visible floor below the object for shadows +// shadowslope is filled with the floor's slope, if provided +// +fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) +{ + fixed_t z, floorz = INT32_MIN; + pslope_t *slope, *floorslope = NULL; + msecnode_t *node; + sector_t *sector; + ffloor_t *rover; + + for (node = thing->touching_sectorlist; node; node = node->m_sectorlist_next) + { + sector = node->m_sector; + + slope = (sector->heightsec != -1) ? NULL : sector->f_slope; + z = slope ? P_GetZAt(slope, thing->x, thing->y) : ( + (sector->heightsec != -1) ? sectors[sector->heightsec].floorheight : sector->floorheight + ); + + if (z < thing->z+thing->height/2 && z > floorz) + { + floorz = z; + floorslope = slope; + } + + if (sector->ffloors) + for (rover = sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || (rover->alpha < 90 && !(rover->flags & FF_SWIMMABLE))) + continue; + + z = *rover->t_slope ? P_GetZAt(*rover->t_slope, thing->x, thing->y) : *rover->topheight; + if (z < thing->z+thing->height/2 && z > floorz) + { + floorz = z; + floorslope = *rover->t_slope; + } + } + } + + if (thing->floorz > floorz + (!floorslope ? 0 : FixedMul(abs(floorslope->zdelta), thing->radius*3/2))) + { + floorz = thing->floorz; + floorslope = NULL; + } + +#if 0 // Unfortunately, this drops CEZ2 down to sub-17 FPS on my i7. +//#ifdef POLYOBJECTS + // Check polyobjects and see if floorz needs to be altered, for rings only because they don't update floorz + if (thing->type == MT_RING) + { + INT32 xl, xh, yl, yh, bx, by; + + xl = (unsigned)(thing->x - thing->radius - bmaporgx)>>MAPBLOCKSHIFT; + xh = (unsigned)(thing->x + thing->radius - bmaporgx)>>MAPBLOCKSHIFT; + yl = (unsigned)(thing->y - thing->radius - bmaporgy)>>MAPBLOCKSHIFT; + yh = (unsigned)(thing->y + thing->radius - bmaporgy)>>MAPBLOCKSHIFT; + + BMBOUNDFIX(xl, xh, yl, yh); + + validcount++; + + for (by = yl; by <= yh; by++) + for (bx = xl; bx <= xh; bx++) + { + INT32 offset; + polymaplink_t *plink; // haleyjd 02/22/06 + + if (bx < 0 || by < 0 || bx >= bmapwidth || by >= bmapheight) + continue; + + offset = by*bmapwidth + bx; + + // haleyjd 02/22/06: consider polyobject lines + plink = polyblocklinks[offset]; + + while (plink) + { + polyobj_t *po = plink->po; + + if (po->validcount != validcount) // if polyobj hasn't been checked + { + po->validcount = validcount; + + if (!P_MobjInsidePolyobj(po, thing) || !(po->flags & POF_RENDERPLANES)) + { + plink = (polymaplink_t *)(plink->link.next); + continue; + } + + // We're inside it! Yess... + z = po->lines[0]->backsector->ceilingheight; + + if (z < thing->z+thing->height/2 && z > floorz) + { + floorz = z; + floorslope = NULL; + } + } + plink = (polymaplink_t *)(plink->link.next); + } + } + } +#endif + + if (shadowslope != NULL) + *shadowslope = floorslope; + + return floorz; +} + static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fixed_t tz) { vissprite_t *shadow; @@ -1106,51 +1220,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix fixed_t floorz; pslope_t *floorslope; - // Get floorz as the first floor below the object that's visible - floorz = (vis->heightsec != -1) ? sectors[vis->heightsec].floorheight : thing->floorz; - floorslope = (vis->heightsec != -1) ? NULL : thing->standingslope; - - { - boolean original = true; - fixed_t z; - - if (vis->sector->ffloors) - { - ffloor_t *rover = vis->sector->ffloors; - - for (; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || (rover->alpha < 90 && !(rover->flags & FF_SWIMMABLE))) - continue; - - z = *rover->t_slope ? P_GetZAt(*rover->t_slope, thing->x, thing->y) : *rover->topheight; - if (z < thing->z+thing->height/3 && z > floorz) - { - floorz = z; - floorslope = *rover->t_slope; - original = false; - } - else if (original && (*rover->t_slope) && z < thing->z+thing->height/3 && z > floorz - FixedMul(abs((*rover->t_slope)->zdelta), thing->radius*2)) - { - // Guesstimated to be a usable floor. This is here to handle floorslope of non-grounded things, I guess. - floorz = z; - floorslope = *rover->t_slope; - original = false; - } - } - } - - if (original && vis->sector->f_slope) - { - z = P_GetZAt(vis->sector->f_slope, thing->x, thing->y); - if (z < thing->z+thing->height/3 && z > floorz - FixedMul(abs(vis->sector->f_slope->zdelta), thing->radius*2)) - { - floorz = z; - floorslope = vis->sector->f_slope; - } - } - } - + floorz = R_GetShadowZ(thing, &floorslope); if (abs(floorz-viewz)/tz > 4) return; // Prevent stretchy shadows and possible crashes diff --git a/src/r_things.h b/src/r_things.h index 12f0008eb..5649b226b 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -55,6 +55,8 @@ void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight); // (only sprites from namelist are added or replaced) void R_AddSpriteDefs(UINT16 wadnum); +fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); + //SoM: 6/5/2000: Light sprites correctly! void R_AddSprites(sector_t *sec, INT32 lightlevel); void R_InitSprites(void); From 9e8d20504e6f25b5d10b1c44731a2ef696dc4554 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 8 Jan 2020 23:24:31 -0600 Subject: [PATCH 10/22] Refactor shadow scale into an argument --- src/r_things.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 018f5d37f..f2b205429 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1209,7 +1209,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) return floorz; } -static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fixed_t tz) +static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, fixed_t tx, fixed_t tz) { vissprite_t *shadow; patch_t *patch; @@ -1229,11 +1229,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t tx, fix trans = floordiff / (100*FRACUNIT) + 3; if (trans >= 9) return; - scalemul = FRACUNIT - floordiff/640; - - //@TODO make this configurable instead of hardcoding to the ring - if (thing->type == MT_RING) - scalemul = scalemul*2/3; + scalemul = FixedMul(FRACUNIT - floordiff/640, scale); patch = W_CachePatchNum(sprites[SPR_THOK].spriteframes[0].lumppat[0], PU_CACHE); xscale = FixedDiv(projection, tz); @@ -1887,7 +1883,7 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->subsector->sector->numlights) R_SplitSprite(vis); - // temporary: whitelist. eventually: MF/2/E flag? + ///@TODO temporary: whitelist. eventually: MF/2/E flag? if (( oldthing->type == MT_PLAYER || (oldthing->state - states) == S_RING || @@ -1896,7 +1892,10 @@ static void R_ProjectSprite(mobj_t *thing) oldthing->type == MT_EGGMOBILE4_MACE || (oldthing->type >= MT_SMALLMACE && oldthing->type <= MT_REDSPRINGBALL) // .W. ) && !papersprite) - R_ProjectDropShadow(oldthing, vis, basetx, tz); + R_ProjectDropShadow(oldthing, vis, + ///@TODO make this scale configurable! + ((oldthing->state - states) == S_RING) ? 2*FRACUNIT/3 : FRACUNIT, + basetx, tz); // Debug ++objectsdrawn; From 7d2402ac62d5c4a8871aa2f89af5b60f8d5c8d45 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 8 Jan 2020 23:33:43 -0600 Subject: [PATCH 11/22] Fix shadows under hiresscale characters --- src/r_things.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/r_things.c b/src/r_things.c index f2b205429..73c598549 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1285,6 +1285,8 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, shadow->gzt = shadow->pz + shadow->patch->height * shadowyscale / 2; shadow->gz = shadow->gzt - shadow->patch->height * shadowyscale; shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale)); + if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) + shadow->texturemid = FixedMul(shadow->texturemid, ((skin_t *)thing->skin)->highresscale); shadow->scalestep = 0; shadow->shear.tan = shadowskew; // repurposed variable From 4e5f49c60d11382bd054f2bb84b80da7e692d0ee Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 11 Jan 2020 17:39:53 -0600 Subject: [PATCH 12/22] Fix player shadows while on rope hangs etc --- src/p_mobj.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index a4231fa74..50f6106d1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3902,11 +3902,15 @@ static void P_PlayerMobjThinker(mobj_t *mobj) mobj->z += mobj->momz; P_SetThingPosition(mobj); P_CheckPosition(mobj, mobj->x, mobj->y); + mobj->floorz = tmfloorz; + mobj->ceilingz = tmceilingz; goto animonly; } else if (mobj->player->powers[pw_carry] == CR_MACESPIN) { P_CheckPosition(mobj, mobj->x, mobj->y); + mobj->floorz = tmfloorz; + mobj->ceilingz = tmceilingz; goto animonly; } } From 1b0a3d0fe3bb6f5af5cb7177b2e6d3ade4e137c0 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 11 Jan 2020 17:56:49 -0600 Subject: [PATCH 13/22] Use dedicated shadow graphic --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 6cedced1c..ff9993525 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1244,7 +1244,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, scalemul = FixedMul(FRACUNIT - floordiff/640, scale); - patch = W_CachePatchNum(sprites[SPR_THOK].spriteframes[0].lumppat[0], PU_CACHE); + patch = W_CachePatchName("DSHADOW", PU_CACHE); xscale = FixedDiv(projection, tz); yscale = FixedDiv(projectiony, tz); shadowxscale = FixedMul(thing->radius*2, scalemul) / patch->width; From ba8ff3d502b2d8e06d1159f5f27062ae8f3cc49e Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 11 Jan 2020 18:24:08 -0600 Subject: [PATCH 14/22] Add mobj shadowscale property --- src/p_inter.c | 1 + src/p_mobj.c | 16 ++++++++++++++++ src/p_mobj.h | 1 + src/r_things.c | 15 ++------------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 71740822e..b2d158062 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1869,6 +1869,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) S_StartSound(toucher, special->info->deathsound); // was NULL, but changed to player so you could hear others pick up rings P_KillMobj(special, NULL, toucher, 0); + special->shadowscale = 0; } /** Prints death messages relating to a dying or hit player. diff --git a/src/p_mobj.c b/src/p_mobj.c index 50f6106d1..e4de59031 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10557,6 +10557,22 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) else mobj->z = z; + // Set shadowscale here, before spawn hook so that Lua can change it + if ( + type == MT_PLAYER || + type == MT_ROLLOUTROCK || + type == MT_EGGMOBILE4_MACE || + (type >= MT_SMALLMACE && type <= MT_REDSPRINGBALL) || + (mobj->flags & MF_ENEMY) + ) + mobj->shadowscale = FRACUNIT; + else if ( + type >= MT_RING && type <= MT_FLINGEMERALD && type != MT_EMERALDSPAWN + ) + mobj->shadowscale = 2*FRACUNIT/3; + else + mobj->shadowscale = 0; + #ifdef HAVE_BLUA // DANGER! This can cause P_SpawnMobj to return NULL! // Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks! diff --git a/src/p_mobj.h b/src/p_mobj.h index 92160d9e2..fd0c95a56 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -375,6 +375,7 @@ typedef struct mobj_s #endif boolean colorized; // Whether the mobj uses the rainbow colormap + fixed_t shadowscale; // If this object casts a shadow, and the size relative to radius // WARNING: New fields must be added separately to savegame and Lua. } mobj_t; diff --git a/src/r_things.c b/src/r_things.c index ff9993525..0fc806071 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1902,19 +1902,8 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->subsector->sector->numlights) R_SplitSprite(vis); - ///@TODO temporary: whitelist. eventually: MF/2/E flag? - if (( - oldthing->type == MT_PLAYER || - (oldthing->state - states) == S_RING || - oldthing->type == MT_ROLLOUTROCK || - oldthing->flags & MF_ENEMY || - oldthing->type == MT_EGGMOBILE4_MACE || - (oldthing->type >= MT_SMALLMACE && oldthing->type <= MT_REDSPRINGBALL) // .W. - ) && !papersprite) - R_ProjectDropShadow(oldthing, vis, - ///@TODO make this scale configurable! - ((oldthing->state - states) == S_RING) ? 2*FRACUNIT/3 : FRACUNIT, - basetx, tz); + if (oldthing->shadowscale && !papersprite) + R_ProjectDropShadow(oldthing, vis, oldthing->shadowscale, basetx, tz); // Debug ++objectsdrawn; From cfb9b3c234ef55dd719174aa50176c41eb45a206 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 11 Jan 2020 18:28:15 -0600 Subject: [PATCH 15/22] Expose mobj->shadowscale to Lua --- src/lua_mobjlib.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 222487751..fd32b2134 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -88,7 +88,8 @@ enum mobj_e { #ifdef ESLOPE mobj_standingslope, #endif - mobj_colorized + mobj_colorized, + mobj_shadowscale }; static const char *const mobj_opt[] = { @@ -156,6 +157,7 @@ static const char *const mobj_opt[] = { "standingslope", #endif "colorized", + "shadowscale", NULL}; #define UNIMPLEMENTED luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " is not implemented for Lua and cannot be accessed.", mobj_opt[field]) @@ -390,6 +392,9 @@ static int mobj_get(lua_State *L) case mobj_colorized: lua_pushboolean(L, mo->colorized); break; + case mobj_shadowscale: + lua_pushfixed(L, mo->shadowscale); + break; default: // extra custom variables in Lua memory lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); I_Assert(lua_istable(L, -1)); @@ -719,6 +724,8 @@ static int mobj_set(lua_State *L) case mobj_colorized: mo->colorized = luaL_checkboolean(L, 3); break; + case mobj_shadowscale: + mo->shadowscale = luaL_checkfixed(L, 3); default: lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); I_Assert(lua_istable(L, -1)); From 9e101fc2bb8d86cbc0e8317368f1e21fd9fed42b Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 12 Jan 2020 09:10:09 -0600 Subject: [PATCH 16/22] Limit shadow Y scale to prevent graphical bugs --- src/r_things.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 0fc806071..41fb103e3 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1247,8 +1247,10 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, patch = W_CachePatchName("DSHADOW", PU_CACHE); xscale = FixedDiv(projection, tz); yscale = FixedDiv(projectiony, tz); - shadowxscale = FixedMul(thing->radius*2, scalemul) / patch->width; - shadowyscale = FixedMul(FixedMul(thing->radius*2 / patch->height, scalemul), FixedDiv(abs(floorz - viewz), tz)); + shadowxscale = FixedMul(thing->radius*2, scalemul); + shadowyscale = FixedMul(FixedMul(thing->radius*2, scalemul), FixedDiv(abs(floorz - viewz), tz)); + shadowyscale = min(shadowyscale, shadowxscale) / patch->height; + shadowxscale /= patch->width; shadowskew = 0; if (floorslope) From f0843cba132c8da35e76d23f59d8ce6ffa542232 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 17 Jan 2020 00:13:05 -0600 Subject: [PATCH 17/22] Let vissprites have shadows too fuck it, hopefully it works --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 41fb103e3..85452b745 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1904,7 +1904,7 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->subsector->sector->numlights) R_SplitSprite(vis); - if (oldthing->shadowscale && !papersprite) + if (oldthing->shadowscale) R_ProjectDropShadow(oldthing, vis, oldthing->shadowscale, basetx, tz); // Debug From 9a4ad2094743a520c9a09222465abed02f1d0197 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 17 Jan 2020 00:13:13 -0600 Subject: [PATCH 18/22] DAMNIT --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 85452b745..430542a20 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1335,7 +1335,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, // reusing x1 variable x1 += (x2-x1)/2; - shadow->shear.offset = (vis->x1-x1)/2; + shadow->shear.offset = (shadow->x1-x1)/2; if (thing->subsector->sector->numlights) { From 4ca44f2d578bf7d708196388b3883fdb6d0a4808 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 17 Jan 2020 00:16:15 -0600 Subject: [PATCH 19/22] Bosses need dropshadows too --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index e4de59031..a8599ceb5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10563,7 +10563,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) type == MT_ROLLOUTROCK || type == MT_EGGMOBILE4_MACE || (type >= MT_SMALLMACE && type <= MT_REDSPRINGBALL) || - (mobj->flags & MF_ENEMY) + (mobj->flags & (MF_ENEMY|MF_BOSS)) ) mobj->shadowscale = FRACUNIT; else if ( From 919661ff8f149878c18c8628484d626b2ffb77ec Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 17 Jan 2020 00:18:00 -0600 Subject: [PATCH 20/22] Give me a break --- src/lua_mobjlib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index fd32b2134..90733b2c6 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -726,6 +726,7 @@ static int mobj_set(lua_State *L) break; case mobj_shadowscale: mo->shadowscale = luaL_checkfixed(L, 3); + break; default: lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); I_Assert(lua_istable(L, -1)); From d39d8506caeeb2530d9b02ac94ac48e8f5eff63a Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 17 Jan 2020 00:20:10 -0600 Subject: [PATCH 21/22] Let nerds turn off shadows --- src/r_main.c | 6 +----- src/r_main.h | 2 -- src/r_things.c | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 3c6aaf6a6..4b044c6cc 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -128,9 +128,7 @@ consvar_t cv_chasecam2 = {"chasecam2", "On", CV_CALL, CV_OnOff, ChaseCam2_OnChan consvar_t cv_flipcam = {"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_flipcam2 = {"flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -#if defined(FLOORSPLATS) || defined(GLBADSHADOWS) -consvar_t cv_shadow = {"shadow", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif //#if defined(FLOORSPLATS) || defined(GLBADSHADOWS) +consvar_t cv_shadow = {"shadow", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #ifdef GLBADSHADOWS consvar_t cv_shadowoffs = {"offsetshadows", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif //#ifdef GLBADSHADOWS @@ -1223,9 +1221,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_chasecam); CV_RegisterVar(&cv_chasecam2); -#if defined(FLOORSPLATS) || defined(GLBADSHADOWS) CV_RegisterVar(&cv_shadow); -#endif //#if defined(FLOORSPLATS) || defined(GLBADSHADOWS) #ifdef GLBADSHADOWS CV_RegisterVar(&cv_shadowoffs); #endif //#ifdef GLBADSHADOWS diff --git a/src/r_main.h b/src/r_main.h index 998bb50ef..0764c40d2 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -76,9 +76,7 @@ extern consvar_t cv_showhud, cv_translucenthud; extern consvar_t cv_homremoval; extern consvar_t cv_chasecam, cv_chasecam2; extern consvar_t cv_flipcam, cv_flipcam2; -#if defined(FLOORSPLATS) || defined(GLBADSHADOWS) extern consvar_t cv_shadow; -#endif #ifdef GLBADSHADOWS extern conscar_t cv_shadowoffs; #endif //#ifdef GLBADSHADOWS diff --git a/src/r_things.c b/src/r_things.c index 430542a20..680ae4d4f 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1904,7 +1904,7 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->subsector->sector->numlights) R_SplitSprite(vis); - if (oldthing->shadowscale) + if (oldthing->shadowscale && cv_shadow.value) R_ProjectDropShadow(oldthing, vis, oldthing->shadowscale, basetx, tz); // Debug From f59ed6b2f48fab3350f6bebe9373128042c49b1d Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 17 Jan 2020 00:34:57 -0600 Subject: [PATCH 22/22] DOUBLE DAMNIT --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 680ae4d4f..8fa0f2d0e 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1335,7 +1335,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, // reusing x1 variable x1 += (x2-x1)/2; - shadow->shear.offset = (shadow->x1-x1)/2; + shadow->shear.offset = shadow->x1-x1; if (thing->subsector->sector->numlights) {