[fixed]Bug in looped animation

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.

[fixed]Bug in looped animation

Postby B@z » Tue Nov 17, 2009 1:11 am

hi
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);
      }
   }

it looks good at first sight, but just think about it.

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));
      }
   }


EDIT: oops, seems like % works only with int. changed to fmod
Image
Image
B@z
 
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Postby CuteAlien » Tue Nov 17, 2009 3:10 am

Hm, I've seen this change already and also wondered about it. But probably there was some reason....

Can you please put an entry for that on the bugtracker?
IRC: #irrlicht on irc.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5349
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Postby B@z » Tue Nov 17, 2009 4:00 am

yeah, tried to replace it with the older code, but it didnt work.. maybe something changed with the variables.
anyway, sent ticket
Image
Image
B@z
 
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Postby CuteAlien » Tue Nov 17, 2009 5:03 am

Ok, thanks.
IRC: #irrlicht on irc.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5349
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Postby hybrid » Tue Nov 17, 2009 9:01 am

Yes, the fix sounds reasonable. I guess we should put this into 1.6 branch in order to get this corrected as early as possible.
hybrid
Admin
 
Posts: 13942
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Postby B@z » Mon Mar 15, 2010 10:04 pm

okay, downloaded 1.7.1 aaaaaand the bug still exists xD
i mean u forgot to change the code

and i dont wanna open a new topic for that, but i would be happy if the getJointNode wouldn't give error if couldnt find specific bone.
i mean im checking if the returned value is null, then why does it gives a warning message?
yea we can turn off warning messages, but i want to see the other warnings, just dont want it to spam my console (coz im trying to get bones in every frame)
its not a big problem, but i have to rebuild the engine every time a new comes out >.>
Image
Image
B@z
 
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Postby CuteAlien » Mon Mar 15, 2010 10:51 pm

We did not forget it and it is still on the bugtracker. The problem is that it is the way it is now because that fixed another bug (see http://sourceforge.net/tracker/?func=de ... tid=540678). Just returning to the old bug isn't really a solution. So we first have to write some tests for all the different situations which can happen so we don't mess it up again. I also wish we would have found time to fix the animations bugs before 1.7 releases, but it just didn't work out. If I ever manage to get a full day for Irrlicht again the animation troubles will be my first priority. But maybe someone else is interested enough to write a bunch of good tests for that for us - actually fixing it is then probably rather easy.

The getJointForNode warnings might have been worth an own topic. Because I think we should have another logging-level for that - ELL_WARNING is imho way to high here and I wouldn't even like to use ELL_INFORMATION. Most logging libraries have some DEBUG level for such stuff, so what I would like to do is to introduce ELL_DEBUG. But I will talk with the team about that first.
IRC: #irrlicht on irc.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5349
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Postby B@z » Tue Mar 16, 2010 12:16 am

well i dont think thats a good idea leaving the bugged version..
i dont know whats the problem with the old one(i mean my fix), but works better than the current version. its pretty ugly

but ok, i thought u forgot it, and wanted to remind
Image
Image
B@z
 
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Postby CuteAlien » Tue Mar 16, 2010 12:51 am

B@z wrote:well i dont think thats a good idea leaving the bugged version..


No, certainly not. I really hope one of us finds time soon for that bug. The problem is not that there is something wrong with your fix, but that we don't know if there is something wrong with it or not before someone writes some tests. It's not the fixing that is blocking this - it is figuring out if the fix this time will solve the troubles. You get a lot more careful when you find out that the reason it's broken is that someone tried to fix another bug. Also it's probably a good idea to care about the other animation problem at the same time, the thing that setAnimationSpeed shouldn't change the current frame.
IRC: #irrlicht on irc.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5349
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Postby B@z » Tue Mar 16, 2010 4:05 am

oh now i understand what u meant.
i hope someone will work on that too
Image
Image
B@z
 
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Postby CuteAlien » Tue Jun 22, 2010 4:24 pm

I fixed it now in the 1.7 svn branch. Did it a little bit different than you, but should work.

There's still another problem which I found when fixing this one. It seems right now we don't interpolate between the last and the first frame. So the only way animations work correct is when the first and last frame are identical. I suppose this isn't like it should be, but changing this is more tricky (I suppose we would have to run CurrentFrameNr to EndFrame+1 and then catch this situation in the place where we do the real interpolation). So something for another day.

For easier testing the meshviewer example shows frames now.

Sorry for taking that long to fix this bug.
IRC: #irrlicht on irc.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5349
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Postby B@z » Wed Jun 23, 2010 2:57 am

thanks for fixing~

well what you said.. i never saw any 3d software or engine what interpolated between the first and the end frame. i think, that doesnt annoy anyone XD
Image
Image
B@z
 
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary


Return to Bug reports

Who is online

Users browsing this forum: No registered users and 1 guest