From 57593adeb00df85011dc7a2ac6ab634884deb8e8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Dec 2016 05:15:23 +0100 Subject: [PATCH] Simplify ESPSResult to a boolean --- src/r_draw.cpp | 14 +++++++------- src/r_draw.h | 10 ++-------- src/r_segs.cpp | 26 ++++++++------------------ src/r_things.cpp | 15 ++++++--------- src/v_draw.cpp | 8 ++++---- 5 files changed, 27 insertions(+), 46 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 4ec274593..c7bf95eed 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -393,7 +393,7 @@ namespace swrenderer FDynamicColormap *basecolormapsave; } - ESPSResult R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color) + bool R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color) { using namespace drawerargs; @@ -445,13 +445,13 @@ namespace swrenderer if (style.BlendOp == STYLEOP_Fuzz) { colfunc = fuzzcolfunc; - return DoDraw; + return true; } else if (style == LegacyRenderStyles[STYLE_Shaded]) { // Shaded drawer only gets 16 levels of alpha because it saves memory. if ((alpha >>= 12) == 0) - return DontDraw; + return false; colfunc = R_DrawShadedColumn; hcolfunc_post1 = rt_shaded1col; hcolfunc_post4 = rt_shaded4cols; @@ -466,7 +466,7 @@ namespace swrenderer { R_SetColorMapLight(basecolormap, 0, 0); } - return DoDraw; + return true; } fglevel = GetAlpha(style.SrcAlpha, alpha); @@ -497,12 +497,12 @@ namespace swrenderer if (!R_SetBlendFunc(style.BlendOp, fglevel, bglevel, style.Flags)) { - return DontDraw; + return false; } - return DoDraw; + return true; } - ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color) + bool R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color) { return R_SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color); } diff --git a/src/r_draw.h b/src/r_draw.h index 367cba36b..752647943 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -127,14 +127,8 @@ namespace swrenderer void R_InitShadeMaps(); void R_InitFuzzTable(int fuzzoff); - enum ESPSResult - { - DontDraw, // not useful to draw this - DoDraw // draw this - }; - - ESPSResult R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color); - ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color); + bool R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color); + bool R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color); void R_FinishSetPatchStyle(); // Call this after finished drawing the current thing, in case its style was STYLE_Shade bool R_GetTransMaskDrawers(void(**drawCol1)(), void(**drawCol4)()); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index f171d7933..edad2aecc 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -218,14 +218,10 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) curline = ds->curline; - // killough 4/11/98: draw translucent 2s normal textures - // [RH] modified because we don't use user-definable translucency maps - ESPSResult drawmode; - - drawmode = R_SetPatchStyle (LegacyRenderStyles[curline->linedef->flags & ML_ADDTRANS ? STYLE_Add : STYLE_Translucent], + bool visible = R_SetPatchStyle (LegacyRenderStyles[curline->linedef->flags & ML_ADDTRANS ? STYLE_Add : STYLE_Translucent], (float)MIN(curline->linedef->alpha, 1.), 0, 0); - if ((drawmode == DontDraw && !ds->bFogBoundary && !ds->bFakeBoundary)) + if (!visible && !ds->bFogBoundary && !ds->bFakeBoundary) { return; } @@ -280,7 +276,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) goto clearfog; } } - if ((ds->bFakeBoundary && !(ds->bFakeBoundary & 4)) || drawmode == DontDraw) + if ((ds->bFakeBoundary && !(ds->bFakeBoundary & 4)) || !visible) { goto clearfog; } @@ -415,7 +411,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) mceilingclip = wallupper; // draw the columns one at a time - if (drawmode == DoDraw) + if (visible) { for (dc_x = x1; dc_x < x2; ++dc_x) { @@ -512,11 +508,10 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) double yscale; fixed_t Alpha = Scale(rover->alpha, OPAQUE, 255); - ESPSResult drawmode; - drawmode = R_SetPatchStyle (LegacyRenderStyles[rover->flags & FF_ADDITIVETRANS ? STYLE_Add : STYLE_Translucent], + bool visible = R_SetPatchStyle (LegacyRenderStyles[rover->flags & FF_ADDITIVETRANS ? STYLE_Add : STYLE_Translucent], Alpha, 0, 0); - if(drawmode == DontDraw) { + if(!visible) { R_FinishSetPatchStyle(); return; } @@ -2297,9 +2292,8 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, do { dc_x = x1; - ESPSResult mode; - mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); + bool visible = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); // R_SetPatchStyle can modify basecolormap. if (rereadcolormap) @@ -2307,11 +2301,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, usecolormap = basecolormap; } - if (mode == DontDraw) - { - needrepeat = 0; - } - else + if (visible) { while (dc_x < x2) { diff --git a/src/r_things.cpp b/src/r_things.cpp index 7b6114d00..22d6b7ac6 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -532,7 +532,6 @@ void R_DrawVisSprite (vissprite_t *vis) FTexture *tex; int x2; fixed_t xiscale; - ESPSResult mode; bool ispsprite = (!vis->sector && vis->gpos != FVector3(0, 0, 0)); if (vis->xscale == 0 || fabs(vis->yscale) < (1.0f / 32000.0f)) @@ -543,7 +542,7 @@ void R_DrawVisSprite (vissprite_t *vis) fixed_t centeryfrac = FLOAT2FIXED(CenterY); R_SetColorMapLight(vis->Style.BaseColormap, 0, vis->Style.ColormapNum << FRACBITS); - mode = R_SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); + bool visible = R_SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Shaded]) { // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but @@ -552,7 +551,7 @@ void R_DrawVisSprite (vissprite_t *vis) R_SetColorMapLight(dc_fcolormap, 0, vis->Style.ColormapNum << FRACBITS); } - if (mode != DontDraw) + if (visible) { tex = vis->pic; spryscale = vis->yscale; @@ -660,9 +659,8 @@ void R_DrawWallSprite(vissprite_t *spr) MaskedScaleY = (float)iyscale; dc_x = x1; - ESPSResult mode; - mode = R_SetPatchStyle (spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); + bool visible = R_SetPatchStyle (spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); // R_SetPatchStyle can modify basecolormap. if (rereadcolormap) @@ -670,7 +668,7 @@ void R_DrawWallSprite(vissprite_t *spr) usecolormap = basecolormap; } - if (mode == DontDraw) + if (!visible) { return; } @@ -707,14 +705,13 @@ void R_WallSpriteColumn (bool useRt) void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop, short *clipbot) { - ESPSResult mode; int flags = 0; // Do setup for blending. R_SetColorMapLight(spr->Style.BaseColormap, 0, spr->Style.ColormapNum << FRACBITS); - mode = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); + bool visible = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); - if (mode == DontDraw) + if (!visible) { return; } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 0e75bc282..df5dd5cf0 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -190,11 +190,11 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) } fixedcolormap = dc_fcolormap; - ESPSResult mode; + bool visible; if (r_swtruecolor) - mode = R_SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor); + visible = R_SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor); else - mode = R_SetPatchStyle(parms.style, parms.Alpha, 0, parms.fillcolor); + visible = R_SetPatchStyle(parms.style, parms.Alpha, 0, parms.fillcolor); BYTE *destorgsave = dc_destorg; int destheightsave = dc_destheight; @@ -208,7 +208,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) double x0 = parms.x - parms.left * parms.destwidth / parms.texwidth; double y0 = parms.y - parms.top * parms.destheight / parms.texheight; - if (mode != DontDraw) + if (visible) { double centeryback = CenterY; CenterY = 0;