Simplify ESPSResult to a boolean

This commit is contained in:
Magnus Norddahl 2016-12-25 05:15:23 +01:00
parent b0febec986
commit 57593adeb0
5 changed files with 27 additions and 46 deletions

View File

@ -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);
}

View File

@ -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)());

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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;