Skip to content

Commit

Permalink
- rename ZSprites to VisualThinkers
Browse files Browse the repository at this point in the history
  • Loading branch information
madame-rachelle committed Nov 22, 2023
1 parent c42b51d commit 8ab3255
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 78 deletions.
2 changes: 1 addition & 1 deletion src/common/engine/namedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ xx(Object)
xx(Actor)
xx(Class)
xx(Thinker)
xx(ZSprite)
xx(VisualThinker)
xx(Crosshairs)

xx(Untranslated)
Expand Down
2 changes: 1 addition & 1 deletion src/g_levellocals.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ struct FLevelLocals
DThinker *thinker = static_cast<DThinker*>(cls->CreateNew());
assert(thinker->IsKindOf(RUNTIME_CLASS(DThinker)));
thinker->ObjectFlags |= OF_JustSpawned;
if (thinker->IsKindOf(RUNTIME_CLASS(DZSprite))) // [MC] This absolutely must happen for this class!
if (thinker->IsKindOf(RUNTIME_CLASS(DVisualThinker))) // [MC] This absolutely must happen for this class!
statnum = STAT_SPRITE;
Thinkers.Link(thinker, statnum);
thinker->Level = this;
Expand Down
2 changes: 1 addition & 1 deletion src/gamedata/r_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ struct subsector_t
int Index() const { return subsectornum; }
// 2: has one-sided walls
FPortalCoverage portalcoverage[2];
TArray<DZSprite *> sprites;
TArray<DVisualThinker *> sprites;
LightmapSurface *lightmap[2];
};

Expand Down
2 changes: 1 addition & 1 deletion src/playsim/dthinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DThinker, ChangeStatNum, ChangeStatNum)
PARAM_INT(stat);

// do not allow ZScript to reposition thinkers in or out of particle ticking.
if (stat != STAT_SPRITE && !dynamic_cast<DZSprite*>(self))
if (stat != STAT_SPRITE && !dynamic_cast<DVisualThinker*>(self))
{
ChangeStatNum(self, stat);
}
Expand Down
108 changes: 54 additions & 54 deletions src/playsim/p_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,27 +207,27 @@ void P_ClearParticles (FLevelLocals *Level)
// Group particles by subsectors. Because particles are always
// in motion, there is little benefit to caching this information
// from one frame to the next.
// [MC] ZSprites hitches a ride here
// [MC] VisualThinkers hitches a ride here

