Update to ZDoom r3640

*Moved the regeneration powerup's effect out of P_PlayerThink() and into APowerRegeneration::DoEffect().
*Did some restructuring of FMultiPatchTexture::CopyTrueColorPixels() so that it composites to a temporary bitmap before copying to the destination bitmap if any fancy stuff is going on. This simplifies the part drawing, since it doesn't need to check if each     
*Added new patch style "Overlay" for TEXTURES. This is the same as CopyAlpha, except it only copies the patch's alpha channel where it has a higher alpha than what's underneath.
*Added a new patch style: CopyNewAlpha. This works just like Copy except it multiplies each pixel's alpha channel by the specified Alpha property.


git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@1391 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
Christoph Oelckers 2012-05-11 10:44:37 +00:00
parent d1abf56649
commit 8e4448adc8
8 changed files with 90 additions and 166 deletions

View file

@ -193,7 +193,6 @@ typedef enum
CF_PREDICTING = 1 << 13, // [RH] Player movement is being predicted CF_PREDICTING = 1 << 13, // [RH] Player movement is being predicted
CF_WEAPONREADY = 1 << 14, // [RH] Weapon is in the ready state and can fire its primary attack CF_WEAPONREADY = 1 << 14, // [RH] Weapon is in the ready state and can fire its primary attack
CF_DRAIN = 1 << 16, // Player owns a drain powerup CF_DRAIN = 1 << 16, // Player owns a drain powerup
CF_REGENERATION = 1 << 17, // Player owns a regeneration artifact
CF_HIGHJUMP = 1 << 18, // more Skulltag flags. Implementation not guaranteed though. ;) CF_HIGHJUMP = 1 << 18, // more Skulltag flags. Implementation not guaranteed though. ;)
CF_REFLECTION = 1 << 19, CF_REFLECTION = 1 << 19,
CF_PROSPERITY = 1 << 20, CF_PROSPERITY = 1 << 20,

View file

@ -1658,35 +1658,18 @@ IMPLEMENT_CLASS(APowerRegeneration)
//=========================================================================== //===========================================================================
// //
// ARuneRegeneration :: InitEffect // APowerRegeneration :: DoEffect
// //
//=========================================================================== //===========================================================================
void APowerRegeneration::InitEffect( ) void APowerRegeneration::DoEffect()
{ {
Super::InitEffect(); if (Owner != NULL && Owner->health > 0 && (level.time & 31) == 0)
if (Owner== NULL || Owner->player == NULL)
return;
// Give the player the power to regnerate lost life.
Owner->player->cheats |= CF_REGENERATION;
}
//===========================================================================
//
// ARuneRegeneration :: EndEffect
//
//===========================================================================
void APowerRegeneration::EndEffect( )
{
Super::EndEffect();
// Nothing to do if there's no owner.
if (Owner != NULL && Owner->player != NULL)
{ {
// Take away the regeneration power. if (P_GiveBody(Owner, 5))
Owner->player->cheats &= ~CF_REGENERATION; {
S_Sound(Owner, CHAN_ITEM, "*regenerate", 1, ATTN_NORM );
}
} }
} }

View file

@ -214,8 +214,7 @@ class APowerRegeneration : public APowerup
{ {
DECLARE_CLASS( APowerRegeneration, APowerup ) DECLARE_CLASS( APowerRegeneration, APowerup )
protected: protected:
void InitEffect( ); void DoEffect();
void EndEffect( );
}; };
class APowerHighJump : public APowerup class APowerHighJump : public APowerup

View file

