mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-27 14:22:13 +00:00
- renamed some fixed point stuff in the texture composition code.
This commit is contained in:
parent
86d1b2955a
commit
5bf806e478
5 changed files with 35 additions and 25 deletions
|
@ -230,12 +230,12 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, f
|
||||||
FTexture * tex= TexMan(texnum);
|
FTexture * tex= TexMan(texnum);
|
||||||
if (!tex) return false;
|
if (!tex) return false;
|
||||||
|
|
||||||
fixed_t totalscale = abs(FixedMul(side->GetTextureYScale(side_t::mid), tex->yScale));
|
double totalscale = fabs(FIXED2DBL(side->GetTextureYScale(side_t::mid)) * tex->GetScaleY());
|
||||||
fixed_t y_offset = side->GetTextureYOffset(side_t::mid);
|
fixed_t y_offset = side->GetTextureYOffset(side_t::mid);
|
||||||
fixed_t textureheight = tex->GetScaledHeight(totalscale) << FRACBITS;
|
fixed_t textureheight = tex->GetScaledHeight(totalscale) << FRACBITS;
|
||||||
if (totalscale != FRACUNIT && !tex->bWorldPanning)
|
if (totalscale != 1. && !tex->bWorldPanning)
|
||||||
{
|
{
|
||||||
y_offset = FixedDiv(y_offset, totalscale);
|
y_offset = fixed_t(y_offset * totalscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line->flags & ML_DONTPEGBOTTOM)
|
if(line->flags & ML_DONTPEGBOTTOM)
|
||||||
|
|
|
@ -146,9 +146,9 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in
|
||||||
a = TSrc::A(pin, tr, tg, tb);
|
a = TSrc::A(pin, tr, tg, tb);
|
||||||
if (TBlend::ProcessAlpha0() || a)
|
if (TBlend::ProcessAlpha0() || a)
|
||||||
{
|
{
|
||||||
r = (TSrc::R(pin)*inf->blendcolor[0])>>FRACBITS;
|
r = (TSrc::R(pin)*inf->blendcolor[0])>>BLENDBITS;
|
||||||
g = (TSrc::G(pin)*inf->blendcolor[1])>>FRACBITS;
|
g = (TSrc::G(pin)*inf->blendcolor[1])>>BLENDBITS;
|
||||||
b = (TSrc::B(pin)*inf->blendcolor[2])>>FRACBITS;
|
b = (TSrc::B(pin)*inf->blendcolor[2])>>BLENDBITS;
|
||||||
|
|
||||||
TBlend::OpC(pout[TDest::RED], r, a, inf);
|
TBlend::OpC(pout[TDest::RED], r, a, inf);
|
||||||
TBlend::OpC(pout[TDest::GREEN], g, a, inf);
|
TBlend::OpC(pout[TDest::GREEN], g, a, inf);
|
||||||
|
@ -167,9 +167,9 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in
|
||||||
a = TSrc::A(pin, tr, tg, tb);
|
a = TSrc::A(pin, tr, tg, tb);
|
||||||
if (TBlend::ProcessAlpha0() || a)
|
if (TBlend::ProcessAlpha0() || a)
|
||||||
{
|
{
|
||||||
r = (TSrc::R(pin)*inf->blendcolor[3] + inf->blendcolor[0]) >> FRACBITS;
|
r = (TSrc::R(pin)*inf->blendcolor[3] + inf->blendcolor[0]) >> BLENDBITS;
|
||||||
g = (TSrc::G(pin)*inf->blendcolor[3] + inf->blendcolor[1]) >> FRACBITS;
|
g = (TSrc::G(pin)*inf->blendcolor[3] + inf->blendcolor[1]) >> BLENDBITS;
|
||||||
b = (TSrc::B(pin)*inf->blendcolor[3] + inf->blendcolor[2]) >> FRACBITS;
|
b = (TSrc::B(pin)*inf->blendcolor[3] + inf->blendcolor[2]) >> BLENDBITS;
|
||||||
|
|
||||||
TBlend::OpC(pout[TDest::RED], r, a, inf);
|
TBlend::OpC(pout[TDest::RED], r, a, inf);
|
||||||
TBlend::OpC(pout[TDest::GREEN], g, a, inf);
|
TBlend::OpC(pout[TDest::GREEN], g, a, inf);
|
||||||
|
|
|
@ -48,6 +48,14 @@ struct FClipRect
|
||||||
bool Intersect(int ix, int iy, int iw, int ih);
|
bool Intersect(int ix, int iy, int iw, int ih);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef int blend_t;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BLENDBITS = 16,
|
||||||
|
BLENDUNIT = (1<<BLENDBITS)
|
||||||
|
};
|
||||||
|
|
||||||
class FBitmap
|
class FBitmap
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
@ -338,9 +346,9 @@ struct FCopyInfo
|
||||||
{
|
{
|
||||||
ECopyOp op;
|
ECopyOp op;
|
||||||
EBlend blend;
|
EBlend blend;
|
||||||
fixed_t blendcolor[4];
|
blend_t blendcolor[4];
|
||||||
fixed_t alpha;
|
blend_t alpha;
|
||||||
fixed_t invalpha;
|
blend_t invalpha;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bOverwrite
|
struct bOverwrite
|
||||||
|
@ -360,7 +368,7 @@ struct bCopy
|
||||||
struct bCopyNewAlpha
|
struct bCopyNewAlpha
|
||||||
{
|
{
|
||||||
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; }
|
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; }
|
||||||
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = (s*i->alpha) >> FRACBITS; }
|
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = (s*i->alpha) >> BLENDBITS; }
|
||||||
static __forceinline bool ProcessAlpha0() { return false; }
|
static __forceinline bool ProcessAlpha0() { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -380,28 +388,28 @@ struct bOverlay
|
||||||
|
|
||||||
struct bBlend
|
struct bBlend
|
||||||
{
|
{
|
||||||
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (d*i->invalpha + s*i->alpha) >> FRACBITS; }
|
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (d*i->invalpha + s*i->alpha) >> BLENDBITS; }
|
||||||
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; }
|
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; }
|
||||||
static __forceinline bool ProcessAlpha0() { return false; }
|
static __forceinline bool ProcessAlpha0() { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bAdd
|
struct bAdd
|
||||||
{
|
{
|
||||||
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MIN<int>((d*FRACUNIT + s*i->alpha) >> FRACBITS, 255); }
|
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MIN<int>((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); }
|
||||||
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; }
|
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; }
|
||||||
static __forceinline bool ProcessAlpha0() { return false; }
|
static __forceinline bool ProcessAlpha0() { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bSubtract
|
struct bSubtract
|
||||||
{
|
{
|
||||||
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MAX<int>((d*FRACUNIT - s*i->alpha) >> FRACBITS, 0); }
|
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MAX<int>((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); }
|
||||||
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; }
|
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; }
|
||||||
static __forceinline bool ProcessAlpha0() { return false; }
|
static __forceinline bool ProcessAlpha0() { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bReverseSubtract
|
struct bReverseSubtract
|
||||||
{
|
{
|
||||||
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MAX<int>((-d*FRACUNIT + s*i->alpha) >> FRACBITS, 0); }
|
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MAX<int>((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); }
|
||||||
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; }
|
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; }
|
||||||
static __forceinline bool ProcessAlpha0() { return false; }
|
static __forceinline bool ProcessAlpha0() { return false; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -180,7 +180,7 @@ protected:
|
||||||
FRemapTable *Translation;
|
FRemapTable *Translation;
|
||||||
PalEntry Blend;
|
PalEntry Blend;
|
||||||
FTexture *Texture;
|
FTexture *Texture;
|
||||||
fixed_t Alpha;
|
blend_t Alpha;
|
||||||
|
|
||||||
TexPart();
|
TexPart();
|
||||||
};
|
};
|
||||||
|
@ -593,7 +593,7 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rota
|
||||||
|
|
||||||
memset (&info, 0, sizeof(info));
|
memset (&info, 0, sizeof(info));
|
||||||
info.alpha = Parts[i].Alpha;
|
info.alpha = Parts[i].Alpha;
|
||||||
info.invalpha = OPAQUE - info.alpha;
|
info.invalpha = BLENDUNIT - info.alpha;
|
||||||
info.op = ECopyOp(Parts[i].op);
|
info.op = ECopyOp(Parts[i].op);
|
||||||
PalEntry b = Parts[i].Blend;
|
PalEntry b = Parts[i].Blend;
|
||||||
if (b.a == 0 && b != BLEND_NONE)
|
if (b.a == 0 && b != BLEND_NONE)
|
||||||
|
@ -604,14 +604,14 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rota
|
||||||
{
|
{
|
||||||
if (b.a == 255)
|
if (b.a == 255)
|
||||||
{
|
{
|
||||||
info.blendcolor[0] = b.r * FRACUNIT / 255;
|
info.blendcolor[0] = b.r * BLENDUNIT / 255;
|
||||||
info.blendcolor[1] = b.g * FRACUNIT / 255;
|
info.blendcolor[1] = b.g * BLENDUNIT / 255;
|
||||||
info.blendcolor[2] = b.b * FRACUNIT / 255;
|
info.blendcolor[2] = b.b * BLENDUNIT / 255;
|
||||||
info.blend = BLEND_MODULATE;
|
info.blend = BLEND_MODULATE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fixed_t blendalpha = b.a * FRACUNIT / 255;
|
blend_t blendalpha = b.a * BLENDUNIT / 255;
|
||||||
info.blendcolor[0] = b.r * blendalpha;
|
info.blendcolor[0] = b.r * blendalpha;
|
||||||
info.blendcolor[1] = b.g * blendalpha;
|
info.blendcolor[1] = b.g * blendalpha;
|
||||||
info.blendcolor[2] = b.b * blendalpha;
|
info.blendcolor[2] = b.b * blendalpha;
|
||||||
|
@ -1165,7 +1165,7 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part, bool silent, i
|
||||||
else if (sc.Compare("alpha"))
|
else if (sc.Compare("alpha"))
|
||||||
{
|
{
|
||||||
sc.MustGetFloat();
|
sc.MustGetFloat();
|
||||||
part.Alpha = clamp<fixed_t>(FLOAT2FIXED(sc.Float), 0, OPAQUE);
|
part.Alpha = clamp<blend_t>(int(sc.Float / BLENDUNIT), 0, BLENDUNIT);
|
||||||
// bComplex is not set because it is only needed when the style is not OP_COPY.
|
// bComplex is not set because it is only needed when the style is not OP_COPY.
|
||||||
}
|
}
|
||||||
else if (sc.Compare("style"))
|
else if (sc.Compare("style"))
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __TEXTURES_H
|
#define __TEXTURES_H
|
||||||
|
|
||||||
#include "doomtype.h"
|
#include "doomtype.h"
|
||||||
|
#include "m_fixed.h"
|
||||||
|
|
||||||
class FBitmap;
|
class FBitmap;
|
||||||
struct FRemapTable;
|
struct FRemapTable;
|
||||||
|
@ -204,9 +205,10 @@ public:
|
||||||
|
|
||||||
int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); }
|
int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); }
|
||||||
int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); }
|
int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); }
|
||||||
int GetScaledHeight(fixed_t scale) { int foo = (Height << 17) / scale; return (foo >> 1) + (foo & 1); }
|
int GetScaledHeight(double scale) { return GetScaledHeight(FLOAT2FIXED(scale)); }
|
||||||
double GetScaledWidthDouble () { return (Width * 65536.) / xScale; }
|
double GetScaledWidthDouble () { return (Width * 65536.) / xScale; }
|
||||||
double GetScaledHeightDouble () { return (Height * 65536.) / yScale; }
|
double GetScaledHeightDouble () { return (Height * 65536.) / yScale; }
|
||||||
|
double GetScaleY() const { return FIXED2DBL(yScale); }
|
||||||
|
|
||||||
int GetScaledLeftOffset () { int foo = (LeftOffset << 17) / xScale; return (foo >> 1) + (foo & 1); }
|
int GetScaledLeftOffset () { int foo = (LeftOffset << 17) / xScale; return (foo >> 1) + (foo & 1); }
|
||||||
int GetScaledTopOffset () { int foo = (TopOffset << 17) / yScale; return (foo >> 1) + (foo & 1); }
|
int GetScaledTopOffset () { int foo = (TopOffset << 17) / yScale; return (foo >> 1) + (foo & 1); }
|
||||||
|
|
Loading…
Reference in a new issue