void P_FindParticleSubsectors (FLevelLocals *Level)
{
// [MC] Hitch a ride on particle subsectors since ZSprites are effectively using the same kind of system.
// [MC] Hitch a ride on particle subsectors since VisualThinkers are effectively using the same kind of system.
for (uint32_t i = 0; i < Level->subsectors.Size(); i++)
{
Level->subsectors[i].sprites.Clear();
}
// [MC] Not too happy about using an iterator for this but I can't think of another way to handle it.
// At least it's on its own statnum for maximum efficiency.
auto it = Level->GetThinkerIterator<DZSprite>(NAME_None, STAT_SPRITE);
DZSprite* sp;
auto it = Level->GetThinkerIterator<DVisualThinker>(NAME_None, STAT_SPRITE);
DVisualThinker* sp;
while (sp = it.Next())
{
if (sp->sub == nullptr)
sp->sub = Level->PointInRenderSubsector(sp->Pos);

sp->sub->sprites.Push(sp);
}
// End ZSprite hitching. Now onto the particles.
// End VisualThinker hitching. Now onto the particles.
if (Level->ParticlesInSubsec.Size() < Level->subsectors.Size())
{
Level->ParticlesInSubsec.Reserve (Level->subsectors.Size() - Level->ParticlesInSubsec.Size());
Expand Down Expand Up @@ -985,13 +985,13 @@ void P_DisconnectEffect (AActor *actor)

//===========================================================================
//
// ZScript Sprite (DZSprite)
// ZScript Sprite (DVisualThinker)
// Concept by Major Cooke
// Most code borrowed by Actor and particles above
//
//===========================================================================

void DZSprite::Construct()
void DVisualThinker::Construct()
{
PT = {};
PT.sprite = this;
Expand All @@ -1010,58 +1010,58 @@ void DZSprite::Construct()
scolor = 0xffffff;
}

DZSprite::DZSprite()
DVisualThinker::DVisualThinker()
{
Construct();
}

void DZSprite::CallPostBeginPlay()
void DVisualThinker::CallPostBeginPlay()
{
PT.texture = Texture;
Super::CallPostBeginPlay();
}

void DZSprite::OnDestroy()
void DVisualThinker::OnDestroy()
{
PT.alpha = 0.0; // stops all rendering.
if (spr) delete spr;
Super::OnDestroy();
}

DZSprite* DZSprite::NewZSprite(FLevelLocals* Level, PClass* type)
DVisualThinker* DVisualThinker::NewVisualThinker(FLevelLocals* Level, PClass* type)
{
if (type == nullptr)
return nullptr;
else if (type->bAbstract)
{
Printf("Attempt to spawn an instance of abstract ZSprite class %s\n", type->TypeName.GetChars());
Printf("Attempt to spawn an instance of abstract VisualThinker class %s\n", type->TypeName.GetChars());
return nullptr;
}
else if (!type->IsDescendantOf(RUNTIME_CLASS(DZSprite)))
else if (!type->IsDescendantOf(RUNTIME_CLASS(DVisualThinker)))
{
Printf("Attempt to spawn class not inherent to ZSprite: %s\n", type->TypeName.GetChars());
Printf("Attempt to spawn class not inherent to VisualThinker: %s\n", type->TypeName.GetChars());
return nullptr;
}

DZSprite *zs = static_cast<DZSprite*>(Level->CreateThinker(type, STAT_SPRITE));
DVisualThinker *zs = static_cast<DVisualThinker*>(Level->CreateThinker(type, STAT_SPRITE));
zs->Construct();
return zs;
}

static DZSprite* SpawnZSprite(FLevelLocals* Level, PClass* type)
static DVisualThinker* SpawnVisualThinker(FLevelLocals* Level, PClass* type)
{
return DZSprite::NewZSprite(Level, type);
return DVisualThinker::NewVisualThinker(Level, type);
}

DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, SpawnZSprite, SpawnZSprite)
DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, SpawnVisualThinker, SpawnVisualThinker)
{
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
PARAM_CLASS_NOT_NULL(type, DZSprite);
DZSprite* zs = SpawnZSprite(self, type);
PARAM_CLASS_NOT_NULL(type, DVisualThinker);
DVisualThinker* zs = SpawnVisualThinker(self, type);
ACTION_RETURN_OBJECT(zs);
}

void DZSprite::UpdateSpriteInfo()
void DVisualThinker::UpdateSpriteInfo()
{
PT.color = scolor;
PT.Pos = Pos;
Expand All @@ -1076,7 +1076,7 @@ void DZSprite::UpdateSpriteInfo()
}

// This runs just like Actor's, make sure to call Super.Tick() in ZScript.
void DZSprite::Tick()
void DVisualThinker::Tick()
{
if (ObjectFlags & OF_EuthanizeMe)
return;
Expand Down Expand Up @@ -1126,7 +1126,7 @@ void DZSprite::Tick()
UpdateSpriteInfo();
}

int DZSprite::GetLightLevel(sector_t* rendersector) const
int DVisualThinker::GetLightLevel(sector_t* rendersector) const
{
int lightlevel = rendersector->GetSpriteLight();

Expand All @@ -1141,7 +1141,7 @@ int DZSprite::GetLightLevel(sector_t* rendersector) const
return lightlevel;
}

FVector3 DZSprite::InterpolatedPosition(double ticFrac) const
FVector3 DVisualThinker::InterpolatedPosition(double ticFrac) const
{
if (bDontInterpolate) return FVector3(Pos);

Expand All @@ -1150,7 +1150,7 @@ FVector3 DZSprite::InterpolatedPosition(double ticFrac) const

}

