Decoupled Animation fixes and improvements
* fixes looping that uses `loopFrame` * adds `endFrame` * adds `SAF_NOOVERRIDE` * fixes crash on SetAnimation if a BaseFrame isn't defined
This commit is contained in:
parent
f2072cec95
commit
7c93cfa97b
5 changed files with 47 additions and 35 deletions
|
|
@ -261,12 +261,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)
|
||||
|
|
@ -277,22 +284,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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue