Page 1 of 1

Animation::RM_Bounce endless loop

Posted: Mon Apr 01, 2013 12:33
by JordanWeber
When attempting to start my program, it gets caught in an infinite loop when using RM_BOUNCE.

delta = 0;
newPosition = 0;

So the following gets stuck, because newPosition never changes:
newPosition = -newPosition;

CEGUIAnimationInstance.cpp

Code: Select all

    else if (d_definition->getReplayMode() == Animation::RM_Bounce)
    {
        if (d_bounceBackwards)
        {
            delta = -delta;
        }

        float newPosition = d_position + delta;

        while (newPosition <= 0 || newPosition > duration)
        {
            if (newPosition <= 0)
            {
                d_bounceBackwards = false;

                newPosition = -newPosition;
                onAnimationLooped();
            }

            if (newPosition > duration)
            {
                d_bounceBackwards = true;

                newPosition = 2.0f * duration - newPosition;
                onAnimationLooped();
            }
        }

        setPosition(newPosition);
    }


Temporary Workaround:
Everytime you start the animation state, step it a small enough amount so delta isnt 0.0f;

Code: Select all

    statsMessageAnimation->start(false);
    statsMessageAnimation->step(0.000001f);


I will be submitting this into mantis.