2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/event/animation/animation-impl.h>
20 #include <dali/public-api/object/property-map.h>
25 #include <dali/public-api/animation/alpha-function.h>
26 #include <dali/public-api/animation/time-period.h>
27 #include <dali/public-api/common/dali-common.h>
28 #include <dali/public-api/object/type-registry.h>
29 #include <dali/public-api/math/vector2.h>
30 #include <dali/public-api/math/radian.h>
31 #include <dali/internal/event/animation/animation-playlist.h>
32 #include <dali/internal/event/animation/animator-connector.h>
33 #include <dali/internal/event/common/notification-manager.h>
34 #include <dali/internal/event/common/property-helper.h>
35 #include <dali/internal/event/common/stage-impl.h>
36 #include <dali/internal/event/common/thread-local-storage.h>
37 #include <dali/internal/update/animation/scene-graph-animator.h>
38 #include <dali/internal/update/manager/update-manager.h>
40 using Dali::Internal::SceneGraph::UpdateManager;
41 using Dali::Internal::SceneGraph::AnimatorBase;
42 using Dali::Internal::SceneGraph::Shader;
50 static bool SHOW_VALUE = true;
51 static bool HIDE_VALUE = false;
58 const char* const SIGNAL_FINISHED = "finished";
62 const char* const ACTION_PLAY = "play";
63 const char* const ACTION_STOP = "stop";
64 const char* const ACTION_PAUSE = "pause";
68 return Dali::Animation::New(0.f);
71 TypeRegistration mType( typeid( Dali::Animation ), typeid( Dali::BaseHandle ), Create );
73 SignalConnectorType signalConnector1( mType, SIGNAL_FINISHED, &Animation::DoConnectSignal );
75 TypeAction action1( mType, ACTION_PLAY, &Animation::DoAction );
76 TypeAction action2( mType, ACTION_STOP, &Animation::DoAction );
77 TypeAction action3( mType, ACTION_PAUSE, &Animation::DoAction );
79 const Dali::Animation::EndAction DEFAULT_END_ACTION( Dali::Animation::Bake );
80 const Dali::Animation::EndAction DEFAULT_DISCONNECT_ACTION( Dali::Animation::BakeFinal );
81 const Dali::Animation::Interpolation DEFAULT_INTERPOLATION( Dali::Animation::Linear );
82 const Dali::AlphaFunction DEFAULT_ALPHA_FUNCTION( Dali::AlphaFunction::DEFAULT );
87 AnimationPtr Animation::New(float durationSeconds)
89 Stage* stage = Stage::GetCurrent();
93 AnimationPlaylist& playlist = stage->GetAnimationPlaylist();
95 if( durationSeconds < 0.0f )
97 DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
98 durationSeconds = 0.0f;
101 AnimationPtr animation = new Animation( *stage, playlist, durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION );
103 // Second-phase construction
104 animation->Initialize();
114 Animation::Animation( EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha )
115 : mAnimation( NULL ),
116 mEventThreadServices( eventThreadServices ),
117 mPlaylist( playlist ),
120 mConnectorTargetValues(),
121 mPlayRange( Vector2(0.0f,1.0f)),
122 mDurationSeconds( durationSeconds ),
124 mNotificationCount( 0 ),
127 mEndAction( endAction ),
128 mDisconnectAction( disconnectAction ),
129 mDefaultAlpha( defaultAlpha ),
130 mState(Dali::Animation::STOPPED)
134 void Animation::Initialize()
136 // Connect to the animation playlist
137 mPlaylist.AnimationCreated( *this );
144 Animation::~Animation()
146 // Guard to allow handle destruction after Core has been destroyed
147 if ( Stage::IsInstalled() )
149 // Disconnect from the animation playlist
150 mPlaylist.AnimationDestroyed( *this );
152 DestroySceneObject();
158 void Animation::CreateSceneObject()
160 DALI_ASSERT_DEBUG( mAnimation == NULL );
162 // Create a new animation, temporarily owned
163 SceneGraph::Animation* animation = SceneGraph::Animation::New( mDurationSeconds, mSpeedFactor, mPlayRange, mLoopCount, mEndAction, mDisconnectAction );
165 // Keep a const pointer to the animation.
166 mAnimation = animation;
168 // Transfer animation ownership to the update manager through a message
169 AddAnimationMessage( mEventThreadServices.GetUpdateManager(), animation );
172 void Animation::DestroySceneObject()
174 if ( mAnimation != NULL )
176 // Remove animation using a message to the update manager
177 RemoveAnimationMessage( mEventThreadServices.GetUpdateManager(), *mAnimation );
182 void Animation::SetDuration(float seconds)
186 DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
190 // Cache for public getters
191 mDurationSeconds = seconds;
193 // mAnimation is being used in a separate thread; queue a message to set the value
194 SetDurationMessage( mEventThreadServices, *mAnimation, seconds );
197 float Animation::GetDuration() const
199 // This is not animatable; the cached value is up-to-date.
200 return mDurationSeconds;
203 void Animation::SetLooping(bool on)
205 SetLoopCount( on ? 0 : 1 );
208 void Animation::SetLoopCount(int count)
210 // Cache for public getters
213 // mAnimation is being used in a separate thread; queue a message to set the value
214 SetLoopingMessage( mEventThreadServices, *mAnimation, mLoopCount );
217 int Animation::GetLoopCount()
222 int Animation::GetCurrentLoop()
227 bool Animation::IsLooping() const
229 return mLoopCount != 1;
232 void Animation::SetEndAction(EndAction action)
234 // Cache for public getters
237 // mAnimation is being used in a separate thread; queue a message to set the value
238 SetEndActionMessage( mEventThreadServices, *mAnimation, action );
241 Dali::Animation::EndAction Animation::GetEndAction() const
243 // This is not animatable; the cached value is up-to-date.
247 void Animation::SetDisconnectAction(EndAction action)
249 // Cache for public getters
250 mDisconnectAction = action;
252 // mAnimation is being used in a separate thread; queue a message to set the value
253 SetDisconnectActionMessage( mEventThreadServices, *mAnimation, action );
256 Dali::Animation::EndAction Animation::GetDisconnectAction() const
258 // This is not animatable; the cached value is up-to-date.
259 return mDisconnectAction;
262 void Animation::Play()
264 // Update the current playlist
265 mPlaylist.OnPlay( *this );
267 mState = Dali::Animation::PLAYING;
269 if( mEndAction != EndAction::Discard ) // If the animation is discarded, then we do not want to change the target values
271 // Sort according to end time with earlier end times coming first, if the end time is the same, then the connectors are not moved
272 std::stable_sort( mConnectorTargetValues.begin(), mConnectorTargetValues.end(), CompareConnectorEndTimes );
274 // Loop through all connector target values sorted by increasing end time
275 ConnectorTargetValuesContainer::const_iterator iter = mConnectorTargetValues.begin();
276 const ConnectorTargetValuesContainer::const_iterator endIter = mConnectorTargetValues.end();
277 for( ; iter != endIter; ++iter )
279 AnimatorConnectorBase* connector = mConnectors[ iter->connectorIndex ];
281 Object* object = connector->GetObject();
284 object->NotifyPropertyAnimation( *this, connector->GetPropertyIndex(), iter->targetValue );
289 // mAnimation is being used in a separate thread; queue a Play message
290 PlayAnimationMessage( mEventThreadServices, *mAnimation );
293 void Animation::PlayFrom( float progress )
295 if( progress >= mPlayRange.x && progress <= mPlayRange.y )
297 // Update the current playlist
298 mPlaylist.OnPlay( *this );
300 mState = Dali::Animation::PLAYING;
302 // mAnimation is being used in a separate thread; queue a Play message
303 PlayAnimationFromMessage( mEventThreadServices, *mAnimation, progress );
307 void Animation::Pause()
309 mState = Dali::Animation::PAUSED;
311 // mAnimation is being used in a separate thread; queue a Pause message
312 PauseAnimationMessage( mEventThreadServices, *mAnimation );
315 Dali::Animation::State Animation::GetState() const
320 void Animation::Stop()
322 mState = Dali::Animation::STOPPED;
324 // mAnimation is being used in a separate thread; queue a Stop message
325 StopAnimationMessage( mEventThreadServices.GetUpdateManager(), *mAnimation );
328 void Animation::Clear()
330 DALI_ASSERT_DEBUG(mAnimation);
332 // Remove all the connectors
335 // Reset the connector target values
336 mConnectorTargetValues.clear();
338 // Replace the old scene-object with a new one
339 DestroySceneObject();
342 // Reset the notification count, since the new scene-object has never been played
343 mNotificationCount = 0;
345 // Update the current playlist
346 mPlaylist.OnClear( *this );
349 void Animation::AnimateBy(Property& target, Property::Value& relativeValue)
351 AnimateBy(target, relativeValue, mDefaultAlpha, TimePeriod(mDurationSeconds));
354 void Animation::AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha)
356 AnimateBy(target, relativeValue, alpha, TimePeriod(mDurationSeconds));
359 void Animation::AnimateBy(Property& target, Property::Value& relativeValue, TimePeriod period)
361 AnimateBy(target, relativeValue, mDefaultAlpha, period);
364 void Animation::AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period)
366 Object& object = GetImplementation( target.object );
367 const Property::Type targetType = object.GetPropertyType( target.propertyIndex );
368 const Property::Type destinationType = relativeValue.GetType();
369 DALI_ASSERT_ALWAYS( targetType == destinationType && "Animated value and Property type don't match" );
371 ExtendDuration( period );
373 switch ( targetType )
375 case Property::BOOLEAN:
377 AddAnimatorConnector( AnimatorConnector<bool>::New( object,
378 target.propertyIndex,
379 target.componentIndex,
380 new AnimateByBoolean(relativeValue.Get<bool>()),
386 case Property::INTEGER:
388 AddAnimatorConnector( AnimatorConnector<int>::New( object,
389 target.propertyIndex,
390 target.componentIndex,
391 new AnimateByInteger(relativeValue.Get<int>()),
397 case Property::FLOAT:
399 AddAnimatorConnector( AnimatorConnector<float>::New( object,
400 target.propertyIndex,
401 target.componentIndex,
402 new AnimateByFloat(relativeValue.Get<float>()),
408 case Property::VECTOR2:
410 AddAnimatorConnector( AnimatorConnector<Vector2>::New( object,
411 target.propertyIndex,
412 target.componentIndex,
413 new AnimateByVector2(relativeValue.Get<Vector2>()),
419 case Property::VECTOR3:
421 AddAnimatorConnector( AnimatorConnector<Vector3>::New( object,
422 target.propertyIndex,
423 target.componentIndex,
424 new AnimateByVector3(relativeValue.Get<Vector3>()),
430 case Property::VECTOR4:
432 AddAnimatorConnector( AnimatorConnector<Vector4>::New( object,
433 target.propertyIndex,
434 target.componentIndex,
435 new AnimateByVector4(relativeValue.Get<Vector4>()),
441 case Property::ROTATION:
443 AngleAxis angleAxis = relativeValue.Get<AngleAxis>();
445 AddAnimatorConnector( AnimatorConnector<Quaternion>::New( object,
446 target.propertyIndex,
447 target.componentIndex,
448 new RotateByAngleAxis(angleAxis.angle, angleAxis.axis),
456 // non animatable types handled already
461 void Animation::AnimateTo(Property& target, Property::Value& destinationValue)
463 AnimateTo(target, destinationValue, mDefaultAlpha, TimePeriod(mDurationSeconds));
466 void Animation::AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha)
468 AnimateTo(target, destinationValue, alpha, TimePeriod(mDurationSeconds));
471 void Animation::AnimateTo(Property& target, Property::Value& destinationValue, TimePeriod period)
473 AnimateTo(target, destinationValue, mDefaultAlpha, period);
476 void Animation::AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period)
478 Object& object = GetImplementation(target.object);
480 AnimateTo( object, target.propertyIndex, target.componentIndex, destinationValue, alpha, period );
483 void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIndex, int componentIndex, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period)
485 Property::Type targetType = targetObject.GetPropertyType(targetPropertyIndex);
486 if( componentIndex != Property::INVALID_COMPONENT_INDEX )
488 if( ( targetType == Property::VECTOR2 ) ||
489 ( targetType == Property::VECTOR3 ) ||
490 ( targetType == Property::VECTOR4 ) )
492 targetType = Property::FLOAT;
495 const Property::Type destinationType = destinationValue.GetType();
496 DALI_ASSERT_ALWAYS( targetType == destinationType && "Animated value and Property type don't match" );
498 ExtendDuration( period );
500 // Store data to later notify the object that its property is being animated
501 ConnectorTargetValues connectorPair;
502 connectorPair.targetValue = destinationValue;
503 connectorPair.connectorIndex = mConnectors.Count();
504 connectorPair.timePeriod = period;
505 mConnectorTargetValues.push_back( connectorPair );
507 switch ( destinationType )
509 case Property::BOOLEAN:
511 AddAnimatorConnector( AnimatorConnector<bool>::New( targetObject,
514 new AnimateToBoolean( destinationValue.Get<bool>() ),
520 case Property::INTEGER:
522 AddAnimatorConnector( AnimatorConnector<int>::New( targetObject,
525 new AnimateToInteger( destinationValue.Get<int>() ),
531 case Property::FLOAT:
533 AddAnimatorConnector( AnimatorConnector<float>::New( targetObject,
536 new AnimateToFloat( destinationValue.Get<float>() ),
542 case Property::VECTOR2:
544 AddAnimatorConnector( AnimatorConnector<Vector2>::New( targetObject,
547 new AnimateToVector2( destinationValue.Get<Vector2>() ),
553 case Property::VECTOR3:
555 AddAnimatorConnector( AnimatorConnector<Vector3>::New( targetObject,
558 new AnimateToVector3( destinationValue.Get<Vector3>() ),
564 case Property::VECTOR4:
566 AddAnimatorConnector( AnimatorConnector<Vector4>::New( targetObject,
569 new AnimateToVector4( destinationValue.Get<Vector4>() ),
575 case Property::ROTATION:
577 AddAnimatorConnector( AnimatorConnector<Quaternion>::New( targetObject,
580 new RotateToQuaternion( destinationValue.Get<Quaternion>() ),
588 // non animatable types handled already
593 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames)
595 AnimateBetween(target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION );
598 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, Interpolation interpolation )
600 AnimateBetween(target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), interpolation );
603 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period)
605 AnimateBetween(target, keyFrames, mDefaultAlpha, period, DEFAULT_INTERPOLATION);
608 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
610 AnimateBetween(target, keyFrames, mDefaultAlpha, period, interpolation);
613 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha)
615 AnimateBetween(target, keyFrames, alpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION);
618 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
620 AnimateBetween(target, keyFrames, alpha, TimePeriod(mDurationSeconds), interpolation);
623 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
625 AnimateBetween(target, keyFrames, alpha, period, DEFAULT_INTERPOLATION);
628 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
630 Object& object = GetImplementation( target.object );
632 ExtendDuration( period );
634 switch(keyFrames.GetType())
636 case Dali::Property::BOOLEAN:
638 const KeyFrameBoolean* kf;
639 GetSpecialization(keyFrames, kf);
640 KeyFrameBooleanPtr kfCopy = KeyFrameBoolean::Clone(*kf);
641 AddAnimatorConnector( AnimatorConnector<bool>::New( object,
642 target.propertyIndex,
643 target.componentIndex,
644 new KeyFrameBooleanFunctor(kfCopy),
650 case Dali::Property::INTEGER:
652 const KeyFrameInteger* kf;
653 GetSpecialization(keyFrames, kf);
654 KeyFrameIntegerPtr kfCopy = KeyFrameInteger::Clone(*kf);
655 AddAnimatorConnector( AnimatorConnector<int>::New( object,
656 target.propertyIndex,
657 target.componentIndex,
658 new KeyFrameIntegerFunctor(kfCopy,interpolation),
664 case Dali::Property::FLOAT:
666 const KeyFrameNumber* kf;
667 GetSpecialization(keyFrames, kf);
668 KeyFrameNumberPtr kfCopy = KeyFrameNumber::Clone(*kf);
669 AddAnimatorConnector( AnimatorConnector<float>::New( object,
670 target.propertyIndex,
671 target.componentIndex,
672 new KeyFrameNumberFunctor(kfCopy,interpolation),
678 case Dali::Property::VECTOR2:
680 const KeyFrameVector2* kf;
681 GetSpecialization(keyFrames, kf);
682 KeyFrameVector2Ptr kfCopy = KeyFrameVector2::Clone(*kf);
683 AddAnimatorConnector( AnimatorConnector<Vector2>::New( object,
684 target.propertyIndex,
685 target.componentIndex,
686 new KeyFrameVector2Functor(kfCopy,interpolation),
692 case Dali::Property::VECTOR3:
694 const KeyFrameVector3* kf;
695 GetSpecialization(keyFrames, kf);
696 KeyFrameVector3Ptr kfCopy = KeyFrameVector3::Clone(*kf);
697 AddAnimatorConnector( AnimatorConnector<Vector3>::New( object,
698 target.propertyIndex,
699 target.componentIndex,
700 new KeyFrameVector3Functor(kfCopy,interpolation),
706 case Dali::Property::VECTOR4:
708 const KeyFrameVector4* kf;
709 GetSpecialization(keyFrames, kf);
710 KeyFrameVector4Ptr kfCopy = KeyFrameVector4::Clone(*kf);
711 AddAnimatorConnector( AnimatorConnector<Vector4>::New( object,
712 target.propertyIndex,
713 target.componentIndex,
714 new KeyFrameVector4Functor(kfCopy,interpolation),
720 case Dali::Property::ROTATION:
722 const KeyFrameQuaternion* kf;
723 GetSpecialization(keyFrames, kf);
724 KeyFrameQuaternionPtr kfCopy = KeyFrameQuaternion::Clone(*kf);
725 AddAnimatorConnector( AnimatorConnector<Quaternion>::New( object,
726 target.propertyIndex,
727 target.componentIndex,
728 new KeyFrameQuaternionFunctor(kfCopy),
736 // non animatable types handled by keyframes
741 bool Animation::HasFinished()
743 bool hasFinished(false);
744 const int playedCount(mAnimation->GetPlayedCount());
746 // If the play count has been incremented, then another notification is required
747 mCurrentLoop = mAnimation->GetCurrentLoop();
749 if (playedCount > mNotificationCount)
751 // Note that only one signal is emitted, if the animation has been played repeatedly
752 mNotificationCount = playedCount;
756 mState = Dali::Animation::STOPPED;
762 Dali::Animation::AnimationSignalType& Animation::FinishedSignal()
764 return mFinishedSignal;
767 void Animation::EmitSignalFinish()
769 if ( !mFinishedSignal.Empty() )
771 Dali::Animation handle( this );
772 mFinishedSignal.Emit( handle );
776 bool Animation::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
778 bool connected( true );
779 Animation* animation = static_cast< Animation* >(object); // TypeRegistry guarantees that this is the correct type.
781 if( 0 == signalName.compare( SIGNAL_FINISHED ) )
783 animation->FinishedSignal().Connect( tracker, functor );
787 // signalName does not match any signal
794 void Animation::AddAnimatorConnector( AnimatorConnectorBase* connector )
796 DALI_ASSERT_DEBUG( NULL != connector );
798 connector->SetParent(*this);
800 mConnectors.PushBack( connector );
803 void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward )
805 Animate( actor, path, forward, mDefaultAlpha, TimePeriod(mDurationSeconds) );
808 void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha )
810 Animate( actor, path, forward, alpha, TimePeriod(mDurationSeconds) );
813 void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, TimePeriod period )
815 Animate( actor, path, forward, mDefaultAlpha, period );
818 void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
820 ExtendDuration( period );
822 PathPtr pathCopy = Path::Clone(path);
825 AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
826 Dali::Actor::Property::POSITION,
827 Property::INVALID_COMPONENT_INDEX,
828 new PathPositionFunctor( pathCopy ),
832 //If forward is zero, PathRotationFunctor will always return the unit quaternion
833 if( forward != Vector3::ZERO )
836 AddAnimatorConnector( AnimatorConnector<Quaternion>::New( actor,
837 Dali::Actor::Property::ORIENTATION,
838 Property::INVALID_COMPONENT_INDEX,
839 new PathRotationFunctor( pathCopy, forward ),
845 void Animation::Show(Actor& actor, float delaySeconds)
847 ExtendDuration( TimePeriod(delaySeconds, 0) );
849 AddAnimatorConnector( AnimatorConnector<bool>::New( actor,
850 Dali::Actor::Property::VISIBLE,
851 Property::INVALID_COMPONENT_INDEX,
852 new AnimateToBoolean(SHOW_VALUE),
854 TimePeriod(delaySeconds, 0.0f/*immediate*/) ) );
857 void Animation::Hide(Actor& actor, float delaySeconds)
859 ExtendDuration( TimePeriod(delaySeconds, 0) );
861 AddAnimatorConnector( AnimatorConnector<bool>::New( actor,
862 Dali::Actor::Property::VISIBLE,
863 Property::INVALID_COMPONENT_INDEX,
864 new AnimateToBoolean(HIDE_VALUE),
866 TimePeriod(delaySeconds, 0.0f/*immediate*/) ) );
869 bool Animation::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
872 Animation* animation = dynamic_cast<Animation*>( object );
876 if( 0 == actionName.compare( ACTION_PLAY ) )
878 if( Property::Value* value = attributes.Find("duration", Property::FLOAT) )
880 animation->SetDuration( value->Get<float>() );
886 else if( 0 == actionName.compare( ACTION_STOP ) )
891 else if( 0 == actionName.compare( ACTION_PAUSE ) )
901 void Animation::SetCurrentProgress(float progress)
903 if( mAnimation && progress >= mPlayRange.x && progress <= mPlayRange.y )
905 // mAnimation is being used in a separate thread; queue a message to set the current progress
906 SetCurrentProgressMessage( mEventThreadServices, *mAnimation, progress );
910 float Animation::GetCurrentProgress()
914 return mAnimation->GetCurrentProgress();
920 void Animation::ExtendDuration( const TimePeriod& timePeriod )
922 float duration = timePeriod.delaySeconds + timePeriod.durationSeconds;
924 if( duration > mDurationSeconds )
926 SetDuration( duration );
930 void Animation::SetSpeedFactor( float factor )
934 mSpeedFactor = factor;
935 SetSpeedFactorMessage( mEventThreadServices, *mAnimation, factor );
939 float Animation::GetSpeedFactor() const
944 void Animation::SetPlayRange( const Vector2& range)
946 //Make sure the range specified is between 0.0 and 1.0
947 if( range.x >= 0.0f && range.x <= 1.0f && range.y >= 0.0f && range.y <= 1.0f )
949 Vector2 orderedRange( range );
950 //If the range is not in order swap values
951 if( range.x > range.y )
953 orderedRange = Vector2(range.y, range.x);
956 // Cache for public getters
957 mPlayRange = orderedRange;
959 // mAnimation is being used in a separate thread; queue a message to set play range
960 SetPlayRangeMessage( mEventThreadServices, *mAnimation, orderedRange );
964 Vector2 Animation::GetPlayRange() const
969 bool Animation::CompareConnectorEndTimes( const Animation::ConnectorTargetValues& lhs, const Animation::ConnectorTargetValues& rhs )
971 return ( ( lhs.timePeriod.delaySeconds + lhs.timePeriod.durationSeconds ) < ( rhs.timePeriod.delaySeconds + rhs.timePeriod.durationSeconds ) );
974 } // namespace Internal