Ogre SkeletonAnimation addFrame error

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
ChicChic
Kobold
Posts: 26
Joined: Tue Sep 05, 2017 10:19 am
x 7

Ogre SkeletonAnimation addFrame error

Post 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
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5292
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Ogre SkeletonAnimation addFrame error

Post by dark_sylinc »

Fixed.

Thanks for the report!
Post Reply