void Animation::OnDestroy(BufferIndex bufferIndex) { if (mState == Playing || mState == Paused) { if (mDestroyAction == Dali::Animation::Bake) { UpdateAnimators(bufferIndex, true/*bake the final result*/); } } mState = Destroyed; }
void Animation::Bake(BufferIndex bufferIndex, EndAction action) { if( action == Dali::Animation::BakeFinal ) { if( mSpeedFactor > 0.0f ) { mElapsedSeconds = mPlayRange.y*mDurationSeconds + Math::MACHINE_EPSILON_1; // Force animation to reach it's end } else { mElapsedSeconds = mPlayRange.x*mDurationSeconds - Math::MACHINE_EPSILON_1; //Force animation to reach it's beginning } } UpdateAnimators( bufferIndex, true/*bake the final result*/, true /*animation finished*/ ); }
bool Animation::Update(BufferIndex bufferIndex, float elapsedSeconds) { if (mState == Stopped || mState == Destroyed) { // Short circuit when animation isn't running return false; } // The animation must still be applied when Paused/Stopping if (mState == Playing) { mElapsedSeconds += elapsedSeconds * mSpeedFactor; } Vector2 playRangeSeconds = mPlayRange * mDurationSeconds; if (mLooping) { if (mElapsedSeconds > playRangeSeconds.y ) { mElapsedSeconds = playRangeSeconds.x + fmod(mElapsedSeconds, playRangeSeconds.y); } else if( mElapsedSeconds < playRangeSeconds.x ) { mElapsedSeconds = playRangeSeconds.y - fmod(mElapsedSeconds, playRangeSeconds.y); } } const bool animationFinished(mState == Playing && (( mSpeedFactor > 0.0f && mElapsedSeconds > playRangeSeconds.y ) || ( mSpeedFactor < 0.0f && mElapsedSeconds < playRangeSeconds.x )) ); UpdateAnimators(bufferIndex, animationFinished && (mEndAction != Dali::Animation::Discard), animationFinished); if (animationFinished) { // The animation has now been played to completion ++mPlayCount; mElapsedSeconds = playRangeSeconds.x; mState = Stopped; } return animationFinished; }
bool Animation::Stop(BufferIndex bufferIndex) { bool animationFinished(false); if (mState == Playing || mState == Paused) { animationFinished = true; // The actor-thread should be notified of this if (mEndAction == Dali::Animation::Bake) { UpdateAnimators(bufferIndex, true/*bake the final result*/); } // The animation has now been played to completion ++mPlayCount; } mElapsedSeconds = 0.0f; mState = Stopped; return animationFinished; }
bool Animation::Update(BufferIndex bufferIndex, float elapsedSeconds) { if (mState == Stopped || mState == Destroyed) { // Short circuit when animation isn't running return false; } // The animation must still be applied when Paused/Stopping if (mState == Playing) { mElapsedSeconds += elapsedSeconds; } if (mLooping) { if (mElapsedSeconds > mDurationSeconds) { mElapsedSeconds = fmod(mElapsedSeconds, mDurationSeconds); } } const bool animationFinished(mState == Playing && mElapsedSeconds > mDurationSeconds); UpdateAnimators(bufferIndex, animationFinished && (mEndAction == Dali::Animation::Bake)); if (animationFinished) { // The animation has now been played to completion ++mPlayCount; mElapsedSeconds = 0.0f; mState = Stopped; } return animationFinished; }