Ogre SkeletonAnimation addFrame error

Design / architecture / roadmap discussions related to future of Ogre3D (version 2.0 and above)
Post Reply
ChicChic
Gnoblar
Posts: 11
Joined: Tue Sep 05, 2017 10:19 am

Ogre SkeletonAnimation addFrame error

Post by ChicChic » Wed Dec 05, 2018 2:56 pm

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
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3806
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 137
Contact:

Re: Ogre SkeletonAnimation addFrame error

Post by dark_sylinc » Wed Dec 05, 2018 9:35 pm

Fixed.

Thanks for the report!
0 x

Post Reply