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; 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; using namespace drawerargs;
@ -445,13 +445,13 @@ namespace swrenderer
if (style.BlendOp == STYLEOP_Fuzz) if (style.BlendOp == STYLEOP_Fuzz)
{ {
colfunc = fuzzcolfunc; colfunc = fuzzcolfunc;
return DoDraw; return true;
} }
else if (style == LegacyRenderStyles[STYLE_Shaded]) else if (style == LegacyRenderStyles[STYLE_Shaded])
{ {
// Shaded drawer only gets 16 levels of alpha because it saves memory. // Shaded drawer only gets 16 levels of alpha because it saves memory.
if ((alpha >>= 12) == 0) if ((alpha >>= 12) == 0)
return DontDraw; return false;
colfunc = R_DrawShadedColumn; colfunc = R_DrawShadedColumn;
hcolfunc_post1 = rt_shaded1col; hcolfunc_post1 = rt_shaded1col;
hcolfunc_post4 = rt_shaded4cols; hcolfunc_post4 = rt_shaded4cols;
@ -466,7 +466,7 @@ namespace swrenderer
{ {
R_SetColorMapLight(basecolormap, 0, 0); R_SetColorMapLight(basecolormap, 0, 0);
} }
return DoDraw; return true;
} }
fglevel = GetAlpha(style.SrcAlpha, alpha); fglevel = GetAlpha(style.SrcAlpha, alpha);
@ -497,12 +497,12 @@ namespace swrenderer
if (!R_SetBlendFunc(style.BlendOp, fglevel, bglevel, style.Flags)) 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); return R_SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color);
} }

View file

@ -127,14 +127,8 @@ namespace swrenderer
void R_InitShadeMaps(); void R_InitShadeMaps();
void R_InitFuzzTable(int fuzzoff); void R_InitFuzzTable(int fuzzoff);
enum ESPSResult 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);
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);
void R_FinishSetPatchStyle(); // Call this after finished drawing the current thing, in case its style was STYLE_Shade 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)()); 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; curline = ds->curline;
// killough 4/11/98: draw translucent 2s normal textures bool visible = R_SetPatchStyle (LegacyRenderStyles[curline->linedef->flags & ML_ADDTRANS ? STYLE_Add : STYLE_Translucent],
// [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],
(float)MIN(curline->linedef->alpha, 1.), 0, 0); (float)MIN(curline->linedef->alpha, 1.), 0, 0);
if ((drawmode == DontDraw && !ds->bFogBoundary && !ds->bFakeBoundary)) if (!visible && !ds->bFogBoundary && !ds->bFakeBoundary)
{ {
return; return;
} }
@ -280,7 +276,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2)
goto clearfog; goto clearfog;
} }
} }
if ((ds->bFakeBoundary && !(ds->bFakeBoundary & 4)) || drawmode == DontDraw) if ((ds->bFakeBoundary && !(ds->bFakeBoundary & 4)) || !visible)
{ {
goto clearfog; goto clearfog;
} }
@ -415,7 +411,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2)
mceilingclip = wallupper; mceilingclip = wallupper;
// draw the columns one at a time // draw the columns one at a time
if (drawmode == DoDraw) if (visible)
{ {
for (dc_x = x1; dc_x < x2; ++dc_x) 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; double yscale;
fixed_t Alpha = Scale(rover->alpha, OPAQUE, 255); fixed_t Alpha = Scale(rover->alpha, OPAQUE, 255);
ESPSResult drawmode; bool visible = R_SetPatchStyle (LegacyRenderStyles[rover->flags & FF_ADDITIVETRANS ? STYLE_Add : STYLE_Translucent],
drawmode = R_SetPatchStyle (LegacyRenderStyles[rover->flags & FF_ADDITIVETRANS ? STYLE_Add : STYLE_Translucent],
Alpha, 0, 0); Alpha, 0, 0);
if(drawmode == DontDraw) { if(!visible) {
R_FinishSetPatchStyle(); R_FinishSetPatchStyle();
return; return;
} }
@ -2297,9 +2292,8 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
do do
{ {
dc_x = x1; 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. // R_SetPatchStyle can modify basecolormap.
if (rereadcolormap) if (rereadcolormap)
@ -2307,11 +2301,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
usecolormap = basecolormap; usecolormap = basecolormap;
} }
if (mode == DontDraw) if (visible)
{
needrepeat = 0;
}
else
{ {
while (dc_x < x2) while (dc_x < x2)
{ {

View file

@ -532,7 +532,6 @@ void R_DrawVisSprite (vissprite_t *vis)
FTexture *tex; FTexture *tex;
int x2; int x2;
fixed_t xiscale; fixed_t xiscale;
ESPSResult mode;
bool ispsprite = (!vis->sector && vis->gpos != FVector3(0, 0, 0)); bool ispsprite = (!vis->sector && vis->gpos != FVector3(0, 0, 0));
if (vis->xscale == 0 || fabs(vis->yscale) < (1.0f / 32000.0f)) 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); fixed_t centeryfrac = FLOAT2FIXED(CenterY);
R_SetColorMapLight(vis->Style.BaseColormap, 0, vis->Style.ColormapNum << FRACBITS); 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]) if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Shaded])
{ // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but { // 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); R_SetColorMapLight(dc_fcolormap, 0, vis->Style.ColormapNum << FRACBITS);
} }
if (mode != DontDraw) if (visible)
{ {
tex = vis->pic; tex = vis->pic;
spryscale = vis->yscale; spryscale = vis->yscale;
@ -660,9 +659,8 @@ void R_DrawWallSprite(vissprite_t *spr)
MaskedScaleY = (float)iyscale; MaskedScaleY = (float)iyscale;
dc_x = x1; 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. // R_SetPatchStyle can modify basecolormap.
if (rereadcolormap) if (rereadcolormap)
@ -670,7 +668,7 @@ void R_DrawWallSprite(vissprite_t *spr)
usecolormap = basecolormap; usecolormap = basecolormap;
} }
if (mode == DontDraw) if (!visible)
{ {
return; return;
} }
@ -707,14 +705,13 @@ void R_WallSpriteColumn (bool useRt)
void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop, short *clipbot) void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop, short *clipbot)
{ {
ESPSResult mode;
int flags = 0; int flags = 0;
// Do setup for blending. // Do setup for blending.
R_SetColorMapLight(spr->Style.BaseColormap, 0, spr->Style.ColormapNum << FRACBITS); 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; return;
} }

View file

@ -190,11 +190,11 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
} }
fixedcolormap = dc_fcolormap; fixedcolormap = dc_fcolormap;
ESPSResult mode; bool visible;
if (r_swtruecolor) if (r_swtruecolor)
mode = R_SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor); visible = R_SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor);
else 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; BYTE *destorgsave = dc_destorg;
int destheightsave = dc_destheight; 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 x0 = parms.x - parms.left * parms.destwidth / parms.texwidth;
double y0 = parms.y - parms.top * parms.destheight / parms.texheight; double y0 = parms.y - parms.top * parms.destheight / parms.texheight;
if (mode != DontDraw) if (visible)
{ {
double centeryback = CenterY; double centeryback = CenterY;
CenterY = 0; CenterY = 0;