- made AActor::alpha a floating point value

- replaced some uses of FRACUNIT with OPAQUE when it was about translucency.
- simplified some overly complicated translucency multiplications in the SBARINFO code.
This commit is contained in:
Christoph Oelckers 2016-03-21 12:18:46 +01:00
commit 4e60ea0252
50 changed files with 235 additions and 216 deletions

View file

@ -114,7 +114,7 @@ FArchive &operator<< (FArchive &arc, FRenderStyle &style)
//
//==========================================================================
bool FRenderStyle::IsVisible(fixed_t alpha) const throw()
bool FRenderStyle::IsVisible(double alpha) const throw()
{
if (BlendOp == STYLEOP_None)
{
@ -124,13 +124,13 @@ bool FRenderStyle::IsVisible(fixed_t alpha) const throw()
{
if (Flags & STYLEF_Alpha1)
{
alpha = FRACUNIT;
alpha = 1.;
}
else
{
alpha = clamp(alpha, 0, FRACUNIT);
alpha = clamp(alpha, 0., 1.);
}
return GetAlpha(SrcAlpha, alpha) != 0 || GetAlpha(DestAlpha, alpha) != FRACUNIT;
return GetAlpha(SrcAlpha, alpha) != 0 || GetAlpha(DestAlpha, alpha) != OPAQUE;
}
// Treat anything else as visible.
return true;
@ -192,10 +192,23 @@ fixed_t GetAlpha(int type, fixed_t alpha)
switch (type)
{
case STYLEALPHA_Zero: return 0;
case STYLEALPHA_One: return FRACUNIT;
case STYLEALPHA_One: return OPAQUE;
case STYLEALPHA_Src: return alpha;
case STYLEALPHA_InvSrc: return FRACUNIT - alpha;
case STYLEALPHA_InvSrc: return OPAQUE - alpha;
default: return 0;
}
}
fixed_t GetAlpha(int type, double alpha)
{
switch (type)
{
case STYLEALPHA_Zero: return 0;
case STYLEALPHA_One: return OPAQUE;
case STYLEALPHA_Src: return FLOAT2FIXED(alpha);
case STYLEALPHA_InvSrc: return FLOAT2FIXED(1. - alpha);
default: return 0;
}
}

View file

@ -35,6 +35,20 @@
**
*/
// <wingdi.h> also #defines OPAQUE
#ifdef OPAQUE
#undef OPAQUE
#endif
enum
{
OPAQUE = 65536,
TRANSLUC25 = (OPAQUE / 4),
TRANSLUC33 = (OPAQUE / 3),
TRANSLUC66 = ((OPAQUE * 2) / 3),
TRANSLUC75 = ((OPAQUE * 3) / 4),
};
// Legacy render styles
enum ERenderStyle
{
@ -127,7 +141,7 @@ union FRenderStyle
operator uint32() const { return AsDWORD; }
bool operator==(const FRenderStyle &o) const { return AsDWORD == o.AsDWORD; }
void CheckFuzz();
bool IsVisible(fixed_t alpha) const throw();
bool IsVisible(double alpha) const throw();
private:
// Code that compares an actor's render style with a legacy render
// style value should be updated. Making these conversion operators
@ -152,5 +166,6 @@ class FArchive;
FArchive &operator<< (FArchive &arc, FRenderStyle &style);
fixed_t GetAlpha(int type, fixed_t alpha);
fixed_t GetAlpha(int type, double alpha);
#endif