1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__
5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/devel-api/common/owner-container.h>
23 #include <dali/internal/event/animation/key-frames-impl.h>
24 #include <dali/internal/event/animation/path-impl.h>
25 #include <dali/internal/update/nodes/node.h>
26 #include <dali/internal/update/common/property-base.h>
27 #include <dali/public-api/animation/alpha-function.h>
28 #include <dali/public-api/animation/animation.h>
29 #include <dali/public-api/animation/time-period.h>
30 #include <dali/public-api/common/constants.h>
31 #include <dali/public-api/common/dali-common.h>
32 #include <dali/public-api/math/quaternion.h>
33 #include <dali/public-api/math/radian.h>
34 #include <dali/internal/update/animation/property-accessor.h>
43 typedef Dali::Animation::Interpolation Interpolation;
45 struct AnimatorFunctionBase;
52 typedef OwnerContainer< AnimatorBase* > AnimatorContainer;
54 typedef AnimatorContainer::Iterator AnimatorIter;
55 typedef AnimatorContainer::ConstIterator AnimatorConstIter;
58 * An abstract base class for Animators, which can be added to scene graph animations.
59 * Each animator changes a single property of an object in the scene graph.
65 typedef float (*AlphaFunc)(float progress); ///< Definition of an alpha function
71 : mDurationSeconds(1.0f),
72 mInitialDelaySeconds(0.0f),
73 mAlphaFunction(AlphaFunction::DEFAULT),
74 mDisconnectAction(Dali::Animation::BakeFinal),
77 mConnectedToSceneGraph(false)
84 virtual ~AnimatorBase()
89 * Called when Animator is added to the scene-graph in update-thread.
91 virtual void ConnectToSceneGraph() = 0;
94 * Set the duration of the animator.
95 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
96 * @param [in] seconds Duration in seconds.
98 void SetDuration(float seconds)
100 DALI_ASSERT_DEBUG(seconds >= 0.0f);
102 mDurationSeconds = seconds;
106 * Retrieve the duration of the animator.
107 * @return The duration in seconds.
109 float GetDuration() const
111 return mDurationSeconds;
115 * Set the delay before the animator should take effect.
116 * The default is zero i.e. no delay.
117 * @param [in] seconds The delay in seconds.
119 void SetInitialDelay(float seconds)
121 mInitialDelaySeconds = seconds;
125 * Retrieve the initial delay of the animator.
126 * @return The delay in seconds.
128 float GetInitialDelay() const
130 return mInitialDelaySeconds;
134 * Set the alpha function for an animator.
135 * @param [in] alphaFunc The alpha function to apply to the animation progress.
137 void SetAlphaFunction(const AlphaFunction& alphaFunction)
139 mAlphaFunction = alphaFunction;
143 * Retrieve the alpha function of an animator.
144 * @return The function.
146 AlphaFunction GetAlphaFunction() const
148 return mAlphaFunction;
152 * Applies the alpha function to the specified progress
153 * @param[in] Current progress
154 * @return The progress after the alpha function has been aplied
156 float ApplyAlphaFunction( float progress ) const
158 float result = progress;
160 AlphaFunction::Mode alphaFunctionMode( mAlphaFunction.GetMode() );
161 if( alphaFunctionMode == AlphaFunction::BUILTIN_FUNCTION )
163 switch(mAlphaFunction.GetBuiltinFunction())
165 case AlphaFunction::DEFAULT:
166 case AlphaFunction::LINEAR:
170 case AlphaFunction::REVERSE:
172 result = 1.0f-progress;
175 case AlphaFunction::EASE_IN_SQUARE:
177 result = progress * progress;
180 case AlphaFunction::EASE_OUT_SQUARE:
182 result = 1.0f - (1.0f-progress) * (1.0f-progress);
185 case AlphaFunction::EASE_IN:
187 result = progress * progress * progress;
190 case AlphaFunction::EASE_OUT:
192 result = (progress-1.0f) * (progress-1.0f) * (progress-1.0f) + 1.0f;
195 case AlphaFunction::EASE_IN_OUT:
197 result = progress*progress*(3.0f-2.0f*progress);
200 case AlphaFunction::EASE_IN_SINE:
202 result = -1.0f * cosf(progress * Math::PI_2) + 1.0f;
205 case AlphaFunction::EASE_OUT_SINE:
207 result = sinf(progress * Math::PI_2);
210 case AlphaFunction::EASE_IN_OUT_SINE:
212 result = -0.5f * (cosf(Math::PI * progress) - 1.0f);
215 case AlphaFunction::BOUNCE:
217 result = sinf(progress * Math::PI);
220 case AlphaFunction::SIN:
222 result = 0.5f - cosf(progress * 2.0f * Math::PI) * 0.5f;
225 case AlphaFunction::EASE_OUT_BACK:
227 const float sqrt2 = 1.70158f;
229 result = 1.0f + progress * progress * ( ( sqrt2 + 1.0f ) * progress + sqrt2 );
232 case AlphaFunction::COUNT:
238 else if( alphaFunctionMode == AlphaFunction::CUSTOM_FUNCTION )
240 AlphaFunctionPrototype customFunction = mAlphaFunction.GetCustomFunction();
243 result = customFunction(progress);
248 //If progress is very close to 0 or very close to 1 we don't need to evaluate the curve as the result will
249 //be almost 0 or almost 1 respectively
250 if( ( progress > Math::MACHINE_EPSILON_1 ) && ((1.0f - progress) > Math::MACHINE_EPSILON_1) )
252 Dali::Vector4 controlPoints = mAlphaFunction.GetBezierControlPoints();
254 static const float tolerance = 0.001f; //10 iteration max
256 //Perform a binary search on the curve
257 float lowerBound(0.0f);
258 float upperBound(1.0f);
259 float currentT(0.5f);
260 float currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
261 while( fabs( progress - currentX ) > tolerance )
263 if( progress > currentX )
265 lowerBound = currentT;
269 upperBound = currentT;
271 currentT = (upperBound+lowerBound)*0.5f;
272 currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
274 result = EvaluateCubicBezier( controlPoints.y, controlPoints.w, currentT);
282 * Whether to bake the animation if attached property owner is disconnected.
283 * Property is only baked if the animator is active.
284 * @param [in] action The disconnect action.
286 void SetDisconnectAction( Dali::Animation::EndAction action )
288 mDisconnectAction = action;
292 * Retrieve the disconnect action of an animator.
293 * @return The disconnect action.
295 Dali::Animation::EndAction GetDisconnectAction() const
297 return mDisconnectAction;
301 * Whether the animator is active or not.
302 * @param [in] active The new active state.
303 * @post When the animator becomes active, it applies the disconnect-action if the property owner is then disconnected.
304 * @note When the property owner is disconnected, the active state is set to false.
306 void SetActive( bool active )
312 * Retrieve whether the animator has been set to active or not.
313 * @return The active state.
315 bool GetActive() const
321 * Retrive wheter the animator's target object is valid and on the stage.
322 * @return The enabled state.
324 bool IsEnabled() const
329 * Returns wheter the target object of the animator is still valid
330 * or has been destroyed.
331 * @return True if animator is orphan, false otherwise *
332 * @note The SceneGraph::Animation will delete any orphan animator in its Update method.
334 virtual bool Orphan() = 0;
337 * Update the scene object attached to the animator.
338 * @param[in] bufferIndex The buffer to animate.
339 * @param[in] progress A value from 0 to 1, where 0 is the start of the animation, and 1 is the end point.
340 * @param[in] bake Bake.
342 virtual void Update(BufferIndex bufferIndex, float progress, bool bake) = 0;
347 * Helper function to evaluate a cubic bezier curve assuming first point is at 0.0 and last point is at 1.0
348 * @param[in] p0 First control point of the bezier curve
349 * @param[in] p1 Second control point of the bezier curve
350 * @param[in] t A floating point value between 0.0 and 1.0
351 * @return Value of the curve at progress t
353 inline float EvaluateCubicBezier( float p0, float p1, float t ) const
356 return 3.0f*(1.0f-t)*(1.0f-t)*t*p0 + 3.0f*(1.0f-t)*tSquare*p1 + tSquare*t;
359 float mDurationSeconds;
360 float mInitialDelaySeconds;
362 AlphaFunction mAlphaFunction;
364 Dali::Animation::EndAction mDisconnectAction; ///< EndAction to apply when target object gets disconnected from the stage.
365 bool mActive:1; ///< Animator is "active" while it's running.
366 bool mEnabled:1; ///< Animator is "enabled" while its target object is valid and on the stage.
367 bool mConnectedToSceneGraph:1; ///< True if ConnectToSceneGraph() has been called in update-thread.
371 * An animator for a specific property type PropertyType.
373 template < typename PropertyType, typename PropertyAccessorType >
374 class Animator : public AnimatorBase, public PropertyOwner::Observer
379 * Construct a new property animator.
380 * @param[in] property The animatable property; only valid while the Animator is attached.
381 * @param[in] animatorFunction The function used to animate the property.
382 * @param[in] alphaFunction The alpha function to apply.
383 * @param[in] timePeriod The time period of this animation.
384 * @return A newly allocated animator.
386 static AnimatorBase* New( const PropertyOwner& propertyOwner,
387 const PropertyBase& property,
388 AnimatorFunctionBase* animatorFunction,
389 AlphaFunction alphaFunction,
390 const TimePeriod& timePeriod )
392 typedef Animator< PropertyType, PropertyAccessorType > AnimatorType;
394 // The property was const in the actor-thread, but animators are used in the scene-graph thread.
395 AnimatorType* animator = new AnimatorType( const_cast<PropertyOwner*>( &propertyOwner ),
396 const_cast<PropertyBase*>( &property ),
399 animator->SetAlphaFunction( alphaFunction );
400 animator->SetInitialDelay( timePeriod.delaySeconds );
401 animator->SetDuration( timePeriod.durationSeconds );
407 * Virtual destructor.
411 if (mPropertyOwner && mConnectedToSceneGraph)
413 mPropertyOwner->RemoveObserver(*this);
416 delete mAnimatorFunction;
420 * Called when Animator is added to the scene-graph in update-thread.
422 virtual void ConnectToSceneGraph()
424 mConnectedToSceneGraph = true;
425 mPropertyOwner->AddObserver(*this);
429 * Called when mPropertyOwner is connected to the scene graph.
431 virtual void PropertyOwnerConnected( PropertyOwner& owner )
437 * Called when mPropertyOwner is disconnected from the scene graph.
439 virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
441 // If we are active, then bake the value if required
442 if ( mActive && mDisconnectAction != Dali::Animation::Discard )
444 // Bake to target-value if BakeFinal, otherwise bake current value
445 Update( bufferIndex, ( mDisconnectAction == Dali::Animation::Bake ? mCurrentProgress : 1.0f ), true );
453 * Called shortly before mPropertyOwner is destroyed
455 virtual void PropertyOwnerDestroyed( PropertyOwner& owner )
457 mPropertyOwner = NULL;
463 virtual void Update( BufferIndex bufferIndex, float progress, bool bake )
465 float alpha = ApplyAlphaFunction(progress);
467 const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
469 const PropertyType result = (*mAnimatorFunction)( alpha, current );
472 mPropertyAccessor.Bake( bufferIndex, result );
476 mPropertyAccessor.Set( bufferIndex, result );
479 mCurrentProgress = progress;
485 virtual bool Orphan()
487 return (mPropertyOwner == NULL);
493 * Private constructor; see also Animator::New().
495 Animator( PropertyOwner* propertyOwner,
496 PropertyBase* property,
497 AnimatorFunctionBase* animatorFunction )
498 : mPropertyOwner( propertyOwner ),
499 mPropertyAccessor( property ),
500 mAnimatorFunction( animatorFunction ),
501 mCurrentProgress( 0.0f )
503 // WARNING - this object is created in the event-thread
504 // The scene-graph mPropertyOwner object cannot be observed here
508 Animator( const Animator& );
511 Animator& operator=( const Animator& );
515 PropertyOwner* mPropertyOwner;
516 PropertyAccessorType mPropertyAccessor;
518 AnimatorFunctionBase* mAnimatorFunction;
519 float mCurrentProgress;
525 * An animator for a specific property type PropertyType.
527 template <typename T, typename PropertyAccessorType>
528 class AnimatorTransformProperty : public AnimatorBase, public PropertyOwner::Observer
533 * Construct a new property animator.
534 * @param[in] property The animatable property; only valid while the Animator is attached.
535 * @param[in] animatorFunction The function used to animate the property.
536 * @param[in] alphaFunction The alpha function to apply.
537 * @param[in] timePeriod The time period of this animation.
538 * @return A newly allocated animator.
540 static AnimatorBase* New( const PropertyOwner& propertyOwner,
541 const PropertyBase& property,
542 AnimatorFunctionBase* animatorFunction,
543 AlphaFunction alphaFunction,
544 const TimePeriod& timePeriod )
547 // The property was const in the actor-thread, but animators are used in the scene-graph thread.
548 AnimatorTransformProperty* animator = new AnimatorTransformProperty( const_cast<PropertyOwner*>( &propertyOwner ),
549 const_cast<PropertyBase*>( &property ),
552 animator->SetAlphaFunction( alphaFunction );
553 animator->SetInitialDelay( timePeriod.delaySeconds );
554 animator->SetDuration( timePeriod.durationSeconds );
560 * Virtual destructor.
562 virtual ~AnimatorTransformProperty()
564 if (mPropertyOwner && mConnectedToSceneGraph)
566 mPropertyOwner->RemoveObserver(*this);
569 delete mAnimatorFunction;
573 * Called when Animator is added to the scene-graph in update-thread.
575 virtual void ConnectToSceneGraph()
577 mConnectedToSceneGraph = true;
578 mPropertyOwner->AddObserver(*this);
582 * Called when mPropertyOwner is connected to the scene graph.
584 virtual void PropertyOwnerConnected( PropertyOwner& owner )
590 * Called when mPropertyOwner is disconnected from the scene graph.
592 virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
594 // If we are active, then bake the value if required
595 if ( mActive && mDisconnectAction != Dali::Animation::Discard )
597 // Bake to target-value if BakeFinal, otherwise bake current value
598 Update( bufferIndex, ( mDisconnectAction == Dali::Animation::Bake ? mCurrentProgress : 1.0f ), true );
606 * Called shortly before mPropertyOwner is destroyed
608 virtual void PropertyOwnerDestroyed( PropertyOwner& owner )
610 mPropertyOwner = NULL;
616 virtual void Update( BufferIndex bufferIndex, float progress, bool bake )
618 float alpha = ApplyAlphaFunction(progress);
620 const T& current = mPropertyAccessor.Get( bufferIndex );
622 const T result = (*mAnimatorFunction)( alpha, current );
627 mPropertyAccessor.Bake( bufferIndex, result );
631 mPropertyAccessor.Set( bufferIndex, result );
634 mCurrentProgress = progress;
640 virtual bool Orphan()
642 return (mPropertyOwner == NULL);
648 * Private constructor; see also Animator::New().
650 AnimatorTransformProperty( PropertyOwner* propertyOwner,
651 PropertyBase* property,
652 AnimatorFunctionBase* animatorFunction )
653 : mPropertyOwner( propertyOwner ),
654 mPropertyAccessor( property ),
655 mAnimatorFunction( animatorFunction ),
656 mCurrentProgress( 0.0f )
658 // WARNING - this object is created in the event-thread
659 // The scene-graph mPropertyOwner object cannot be observed here
663 AnimatorTransformProperty( const AnimatorTransformProperty& );
666 AnimatorTransformProperty& operator=( const AnimatorTransformProperty& );
670 PropertyOwner* mPropertyOwner;
671 PropertyAccessorType mPropertyAccessor;
673 AnimatorFunctionBase* mAnimatorFunction;
674 float mCurrentProgress;
677 } // namespace SceneGraph
680 * AnimatorFunction base class.
681 * All update functions must inherit from AnimatorFunctionBase and overload the appropiate "()" operator
683 struct AnimatorFunctionBase
688 AnimatorFunctionBase(){}
691 * Virtual destructor (Intended as base class)
693 virtual ~AnimatorFunctionBase(){}
695 ///Stub "()" operators.
696 virtual bool operator()(float progress, const bool& property)
701 virtual float operator()(float progress, const int& property)
706 virtual float operator()(float progress, const unsigned int& property)
711 virtual float operator()(float progress, const float& property)
716 virtual Vector2 operator()(float progress, const Vector2& property)
721 virtual Vector3 operator()(float progress, const Vector3& property)
726 virtual Vector4 operator()(float progress, const Vector4& property)
731 virtual Quaternion operator()(float progress, const Quaternion& property)
739 struct AnimateByInteger : public AnimatorFunctionBase
741 AnimateByInteger(const int& relativeValue)
742 : mRelative(relativeValue)
746 using AnimatorFunctionBase::operator();
747 float operator()(float alpha, const int& property)
749 return int(property + mRelative * alpha + 0.5f );
755 struct AnimateToInteger : public AnimatorFunctionBase
757 AnimateToInteger(const int& targetValue)
758 : mTarget(targetValue)
762 using AnimatorFunctionBase::operator();
763 float operator()(float alpha, const int& property)
765 return int(property + ((mTarget - property) * alpha) + 0.5f);
771 struct AnimateByFloat : public AnimatorFunctionBase
773 AnimateByFloat(const float& relativeValue)
774 : mRelative(relativeValue)
778 using AnimatorFunctionBase::operator();
779 float operator()(float alpha, const float& property)
781 return float(property + mRelative * alpha);
787 struct AnimateToFloat : public AnimatorFunctionBase
789 AnimateToFloat(const float& targetValue)
790 : mTarget(targetValue)
794 using AnimatorFunctionBase::operator();
795 float operator()(float alpha, const float& property)
797 return float(property + ((mTarget - property) * alpha));
803 struct AnimateByVector2 : public AnimatorFunctionBase
805 AnimateByVector2(const Vector2& relativeValue)
806 : mRelative(relativeValue)
810 using AnimatorFunctionBase::operator();
811 Vector2 operator()(float alpha, const Vector2& property)
813 return Vector2(property + mRelative * alpha);
819 struct AnimateToVector2 : public AnimatorFunctionBase
821 AnimateToVector2(const Vector2& targetValue)
822 : mTarget(targetValue)
826 using AnimatorFunctionBase::operator();
827 Vector2 operator()(float alpha, const Vector2& property)
829 return Vector2(property + ((mTarget - property) * alpha));
835 struct AnimateByVector3 : public AnimatorFunctionBase
837 AnimateByVector3(const Vector3& relativeValue)
838 : mRelative(relativeValue)
842 using AnimatorFunctionBase::operator();
843 Vector3 operator()(float alpha, const Vector3& property)
845 return Vector3(property + mRelative * alpha);
851 struct AnimateToVector3 : public AnimatorFunctionBase
853 AnimateToVector3(const Vector3& targetValue)
854 : mTarget(targetValue)
858 using AnimatorFunctionBase::operator();
859 Vector3 operator()(float alpha, const Vector3& property)
861 return Vector3(property + ((mTarget - property) * alpha));
867 struct AnimateByVector4 : public AnimatorFunctionBase
869 AnimateByVector4(const Vector4& relativeValue)
870 : mRelative(relativeValue)
874 using AnimatorFunctionBase::operator();
875 Vector4 operator()(float alpha, const Vector4& property)
877 return Vector4(property + mRelative * alpha);
883 struct AnimateToVector4 : public AnimatorFunctionBase
885 AnimateToVector4(const Vector4& targetValue)
886 : mTarget(targetValue)
890 using AnimatorFunctionBase::operator();
891 Vector4 operator()(float alpha, const Vector4& property)
893 return Vector4(property + ((mTarget - property) * alpha));
899 struct AnimateByOpacity : public AnimatorFunctionBase
901 AnimateByOpacity(const float& relativeValue)
902 : mRelative(relativeValue)
906 using AnimatorFunctionBase::operator();
907 Vector4 operator()(float alpha, const Vector4& property)
909 Vector4 result(property);
910 result.a += mRelative * alpha;
918 struct AnimateToOpacity : public AnimatorFunctionBase
920 AnimateToOpacity(const float& targetValue)
921 : mTarget(targetValue)
925 using AnimatorFunctionBase::operator();
926 Vector4 operator()(float alpha, const Vector4& property)
928 Vector4 result(property);
929 result.a = property.a + ((mTarget - property.a) * alpha);
937 struct AnimateByBoolean : public AnimatorFunctionBase
939 AnimateByBoolean(bool relativeValue)
940 : mRelative(relativeValue)
944 using AnimatorFunctionBase::operator();
945 bool operator()(float alpha, const bool& property)
947 // Alpha is not useful here, just keeping to the same template as other update functors
948 return bool(alpha >= 1.0f ? (property || mRelative) : property);
954 struct AnimateToBoolean : public AnimatorFunctionBase
956 AnimateToBoolean(bool targetValue)
957 : mTarget(targetValue)
961 using AnimatorFunctionBase::operator();
962 bool operator()(float alpha, const bool& property)
964 // Alpha is not useful here, just keeping to the same template as other update functors
965 return bool(alpha >= 1.0f ? mTarget : property);
971 struct RotateByAngleAxis : public AnimatorFunctionBase
973 RotateByAngleAxis(const Radian& angleRadians, const Vector3& axis)
974 : mAngleRadians( angleRadians ),
975 mAxis(axis.x, axis.y, axis.z)
979 using AnimatorFunctionBase::operator();
980 Quaternion operator()(float alpha, const Quaternion& rotation)
984 return rotation * Quaternion(mAngleRadians * alpha, mAxis);
990 Radian mAngleRadians;
994 struct RotateToQuaternion : public AnimatorFunctionBase
996 RotateToQuaternion(const Quaternion& targetValue)
997 : mTarget(targetValue)
1001 using AnimatorFunctionBase::operator();
1002 Quaternion operator()(float alpha, const Quaternion& rotation)
1004 return Quaternion::Slerp(rotation, mTarget, alpha);
1011 struct KeyFrameBooleanFunctor : public AnimatorFunctionBase
1013 KeyFrameBooleanFunctor(KeyFrameBooleanPtr keyFrames)
1014 : mKeyFrames(keyFrames)
1018 using AnimatorFunctionBase::operator();
1019 bool operator()(float progress, const bool& property)
1021 if(mKeyFrames->IsActive(progress))
1023 return mKeyFrames->GetValue(progress, Dali::Animation::Linear);
1028 KeyFrameBooleanPtr mKeyFrames;
1031 struct KeyFrameIntegerFunctor : public AnimatorFunctionBase
1033 KeyFrameIntegerFunctor(KeyFrameIntegerPtr keyFrames, Interpolation interpolation)
1034 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1038 using AnimatorFunctionBase::operator();
1039 float operator()(float progress, const int& property)
1041 if(mKeyFrames->IsActive(progress))
1043 return mKeyFrames->GetValue(progress, mInterpolation);
1048 KeyFrameIntegerPtr mKeyFrames;
1049 Interpolation mInterpolation;
1052 struct KeyFrameNumberFunctor : public AnimatorFunctionBase
1054 KeyFrameNumberFunctor(KeyFrameNumberPtr keyFrames, Interpolation interpolation)
1055 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1059 using AnimatorFunctionBase::operator();
1060 float operator()(float progress, const float& property)
1062 if(mKeyFrames->IsActive(progress))
1064 return mKeyFrames->GetValue(progress, mInterpolation);
1069 KeyFrameNumberPtr mKeyFrames;
1070 Interpolation mInterpolation;
1073 struct KeyFrameVector2Functor : public AnimatorFunctionBase
1075 KeyFrameVector2Functor(KeyFrameVector2Ptr keyFrames, Interpolation interpolation)
1076 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1080 using AnimatorFunctionBase::operator();
1081 Vector2 operator()(float progress, const Vector2& property)
1083 if(mKeyFrames->IsActive(progress))
1085 return mKeyFrames->GetValue(progress, mInterpolation);
1090 KeyFrameVector2Ptr mKeyFrames;
1091 Interpolation mInterpolation;
1095 struct KeyFrameVector3Functor : public AnimatorFunctionBase
1097 KeyFrameVector3Functor(KeyFrameVector3Ptr keyFrames, Interpolation interpolation)
1098 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1102 using AnimatorFunctionBase::operator();
1103 Vector3 operator()(float progress, const Vector3& property)
1105 if(mKeyFrames->IsActive(progress))
1107 return mKeyFrames->GetValue(progress, mInterpolation);
1112 KeyFrameVector3Ptr mKeyFrames;
1113 Interpolation mInterpolation;
1116 struct KeyFrameVector4Functor : public AnimatorFunctionBase
1118 KeyFrameVector4Functor(KeyFrameVector4Ptr keyFrames, Interpolation interpolation)
1119 : mKeyFrames(keyFrames),mInterpolation(interpolation)
1123 using AnimatorFunctionBase::operator();
1124 Vector4 operator()(float progress, const Vector4& property)
1126 if(mKeyFrames->IsActive(progress))
1128 return mKeyFrames->GetValue(progress, mInterpolation);
1133 KeyFrameVector4Ptr mKeyFrames;
1134 Interpolation mInterpolation;
1137 struct KeyFrameQuaternionFunctor : public AnimatorFunctionBase
1139 KeyFrameQuaternionFunctor(KeyFrameQuaternionPtr keyFrames)
1140 : mKeyFrames(keyFrames)
1144 using AnimatorFunctionBase::operator();
1145 Quaternion operator()(float progress, const Quaternion& property)
1147 if(mKeyFrames->IsActive(progress))
1149 return mKeyFrames->GetValue(progress, Dali::Animation::Linear);
1154 KeyFrameQuaternionPtr mKeyFrames;
1157 struct PathPositionFunctor : public AnimatorFunctionBase
1159 PathPositionFunctor( PathPtr path )
1164 using AnimatorFunctionBase::operator();
1165 Vector3 operator()(float progress, const Vector3& property)
1167 Vector3 position(property);
1168 static_cast<void>( mPath->SamplePosition(progress, position) );
1175 struct PathRotationFunctor : public AnimatorFunctionBase
1177 PathRotationFunctor( PathPtr path, const Vector3& forward )
1181 mForward.Normalize();
1184 using AnimatorFunctionBase::operator();
1185 Quaternion operator()(float progress, const Quaternion& property)
1188 if( mPath->SampleTangent(progress, tangent) )
1190 return Quaternion( mForward, tangent );
1202 } // namespace Internal
1206 #endif // __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__