i found an interesting glitch in irrlicht 1.6
i place an animated, looped character somewhere, it works cool.
but then if i pause the render (debugging, or just use the pause button), the frame glitches.
it jumps over the EndFrame, and start playing the animation reversed until it reaches the EndFrame.
the problem is that it does the same thing when loading (so there is a pause)
in my game, i load things, then show up my model. but because the loading pause, the frame glitch appears, and my character is moving wierd xD
after looking into irrlicht code, what changed i found this:
Code: Select all
void CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs)
// ....
else if (Looping)
{
// play animation looped
CurrentFrameNr += timeMs * FramesPerSecond;
if (FramesPerSecond > 0.f) //forwards...
{
if (CurrentFrameNr > EndFrame)
CurrentFrameNr -= (EndFrame-StartFrame);
}
else //backwards...
{
if (CurrentFrameNr < StartFrame)
CurrentFrameNr += (EndFrame-StartFrame);
}
}
StartFrame = 5
EndFrame = 10
FramesPerSecond = 0.025
CurrentFrameNr = 7
i had a big pause, so the timeMs is 4200 (just for testing)
CurrentFrameNr += 4200 * 0.025; (112)
CurrentFrameNr -= (10-5); (107)
and next run
timeMs = 1
CurrentFrameNr(107) += 1*0.025; (107.025)
CurrentFrameNr -= (10-5); (102.025);
etc. so it goes back to EndFrame, then because the CurrentFrameNr -= (EndFrame-StartFrame);, it returns to StartFrame, and everything going well from now.
in irrlicht 1.5 it was good (the code was different), but this one really looks ugly (i wonder why nobody posted about it in forums)
and the solution (at last worked for me, i dunno if its fast enough, or have some problem)
Code: Select all
else if (Looping)
{
// play animation looped
CurrentFrameNr += timeMs * FramesPerSecond;
if (FramesPerSecond > 0.f) //forwards...
{
if (CurrentFrameNr > EndFrame)
CurrentFrameNr = StartFrame + fmod(CurrentFrameNr - EndFrame, (f32)(EndFrame-StartFrame));
}
else //backwards...
{
if (CurrentFrameNr < StartFrame)
CurrentFrameNr = EndFrame - fmod(StartFrame - CurrentFrameNr, (f32)(EndFrame-StartFrame));
}
}