mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-18 23:52:02 +00:00
Compress visualthinker bools into a flags field
This commit is contained in:
parent
3a83762c51
commit
3622e2bb2a
5 changed files with 49 additions and 39 deletions
|
@ -364,9 +364,9 @@ void P_SpawnParticle(FLevelLocals *Level, const DVector3 &pos, const DVector3 &v
|
|||
particle->sizestep = sizestep;
|
||||
particle->texture = texture;
|
||||
particle->style = style;
|
||||
particle->Roll = startroll;
|
||||
particle->RollVel = rollvel;
|
||||
particle->RollAcc = rollacc;
|
||||
particle->Roll = (float)startroll;
|
||||
particle->RollVel = (float)rollvel;
|
||||
particle->RollAcc = (float)rollacc;
|
||||
particle->flags = flags;
|
||||
if(flags & SPF_LOCAL_ANIM)
|
||||
{
|
||||
|
@ -1125,7 +1125,7 @@ int DVisualThinker::GetLightLevel(sector_t* rendersector) const
|
|||
{
|
||||
int lightlevel = rendersector->GetSpriteLight();
|
||||
|
||||
if (bAddLightLevel)
|
||||
if (flags & VTF_AddLightLevel)
|
||||
{
|
||||
lightlevel += LightLevel;
|
||||
}
|
||||
|
@ -1138,7 +1138,7 @@ int DVisualThinker::GetLightLevel(sector_t* rendersector) const
|
|||
|
||||
FVector3 DVisualThinker::InterpolatedPosition(double ticFrac) const
|
||||
{
|
||||
if (bDontInterpolate) return FVector3(PT.Pos);
|
||||
if (flags & VTF_DontInterpolate) return FVector3(PT.Pos);
|
||||
|
||||
DVector3 proc = Prev + (ticFrac * (PT.Pos - Prev));
|
||||
return FVector3(proc);
|
||||
|
@ -1147,7 +1147,7 @@ FVector3 DVisualThinker::InterpolatedPosition(double ticFrac) const
|
|||
|
||||
float DVisualThinker::InterpolatedRoll(double ticFrac) const
|
||||
{
|
||||
if (bDontInterpolate) return PT.Roll;
|
||||
if (flags & VTF_DontInterpolate) return PT.Roll;
|
||||
|
||||
return float(PrevRoll + (PT.Roll - PrevRoll) * ticFrac);
|
||||
}
|
||||
|
@ -1227,9 +1227,9 @@ int DVisualThinker::GetRenderStyle()
|
|||
float DVisualThinker::GetOffset(bool y) const // Needed for the renderer.
|
||||
{
|
||||
if (y)
|
||||
return (float)(bFlipOffsetY ? Offset.Y : -Offset.Y);
|
||||
return (float)((flags & VTF_FlipOffsetY) ? Offset.Y : -Offset.Y);
|
||||
else
|
||||
return (float)(bFlipOffsetX ? Offset.X : -Offset.X);
|
||||
return (float)((flags & VTF_FlipOffsetX) ? Offset.X : -Offset.X);
|
||||
}
|
||||
|
||||
void DVisualThinker::Serialize(FSerializer& arc)
|
||||
|
@ -1250,14 +1250,9 @@ void DVisualThinker::Serialize(FSerializer& arc)
|
|||
("translation", Translation)
|
||||
("cursector", cursector)
|
||||
("scolor", PT.color)
|
||||
("flipx", bXFlip)
|
||||
("flipy", bYFlip)
|
||||
("dontinterpolate", bDontInterpolate)
|
||||
("addlightlevel", bAddLightLevel)
|
||||
("flipoffsetx", bFlipOffsetX)
|
||||
("flipoffsetY", bFlipOffsetY)
|
||||
("lightlevel", LightLevel)
|
||||
("flags", PT.flags);
|
||||
("flags", PT.flags)
|
||||
("visualThinkerFlags", flags);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1269,6 +1264,7 @@ DEFINE_FIELD_NAMED(DVisualThinker, PT.Roll, Roll);
|
|||
DEFINE_FIELD_NAMED(DVisualThinker, PT.alpha, Alpha);
|
||||
DEFINE_FIELD_NAMED(DVisualThinker, PT.texture, Texture);
|
||||
DEFINE_FIELD_NAMED(DVisualThinker, PT.flags, Flags);
|
||||
DEFINE_FIELD_NAMED(DVisualThinker, flags, VisualThinkerFlags);
|
||||
|
||||
DEFINE_FIELD(DVisualThinker, Prev);
|
||||
DEFINE_FIELD(DVisualThinker, Scale);
|
||||
|
@ -1277,9 +1273,3 @@ DEFINE_FIELD(DVisualThinker, PrevRoll);
|
|||
DEFINE_FIELD(DVisualThinker, Translation);
|
||||
DEFINE_FIELD(DVisualThinker, LightLevel);
|
||||
DEFINE_FIELD(DVisualThinker, cursector);
|
||||
DEFINE_FIELD(DVisualThinker, bXFlip);
|
||||
DEFINE_FIELD(DVisualThinker, bYFlip);
|
||||
DEFINE_FIELD(DVisualThinker, bDontInterpolate);
|
||||
DEFINE_FIELD(DVisualThinker, bAddLightLevel);
|
||||
DEFINE_FIELD(DVisualThinker, bFlipOffsetX);
|
||||
DEFINE_FIELD(DVisualThinker, bFlipOffsetY);
|
||||
|
|
|
@ -158,6 +158,17 @@ void P_DisconnectEffect (AActor *actor);
|
|||
//===========================================================================
|
||||
class HWSprite;
|
||||
struct FTranslationID;
|
||||
|
||||
enum EVisualThinkerFlags
|
||||
{
|
||||
VTF_FlipOffsetX = 1 << 0,
|
||||
VTF_FlipOffsetY = 1 << 1,
|
||||
VTF_FlipX = 1 << 2,
|
||||
VTF_FlipY = 1 << 3, // flip the sprite on the x/y axis.
|
||||
VTF_DontInterpolate = 1 << 4, // disable all interpolation
|
||||
VTF_AddLightLevel = 1 << 5, // adds sector light level to 'LightLevel'
|
||||
};
|
||||
|
||||
class DVisualThinker : public DThinker
|
||||
{
|
||||
DECLARE_CLASS(DVisualThinker, DThinker);
|
||||
|
@ -171,12 +182,7 @@ public:
|
|||
FTextureID AnimatedTexture;
|
||||
sector_t *cursector;
|
||||
|
||||
bool bFlipOffsetX,
|
||||
bFlipOffsetY,
|
||||
bXFlip,
|
||||
bYFlip, // flip the sprite on the x/y axis.
|
||||
bDontInterpolate, // disable all interpolation
|
||||
bAddLightLevel; // adds sector light level to 'LightLevel'
|
||||
int flags;
|
||||
|
||||
// internal only variables
|
||||
particle_t PT;
|
||||
|
|
|
@ -1599,7 +1599,7 @@ void HWSprite::AdjustVisualThinker(HWDrawInfo* di, DVisualThinker* spr, sector_t
|
|||
? TexAnim.UpdateStandaloneAnimation(spr->PT.animData, di->Level->maptime + timefrac)
|
||||
: spr->PT.texture, !custom_anim);
|
||||
|
||||
if (spr->bDontInterpolate)
|
||||
if (spr->flags & VTF_DontInterpolate)
|
||||
timefrac = 0.;
|
||||
|
||||
FVector3 interp = spr->InterpolatedPosition(timefrac);
|
||||
|
@ -1629,13 +1629,12 @@ void HWSprite::AdjustVisualThinker(HWDrawInfo* di, DVisualThinker* spr, sector_t
|
|||
double mult = 1.0 / sqrt(ps); // shrink slightly
|
||||
r.Scale(mult * ps, mult);
|
||||
}
|
||||
|
||||
if (spr->bXFlip)
|
||||
if (spr->flags & VTF_FlipX)
|
||||
{
|
||||
std::swap(ul,ur);
|
||||
r.left = -r.width - r.left; // mirror the sprite's x-offset
|
||||
}
|
||||
if (spr->bYFlip) std::swap(vt,vb);
|
||||
if (spr->flags & VTF_FlipY) std::swap(vt,vb);
|
||||
|
||||
float viewvecX = vp.ViewVector.X;
|
||||
float viewvecY = vp.ViewVector.Y;
|
||||
|
|
|
@ -1516,3 +1516,13 @@ enum EModelFlags
|
|||
MDL_CORRECTPIXELSTRETCH = 1<<13, // ensure model does not distort with pixel stretch when pitch/roll is applied
|
||||
MDL_FORCECULLBACKFACES = 1<<14,
|
||||
};
|
||||
|
||||
enum EVisualThinkerFlags
|
||||
{
|
||||
VTF_FlipOffsetX = 1 << 0,
|
||||
VTF_FlipOffsetY = 1 << 1,
|
||||
VTF_FlipX = 1 << 2,
|
||||
VTF_FlipY = 1 << 3, // flip the sprite on the x/y axis.
|
||||
VTF_DontInterpolate = 1 << 4, // disable all interpolation
|
||||
VTF_AddLightLevel = 1 << 5, // adds sector light level to 'LightLevel'
|
||||
};
|
||||
|
|
|
@ -10,14 +10,18 @@ Class VisualThinker : Thinker native
|
|||
Alpha;
|
||||
native TextureID Texture;
|
||||
native TranslationID Translation;
|
||||
native uint16 Flags;
|
||||
native int16 LightLevel;
|
||||
native bool bFlipOffsetX,
|
||||
bFlipOffsetY,
|
||||
bXFlip,
|
||||
bYFlip,
|
||||
bDontInterpolate,
|
||||
bAddLightLevel;
|
||||
|
||||
native uint16 Flags;
|
||||
native int VisualThinkerFlags;
|
||||
|
||||
FlagDef FlipOffsetX : VisualThinkerFlags, 0;
|
||||
FlagDef FlipOffsetY : VisualThinkerFlags, 1;
|
||||
FlagDef XFlip : VisualThinkerFlags, 2;
|
||||
FlagDef YFlip : VisualThinkerFlags, 3;
|
||||
FlagDef DontInterpolate : VisualThinkerFlags, 4;
|
||||
FlagDef AddLightLevel : VisualThinkerFlags, 5;
|
||||
|
||||
native Color scolor;
|
||||
|
||||
native Sector CurSector; // can be null!
|
||||
|
@ -27,7 +31,7 @@ Class VisualThinker : Thinker native
|
|||
native bool IsFrozen();
|
||||
|
||||
static VisualThinker Spawn(Class<VisualThinker> type, TextureID tex, Vector3 pos, Vector3 vel, double alpha = 1.0, int flags = 0,
|
||||
double roll = 0.0, Vector2 scale = (1,1), Vector2 offset = (0,0), int style = STYLE_Normal, TranslationID trans = 0)
|
||||
double roll = 0.0, Vector2 scale = (1,1), Vector2 offset = (0,0), int style = STYLE_Normal, TranslationID trans = 0, int VisualThinkerFlags = 0)
|
||||
{
|
||||
if (!Level) return null;
|
||||
|
||||
|
@ -44,6 +48,7 @@ Class VisualThinker : Thinker native
|
|||
p.SetRenderStyle(style);
|
||||
p.Translation = trans;
|
||||
p.Flags = flags;
|
||||
p.VisualThinkerFlags = VisualThinkerFlags;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue