Make wallsetup globals local to where they are used

This commit is contained in:
Magnus Norddahl 2017-01-24 07:06:47 +01:00
parent ac74a7a1e0
commit b256f6ed89
9 changed files with 38 additions and 32 deletions

View file

@ -579,7 +579,7 @@ namespace swrenderer
// [ZZ] Only if not an active mirror // [ZZ] Only if not an active mirror
if (!rw_markportal) 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) if (rw_markportal)

View file

@ -123,5 +123,11 @@ namespace swrenderer
FDynamicColormap *basecolormap; FDynamicColormap *basecolormap;
double lwallscale; double lwallscale;
ProjectedWallLine walltop;
ProjectedWallLine wallbottom;
ProjectedWallLine wallupper;
ProjectedWallLine walllower;
ProjectedWallTexcoords walltexcoords;
}; };
} }

View file

@ -27,12 +27,6 @@
namespace swrenderer namespace swrenderer
{ {
ProjectedWallLine walltop;
ProjectedWallLine wallbottom;
ProjectedWallLine wallupper;
ProjectedWallLine walllower;
ProjectedWallTexcoords walltexcoords;
ProjectedWallCull ProjectedWallLine::Project(double z, const FWallCoords *wallc) ProjectedWallCull ProjectedWallLine::Project(double z, const FWallCoords *wallc)
{ {
return Project(z, z, wallc); return Project(z, z, wallc);

View file

@ -34,10 +34,4 @@ namespace swrenderer
void Project(double walxrepeat, int x1, int x2, const FWallTmapVals &WallT); void Project(double walxrepeat, int x1, int x2, const FWallTmapVals &WallT);
void ProjectPos(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;
} }

View file

@ -68,6 +68,9 @@ namespace swrenderer
float rw_lightstep; float rw_lightstep;
fixed_t rw_offset; fixed_t rw_offset;
FTexture *rw_pic; FTexture *rw_pic;
ProjectedWallLine wallupper;
ProjectedWallLine walllower;
} }
void R_FreeDrawSegs() void R_FreeDrawSegs()
@ -546,6 +549,7 @@ namespace swrenderer
walllower.ScreenY[i] = mfloorclip[i]; walllower.ScreenY[i] = mfloorclip[i];
} }
ProjectedWallTexcoords walltexcoords;
walltexcoords.ProjectPos(curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2, WallT); 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); 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);
} }

View file

@ -47,11 +47,11 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
namespace swrenderer 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) 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) // = 1: drawing masked textures (including sprites)
// Currently, only pass = 0 is done or used // 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; DVector2 decal_left, decal_right, decal_pos;
int x1, x2; int x1, x2;
@ -72,8 +72,8 @@ namespace swrenderer
bool rereadcolormap; bool rereadcolormap;
FDynamicColormap *usecolormap; FDynamicColormap *usecolormap;
float light = 0; float light = 0;
short *mfloorclip; const short *mfloorclip;
short *mceilingclip; const short *mceilingclip;
if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid()) if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid())
return; return;
@ -171,12 +171,12 @@ namespace swrenderer
{ {
goto done; goto done;
} }
mceilingclip = walltop.ScreenY; mceilingclip = walltop;
mfloorclip = wallbottom.ScreenY; mfloorclip = wallbottom;
} }
else if (pass == 0) else if (pass == 0)
{ {
mceilingclip = walltop.ScreenY; mceilingclip = walltop;
mfloorclip = RenderOpaquePass::Instance()->ceilingclip; mfloorclip = RenderOpaquePass::Instance()->ceilingclip;
needrepeat = 1; needrepeat = 1;
} }
@ -192,7 +192,7 @@ namespace swrenderer
{ {
goto done; goto done;
} }
mceilingclip = walltop.ScreenY; mceilingclip = walltop;
mfloorclip = RenderOpaquePass::Instance()->ceilingclip; mfloorclip = RenderOpaquePass::Instance()->ceilingclip;
break; break;
@ -211,7 +211,7 @@ namespace swrenderer
goto done; goto done;
} }
mceilingclip = RenderOpaquePass::Instance()->floorclip; mceilingclip = RenderOpaquePass::Instance()->floorclip;
mfloorclip = wallbottom.ScreenY; mfloorclip = wallbottom;
break; break;
} }
@ -226,6 +226,7 @@ namespace swrenderer
goto done; goto done;
} }
ProjectedWallTexcoords walltexcoords;
walltexcoords.Project(WallSpriteTile->GetWidth(), x1, x2, WallT); walltexcoords.Project(WallSpriteTile->GetWidth(), x1, x2, WallT);
if (flipx) if (flipx)
@ -295,7 +296,7 @@ namespace swrenderer
{ // calculate lighting { // calculate lighting
R_SetColorMapLight(usecolormap, light, wallshade); R_SetColorMapLight(usecolormap, light, wallshade);
} }
DrawColumn(x, WallSpriteTile, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip); DrawColumn(x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip);
light += lightstep; light += lightstep;
x++; x++;
} }
@ -305,7 +306,7 @@ namespace swrenderer
// be set 1 if we need to draw on the lower wall. In all other cases, // 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. // needrepeat will be 0, and the while will fail.
mceilingclip = RenderOpaquePass::Instance()->floorclip; mceilingclip = RenderOpaquePass::Instance()->floorclip;
mfloorclip = wallbottom.ScreenY; mfloorclip = wallbottom;
} while (needrepeat--); } while (needrepeat--);
colfunc = basecolfunc; colfunc = basecolfunc;
@ -314,7 +315,7 @@ namespace swrenderer
WallC = savecoord; 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; float iscale = walltexcoords.VStep[x] * maskedScaleY;
double spryscale = 1 / iscale; double spryscale = 1 / iscale;