@ -2446,15 +2446,6 @@ void P_PlayerThink (player_t *player)
P_PoisonDamage (player, player->poisoner, 1, true); P_PoisonDamage (player, player->poisoner, 1, true);
} }
// [BC] Apply regeneration.
if (( level.time & 31 ) == 0 && ( player->cheats & CF_REGENERATION ) && ( player->health ))
{
if ( P_GiveBody( player->mo, 5 ))
{
S_Sound(player->mo, CHAN_ITEM, "*regenerate", 1, ATTN_NORM );
}
}
// Apply degeneration. // Apply degeneration.
if (dmflags2 & DF2_YES_DEGENERATION) if (dmflags2 & DF2_YES_DEGENERATION)
{ {
@ -2702,6 +2693,10 @@ void player_t::Serialize (FArchive &arc)
{ {
cheats &= ~(1 << 15); // make sure old CF_TIMEFREEZE bit is cleared cheats &= ~(1 << 15); // make sure old CF_TIMEFREEZE bit is cleared
} }
if (SaveVersion < 3640)
{
cheats &= ~(1 << 17); // make sure old CF_REGENERATION bit is cleared
}
if (isbot) if (isbot)
{ {

View file

@ -3,5 +3,5 @@
// This file was automatically generated by the // This file was automatically generated by the
// updaterevision tool. Do not edit by hand. // updaterevision tool. Do not edit by hand.
#define ZD_SVN_REVISION_STRING "3636" #define ZD_SVN_REVISION_STRING "3640"
#define ZD_SVN_REVISION_NUMBER 3636 #define ZD_SVN_REVISION_NUMBER 3640

View file

@ -185,96 +185,31 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in
typedef void (*CopyFunc)(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf); typedef void (*CopyFunc)(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf);
#define COPY_FUNCS(op) \
{ \
iCopyColors<cRGB, cBGRA, op>, \
iCopyColors<cRGBA, cBGRA, op>, \
iCopyColors<cIA, cBGRA, op>, \
iCopyColors<cCMYK, cBGRA, op>, \
iCopyColors<cBGR, cBGRA, op>, \
iCopyColors<cBGRA, cBGRA, op>, \
iCopyColors<cI16, cBGRA, op>, \
iCopyColors<cRGB555, cBGRA, op>, \
iCopyColors<cPalEntry, cBGRA, op> \
}
static const CopyFunc copyfuncs[][9]={ static const CopyFunc copyfuncs[][9]={
{ COPY_FUNCS(bCopy),
iCopyColors<cRGB, cBGRA, bCopy>, COPY_FUNCS(bBlend),
iCopyColors<cRGBA, cBGRA, bCopy>, COPY_FUNCS(bAdd),
iCopyColors<cIA, cBGRA, bCopy>, COPY_FUNCS(bSubtract),
iCopyColors<cCMYK, cBGRA, bCopy>, COPY_FUNCS(bReverseSubtract),
iCopyColors<cBGR, cBGRA, bCopy>, COPY_FUNCS(bModulate),
iCopyColors<cBGRA, cBGRA, bCopy>, COPY_FUNCS(bCopyAlpha),
iCopyColors<cI16, cBGRA, bCopy>, COPY_FUNCS(bCopyNewAlpha),
iCopyColors<cRGB555, cBGRA, bCopy>, COPY_FUNCS(bOverlay),
iCopyColors<cPalEntry, cBGRA, bCopy> COPY_FUNCS(bOverwrite)
},
{
iCopyColors<cRGB, cBGRA, bBlend>,
iCopyColors<cRGBA, cBGRA, bBlend>,
iCopyColors<cIA, cBGRA, bBlend>,
iCopyColors<cCMYK, cBGRA, bBlend>,
iCopyColors<cBGR, cBGRA, bBlend>,
iCopyColors<cBGRA, cBGRA, bBlend>,
iCopyColors<cI16, cBGRA, bBlend>,
iCopyColors<cRGB555, cBGRA, bBlend>,
iCopyColors<cPalEntry, cBGRA, bBlend>
},
{
iCopyColors<cRGB, cBGRA, bAdd>,
iCopyColors<cRGBA, cBGRA, bAdd>,
iCopyColors<cIA, cBGRA, bAdd>,
iCopyColors<cCMYK, cBGRA, bAdd>,
iCopyColors<cBGR, cBGRA, bAdd>,
iCopyColors<cBGRA, cBGRA, bAdd>,
iCopyColors<cI16, cBGRA, bAdd>,
iCopyColors<cRGB555, cBGRA, bAdd>,
iCopyColors<cPalEntry, cBGRA, bAdd>
},
{
iCopyColors<cRGB, cBGRA, bSubtract>,
iCopyColors<cRGBA, cBGRA, bSubtract>,
iCopyColors<cIA, cBGRA, bSubtract>,
iCopyColors<cCMYK, cBGRA, bSubtract>,
iCopyColors<cBGR, cBGRA, bSubtract>,
iCopyColors<cBGRA, cBGRA, bSubtract>,
iCopyColors<cI16, cBGRA, bSubtract>,
iCopyColors<cRGB555, cBGRA, bSubtract>,
iCopyColors<cPalEntry, cBGRA, bSubtract>
},
{
iCopyColors<cRGB, cBGRA, bReverseSubtract>,
iCopyColors<cRGBA, cBGRA, bReverseSubtract>,
iCopyColors<cIA, cBGRA, bReverseSubtract>,
iCopyColors<cCMYK, cBGRA, bReverseSubtract>,
iCopyColors<cBGR, cBGRA, bReverseSubtract>,
iCopyColors<cBGRA, cBGRA, bReverseSubtract>,
iCopyColors<cI16, cBGRA, bReverseSubtract>,
iCopyColors<cRGB555, cBGRA, bReverseSubtract>,
iCopyColors<cPalEntry, cBGRA, bReverseSubtract>
},
{
iCopyColors<cRGB, cBGRA, bModulate>,
iCopyColors<cRGBA, cBGRA, bModulate>,
iCopyColors<cIA, cBGRA, bModulate>,
iCopyColors<cCMYK, cBGRA, bModulate>,
iCopyColors<cBGR, cBGRA, bModulate>,
iCopyColors<cBGRA, cBGRA, bModulate>,
iCopyColors<cI16, cBGRA, bModulate>,
iCopyColors<cRGB555, cBGRA, bModulate>,
iCopyColors<cPalEntry, cBGRA, bModulate>
},
{
iCopyColors<cRGB, cBGRA, bCopyAlpha>,
iCopyColors<cRGBA, cBGRA, bCopyAlpha>,
iCopyColors<cIA, cBGRA, bCopyAlpha>,
iCopyColors<cCMYK, cBGRA, bCopyAlpha>,
iCopyColors<cBGR, cBGRA, bCopyAlpha>,
iCopyColors<cBGRA, cBGRA, bCopyAlpha>,
iCopyColors<cI16, cBGRA, bCopyAlpha>,
iCopyColors<cRGB555, cBGRA, bCopyAlpha>,
iCopyColors<cPalEntry, cBGRA, bCopyAlpha>
},
{
iCopyColors<cRGB, cBGRA, bOverwrite>,
iCopyColors<cRGBA, cBGRA, bOverwrite>,
iCopyColors<cIA, cBGRA, bOverwrite>,
iCopyColors<cCMYK, cBGRA, bOverwrite>,
iCopyColors<cBGR, cBGRA, bOverwrite>,
iCopyColors<cBGRA, cBGRA, bOverwrite>,
iCopyColors<cI16, cBGRA, bOverwrite>,
iCopyColors<cRGB555, cBGRA, bOverwrite>,
iCopyColors<cPalEntry, cBGRA, bOverwrite>
},
}; };
#undef COPY_FUNCS
//=========================================================================== //===========================================================================
// //
@ -487,6 +422,8 @@ static const CopyPalettedFunc copypalettedfuncs[]=
iCopyPaletted<cBGRA, bReverseSubtract>, iCopyPaletted<cBGRA, bReverseSubtract>,
iCopyPaletted<cBGRA, bModulate>, iCopyPaletted<cBGRA, bModulate>,
iCopyPaletted<cBGRA, bCopyAlpha>, iCopyPaletted<cBGRA, bCopyAlpha>,
iCopyPaletted<cBGRA, bCopyNewAlpha>,
iCopyPaletted<cBGRA, bOverlay>,
iCopyPaletted<cBGRA, bOverwrite> iCopyPaletted<cBGRA, bOverwrite>
}; };

View file

@ -318,6 +318,8 @@ enum ECopyOp
OP_REVERSESUBTRACT, OP_REVERSESUBTRACT,
OP_MODULATE, OP_MODULATE,
OP_COPYALPHA, OP_COPYALPHA,
OP_COPYNEWALPHA,
OP_OVERLAY,
OP_OVERWRITE OP_OVERWRITE
}; };
@ -330,6 +332,13 @@ struct FCopyInfo
fixed_t invalpha; fixed_t invalpha;
}; };
struct bOverwrite
{
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; }
static __forceinline bool ProcessAlpha0() { return true; }
};
struct bCopy struct bCopy
{ {
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; }
@ -337,11 +346,25 @@ struct bCopy
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bOverwrite 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 bool ProcessAlpha0() { return false; }
};
struct bCopyAlpha
{
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/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 true; } static __forceinline bool ProcessAlpha0() { return false; }
};
struct bOverlay
{
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = MAX(s,d); }
static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bBlend struct bBlend
@ -379,13 +402,5 @@ struct bModulate
static __forceinline bool ProcessAlpha0() { return false; } static __forceinline bool ProcessAlpha0() { return false; }
}; };
struct bCopyAlpha
{
static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; }
static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; }
static __forceinline bool ProcessAlpha0() { return false; }
};
#endif #endif

