This commit is contained in:
Rachael Alexanderson 2024-04-16 23:10:57 -04:00
commit b31c62568b
No known key found for this signature in database
GPG key ID: 26A8ACCE97115EE0
56 changed files with 691 additions and 450 deletions

View file

@ -278,12 +278,19 @@ double getCurrentFrame(const AnimOverride &anim, double tic)
{
if(anim.framerate <= 0) return anim.startFrame;
double duration = double(anim.lastFrame - anim.firstFrame) / double(anim.framerate); // duration in seconds
double startPos = double(anim.startFrame - anim.firstFrame) / double(anim.framerate);
double frame = ((tic - anim.startTic) / GameTicRate) * anim.framerate; // position in frames
double pos = startPos + ((tic - anim.startTic) / GameTicRate); // position in seconds
double duration = double(anim.lastFrame) - anim.startFrame;
return (((anim.flags & ANIMOVERRIDE_LOOP) ? fmod(pos, duration) : min(pos, duration)) * anim.framerate) + anim.firstFrame;
if((anim.flags & ANIMOVERRIDE_LOOP) && frame >= duration)
{
frame = frame - duration;
return fmod(frame, anim.lastFrame - anim.loopFrame) + anim.loopFrame;
}
else
{
return min(frame, duration) + anim.startFrame;
}
}
static void calcFrame(const AnimOverride &anim, double tic, double &inter, int &prev, int &next)
@ -294,22 +301,7 @@ static void calcFrame(const AnimOverride &anim, double tic, double &inter, int &
inter = frame - prev;
if(frame > anim.lastFrame)
{
if(anim.flags & ANIMOVERRIDE_LOOP)
{
next = anim.loopFrame + (prev - anim.lastFrame);
}
else
{
inter = 0;
prev = next = anim.lastFrame;
}
}
else
{
next = int(ceil(frame));
}
next = int(ceil(frame));
}
void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, const FSpriteModelFrame *smf, const FState *curState, const int curTics, FTranslationID translation, AActor* actor)
@ -523,7 +515,7 @@ void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, const FSpr
skinid = smf->skinIDs[i];
}
if (modelid >= 0)
if (modelid >= 0 && modelid < Models.size())
{
FModel * mdl = Models[modelid];
auto tex = skinid.isValid() ? TexMan.GetGameTexture(skinid, true) : nullptr;