float DZSprite::InterpolatedRoll(double ticFrac) const
float DVisualThinker::InterpolatedRoll(double ticFrac) const
{
if (bDontInterpolate) return Roll;

Expand All @@ -1159,7 +1159,7 @@ float DZSprite::InterpolatedRoll(double ticFrac) const



void DZSprite::SetTranslation(FName trname)
void DVisualThinker::SetTranslation(FName trname)
{
// There is no constant for the empty name...
if (trname.GetChars()[0] == 0)
Expand All @@ -1177,35 +1177,35 @@ void DZSprite::SetTranslation(FName trname)
// silently ignore if the name does not exist, this would create some insane message spam otherwise.
}

DEFINE_ACTION_FUNCTION(DZSprite, SetTranslation)
DEFINE_ACTION_FUNCTION(DVisualThinker, SetTranslation)
{
PARAM_SELF_PROLOGUE(DZSprite);
PARAM_SELF_PROLOGUE(DVisualThinker);
PARAM_NAME(trans);
self->SetTranslation(trans);
return 0;
}

bool DZSprite::isFrozen()
bool DVisualThinker::isFrozen()
{
return (Level->isFrozen() && !(Flags & SPF_NOTIMEFREEZE));
}

DEFINE_ACTION_FUNCTION(DZSprite, IsFrozen)
DEFINE_ACTION_FUNCTION(DVisualThinker, IsFrozen)
{
PARAM_SELF_PROLOGUE(DZSprite);
PARAM_SELF_PROLOGUE(DVisualThinker);
ACTION_RETURN_BOOL(self->isFrozen());
}

DEFINE_ACTION_FUNCTION(DZSprite, SetRenderStyle)
DEFINE_ACTION_FUNCTION(DVisualThinker, SetRenderStyle)
{
PARAM_SELF_PROLOGUE(DZSprite);
PARAM_SELF_PROLOGUE(DVisualThinker);
PARAM_INT(mode);

self->Style = ERenderStyle(mode);
return 0;
}

int DZSprite::GetRenderStyle()
int DVisualThinker::GetRenderStyle()
{
for (unsigned i = 0; i < STYLE_Count; i++)
{
Expand All @@ -1214,7 +1214,7 @@ int DZSprite::GetRenderStyle()
return -1;
}

void DZSprite::Serialize(FSerializer& arc)
void DVisualThinker::Serialize(FSerializer& arc)
{
Super::Serialize(arc);

Expand All @@ -1241,22 +1241,22 @@ void DZSprite::Serialize(FSerializer& arc)

}

IMPLEMENT_CLASS(DZSprite, false, false);
DEFINE_FIELD(DZSprite, Pos);
DEFINE_FIELD(DZSprite, Vel);
DEFINE_FIELD(DZSprite, Prev);
DEFINE_FIELD(DZSprite, Scale);
DEFINE_FIELD(DZSprite, Offset);
DEFINE_FIELD(DZSprite, Roll);
DEFINE_FIELD(DZSprite, PrevRoll);
DEFINE_FIELD(DZSprite, Alpha);
DEFINE_FIELD(DZSprite, Texture);
DEFINE_FIELD(DZSprite, Translation);
DEFINE_FIELD(DZSprite, Flags);
DEFINE_FIELD(DZSprite, LightLevel);
DEFINE_FIELD(DZSprite, scolor);
DEFINE_FIELD(DZSprite, cursector);
DEFINE_FIELD(DZSprite, bXFlip);
DEFINE_FIELD(DZSprite, bYFlip);
DEFINE_FIELD(DZSprite, bDontInterpolate);
DEFINE_FIELD(DZSprite, bAddLightLevel);
IMPLEMENT_CLASS(DVisualThinker, false, false);
DEFINE_FIELD(DVisualThinker, Pos);
DEFINE_FIELD(DVisualThinker, Vel);
DEFINE_FIELD(DVisualThinker, Prev);
DEFINE_FIELD(DVisualThinker, Scale);
DEFINE_FIELD(DVisualThinker, Offset);
DEFINE_FIELD(DVisualThinker, Roll);
DEFINE_FIELD(DVisualThinker, PrevRoll);
DEFINE_FIELD(DVisualThinker, Alpha);
DEFINE_FIELD(DVisualThinker, Texture);
DEFINE_FIELD(DVisualThinker, Translation);
DEFINE_FIELD(DVisualThinker, Flags);
DEFINE_FIELD(DVisualThinker, LightLevel);
DEFINE_FIELD(DVisualThinker, scolor);
DEFINE_FIELD(DVisualThinker, cursector);
DEFINE_FIELD(DVisualThinker, bXFlip);
DEFINE_FIELD(DVisualThinker, bYFlip);
DEFINE_FIELD(DVisualThinker, bDontInterpolate);
DEFINE_FIELD(DVisualThinker, bAddLightLevel);
14 changes: 7 additions & 7 deletions src/playsim/p_effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ enum EParticleFlags
SPF_REPLACE = 1 << 7,
SPF_NO_XY_BILLBOARD = 1 << 8,
};
class DZSprite;
class DVisualThinker;
struct particle_t
{
DVector3 Pos;
Expand All @@ -81,7 +81,7 @@ struct particle_t
uint16_t tnext, snext, tprev;
bool bright;
uint16_t flags;
DZSprite *sprite;
DVisualThinker *sprite;
};

const uint16_t NO_PARTICLE = 0xffff;
Expand Down Expand Up @@ -141,16 +141,16 @@ void P_DisconnectEffect (AActor *actor);

//===========================================================================
//
// ZSprites
// VisualThinkers
// by Major Cooke
// Credit to phantombeta, RicardoLuis0 & RaveYard for aid
//
//===========================================================================
class HWSprite;
struct FTranslationID;
class DZSprite : public DThinker
class DVisualThinker : public DThinker
{
DECLARE_CLASS(DZSprite, DThinker);
DECLARE_CLASS(DVisualThinker, DThinker);
public:
DVector3 Pos, Vel, Prev;
DVector2 Scale, Offset;
Expand All @@ -177,12 +177,12 @@ class DZSprite : public DThinker



DZSprite();
DVisualThinker();
void Construct();
void CallPostBeginPlay() override;
void OnDestroy() override;

static DZSprite* NewZSprite(FLevelLocals* Level, PClass* type);
static DVisualThinker* NewVisualThinker(FLevelLocals* Level, PClass* type);
void SetTranslation(FName trname);
int GetRenderStyle();
bool isFrozen();
Expand Down
2 changes: 1 addition & 1 deletion src/playsim/statnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ enum
STAT_ACTORMOVER, // actor movers
STAT_SCRIPTS, // The ACS thinker. This is to ensure that it can't tick before all actors called PostBeginPlay
STAT_BOT, // Bot thinker
STAT_SPRITE, // ZSprite Thinker
STAT_SPRITE, // VisualThinker Thinker
};

#endif
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/scene/hw_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ void HWDrawInfo::RenderParticles(subsector_t *sub, sector_t *front)
SetupSprite.Clock();
for (uint32_t i = 0; i < sub->sprites.Size(); i++)
{
DZSprite *sp = sub->sprites[i];
DVisualThinker *sp = sub->sprites[i];
if (!sp || sp->ObjectFlags & OF_EuthanizeMe)
continue;
if (mClipPortal)
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/scene/hw_drawstructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class HWSprite
void PutSprite(HWDrawInfo *di, bool translucent);
void Process(HWDrawInfo *di, AActor* thing,sector_t * sector, area_t in_area, int thruportal = false, bool isSpriteShadow = false);
void ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *sector);//, int shade, int fakeside)
void AdjustZSprite(HWDrawInfo *di, DZSprite *spr, sector_t *sector);
void AdjustVisualThinker(HWDrawInfo *di, DVisualThinker *spr, sector_t *sector);

void DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent);
};
Expand Down
Loading

0 comments on commit 8ab3255

Please sign in to comment.