View file

@ -552,9 +552,26 @@ void FMultiPatchTexture::MakeTexture ()
int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
{ {
int retv = -1; int retv = -1;
FCopyInfo info;
// When compositing a multipatch texture with multipatch parts if (bRedirect)
{ // Redirect straight to the real texture's routine.
return Parts[0].Texture->CopyTrueColorPixels(bmp, x, y, rotate, inf);
}
if (rotate != 0 || (inf != NULL && inf->op != OP_OVERWRITE && inf->op != OP_COPY))
{ // We are doing some sort of fancy stuff to the destination bitmap, so composite to
// a temporary bitmap, and copy that.
FBitmap tbmp;
if (tbmp.Create(Width, Height))
{
retv = MAX(retv, CopyTrueColorPixels(&tbmp, 0, 0, 0));
bmp->CopyPixelDataRGB(x, y, tbmp.GetPixels(), Width, Height,
4, tbmp.GetPitch(), rotate, CF_BGRA, inf);
}
return retv;
}
// When compositing a multipatch texture with multipatch parts,
// drawing must be restricted to the actual area which is covered by this texture. // drawing must be restricted to the actual area which is covered by this texture.
FClipRect saved_cr = bmp->GetClipRect(); FClipRect saved_cr = bmp->GetClipRect();
bmp->IntersectClipRect(x, y, Width, Height); bmp->IntersectClipRect(x, y, Width, Height);
@ -567,11 +584,9 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rota
for(int i = 0; i < NumParts; i++) for(int i = 0; i < NumParts; i++)
{ {
int ret = -1; int ret = -1;
FCopyInfo info;
if (Parts[i].Texture->bHasCanvas) continue; // cannot use camera textures as patch.
// rotated multipatch parts cannot be composited directly if (Parts[i].Texture->bHasCanvas) continue; // cannot use camera textures as patch.
bool rotatedmulti = Parts[i].Rotate != 0 && Parts[i].Texture->bMultiPatch;
memset (&info, 0, sizeof(info)); memset (&info, 0, sizeof(info));
info.alpha = Parts[i].Alpha; info.alpha = Parts[i].Alpha;
@ -601,32 +616,13 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rota
} }
} }
if (!Parts[i].Texture->bComplex && !rotatedmulti) if (Parts[i].Translation != NULL)
{ { // Using a translation forces downconversion to the base palette
if (Parts[i].Translation != NULL) ret = Parts[i].Texture->CopyTrueColorTranslated(bmp, x+Parts[i].OriginX, y+Parts[i].OriginY, Parts[i].Rotate, Parts[i].Translation, &info);
{
// Using a translation forces downconversion to the base palette
ret = Parts[i].Texture->CopyTrueColorTranslated(bmp, x+Parts[i].OriginX, y+Parts[i].OriginY, Parts[i].Rotate, Parts[i].Translation, &info);
}
else
{
ret = Parts[i].Texture->CopyTrueColorPixels(bmp, x+Parts[i].OriginX, y+Parts[i].OriginY, Parts[i].Rotate, &info);
}
} }
else else
{ {
// If the patch is a texture with some kind of processing involved ret = Parts[i].Texture->CopyTrueColorPixels(bmp, x+Parts[i].OriginX, y+Parts[i].OriginY, Parts[i].Rotate, &info);
// and being drawn with additional processing
// the copying must be done in 2 steps: First create a complete image of the patch
// including all processing and then copy from that intermediate image to the destination
FBitmap bmp1;
if (bmp1.Create(Parts[i].Texture->GetWidth(), Parts[i].Texture->GetHeight()))
{
bmp1.Zero();
Parts[i].Texture->CopyTrueColorPixels(&bmp1, 0, 0);
bmp->CopyPixelDataRGB(x+Parts[i].OriginX, y+Parts[i].OriginY, bmp1.GetPixels(),
bmp1.GetWidth(), bmp1.GetHeight(), 4, bmp1.GetPitch(), Parts[i].Rotate, CF_BGRA, &info);
}
} }
if (ret > retv) retv = ret; if (ret > retv) retv = ret;
@ -1180,7 +1176,7 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part, bool silent, i
} }
else if (sc.Compare("style")) else if (sc.Compare("style"))
{ {
static const char *styles[] = {"copy", "translucent", "add", "subtract", "reversesubtract", "modulate", "copyalpha", NULL }; static const char *styles[] = {"copy", "translucent", "add", "subtract", "reversesubtract", "modulate", "copyalpha", "copynewalpha", "overlay", NULL };
sc.MustGetString(); sc.MustGetString();
part.op = sc.MustMatchString(styles); part.op = sc.MustMatchString(styles);
bComplex |= (part.op != OP_COPY); bComplex |= (part.op != OP_COPY);