Colorize opaque decals using the bleeding actor's blood color, if the 'Shaded' keyword is omitted from the DECALDEF.

This commit is contained in:
nashmuhandes 2020-03-16 07:00:10 +08:00 committed by Christoph Oelckers
parent 5e262c6145
commit 8facd5f3f3
3 changed files with 34 additions and 7 deletions

View file

@ -242,6 +242,17 @@ void DBaseDecal::SetShade (int r, int g, int b)
AlphaColor = MAKEARGB(ColorMatcher.Pick (r, g, b), r, g, b); AlphaColor = MAKEARGB(ColorMatcher.Pick (r, g, b), r, g, b);
} }
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void DBaseDecal::SetTranslation(uint32_t trans)
{
Translation = trans;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// //
// Returns the texture the decal stuck to. // Returns the texture the decal stuck to.
@ -696,7 +707,7 @@ void DImpactDecal::Expired()
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color) DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color, uint32_t bloodTranslation)
{ {
if (cl_maxdecals > 0) if (cl_maxdecals > 0)
{ {
@ -704,7 +715,7 @@ DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const char *name,
if (tpl != NULL && (tpl = tpl->GetDecal()) != NULL) if (tpl != NULL && (tpl = tpl->GetDecal()) != NULL)
{ {
return StaticCreate (Level, tpl, pos, wall, ffloor, color); return StaticCreate (Level, tpl, pos, wall, ffloor, color, bloodTranslation);
} }
} }
return NULL; return NULL;
@ -716,7 +727,7 @@ DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const char *name,
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color) DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color, uint32_t bloodTranslation)
{ {
DImpactDecal *decal = NULL; DImpactDecal *decal = NULL;
if (tpl != NULL && cl_maxdecals > 0 && !(wall->Flags & WALLF_NOAUTODECALS)) if (tpl != NULL && cl_maxdecals > 0 && !(wall->Flags & WALLF_NOAUTODECALS))
@ -730,7 +741,10 @@ DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const FDecalTempl
// apply the custom color as well. // apply the custom color as well.
if (tpl->ShadeColor != tpl_low->ShadeColor) lowercolor=0; if (tpl->ShadeColor != tpl_low->ShadeColor) lowercolor=0;
else lowercolor = color; else lowercolor = color;
StaticCreate (Level, tpl_low, pos, wall, ffloor, lowercolor);
uint32_t lowerTrans = (bloodTranslation != 0 ? bloodTranslation : 0);
StaticCreate (Level, tpl_low, pos, wall, ffloor, lowercolor, lowerTrans);
} }
decal = Level->CreateThinker<DImpactDecal>(pos.Z); decal = Level->CreateThinker<DImpactDecal>(pos.Z);
if (decal == NULL) if (decal == NULL)
@ -750,6 +764,12 @@ DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const FDecalTempl
decal->SetShade (color.r, color.g, color.b); decal->SetShade (color.r, color.g, color.b);
} }
// [Nash] For compatibility reasons, only do this if the 'Shaded' keyword is omitted from the base decal.
if (bloodTranslation != 0 && tpl->ShadeColor == 0)
{
decal->SetTranslation(bloodTranslation);
}
if (!cl_spreaddecals || !decal->PicNum.isValid()) if (!cl_spreaddecals || !decal->PicNum.isValid())
{ {
return decal; return decal;
@ -782,6 +802,10 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl
decal->CheckMax(); decal->CheckMax();
tpl->ApplyToDecal (decal, wall); tpl->ApplyToDecal (decal, wall);
decal->AlphaColor = AlphaColor; decal->AlphaColor = AlphaColor;
// [Nash] For compatibility reasons, only do this if the 'Shaded' keyword is omitted from the base decal.
if (tpl->ShadeColor == 0) decal->SetTranslation(Translation);
decal->RenderFlags = (decal->RenderFlags & RF_DECALMASK) | decal->RenderFlags = (decal->RenderFlags & RF_DECALMASK) |
(this->RenderFlags & ~RF_DECALMASK); (this->RenderFlags & ~RF_DECALMASK);
} }

View file

@ -31,6 +31,7 @@ public:
double GetRealZ (const side_t *wall) const; double GetRealZ (const side_t *wall) const;
void SetShade (uint32_t rgb); void SetShade (uint32_t rgb);
void SetShade (int r, int g, int b); void SetShade (int r, int g, int b);
void SetTranslation(uint32_t trans);
void Spread (const FDecalTemplate *tpl, side_t *wall, double x, double y, double z, F3DFloor * ffloor); void Spread (const FDecalTemplate *tpl, side_t *wall, double x, double y, double z, F3DFloor * ffloor);
void GetXY (side_t *side, double &x, double &y) const; void GetXY (side_t *side, double &x, double &y) const;
@ -68,8 +69,8 @@ public:
} }
void Construct(side_t *wall, const FDecalTemplate *templ); void Construct(side_t *wall, const FDecalTemplate *templ);
static DImpactDecal *StaticCreate(FLevelLocals *Level, const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0); static DImpactDecal *StaticCreate(FLevelLocals *Level, const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0, uint32_t bloodTranslation = 0);
static DImpactDecal *StaticCreate(FLevelLocals *Level, const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0); static DImpactDecal *StaticCreate(FLevelLocals *Level, const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0, uint32_t bloodTranslation = 0);
void BeginPlay (); void BeginPlay ();
void Expired() override; void Expired() override;

View file

@ -4967,8 +4967,10 @@ void P_TraceBleed(int damage, const DVector3 &pos, AActor *actor, DAngle angle,
bloodcolor.a = 1; bloodcolor.a = 1;
} }
uint32_t bloodTrans = (bloodcolor != 0 ? actor->BloodTranslation : 0);
DImpactDecal::StaticCreate(actor->Level, bloodType, bleedtrace.HitPos, DImpactDecal::StaticCreate(actor->Level, bloodType, bleedtrace.HitPos,
bleedtrace.Line->sidedef[bleedtrace.Side], bleedtrace.ffloor, bloodcolor); bleedtrace.Line->sidedef[bleedtrace.Side], bleedtrace.ffloor, bloodcolor, bloodTrans);
} }
} }
} }