diff --git a/src/swrenderer/line/r_line.cpp b/src/swrenderer/line/r_line.cpp index d702813606..983e3494f9 100644 --- a/src/swrenderer/line/r_line.cpp +++ b/src/swrenderer/line/r_line.cpp @@ -579,7 +579,7 @@ namespace swrenderer // [ZZ] Only if not an active mirror if (!rw_markportal) { - RenderDecal::RenderDecals(curline->sidedef, draw_segment, wallshade, rw_lightleft, rw_lightstep, curline, WallC, foggy, basecolormap); + RenderDecal::RenderDecals(curline->sidedef, draw_segment, wallshade, rw_lightleft, rw_lightstep, curline, WallC, foggy, basecolormap, walltop.ScreenY, wallbottom.ScreenY); } if (rw_markportal) diff --git a/src/swrenderer/line/r_line.h b/src/swrenderer/line/r_line.h index 51ec10787e..3da9e0d854 100644 --- a/src/swrenderer/line/r_line.h +++ b/src/swrenderer/line/r_line.h @@ -123,5 +123,11 @@ namespace swrenderer FDynamicColormap *basecolormap; double lwallscale; + + ProjectedWallLine walltop; + ProjectedWallLine wallbottom; + ProjectedWallLine wallupper; + ProjectedWallLine walllower; + ProjectedWallTexcoords walltexcoords; }; } diff --git a/src/swrenderer/line/r_wallsetup.cpp b/src/swrenderer/line/r_wallsetup.cpp index 4c34f3483c..2c9c824422 100644 --- a/src/swrenderer/line/r_wallsetup.cpp +++ b/src/swrenderer/line/r_wallsetup.cpp @@ -27,12 +27,6 @@ namespace swrenderer { - ProjectedWallLine walltop; - ProjectedWallLine wallbottom; - ProjectedWallLine wallupper; - ProjectedWallLine walllower; - ProjectedWallTexcoords walltexcoords; - ProjectedWallCull ProjectedWallLine::Project(double z, const FWallCoords *wallc) { return Project(z, z, wallc); diff --git a/src/swrenderer/line/r_wallsetup.h b/src/swrenderer/line/r_wallsetup.h index 628a9029b6..1234a33dcf 100644 --- a/src/swrenderer/line/r_wallsetup.h +++ b/src/swrenderer/line/r_wallsetup.h @@ -34,10 +34,4 @@ namespace swrenderer void Project(double walxrepeat, int x1, int x2, const FWallTmapVals &WallT); void ProjectPos(double walxrepeat, int x1, int x2, const FWallTmapVals &WallT); }; - - extern ProjectedWallLine walltop; - extern ProjectedWallLine wallbottom; - extern ProjectedWallLine wallupper; - extern ProjectedWallLine walllower; - extern ProjectedWallTexcoords walltexcoords; } diff --git a/src/swrenderer/segments/r_drawsegment.cpp b/src/swrenderer/segments/r_drawsegment.cpp index e5864f8050..da42923337 100644 --- a/src/swrenderer/segments/r_drawsegment.cpp +++ b/src/swrenderer/segments/r_drawsegment.cpp @@ -68,6 +68,9 @@ namespace swrenderer float rw_lightstep; fixed_t rw_offset; FTexture *rw_pic; + + ProjectedWallLine wallupper; + ProjectedWallLine walllower; } void R_FreeDrawSegs() @@ -546,6 +549,7 @@ namespace swrenderer walllower.ScreenY[i] = mfloorclip[i]; } + ProjectedWallTexcoords walltexcoords; walltexcoords.ProjectPos(curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2, WallT); R_DrawDrawSeg(frontsector, curline, WallC, rw_pic, ds, x1, x2, wallupper.ScreenY, walllower.ScreenY, texturemid, MaskedSWall, walltexcoords.UPos, yscale, wallshade, rw_offset, rw_light, rw_lightstep, ds->foggy, basecolormap); } diff --git a/src/swrenderer/things/r_decal.cpp b/src/swrenderer/things/r_decal.cpp index c25341c09e..3e082aeb4a 100644 --- a/src/swrenderer/things/r_decal.cpp +++ b/src/swrenderer/things/r_decal.cpp @@ -47,11 +47,11 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); namespace swrenderer { - void RenderDecal::RenderDecals(side_t *sidedef, drawseg_t *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap) + void RenderDecal::RenderDecals(side_t *sidedef, drawseg_t *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom) { for (DBaseDecal *decal = sidedef->AttachedDecals; decal != NULL; decal = decal->WallNext) { - Render(sidedef, decal, draw_segment, wallshade, lightleft, lightstep, curline, wallC, foggy, basecolormap, 0); + Render(sidedef, decal, draw_segment, wallshade, lightleft, lightstep, curline, wallC, foggy, basecolormap, walltop, wallbottom, 0); } } @@ -59,7 +59,7 @@ namespace swrenderer // = 1: drawing masked textures (including sprites) // Currently, only pass = 0 is done or used - void RenderDecal::Render(side_t *wall, DBaseDecal *decal, drawseg_t *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, FWallCoords WallC, bool foggy, FDynamicColormap *basecolormap, int pass) + void RenderDecal::Render(side_t *wall, DBaseDecal *decal, drawseg_t *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, FWallCoords WallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, int pass) { DVector2 decal_left, decal_right, decal_pos; int x1, x2; @@ -72,8 +72,8 @@ namespace swrenderer bool rereadcolormap; FDynamicColormap *usecolormap; float light = 0; - short *mfloorclip; - short *mceilingclip; + const short *mfloorclip; + const short *mceilingclip; if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid()) return; @@ -171,12 +171,12 @@ namespace swrenderer { goto done; } - mceilingclip = walltop.ScreenY; - mfloorclip = wallbottom.ScreenY; + mceilingclip = walltop; + mfloorclip = wallbottom; } else if (pass == 0) { - mceilingclip = walltop.ScreenY; + mceilingclip = walltop; mfloorclip = RenderOpaquePass::Instance()->ceilingclip; needrepeat = 1; } @@ -192,7 +192,7 @@ namespace swrenderer { goto done; } - mceilingclip = walltop.ScreenY; + mceilingclip = walltop; mfloorclip = RenderOpaquePass::Instance()->ceilingclip; break; @@ -211,7 +211,7 @@ namespace swrenderer goto done; } mceilingclip = RenderOpaquePass::Instance()->floorclip; - mfloorclip = wallbottom.ScreenY; + mfloorclip = wallbottom; break; } @@ -226,6 +226,7 @@ namespace swrenderer goto done; } + ProjectedWallTexcoords walltexcoords; walltexcoords.Project(WallSpriteTile->GetWidth(), x1, x2, WallT); if (flipx) @@ -295,7 +296,7 @@ namespace swrenderer { // calculate lighting R_SetColorMapLight(usecolormap, light, wallshade); } - DrawColumn(x, WallSpriteTile, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip); + DrawColumn(x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip); light += lightstep; x++; } @@ -305,7 +306,7 @@ namespace swrenderer // be set 1 if we need to draw on the lower wall. In all other cases, // needrepeat will be 0, and the while will fail. mceilingclip = RenderOpaquePass::Instance()->floorclip; - mfloorclip = wallbottom.ScreenY; + mfloorclip = wallbottom; } while (needrepeat--); colfunc = basecolfunc; @@ -314,7 +315,7 @@ namespace swrenderer WallC = savecoord; } - void RenderDecal::DrawColumn(int x, FTexture *WallSpriteTile, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip) + void RenderDecal::DrawColumn(int x, FTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip) { float iscale = walltexcoords.VStep[x] * maskedScaleY; double spryscale = 1 / iscale; diff --git a/src/swrenderer/things/r_decal.h b/src/swrenderer/things/r_decal.h index 1bd9f85b70..20670c6f47 100644 --- a/src/swrenderer/things/r_decal.h +++ b/src/swrenderer/things/r_decal.h @@ -19,14 +19,15 @@ class DBaseDecal; namespace swrenderer { struct drawseg_t; + class ProjectedWallTexcoords; class RenderDecal { public: - static void RenderDecals(side_t *wall, drawseg_t *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap); + static void RenderDecals(side_t *wall, drawseg_t *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom); private: - static void Render(side_t *wall, DBaseDecal *first, drawseg_t *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, FWallCoords wallC, bool foggy, FDynamicColormap *basecolormap, int pass); - static void DrawColumn(int x, FTexture *WallSpriteTile, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip); + static void Render(side_t *wall, DBaseDecal *first, drawseg_t *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, FWallCoords wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, int pass); + static void DrawColumn(int x, FTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip); }; } diff --git a/src/swrenderer/things/r_wallsprite.cpp b/src/swrenderer/things/r_wallsprite.cpp index 8951724b30..a6da5ff0e8 100644 --- a/src/swrenderer/things/r_wallsprite.cpp +++ b/src/swrenderer/things/r_wallsprite.cpp @@ -149,9 +149,13 @@ namespace swrenderer x2 = MIN(spr->x2, spr->wallc.sx2); if (x1 >= x2) return; + FWallTmapVals WallT; WallT.InitFromWallCoords(&spr->wallc); + + ProjectedWallTexcoords walltexcoords; walltexcoords.Project(spr->pic->GetWidth() << FRACBITS, x1, x2, WallT); + iyscale = 1 / spr->yscale; double texturemid = (spr->gzt - ViewPos.Z) * iyscale; if (spr->renderflags & RF_XFLIP) @@ -229,14 +233,14 @@ namespace swrenderer R_SetColorMapLight(usecolormap, light, shade); } if (!RenderTranslucentPass::ClipSpriteColumnWithPortals(x, spr)) - DrawColumn(x, WallSpriteTile, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip); + DrawColumn(x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip); light += lightstep; x++; } } } - void RenderWallSprite::DrawColumn(int x, FTexture *WallSpriteTile, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip) + void RenderWallSprite::DrawColumn(int x, FTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip) { float iscale = walltexcoords.VStep[x] * maskedScaleY; double spryscale = 1 / iscale; diff --git a/src/swrenderer/things/r_wallsprite.h b/src/swrenderer/things/r_wallsprite.h index a68454b2e4..6c2976d361 100644 --- a/src/swrenderer/things/r_wallsprite.h +++ b/src/swrenderer/things/r_wallsprite.h @@ -17,6 +17,8 @@ namespace swrenderer { + class ProjectedWallTexcoords; + class RenderWallSprite : public VisibleSprite { public: @@ -27,7 +29,7 @@ namespace swrenderer void Render(short *cliptop, short *clipbottom, int minZ, int maxZ) override; private: - static void DrawColumn(int x, FTexture *WallSpriteTile, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip); + static void DrawColumn(int x, FTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip); FWallCoords wallc; uint32_t Translation = 0;