From eee7b143e389c3de84c936dfb0c91f87b110aa7f Mon Sep 17 00:00:00 2001 From: Maru <priceisrightfan1988@gmail.com> Date: Fri, 6 Sep 2024 07:20:01 +0000 Subject: [PATCH] Replace r_plane.c --- src/r_plane.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/r_plane.c b/src/r_plane.c index 04272f8d31..45fdb3d80a 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -200,6 +200,8 @@ static void R_MapPlane(INT32 y, INT32 x1, INT32 x2) if (currentplane->extra_colormap) ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps); + ds_fullbright = colormaps; // rr + ds_y = y; ds_x1 = x1; ds_x2 = x2; @@ -239,6 +241,8 @@ static void R_MapTiltedPlane(INT32 y, INT32 x1, INT32 x2) else ds_colormap = colormaps; + ds_fullbright = colormaps; // rr + ds_y = y; ds_x1 = x1; ds_x2 = x2; @@ -371,7 +375,8 @@ static visplane_t *new_visplane(unsigned hash) visplane_t *R_FindPlane(sector_t *sector, fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, fixed_t xscale, fixed_t yscale, angle_t plangle, extracolormap_t *planecolormap, - ffloor_t *pfloor, polyobj_t *polyobj, pslope_t *slope, sectorportal_t *portalsector) + ffloor_t *pfloor, polyobj_t *polyobj, pslope_t *slope, sectorportal_t *portalsector, + boolean reverseLight, const sector_t *lighting_sector) // rr { visplane_t *check; unsigned hash; @@ -408,6 +413,19 @@ visplane_t *R_FindPlane(sector_t *sector, fixed_t height, INT32 picnum, INT32 li yoff += polyobj->centerPt.y; } } + + // rr + if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector)) + { + if (reverseLight && maplighting.directional == true) + { + lightlevel -= slope->lightOffset * 8; + } + else + { + lightlevel += slope->lightOffset * 8; + } + } // This appears to fix the Nimbus Ruins sky bug. if (picnum == skyflatnum && pfloor) @@ -638,6 +656,9 @@ static void R_DrawSkyPlane(visplane_t *pl) dc_colormap = colormaps; dc_texturemid = skytexturemid; dc_texheight = textureheight[texture]>>FRACBITS; + + // rr + dc_fullbright = colormaps; R_CheckTextureCache(texture); @@ -652,6 +673,7 @@ static void R_DrawSkyPlane(visplane_t *pl) dc_iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT)); dc_x = x; dc_source = R_GetColumn(texture, -angle)->pixels; // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18 + dc_brightmap = NULL; // rr colfunc(); } } @@ -894,6 +916,8 @@ void R_DrawSinglePlane(visplane_t *pl) ds_powersoftwo = ds_solidcolor = ds_fog = false; planeripple.active = false; + + ds_brightmap = NULL; // rr if (pl->polyobj) { @@ -1017,6 +1041,21 @@ void R_DrawSinglePlane(visplane_t *pl) R_SetFlatVars(ds_flatwidth * ds_flatheight); ds_powersoftwo = true; } + + // rr + if (levelflat->type == LEVELFLAT_TEXTURE) + { + // Get the span's brightmap. + // FLATS not supported, SORRY!! + INT32 bmNum = R_GetTextureBrightmap(R_GetTextureNumForFlat(levelflat)); + if (bmNum != 0) + { + // FIXME: This has the potential to read out of + // bounds if the brightmap texture is not as + // large as the flat. + ds_brightmap = (UINT8 *)R_GetFlatForTexture(bmNum); + } + } mapfunc = R_MapPlane; -- GitLab