Page 1 of 1

Ogre SkeletonAnimation addFrame error

Posted: Wed Dec 05, 2018 2:56 pm
by ChicChic
Hi,

I guess there is a mistake for the code of SkeletonAnimation::addFrame and SkeletonAnimation::setFrame :

Code: Select all

            mCurrentFrame = fmod( mCurrentFrame, maxFrame );
            if( mCurrentFrame < 0 )
                mCurrentFrame = maxFrame - mCurrentFrame;
If the "mCurrentFrame" value is negative (which is possible with "fmod" as stated by the 'if' and the doc of fmod) the value mCurrentFrame is computed badly because

Code: Select all

mCurrentFrame = maxFrame - mCurrentFrame;
will be greater than maxFrame, and lead to incorrect animation as I saw in my software...

the good version might be in fact :

Code: Select all

mCurrentFrame = mCurrentFrame + maxFrame; // or simply "mCurrentFrame += maxFrame;" 
for exemple :

Code: Select all

	mCurrentFrame = fmod( -5.1, 3.0 ); // mCurrentFrame = -2.1
	if( mCurrentFrame < 0 ) // true
                mCurrentFrame = -2.1 + 3.0; // mCurrentFrame = 0.9 => good behavior

Re: Ogre SkeletonAnimation addFrame error

Posted: Wed Dec 05, 2018 9:35 pm
by dark_sylinc
Fixed.

Thanks for the report!