Do the same for Visual Thinkers

This commit is contained in:
Ricardo Luís Vaz Silva 2024-01-08 01:58:11 -03:00 committed by Rachael Alexanderson
parent 7eab519795
commit 3bd80ab8f6
4 changed files with 21 additions and 4 deletions

View File

@ -984,7 +984,7 @@ bool FTextureAnimator::InitStandaloneAnimation(FStandaloneAnimation &animInfo, F
{
FAnimDef * anim;
animInfo.ok = false;
for(int i = 0; i < mAnimations.Size(); i++)
for(unsigned i = 0; i < mAnimations.Size(); i++)
{
if(mAnimations[i].BasePic == tex)
{

View File

@ -1024,6 +1024,7 @@ void DVisualThinker::Construct()
cursector = nullptr;
PT.color = 0xffffff;
spr = new HWSprite();
AnimatedTexture.SetNull();
}
DVisualThinker::DVisualThinker()
@ -1078,6 +1079,11 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, SpawnVisualThinker, SpawnVisualThink
void DVisualThinker::UpdateSpriteInfo()
{
PT.style = ERenderStyle(GetRenderStyle());
if((PT.flags & SPF_STANDALONE_ANIMATIONS) && PT.texture != AnimatedTexture)
{
AnimatedTexture = PT.texture;
TexAnim.InitStandaloneAnimation(PT.animData, PT.texture, Level->maptime);
}
}
// This runs just like Actor's, make sure to call Super.Tick() in ZScript.

View File

@ -163,6 +163,7 @@ public:
float PrevRoll;
int16_t LightLevel;
FTranslationID Translation;
FTextureID AnimatedTexture;
sector_t *cursector;
bool bXFlip,

View File

@ -1343,7 +1343,7 @@ void HWSprite::ProcessParticle(HWDrawInfo *di, particle_t *particle, sector_t *s
else
{
bool has_texture = particle->texture.isValid();
bool custom_animated_texture = has_texture && (particle->flags & SPF_STANDALONE_ANIMATIONS) && particle->animData.ok;
bool custom_animated_texture = (particle->flags & SPF_STANDALONE_ANIMATIONS) && particle->animData.ok;
int particle_style = has_texture ? 2 : gl_particles_style; // Treat custom texture the same as smooth particles
@ -1442,11 +1442,21 @@ void HWSprite::ProcessParticle(HWDrawInfo *di, particle_t *particle, sector_t *s
void HWSprite::AdjustVisualThinker(HWDrawInfo* di, DVisualThinker* spr, sector_t* sector)
{
translation = spr->Translation;
texture = TexMan.GetGameTexture(spr->PT.texture, true);
const auto& vp = di->Viewpoint;
double timefrac = vp.TicFrac;
if (paused || spr->isFrozen() || spr->bDontInterpolate)
if (paused || spr->isFrozen())
timefrac = 0.;
bool custom_anim = ((spr->PT.flags & SPF_STANDALONE_ANIMATIONS) && spr->PT.animData.ok);
texture = TexMan.GetGameTexture(
custom_anim
? TexAnim.UpdateStandaloneAnimation(spr->PT.animData, di->Level->maptime + timefrac)
: spr->PT.texture, !custom_anim);
if (spr->bDontInterpolate)
timefrac = 0.;
FVector3 interp = spr->InterpolatedPosition(timefrac);