1 #ifndef DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H
2 #define DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H
5 * Copyright (c) 2019 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.
26 #include <dali/public-api/animation/alpha-function.h>
27 #include <dali/public-api/animation/animation.h>
28 #include <dali/public-api/animation/time-period.h>
29 #include <dali/public-api/common/constants.h>
30 #include <dali/public-api/common/dali-common.h>
31 #include <dali/public-api/math/quaternion.h>
32 #include <dali/public-api/math/radian.h>
33 #include <dali/devel-api/common/owner-container.h>
34 #include <dali/internal/event/animation/key-frames-impl.h>
35 #include <dali/internal/event/animation/path-impl.h>
36 #include <dali/internal/update/nodes/node.h>
37 #include <dali/internal/update/common/property-base.h>
38 #include <dali/internal/update/animation/property-accessor.h>
39 #include <dali/integration-api/debug.h>
47 using Interpolation = Dali::Animation::Interpolation;
54 * An abstract base class for Animators, which can be added to scene graph animations.
55 * Each animator changes a single property of an object in the scene graph.
57 class AnimatorBase : public PropertyOwner::Observer
61 using AlphaFunc = float (*)(float progress); ///< Definition of an alpha function
64 * Observer to determine when the animator is no longer present
66 class LifecycleObserver
70 * Called shortly before the animator is destroyed.
72 virtual void ObjectDestroyed() = 0;
76 * Virtual destructor, no deletion through this interface
78 virtual ~LifecycleObserver() = default;
85 AnimatorBase( PropertyOwner* propertyOwner,
86 AlphaFunction alphaFunction,
87 const TimePeriod& timePeriod )
88 : mLifecycleObserver( nullptr ),
89 mPropertyOwner( propertyOwner ),
90 mDurationSeconds( timePeriod.durationSeconds ),
91 mIntervalDelaySeconds( timePeriod.delaySeconds ),
93 mCurrentProgress( 0.f ),
94 mAlphaFunction( alphaFunction ),
95 mDisconnectAction( Dali::Animation::BAKE_FINAL ),
96 mAnimationPlaying( false ),
98 mConnectedToSceneGraph( false ),
99 mAutoReverseEnabled( false )
104 * Virtual destructor.
106 ~AnimatorBase() override
108 if (mPropertyOwner && mConnectedToSceneGraph)
110 mPropertyOwner->RemoveObserver(*this);
112 if( mLifecycleObserver != nullptr )
114 mLifecycleObserver->ObjectDestroyed();
118 void AddLifecycleObserver( LifecycleObserver& observer )
120 mLifecycleObserver = &observer;
123 void RemoveLifecycleObserver( LifecycleObserver& observer )
125 mLifecycleObserver = nullptr;
128 private: // From PropertyOwner::Observer
131 * @copydoc PropertyOwner::Observer::PropertyOwnerConnected( PropertyOwner& owner )
133 void PropertyOwnerConnected( PropertyOwner& owner ) final
139 * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
141 void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner ) final
143 // If we are active, then bake the value if required
144 if ( mAnimationPlaying && mDisconnectAction != Dali::Animation::DISCARD )
146 // Bake to target-value if BakeFinal, otherwise bake current value
147 Update( bufferIndex, ( mDisconnectAction == Dali::Animation::BAKE ? mCurrentProgress : 1.0f ), true );
154 * @copydoc PropertyOwner::Observer::PropertyOwnerDestroyed( PropertyOwner& owner )
156 void PropertyOwnerDestroyed( PropertyOwner& owner ) final
158 mPropertyOwner = nullptr;
163 * Called when Animator is added to the scene-graph in update-thread.
165 void ConnectToSceneGraph()
167 mConnectedToSceneGraph = true;
168 mPropertyOwner->AddObserver(*this);
170 // Enable if the target object is valid and connected to the scene graph.
171 mEnabled = mPropertyOwner->IsAnimationPossible();
175 * Set the duration of the animator.
176 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
177 * @param [in] seconds Duration in seconds.
179 void SetDuration(float seconds)
181 DALI_ASSERT_DEBUG(seconds >= 0.0f);
183 mDurationSeconds = seconds;
187 * Retrieve the duration of the animator.
188 * @return The duration in seconds.
190 float GetDuration() const
192 return mDurationSeconds;
195 void SetSpeedFactor( float factor )
197 mSpeedFactor = factor;
200 void SetLoopCount(int32_t loopCount)
202 mLoopCount = loopCount;
205 float SetProgress( float progress )
209 if( mAutoReverseEnabled )
211 if( mSpeedFactor > 0.0f )
213 value = 1.0f - 2.0f * std::abs( progress - 0.5f );
216 else if( mSpeedFactor < 0.0f )
218 value = 2.0f * std::abs( progress - 0.5f );
230 * Set the delay before the animator should take effect.
231 * The default is zero i.e. no delay.
232 * @param [in] seconds The delay in seconds.
234 void SetIntervalDelay(float seconds)
236 mIntervalDelaySeconds = seconds;
240 * Retrieve the delay before the animator should take effect.
241 * @return The delay in seconds.
243 float GetIntervalDelay() const
245 return mIntervalDelaySeconds;
249 * Set the alpha function for an animator.
250 * @param [in] alphaFunc The alpha function to apply to the animation progress.
252 void SetAlphaFunction(const AlphaFunction& alphaFunction)
254 mAlphaFunction = alphaFunction;
258 * Retrieve the alpha function of an animator.
259 * @return The function.
261 AlphaFunction GetAlphaFunction() const
263 return mAlphaFunction;
267 * Applies the alpha function to the specified progress
268 * @param[in] Current progress
269 * @return The progress after the alpha function has been aplied
271 float ApplyAlphaFunction( float progress ) const
273 float result = progress;
275 AlphaFunction::Mode alphaFunctionMode( mAlphaFunction.GetMode() );
276 if( alphaFunctionMode == AlphaFunction::BUILTIN_FUNCTION )
278 switch(mAlphaFunction.GetBuiltinFunction())
280 case AlphaFunction::DEFAULT:
281 case AlphaFunction::LINEAR:
285 case AlphaFunction::REVERSE:
287 result = 1.0f-progress;
290 case AlphaFunction::EASE_IN_SQUARE:
292 result = progress * progress;
295 case AlphaFunction::EASE_OUT_SQUARE:
297 result = 1.0f - (1.0f-progress) * (1.0f-progress);
300 case AlphaFunction::EASE_IN:
302 result = progress * progress * progress;
305 case AlphaFunction::EASE_OUT:
307 result = (progress-1.0f) * (progress-1.0f) * (progress-1.0f) + 1.0f;
310 case AlphaFunction::EASE_IN_OUT:
312 result = progress*progress*(3.0f-2.0f*progress);
315 case AlphaFunction::EASE_IN_SINE:
317 result = -1.0f * cosf(progress * Math::PI_2) + 1.0f;
320 case AlphaFunction::EASE_OUT_SINE:
322 result = sinf(progress * Math::PI_2);
325 case AlphaFunction::EASE_IN_OUT_SINE:
327 result = -0.5f * (cosf(Math::PI * progress) - 1.0f);
330 case AlphaFunction::BOUNCE:
332 result = sinf(progress * Math::PI);
335 case AlphaFunction::SIN:
337 result = 0.5f - cosf(progress * 2.0f * Math::PI) * 0.5f;
340 case AlphaFunction::EASE_OUT_BACK:
342 const float sqrt2 = 1.70158f;
344 result = 1.0f + progress * progress * ( ( sqrt2 + 1.0f ) * progress + sqrt2 );
347 case AlphaFunction::COUNT:
353 else if( alphaFunctionMode == AlphaFunction::CUSTOM_FUNCTION )
355 AlphaFunctionPrototype customFunction = mAlphaFunction.GetCustomFunction();
358 result = customFunction(progress);
363 //If progress is very close to 0 or very close to 1 we don't need to evaluate the curve as the result will
364 //be almost 0 or almost 1 respectively
365 if( ( progress > Math::MACHINE_EPSILON_1 ) && ((1.0f - progress) > Math::MACHINE_EPSILON_1) )
367 Dali::Vector4 controlPoints = mAlphaFunction.GetBezierControlPoints();
369 static const float tolerance = 0.001f; //10 iteration max
371 //Perform a binary search on the curve
372 float lowerBound(0.0f);
373 float upperBound(1.0f);
374 float currentT(0.5f);
375 float currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
376 while( fabsf( progress - currentX ) > tolerance )
378 if( progress > currentX )
380 lowerBound = currentT;
384 upperBound = currentT;
386 currentT = (upperBound+lowerBound)*0.5f;
387 currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
389 result = EvaluateCubicBezier( controlPoints.y, controlPoints.w, currentT);
397 * Whether to bake the animation if attached property owner is disconnected.
398 * Property is only baked if the animator is active.
399 * @param [in] action The disconnect action.
401 void SetDisconnectAction( Dali::Animation::EndAction action )
403 mDisconnectAction = action;
407 * Retrieve the disconnect action of an animator.
408 * @return The disconnect action.
410 Dali::Animation::EndAction GetDisconnectAction() const
412 return mDisconnectAction;
416 * Whether the animator is active or not.
417 * @param [in] active The new active state.
418 * @post When the animator becomes active, it applies the disconnect-action if the property owner is then disconnected.
419 * @note When the property owner is disconnected, the active state is set to false.
421 void SetActive( bool active )
423 mAnimationPlaying = active;
427 * Whether the animator's target object is valid and on the stage.
428 * @return The enabled state.
430 bool IsEnabled() const
436 * @brief Sets the looping mode.
437 * @param[in] loopingMode True when the looping mode is AUTO_REVERSE
439 void SetLoopingMode( bool loopingMode )
441 mAutoReverseEnabled = loopingMode;
445 * Returns wheter the target object of the animator is still valid
446 * or has been destroyed.
447 * @return True if animator is orphan, false otherwise *
448 * @note The SceneGraph::Animation will delete any orphan animator in its Update method.
452 return (mPropertyOwner == nullptr);
456 * Update the scene object attached to the animator.
457 * @param[in] bufferIndex The buffer to animate.
458 * @param[in] progress A value from 0 to 1, where 0 is the start of the animation, and 1 is the end point.
459 * @param[in] bake Bake.
461 void Update( BufferIndex bufferIndex, float progress, bool bake )
463 if( mLoopCount >= 0 )
465 // Update the progress value
466 progress = SetProgress( progress );
471 mPropertyOwner->SetUpdated( true );
474 float alpha = ApplyAlphaFunction( progress );
476 // PropertyType specific part
477 DoUpdate( bufferIndex, bake, alpha );
479 mCurrentProgress = progress;
483 * Type specific part of the animator
484 * @param bufferIndex index to use
485 * @param bake whether to bake or not
486 * @param alpha value from alpha based on progress
488 virtual void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) = 0;
493 * Helper function to evaluate a cubic bezier curve assuming first point is at 0.0 and last point is at 1.0
494 * @param[in] p0 First control point of the bezier curve
495 * @param[in] p1 Second control point of the bezier curve
496 * @param[in] t A floating point value between 0.0 and 1.0
497 * @return Value of the curve at progress t
499 inline float EvaluateCubicBezier( float p0, float p1, float t ) const
502 return 3.0f*(1.0f-t)*(1.0f-t)*t*p0 + 3.0f*(1.0f-t)*tSquare*p1 + tSquare*t;
505 LifecycleObserver* mLifecycleObserver;
506 PropertyOwner* mPropertyOwner;
508 float mDurationSeconds;
509 float mIntervalDelaySeconds;
511 float mCurrentProgress;
513 AlphaFunction mAlphaFunction;
515 int32_t mLoopCount{1};
516 Dali::Animation::EndAction mDisconnectAction; ///< EndAction to apply when target object gets disconnected from the stage.
517 bool mAnimationPlaying:1; ///< whether disconnect has been applied while it's running.
518 bool mEnabled:1; ///< Animator is "enabled" while its target object is valid and on the stage.
519 bool mConnectedToSceneGraph:1; ///< True if ConnectToSceneGraph() has been called in update-thread.
520 bool mAutoReverseEnabled:1;
524 * An animator for a specific property type PropertyType.
526 template<typename PropertyType, typename PropertyAccessorType>
527 class Animator final : public AnimatorBase
529 using AnimatorFunction = std::function<PropertyType(float, const PropertyType&)>;
531 AnimatorFunction mAnimatorFunction;
536 * Construct a new property animator.
537 * @param[in] property The animatable property; only valid while the Animator is attached.
538 * @param[in] animatorFunction The function used to animate the property.
539 * @param[in] alphaFunction The alpha function to apply.
540 * @param[in] timePeriod The time period of this animation.
541 * @return A newly allocated animator.
543 static AnimatorBase* New(const PropertyOwner& propertyOwner,
544 const PropertyBase& property,
545 AnimatorFunction animatorFunction,
546 AlphaFunction alphaFunction,
547 const TimePeriod& timePeriod)
549 // The property was const in the actor-thread, but animators are used in the scene-graph thread.
550 return new Animator(const_cast<PropertyOwner*>(&propertyOwner),
551 const_cast<PropertyBase*>(&property),
552 std::move(animatorFunction),
558 * @copydoc AnimatorBase::DoUpdate( BufferIndex bufferIndex, bool bake, float alpha )
560 void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) final
562 const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
564 // need to cast the return value in case property is integer
565 const PropertyType result = static_cast<PropertyType>(mAnimatorFunction(alpha, current));
569 mPropertyAccessor.Bake( bufferIndex, result );
573 mPropertyAccessor.Set( bufferIndex, result );
580 * Private constructor; see also Animator::New().
582 Animator(PropertyOwner* propertyOwner,
583 PropertyBase* property,
584 AnimatorFunction animatorFunction,
585 AlphaFunction alphaFunction,
586 const TimePeriod& timePeriod)
587 : AnimatorBase(propertyOwner, alphaFunction, timePeriod),
588 mAnimatorFunction(std::move(animatorFunction)),
589 mPropertyAccessor(property)
591 // WARNING - this object is created in the event-thread
592 // The scene-graph mPropertyOwner object cannot be observed here
596 Animator( const Animator& );
599 Animator& operator=( const Animator& );
603 PropertyAccessorType mPropertyAccessor;
610 * An animator for a specific property type PropertyType.
612 template<typename PropertyType, typename PropertyAccessorType>
613 class AnimatorTransformProperty final : public AnimatorBase
615 using AnimatorFunction = std::function<PropertyType(float, const PropertyType&)>;
617 AnimatorFunction mAnimatorFunction;
622 * Construct a new property animator.
623 * @param[in] property The animatable property; only valid while the Animator is attached.
624 * @param[in] animatorFunction The function used to animate the property.
625 * @param[in] alphaFunction The alpha function to apply.
626 * @param[in] timePeriod The time period of this animation.
627 * @return A newly allocated animator.
629 static AnimatorBase* New(const PropertyOwner& propertyOwner,
630 const PropertyBase& property,
631 AnimatorFunction animatorFunction,
632 AlphaFunction alphaFunction,
633 const TimePeriod& timePeriod)
636 // The property was const in the actor-thread, but animators are used in the scene-graph thread.
637 return new AnimatorTransformProperty(const_cast<PropertyOwner*>(&propertyOwner),
638 const_cast<PropertyBase*>(&property),
639 std::move(animatorFunction),
645 * @copydoc AnimatorBase::DoUpdate( BufferIndex bufferIndex, bool bake, float alpha )
647 void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) final
649 const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
651 // need to cast the return value in case property is integer
652 const PropertyType result = static_cast<PropertyType>(mAnimatorFunction(alpha, current));
656 mPropertyAccessor.Bake( bufferIndex, result );
660 mPropertyAccessor.Set( bufferIndex, result );
667 * Private constructor; see also Animator::New().
669 AnimatorTransformProperty(PropertyOwner* propertyOwner,
670 PropertyBase* property,
671 AnimatorFunction animatorFunction,
672 AlphaFunction alphaFunction,
673 const TimePeriod& timePeriod)
674 : AnimatorBase(propertyOwner, alphaFunction, timePeriod),
675 mAnimatorFunction(std::move(animatorFunction)),
676 mPropertyAccessor(property)
678 // WARNING - this object is created in the event-thread
679 // The scene-graph mPropertyOwner object cannot be observed here
683 AnimatorTransformProperty() = delete;
684 AnimatorTransformProperty( const AnimatorTransformProperty& ) = delete;
685 AnimatorTransformProperty& operator=( const AnimatorTransformProperty& ) = delete;
689 PropertyAccessorType mPropertyAccessor;
693 } // namespace SceneGraph
697 struct AnimateByInteger
699 AnimateByInteger(const int& relativeValue)
700 : mRelative(relativeValue)
704 float operator()(float alpha, const int32_t& property)
706 // integers need to be correctly rounded
707 return roundf(static_cast<float>( property ) + static_cast<float>( mRelative ) * alpha );
713 struct AnimateToInteger
715 AnimateToInteger(const int& targetValue)
716 : mTarget(targetValue)
720 float operator()(float alpha, const int32_t& property)
722 // integers need to be correctly rounded
723 return roundf(static_cast<float>( property ) + (static_cast<float>(mTarget - property) * alpha) );
729 struct AnimateByFloat
731 AnimateByFloat(const float& relativeValue)
732 : mRelative(relativeValue)
736 float operator()(float alpha, const float& property)
738 return float(property + mRelative * alpha);
744 struct AnimateToFloat
746 AnimateToFloat(const float& targetValue)
747 : mTarget(targetValue)
751 float operator()(float alpha, const float& property)
753 return float(property + ((mTarget - property) * alpha));
759 struct AnimateByVector2
761 AnimateByVector2(const Vector2& relativeValue)
762 : mRelative(relativeValue)
766 Vector2 operator()(float alpha, const Vector2& property)
768 return Vector2(property + mRelative * alpha);
774 struct AnimateToVector2
776 AnimateToVector2(const Vector2& targetValue)
777 : mTarget(targetValue)
781 Vector2 operator()(float alpha, const Vector2& property)
783 return Vector2(property + ((mTarget - property) * alpha));
789 struct AnimateByVector3
791 AnimateByVector3(const Vector3& relativeValue)
792 : mRelative(relativeValue)
796 Vector3 operator()(float alpha, const Vector3& property)
798 return Vector3(property + mRelative * alpha);
804 struct AnimateToVector3
806 AnimateToVector3(const Vector3& targetValue)
807 : mTarget(targetValue)
811 Vector3 operator()(float alpha, const Vector3& property)
813 return Vector3(property + ((mTarget - property) * alpha));
819 struct AnimateByVector4
821 AnimateByVector4(const Vector4& relativeValue)
822 : mRelative(relativeValue)
826 Vector4 operator()(float alpha, const Vector4& property)
828 return Vector4(property + mRelative * alpha);
834 struct AnimateToVector4
836 AnimateToVector4(const Vector4& targetValue)
837 : mTarget(targetValue)
841 Vector4 operator()(float alpha, const Vector4& property)
843 return Vector4(property + ((mTarget - property) * alpha));
849 struct AnimateByOpacity
851 AnimateByOpacity(const float& relativeValue)
852 : mRelative(relativeValue)
856 Vector4 operator()(float alpha, const Vector4& property)
858 Vector4 result(property);
859 result.a += mRelative * alpha;
867 struct AnimateToOpacity
869 AnimateToOpacity(const float& targetValue)
870 : mTarget(targetValue)
874 Vector4 operator()(float alpha, const Vector4& property)
876 Vector4 result(property);
877 result.a = property.a + ((mTarget - property.a) * alpha);
885 struct AnimateByBoolean
887 AnimateByBoolean(bool relativeValue)
888 : mRelative(relativeValue)
892 bool operator()(float alpha, const bool& property)
894 // Alpha is not useful here, just keeping to the same template as other update functors
895 return bool(alpha >= 1.0f ? (property || mRelative) : property);
901 struct AnimateToBoolean
903 AnimateToBoolean(bool targetValue)
904 : mTarget(targetValue)
908 bool operator()(float alpha, const bool& property)
910 // Alpha is not useful here, just keeping to the same template as other update functors
911 return bool(alpha >= 1.0f ? mTarget : property);
917 struct RotateByAngleAxis
919 RotateByAngleAxis(const Radian& angleRadians, const Vector3& axis)
920 : mAngleRadians( angleRadians ),
921 mAxis(axis.x, axis.y, axis.z)
925 Quaternion operator()(float alpha, const Quaternion& rotation)
929 return rotation * Quaternion(mAngleRadians * alpha, mAxis);
935 Radian mAngleRadians;
939 struct RotateToQuaternion
941 RotateToQuaternion(const Quaternion& targetValue)
942 : mTarget(targetValue)
946 Quaternion operator()(float alpha, const Quaternion& rotation)
948 return Quaternion::Slerp(rotation, mTarget, alpha);
954 struct KeyFrameBooleanFunctor
956 KeyFrameBooleanFunctor(KeyFrameBoolean keyFrames)
957 : mKeyFrames(std::move(keyFrames))
961 bool operator()(float progress, const bool& property)
963 if(mKeyFrames.IsActive(progress))
965 return mKeyFrames.GetValue(progress, Dali::Animation::LINEAR);
970 KeyFrameBoolean mKeyFrames;
973 struct KeyFrameIntegerFunctor
975 KeyFrameIntegerFunctor(KeyFrameInteger keyFrames, Interpolation interpolation)
976 : mKeyFrames(std::move(keyFrames)),
977 mInterpolation(interpolation)
981 float operator()(float progress, const int32_t& property)
983 if(mKeyFrames.IsActive(progress))
985 return static_cast<float>(mKeyFrames.GetValue(progress, mInterpolation));
987 return static_cast<float>( property );
990 KeyFrameInteger mKeyFrames;
991 Interpolation mInterpolation;
994 struct KeyFrameNumberFunctor
996 KeyFrameNumberFunctor(KeyFrameNumber keyFrames, Interpolation interpolation)
997 : mKeyFrames(std::move(keyFrames)),
998 mInterpolation(interpolation)
1002 float operator()(float progress, const float& property)
1004 if(mKeyFrames.IsActive(progress))
1006 return mKeyFrames.GetValue(progress, mInterpolation);
1011 KeyFrameNumber mKeyFrames;
1012 Interpolation mInterpolation;
1015 struct KeyFrameVector2Functor
1017 KeyFrameVector2Functor(KeyFrameVector2 keyFrames, Interpolation interpolation)
1018 : mKeyFrames(std::move(keyFrames)),
1019 mInterpolation(interpolation)
1023 Vector2 operator()(float progress, const Vector2& property)
1025 if(mKeyFrames.IsActive(progress))
1027 return mKeyFrames.GetValue(progress, mInterpolation);
1032 KeyFrameVector2 mKeyFrames;
1033 Interpolation mInterpolation;
1036 struct KeyFrameVector3Functor
1038 KeyFrameVector3Functor(KeyFrameVector3 keyFrames, Interpolation interpolation)
1039 : mKeyFrames(std::move(keyFrames)),
1040 mInterpolation(interpolation)
1044 Vector3 operator()(float progress, const Vector3& property)
1046 if(mKeyFrames.IsActive(progress))
1048 return mKeyFrames.GetValue(progress, mInterpolation);
1053 KeyFrameVector3 mKeyFrames;
1054 Interpolation mInterpolation;
1057 struct KeyFrameVector4Functor
1059 KeyFrameVector4Functor(KeyFrameVector4 keyFrames, Interpolation interpolation)
1060 : mKeyFrames(std::move(keyFrames)),
1061 mInterpolation(interpolation)
1065 Vector4 operator()(float progress, const Vector4& property)
1067 if(mKeyFrames.IsActive(progress))
1069 return mKeyFrames.GetValue(progress, mInterpolation);
1074 KeyFrameVector4 mKeyFrames;
1075 Interpolation mInterpolation;
1078 struct KeyFrameQuaternionFunctor
1080 KeyFrameQuaternionFunctor(KeyFrameQuaternion keyFrames)
1081 : mKeyFrames(std::move(keyFrames))
1085 Quaternion operator()(float progress, const Quaternion& property)
1087 if(mKeyFrames.IsActive(progress))
1089 return mKeyFrames.GetValue(progress, Dali::Animation::LINEAR);
1094 KeyFrameQuaternion mKeyFrames;
1097 struct PathPositionFunctor
1099 PathPositionFunctor( PathPtr path )
1104 Vector3 operator()(float progress, const Vector3& property)
1106 Vector3 position(property);
1107 static_cast<void>( mPath->SamplePosition(progress, position) );
1114 struct PathRotationFunctor
1116 PathRotationFunctor( PathPtr path, const Vector3& forward )
1120 mForward.Normalize();
1123 Quaternion operator()(float progress, const Quaternion& property)
1126 if( mPath->SampleTangent(progress, tangent) )
1128 return Quaternion( mForward, tangent );
1140 } // namespace Internal
1144 #endif // DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H