mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-20 09:52:06 +00:00
- rename ZSprites to VisualThinkers
This commit is contained in:
parent
c42b51d5eb
commit
4b54aac288
13 changed files with 79 additions and 79 deletions
|
@ -10,7 +10,7 @@ xx(Object)
|
|||
xx(Actor)
|
||||
xx(Class)
|
||||
xx(Thinker)
|
||||
xx(ZSprite)
|
||||
xx(VisualThinker)
|
||||
xx(Crosshairs)
|
||||
|
||||
xx(Untranslated)
|
||||
|
|
|
@ -427,8 +427,8 @@ public:
|
|||
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!
|
||||
statnum = STAT_SPRITE;
|
||||
if (thinker->IsKindOf(RUNTIME_CLASS(DVisualThinker))) // [MC] This absolutely must happen for this class!
|
||||
statnum = STAT_VISUALTHINKER;
|
||||
Thinkers.Link(thinker, statnum);
|
||||
thinker->Level = this;
|
||||
return thinker;
|
||||
|
|
|
@ -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];
|
||||
};
|
||||
|
||||
|
|
|
@ -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_VISUALTHINKER && !dynamic_cast<DVisualThinker*>(self))
|
||||
{
|
||||
ChangeStatNum(self, stat);
|
||||
}
|
||||
|
|
|
@ -207,19 +207,19 @@ 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_VISUALTHINKER);
|
||||
DVisualThinker* sp;
|
||||
while (sp = it.Next())
|
||||
{
|
||||
if (sp->sub == nullptr)
|
||||
|
@ -227,7 +227,7 @@ void P_FindParticleSubsectors (FLevelLocals *Level)
|
|||
|
||||
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());
|
||||
|
@ -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;
|
||||
|
@ -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_VISUALTHINKER));
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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++)
|
||||
{
|
||||
|
@ -1214,7 +1214,7 @@ int DZSprite::GetRenderStyle()
|
|||
return -1;
|
||||
}
|
||||
|
||||
void DZSprite::Serialize(FSerializer& arc)
|
||||
void DVisualThinker::Serialize(FSerializer& arc)
|
||||
{
|
||||
Super::Serialize(arc);
|
||||
|
||||
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -177,12 +177,12 @@ public:
|
|||
|
||||
|
||||
|
||||
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();
|
||||
|
|
|
@ -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_VISUALTHINKER, // VisualThinker Thinker
|
||||
};
|
||||
|
||||
#endif
|
|
@ -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)
|
||||
|
|
|
@ -403,7 +403,7 @@ public:
|
|||
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);
|
||||
};
|
||||
|
|
|
@ -1252,7 +1252,7 @@ void HWSprite::ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *
|
|||
if (!particle || particle->alpha <= 0)
|
||||
return;
|
||||
|
||||
DZSprite *spr = particle->sprite;
|
||||
DVisualThinker *spr = particle->sprite;
|
||||
if (spr && spr->Texture.isNull())
|
||||
return;
|
||||
|
||||
|
@ -1318,7 +1318,7 @@ void HWSprite::ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *
|
|||
const auto& vp = di->Viewpoint;
|
||||
|
||||
if (spr)
|
||||
AdjustZSprite(di, spr, sector);
|
||||
AdjustVisualThinker(di, spr, sector);
|
||||
else
|
||||
{
|
||||
bool has_texture = !particle->texture.isNull();
|
||||
|
@ -1405,10 +1405,10 @@ void HWSprite::ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *
|
|||
rendered_sprites++;
|
||||
}
|
||||
|
||||
// [MC] ZSprites are to be rendered akin to actor sprites. The reason this whole system
|
||||
// [MC] VisualThinkers are to be rendered akin to actor sprites. The reason this whole system
|
||||
// is hitching a ride on particle_t is because of the large number of checks with
|
||||
// HWSprite elsewhere in the draw lists.
|
||||
void HWSprite::AdjustZSprite(HWDrawInfo* di, DZSprite* spr, sector_t* sector)
|
||||
void HWSprite::AdjustVisualThinker(HWDrawInfo* di, DVisualThinker* spr, sector_t* sector)
|
||||
{
|
||||
translation = spr->Translation;
|
||||
texture = TexMan.GetGameTexture(spr->Texture, true);
|
||||
|
|
|
@ -926,9 +926,9 @@ static DObject *BuiltinNewDoom(PClass *cls, int outerside, int backwardscompatib
|
|||
ThrowAbortException(X_OTHER, "Cannot create actors with 'new'");
|
||||
return nullptr;
|
||||
}
|
||||
if (cls->IsDescendantOf(NAME_ZSprite)) // Same for ZSprites.
|
||||
if (cls->IsDescendantOf(NAME_VisualThinker)) // Same for VisualThinkers.
|
||||
{
|
||||
ThrowAbortException(X_OTHER, "Cannot create ZSprite or inheriting classes with 'new'. Use 'ZSprite.Spawn' instead.");
|
||||
ThrowAbortException(X_OTHER, "Cannot create VisualThinker or inheriting classes with 'new'. Use 'VisualThinker.Spawn' instead.");
|
||||
return nullptr;
|
||||
}
|
||||
if ((vm_warnthinkercreation || !backwardscompatible) && cls->IsDescendantOf(NAME_Thinker))
|
||||
|
|
|
@ -545,7 +545,7 @@ struct LevelLocals native
|
|||
native String GetEpisodeName();
|
||||
|
||||
native void SpawnParticle(FSpawnParticleParams p);
|
||||
native ZSprite SpawnZSprite(Class<ZSprite> type);
|
||||
native VisualThinker SpawnVisualThinker(Class<VisualThinker> type);
|
||||
}
|
||||
|
||||
// a few values of this need to be readable by the play code.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Class ZSprite : Thinker native
|
||||
Class VisualThinker : Thinker native
|
||||
{
|
||||
native Vector3 Pos, Vel, Prev;
|
||||
native Vector2 Scale, Offset;
|
||||
|
@ -18,12 +18,12 @@ Class ZSprite : Thinker native
|
|||
native void SetRenderStyle(int mode); // see ERenderStyle
|
||||
native bool IsFrozen();
|
||||
|
||||
static ZSprite Spawn(Class<ZSprite> type, TextureID tex, Vector3 pos, Vector3 vel, double alpha = 1.0, int flags = 0,
|
||||
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)
|
||||
{
|
||||
if (!Level) return null;
|
||||
|
||||
let p = level.SpawnZSprite(type);
|
||||
let p = level.SpawnVisualThinker(type);
|
||||
if (p)
|
||||
{
|
||||
p.Texture = tex;
|
||||
|
|
Loading…
Reference in a new issue