mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-25 13:31:07 +00:00
Added priority renderstyles, and added PSPF_FORCE(ALPHA / STYLE).
- Renderstyles now override alpha based on which is used. - The new flags will override whatever renderstyle and alpha is currently being utilized.
This commit is contained in:
parent
4865e7109c
commit
8cfeca655d
3 changed files with 98 additions and 14 deletions
|
@ -60,6 +60,8 @@ enum PSPFlags
|
|||
PSPF_ALPHA = 1 << 4,
|
||||
PSPF_RENDERSTYLE = 1 << 5,
|
||||
PSPF_FLIP = 1 << 6,
|
||||
PSPF_FORCEALPHA = 1 << 7,
|
||||
PSPF_FORCESTYLE = 1 << 8,
|
||||
};
|
||||
|
||||
class DPSprite : public DObject
|
||||
|
|
|
@ -1424,27 +1424,104 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double
|
|||
FDynamicColormap *colormap_to_use = nullptr;
|
||||
if (pspr->GetID() < PSP_TARGETCENTER)
|
||||
{
|
||||
// Set the alpha based on if using the overlay's own or not.
|
||||
vis->Style.Alpha = (pspr->Flags & PSPF_ALPHA) ? float(alpha) : float(owner->Alpha);
|
||||
// [MC] Set the render style
|
||||
|
||||
// Set the render style
|
||||
if (pspr->Flags & PSPF_RENDERSTYLE)
|
||||
{
|
||||
const int rs = clamp<int>(pspr->RenderStyle, 0, STYLE_Count);
|
||||
|
||||
if (rs == STYLE_Normal && vis->Style.Alpha < 1.0)
|
||||
vis->Style.RenderStyle = LegacyRenderStyles[STYLE_Translucent];
|
||||
|
||||
if (pspr->Flags & PSPF_FORCESTYLE)
|
||||
{
|
||||
if (rs == STYLE_Normal && vis->Style.Alpha < 1.0)
|
||||
{
|
||||
vis->Style.RenderStyle = LegacyRenderStyles[STYLE_Translucent];
|
||||
}
|
||||
else
|
||||
{
|
||||
vis->Style.RenderStyle = LegacyRenderStyles[rs];
|
||||
}
|
||||
}
|
||||
else if (owner->RenderStyle == LegacyRenderStyles[STYLE_Fuzzy])
|
||||
{
|
||||
vis->Style.RenderStyle = LegacyRenderStyles[STYLE_Fuzzy];
|
||||
}
|
||||
else if (owner->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])
|
||||
{
|
||||
vis->Style.RenderStyle = LegacyRenderStyles[STYLE_OptFuzzy];
|
||||
vis->Style.RenderStyle.CheckFuzz();
|
||||
}
|
||||
else if (owner->RenderStyle == LegacyRenderStyles[STYLE_Subtract])
|
||||
{
|
||||
vis->Style.RenderStyle = LegacyRenderStyles[STYLE_Subtract];
|
||||
}
|
||||
else
|
||||
{
|
||||
vis->Style.RenderStyle = LegacyRenderStyles[rs];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (owner->RenderStyle == LegacyRenderStyles[STYLE_Normal] && vis->Style.Alpha < 1.0)
|
||||
vis->Style.RenderStyle = LegacyRenderStyles[STYLE_Translucent];
|
||||
else
|
||||
vis->Style.RenderStyle = owner->RenderStyle;
|
||||
vis->Style.RenderStyle = owner->RenderStyle;
|
||||
}
|
||||
|
||||
// Set the alpha based on if using the overlay's own or not. Also adjust
|
||||
// and override the alpha if not forced.
|
||||
if (pspr->Flags & PSPF_ALPHA)
|
||||
{
|
||||
if (pspr->Flags & PSPF_FORCEALPHA)
|
||||
{
|
||||
vis->Style.Alpha = float(alpha);
|
||||
}
|
||||
else if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Fuzzy])
|
||||
{
|
||||
vis->Style.Alpha = float(owner->Alpha);
|
||||
}
|
||||
else if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])
|
||||
{
|
||||
FRenderStyle style = vis->Style.RenderStyle;
|
||||
style.CheckFuzz();
|
||||
switch (style.BlendOp)
|
||||
{
|
||||
default:
|
||||
vis->Style.Alpha = float(alpha * owner->Alpha);
|
||||
break;
|
||||
case STYLEOP_Fuzz:
|
||||
case STYLEOP_Sub:
|
||||
vis->Style.Alpha = float(owner->Alpha);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Subtract])
|
||||
{
|
||||
vis->Style.Alpha = float(owner->Alpha);
|
||||
}
|
||||
else if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Add] ||
|
||||
vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Translucent] ||
|
||||
vis->Style.RenderStyle == LegacyRenderStyles[STYLE_TranslucentStencil] ||
|
||||
vis->Style.RenderStyle == LegacyRenderStyles[STYLE_AddStencil] ||
|
||||
vis->Style.RenderStyle == LegacyRenderStyles[STYLE_AddShaded])
|
||||
{
|
||||
vis->Style.Alpha = float(alpha * owner->Alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
vis->Style.Alpha = float(owner->Alpha);
|
||||
}
|
||||
}
|
||||
|
||||
// Should normal renderstyle come out on top at the end and we desire alpha,
|
||||
// switch it to translucent. Normal never applies any sort of alpha.
|
||||
if ((pspr->Flags & PSPF_ALPHA) &&
|
||||
vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Normal] &&
|
||||
vis->Style.Alpha < 1.0)
|
||||
{
|
||||
vis->Style.RenderStyle = LegacyRenderStyles[STYLE_Translucent];
|
||||
vis->Style.Alpha = (pspr->Flags & PSPF_FORCEALPHA) ? float(alpha) : float(alpha * owner->Alpha);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// The software renderer cannot invert the source without inverting the overlay
|
||||
// too. That means if the source is inverted, we need to do the reverse of what
|
||||
// the invert overlay flag says to do.
|
||||
|
|
|
@ -594,10 +594,15 @@ enum
|
|||
// Flags for psprite layers
|
||||
enum
|
||||
{
|
||||
PSPF_ADDWEAPON = 1 << 0,
|
||||
PSPF_ADDBOB = 1 << 1,
|
||||
PSPF_POWDOUBLE = 1 << 2,
|
||||
PSPF_CVARFAST = 1 << 3,
|
||||
PSPF_ADDWEAPON = 1 << 0,
|
||||
PSPF_ADDBOB = 1 << 1,
|
||||
PSPF_POWDOUBLE = 1 << 2,
|
||||
PSPF_CVARFAST = 1 << 3,
|
||||
PSPF_ALPHA = 1 << 4,
|
||||
PSPF_RENDERSTYLE = 1 << 5,
|
||||
PSPF_FLIP = 1 << 6,
|
||||
PSPF_FORCEALPHA = 1 << 7,
|
||||
PSPF_FORCESTYLE = 1 << 8,
|
||||
};
|
||||
|
||||
// Default psprite layers
|
||||
|
|
Loading…
Reference in a new issue