View file

@ -19,14 +19,15 @@ class DBaseDecal;
namespace swrenderer namespace swrenderer
{ {
struct drawseg_t; struct drawseg_t;
class ProjectedWallTexcoords;
class RenderDecal class RenderDecal
{ {
public: 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: 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 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, 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);
}; };
} }

View file

@ -149,9 +149,13 @@ namespace swrenderer
x2 = MIN<int>(spr->x2, spr->wallc.sx2); x2 = MIN<int>(spr->x2, spr->wallc.sx2);
if (x1 >= x2) if (x1 >= x2)
return; return;
FWallTmapVals WallT; FWallTmapVals WallT;
WallT.InitFromWallCoords(&spr->wallc); WallT.InitFromWallCoords(&spr->wallc);
ProjectedWallTexcoords walltexcoords;
walltexcoords.Project(spr->pic->GetWidth() << FRACBITS, x1, x2, WallT); walltexcoords.Project(spr->pic->GetWidth() << FRACBITS, x1, x2, WallT);
iyscale = 1 / spr->yscale; iyscale = 1 / spr->yscale;
double texturemid = (spr->gzt - ViewPos.Z) * iyscale; double texturemid = (spr->gzt - ViewPos.Z) * iyscale;
if (spr->renderflags & RF_XFLIP) if (spr->renderflags & RF_XFLIP)
@ -229,14 +233,14 @@ namespace swrenderer
R_SetColorMapLight(usecolormap, light, shade); R_SetColorMapLight(usecolormap, light, shade);
} }
if (!RenderTranslucentPass::ClipSpriteColumnWithPortals(x, spr)) if (!RenderTranslucentPass::ClipSpriteColumnWithPortals(x, spr))
DrawColumn(x, WallSpriteTile, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip); DrawColumn(x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip);
light += lightstep; light += lightstep;
x++; 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; float iscale = walltexcoords.VStep[x] * maskedScaleY;
double spryscale = 1 / iscale; double spryscale = 1 / iscale;

View file

@ -17,6 +17,8 @@
namespace swrenderer namespace swrenderer
{ {
class ProjectedWallTexcoords;
class RenderWallSprite : public VisibleSprite class RenderWallSprite : public VisibleSprite
{ {
public: public:
@ -27,7 +29,7 @@ namespace swrenderer
void Render(short *cliptop, short *clipbottom, int minZ, int maxZ) override; void Render(short *cliptop, short *clipbottom, int minZ, int maxZ) override;
private: 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; FWallCoords wallc;
uint32_t Translation = 0; uint32_t Translation = 0;