From b98207035d4c8ed55fb458d5bd7e221e5e129206 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 25 Apr 2022 14:16:41 -0400 Subject: [PATCH] Fix plane interpolation light level flickering --- src/r_bsp.c | 20 ++++++++++++++++++-- src/r_fps.c | 7 ++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index c9f269816..b8e1d69c5 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -836,6 +836,7 @@ static void R_Subsector(size_t num) extracolormap_t *floorcolormap; extracolormap_t *ceilingcolormap; fixed_t floorcenterz, ceilingcenterz; + ffloor_t *rover; #ifdef RANGECHECK if (num >= numsubsectors) @@ -862,7 +863,23 @@ static void R_Subsector(size_t num) // Check and prep all 3D floors. Set the sector floor/ceiling light levels and colormaps. if (frontsector->ffloors) { - if (frontsector->moved) + boolean anyMoved = frontsector->moved; + + if (anyMoved == false) + { + for (rover = frontsector->ffloors; rover; rover = rover->next) + { + sector_t *controlSec = §ors[rover->secnum]; + + if (controlSec->moved == true) + { + anyMoved = true; + break; + } + } + } + + if (anyMoved == true) { frontsector->numlights = sub->sector->numlights = 0; R_Prep3DFloors(frontsector); @@ -910,7 +927,6 @@ static void R_Subsector(size_t num) ffloor[numffloors].polyobj = NULL; if (frontsector->ffloors) { - ffloor_t *rover; fixed_t heightcheck, planecenterz; for (rover = frontsector->ffloors; rover && numffloors < MAXFFLOORS; rover = rover->next) diff --git a/src/r_fps.c b/src/r_fps.c index 732052eac..738df2020 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -455,20 +455,19 @@ void R_UpdateLevelInterpolators(void) for (i = 0; i < levelinterpolators_len; i++) { levelinterpolator_t *interp = levelinterpolators[i]; - + UpdateLevelInterpolatorState(interp); } } void R_ClearLevelInterpolatorState(thinker_t *thinker) { - size_t i; for (i = 0; i < levelinterpolators_len; i++) { levelinterpolator_t *interp = levelinterpolators[i]; - + if (interp->thinker == thinker) { // Do it twice to make the old state match the new @@ -497,6 +496,7 @@ void R_ApplyLevelInterpolators(fixed_t frac) { interp->sectorplane.sector->floorheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); } + interp->sectorplane.sector->moved = true; break; case LVLINTERP_SectorScroll: if (interp->sectorscroll.ceiling) @@ -551,6 +551,7 @@ void R_RestoreLevelInterpolators(void) { interp->sectorplane.sector->floorheight = interp->sectorplane.bakheight; } + interp->sectorplane.sector->moved = true; break; case LVLINTERP_SectorScroll: if (interp->sectorscroll.ceiling)