-#ifndef __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__
+#ifndef DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H
+#define DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
+// EXTERNAL INCLUDES
+#include <cmath>
+
// INTERNAL INCLUDES
-#include <dali/internal/common/owner-container.h>
-#include <dali/internal/event/animation/key-frames-impl.h>
-#include <dali/internal/event/animation/path-impl.h>
-#include <dali/internal/update/nodes/node.h>
-#include <dali/internal/update/common/property-base.h>
#include <dali/public-api/animation/alpha-function.h>
#include <dali/public-api/animation/animation.h>
#include <dali/public-api/animation/time-period.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/math/quaternion.h>
#include <dali/public-api/math/radian.h>
+#include <dali/devel-api/common/owner-container.h>
+#include <dali/internal/event/animation/key-frames-impl.h>
+#include <dali/internal/event/animation/path-impl.h>
+#include <dali/internal/update/nodes/node.h>
+#include <dali/internal/update/common/property-base.h>
+#include <dali/internal/update/animation/property-accessor.h>
+#include <dali/integration-api/debug.h>
namespace Dali
{
namespace Internal
{
-typedef Dali::Animation::Interpolation Interpolation;
+using Interpolation = Dali::Animation::Interpolation;
-struct AnimatorFunctionBase;
-
-namespace SceneGraph
+/**
+ * AnimatorFunction base class.
+ * Needs to be declared first so AnimatorBase knows about it's destructor
+ * All update functions must inherit from AnimatorFunctionBase and overload the appropiate "()" operator
+ */
+struct AnimatorFunctionBase
{
+ /**
+ * Constructor
+ */
+ AnimatorFunctionBase() {}
+
+ /*
+ * Virtual destructor (Intended as base class)
+ */
+ virtual ~AnimatorFunctionBase() {}
-class AnimatorBase;
+ ///Stub "()" operators.
+ virtual bool operator()(float progress, const bool& property)
+ {
+ return property;
+ }
-typedef OwnerContainer< AnimatorBase* > AnimatorContainer;
+ virtual float operator()(float progress, const int32_t& property)
+ {
+ return static_cast<float>( property );
+ }
-typedef AnimatorContainer::Iterator AnimatorIter;
-typedef AnimatorContainer::ConstIterator AnimatorConstIter;
+ virtual float operator()(float progress, const float& property)
+ {
+ return property;
+ }
+
+ virtual Vector2 operator()(float progress, const Vector2& property)
+ {
+ return property;
+ }
+
+ virtual Vector3 operator()(float progress, const Vector3& property)
+ {
+ return property;
+ }
+
+ virtual Vector4 operator()(float progress, const Vector4& property)
+ {
+ return property;
+ }
+
+ virtual Quaternion operator()(float progress, const Quaternion& property)
+ {
+ return property;
+ }
+};
+
+namespace SceneGraph
+{
/**
* An abstract base class for Animators, which can be added to scene graph animations.
* Each animator changes a single property of an object in the scene graph.
*/
-class AnimatorBase
+class AnimatorBase : public PropertyOwner::Observer
{
public:
- typedef float (*AlphaFunc)(float progress); ///< Definition of an alpha function
+ using AlphaFunc = float (*)(float progress); ///< Definition of an alpha function
+
+ /**
+ * Observer to determine when the animator is no longer present
+ */
+ class LifecycleObserver
+ {
+ public:
+ /**
+ * Called shortly before the animator is destroyed.
+ */
+ virtual void ObjectDestroyed() = 0;
+
+ protected:
+ /**
+ * Virtual destructor, no deletion through this interface
+ */
+ virtual ~LifecycleObserver() = default;
+ };
+
/**
* Constructor.
*/
- AnimatorBase()
- : mDurationSeconds(1.0f),
- mInitialDelaySeconds(0.0f),
- mAlphaFunction(AlphaFunction::DEFAULT),
- mDisconnectAction(Dali::Animation::BakeFinal),
- mActive(false),
- mEnabled(true)
+ AnimatorBase( PropertyOwner* propertyOwner,
+ AnimatorFunctionBase* animatorFunction,
+ AlphaFunction alphaFunction,
+ const TimePeriod& timePeriod )
+ : mLifecycleObserver( nullptr ),
+ mPropertyOwner( propertyOwner ),
+ mAnimatorFunction( animatorFunction ),
+ mDurationSeconds( timePeriod.durationSeconds ),
+ mIntervalDelaySeconds( timePeriod.delaySeconds ),
+ mSpeedFactor( 1.0f ),
+ mCurrentProgress( 0.f ),
+ mLoopCount( 1 ),
+ mAlphaFunction( alphaFunction ),
+ mDisconnectAction( Dali::Animation::BakeFinal ),
+ mAnimationPlaying( false ),
+ mEnabled( true ),
+ mConnectedToSceneGraph( false ),
+ mAutoReverseEnabled( false )
{
}
*/
virtual ~AnimatorBase()
{
+ delete mAnimatorFunction;
+ if (mPropertyOwner && mConnectedToSceneGraph)
+ {
+ mPropertyOwner->RemoveObserver(*this);
+ }
+ if( mLifecycleObserver != nullptr )
+ {
+ mLifecycleObserver->ObjectDestroyed();
+ }
+ }
+
+ void AddLifecycleObserver( LifecycleObserver& observer )
+ {
+ mLifecycleObserver = &observer;
+ }
+
+ void RemoveLifecycleObserver( LifecycleObserver& observer )
+ {
+ mLifecycleObserver = nullptr;
+ }
+
+private: // From PropertyOwner::Observer
+
+ /**
+ * @copydoc PropertyOwner::Observer::PropertyOwnerConnected( PropertyOwner& owner )
+ */
+ void PropertyOwnerConnected( PropertyOwner& owner ) override final
+ {
+ mEnabled = true;
+ }
+
+ /**
+ * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
+ */
+ void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner ) override final
+ {
+ // If we are active, then bake the value if required
+ if ( mAnimationPlaying && mDisconnectAction != Dali::Animation::Discard )
+ {
+ // Bake to target-value if BakeFinal, otherwise bake current value
+ Update( bufferIndex, ( mDisconnectAction == Dali::Animation::Bake ? mCurrentProgress : 1.0f ), true );
+ }
+
+ mEnabled = false;
+ }
+
+ /**
+ * @copydoc PropertyOwner::Observer::PropertyOwnerDestroyed( PropertyOwner& owner )
+ */
+ void PropertyOwnerDestroyed( PropertyOwner& owner ) override final
+ {
+ mPropertyOwner = nullptr;
+ }
+
+public:
+ /**
+ * Called when Animator is added to the scene-graph in update-thread.
+ */
+ void ConnectToSceneGraph()
+ {
+ mConnectedToSceneGraph = true;
+ mPropertyOwner->AddObserver(*this);
}
/**
* Retrieve the duration of the animator.
* @return The duration in seconds.
*/
- float GetDuration()
+ float GetDuration() const
{
return mDurationSeconds;
}
+ void SetSpeedFactor( float factor )
+ {
+ mSpeedFactor = factor;
+ }
+
+ void SetLoopCount(int32_t loopCount)
+ {
+ mLoopCount = loopCount;
+ }
+
+ float SetProgress( float progress )
+ {
+ float value = 0.0f;
+
+ if( mAutoReverseEnabled )
+ {
+ if( mSpeedFactor > 0.0f )
+ {
+ value = 1.0f - 2.0f * std::abs( progress - 0.5f );
+ }
+ // Reverse mode
+ else if( mSpeedFactor < 0.0f )
+ {
+ value = 2.0f * std::abs( progress - 0.5f );
+ }
+ }
+ else
+ {
+ value = progress;
+ }
+
+ return value;
+ }
+
/**
* Set the delay before the animator should take effect.
* The default is zero i.e. no delay.
* @param [in] seconds The delay in seconds.
*/
- void SetInitialDelay(float seconds)
+ void SetIntervalDelay(float seconds)
{
- mInitialDelaySeconds = seconds;
+ mIntervalDelaySeconds = seconds;
}
/**
- * Retrieve the initial delay of the animator.
+ * Retrieve the delay before the animator should take effect.
* @return The delay in seconds.
*/
- float GetInitialDelay()
+ float GetIntervalDelay() const
{
- return mInitialDelaySeconds;
+ return mIntervalDelaySeconds;
}
/**
return mAlphaFunction;
}
- /*
+ /**
* Applies the alpha function to the specified progress
* @param[in] Current progress
* @return The progress after the alpha function has been aplied
result = 1.0f + progress * progress * ( ( sqrt2 + 1.0f ) * progress + sqrt2 );
break;
}
- default:
+ case AlphaFunction::COUNT:
+ {
break;
+ }
}
}
else if( alphaFunctionMode == AlphaFunction::CUSTOM_FUNCTION )
float upperBound(1.0f);
float currentT(0.5f);
float currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
- while( fabs( progress - currentX ) > tolerance )
+ while( fabsf( progress - currentX ) > tolerance )
{
if( progress > currentX )
{
*/
void SetActive( bool active )
{
- mActive = active;
+ mAnimationPlaying = active;
}
/**
- * Retrieve whether the animator has been set to active or not.
- * @return The active state.
+ * Whether the animator's target object is valid and on the stage.
+ * @return The enabled state.
*/
- bool GetActive() const
+ bool IsEnabled() const
{
- return mActive;
+ return mEnabled;
}
- /*
- * Retrive wheter the animator's target object is valid and on the stage.
- * @return The enabled state.
+ /**
+ * @brief Sets the looping mode.
+ * @param[in] loopingMode True when the looping mode is AUTO_REVERSE
*/
- bool IsEnabled() const
+ void SetLoopingMode( bool loopingMode )
{
- return mEnabled;
+ mAutoReverseEnabled = loopingMode;
}
+
/**
* Returns wheter the target object of the animator is still valid
* or has been destroyed.
* @return True if animator is orphan, false otherwise *
* @note The SceneGraph::Animation will delete any orphan animator in its Update method.
*/
- virtual bool Orphan() = 0;
+ bool Orphan()
+ {
+ return (mPropertyOwner == nullptr);
+ }
/**
* Update the scene object attached to the animator.
* @param[in] progress A value from 0 to 1, where 0 is the start of the animation, and 1 is the end point.
* @param[in] bake Bake.
*/
- virtual void Update(BufferIndex bufferIndex, float progress, bool bake) = 0;
+ void Update( BufferIndex bufferIndex, float progress, bool bake )
+ {
+ if( mLoopCount >= 0 )
+ {
+ // Update the progress value
+ progress = SetProgress( progress );
+ }
+
+ if( mPropertyOwner )
+ {
+ mPropertyOwner->SetPropertyDirty( true );
+ }
+
+ float alpha = ApplyAlphaFunction( progress );
+
+ // PropertyType specific part
+ DoUpdate( bufferIndex, bake, alpha );
+
+ mCurrentProgress = progress;
+ }
+
+ /**
+ * Type specific part of the animator
+ * @param bufferIndex index to use
+ * @param bake whether to bake or not
+ * @param alpha value from alpha based on progress
+ */
+ virtual void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) = 0;
protected:
return 3.0f*(1.0f-t)*(1.0f-t)*t*p0 + 3.0f*(1.0f-t)*tSquare*p1 + tSquare*t;
}
+ LifecycleObserver* mLifecycleObserver;
+ PropertyOwner* mPropertyOwner;
+ AnimatorFunctionBase* mAnimatorFunction;
float mDurationSeconds;
- float mInitialDelaySeconds;
+ float mIntervalDelaySeconds;
+ float mSpeedFactor;
+ float mCurrentProgress;
+
+ int32_t mLoopCount;
AlphaFunction mAlphaFunction;
Dali::Animation::EndAction mDisconnectAction; ///< EndAction to apply when target object gets disconnected from the stage.
- bool mActive:1; ///< Animator is "active" while it's running.
+ bool mAnimationPlaying:1; ///< whether disconnect has been applied while it's running.
bool mEnabled:1; ///< Animator is "enabled" while its target object is valid and on the stage.
+ bool mConnectedToSceneGraph:1; ///< True if ConnectToSceneGraph() has been called in update-thread.
+ bool mAutoReverseEnabled:1;
};
/**
* An animator for a specific property type PropertyType.
*/
template < typename PropertyType, typename PropertyAccessorType >
-class Animator : public AnimatorBase, public PropertyOwner::Observer
+class Animator : public AnimatorBase
{
public:
AlphaFunction alphaFunction,
const TimePeriod& timePeriod )
{
- typedef Animator< PropertyType, PropertyAccessorType > AnimatorType;
-
// The property was const in the actor-thread, but animators are used in the scene-graph thread.
- AnimatorType* animator = new AnimatorType( const_cast<PropertyOwner*>( &propertyOwner ),
- const_cast<PropertyBase*>( &property ),
- animatorFunction );
-
- animator->SetAlphaFunction( alphaFunction );
- animator->SetInitialDelay( timePeriod.delaySeconds );
- animator->SetDuration( timePeriod.durationSeconds );
-
- return animator;
+ return new Animator( const_cast<PropertyOwner*>( &propertyOwner ),
+ const_cast<PropertyBase*>( &property ),
+ animatorFunction,
+ alphaFunction,
+ timePeriod );
}
/**
*/
virtual ~Animator()
{
- if (mPropertyOwner)
- {
- mPropertyOwner->RemoveObserver(*this);
- }
-
- if( mAnimatorFunction )
- {
- delete mAnimatorFunction;
- }
- }
-
- /**
- * Called when mPropertyOwner is connected to the scene graph.
- */
- virtual void PropertyOwnerConnected( PropertyOwner& owner )
- {
- mEnabled = true;
- }
-
- /**
- * Called when mPropertyOwner is disconnected from the scene graph.
- */
- virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
- {
- // If we are active, then bake the value if required
- if ( mActive && mDisconnectAction != Dali::Animation::Discard )
- {
- // Bake to target-value if BakeFinal, otherwise bake current value
- Update( bufferIndex, ( mDisconnectAction == Dali::Animation::Bake ? mCurrentProgress : 1.0f ), true );
- }
-
- mActive = false;
- mEnabled = false;
- }
-
- /**
- * Called shortly before mPropertyOwner is destroyed
- */
- virtual void PropertyOwnerDestroyed( PropertyOwner& owner )
- {
- mPropertyOwner = NULL;
- mPropertyAccessor.Reset();
- mEnabled = false;
}
/**
- * From AnimatorBase.
+ * @copydoc AnimatorBase::DoUpdate( BufferIndex bufferIndex, bool bake, float alpha )
*/
- virtual void Update( BufferIndex bufferIndex, float progress, bool bake )
+ virtual void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) override final
{
- float alpha = ApplyAlphaFunction(progress);
-
const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
- const PropertyType result = (*mAnimatorFunction)( alpha, current );
+ // need to cast the return value in case property is integer
+ const PropertyType result = static_cast<PropertyType>( (*mAnimatorFunction)( alpha, current ) );
+
if ( bake )
{
mPropertyAccessor.Bake( bufferIndex, result );
{
mPropertyAccessor.Set( bufferIndex, result );
}
-
- mCurrentProgress = progress;
- }
-
- /**
- * From AnimatorBase.
- */
- virtual bool Orphan()
- {
- return (mPropertyOwner == NULL);
}
private:
*/
Animator( PropertyOwner* propertyOwner,
PropertyBase* property,
- AnimatorFunctionBase* animatorFunction )
- : mPropertyOwner( propertyOwner ),
- mPropertyAccessor( property ),
- mAnimatorFunction( animatorFunction ),
- mCurrentProgress( 0.0f )
+ AnimatorFunctionBase* animatorFunction,
+ AlphaFunction alphaFunction,
+ const TimePeriod& timePeriod )
+ : AnimatorBase( propertyOwner, animatorFunction, alphaFunction, timePeriod ),
+ mPropertyAccessor( property )
{
- mPropertyOwner->AddObserver(*this);
+ // WARNING - this object is created in the event-thread
+ // The scene-graph mPropertyOwner object cannot be observed here
}
// Undefined
protected:
- PropertyOwner* mPropertyOwner;
PropertyAccessorType mPropertyAccessor;
- AnimatorFunctionBase* mAnimatorFunction;
- float mCurrentProgress;
};
-} // namespace SceneGraph
-/*
- * AnimatorFunction base class.
- * All update functions must inherit from AnimatorFunctionBase and overload the appropiate "()" operator
+
+/**
+ * An animator for a specific property type PropertyType.
*/
-struct AnimatorFunctionBase
+template <typename PropertyType, typename PropertyAccessorType>
+class AnimatorTransformProperty : public AnimatorBase
{
- /**
- * Constructor
- */
- AnimatorFunctionBase(){}
+public:
- /*
- * Virtual destructor (Intended as base class)
+ /**
+ * Construct a new property animator.
+ * @param[in] property The animatable property; only valid while the Animator is attached.
+ * @param[in] animatorFunction The function used to animate the property.
+ * @param[in] alphaFunction The alpha function to apply.
+ * @param[in] timePeriod The time period of this animation.
+ * @return A newly allocated animator.
*/
- virtual ~AnimatorFunctionBase(){}
-
- ///Stub "()" operators.
- virtual bool operator()(float progress, const bool& property)
+ static AnimatorBase* New( const PropertyOwner& propertyOwner,
+ const PropertyBase& property,
+ AnimatorFunctionBase* animatorFunction,
+ AlphaFunction alphaFunction,
+ const TimePeriod& timePeriod )
{
- return property;
- }
- virtual float operator()(float progress, const int& property)
- {
- return property;
+ // The property was const in the actor-thread, but animators are used in the scene-graph thread.
+ return new AnimatorTransformProperty( const_cast<PropertyOwner*>( &propertyOwner ),
+ const_cast<PropertyBase*>( &property ),
+ animatorFunction,
+ alphaFunction,
+ timePeriod );
}
- virtual float operator()(float progress, const unsigned int& property)
+ /**
+ * Virtual destructor.
+ */
+ virtual ~AnimatorTransformProperty()
{
- return property;
}
- virtual float operator()(float progress, const float& property)
+ /**
+ * @copydoc AnimatorBase::DoUpdate( BufferIndex bufferIndex, bool bake, float alpha )
+ */
+ virtual void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) override final
{
- return property;
- }
+ const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
- virtual Vector2 operator()(float progress, const Vector2& property)
- {
- return property;
- }
+ // need to cast the return value in case property is integer
+ const PropertyType result = static_cast<PropertyType>( (*mAnimatorFunction)( alpha, current ) );
- virtual Vector3 operator()(float progress, const Vector3& property)
- {
- return property;
+ if ( bake )
+ {
+ mPropertyAccessor.Bake( bufferIndex, result );
+ }
+ else
+ {
+ mPropertyAccessor.Set( bufferIndex, result );
+ }
}
- virtual Vector4 operator()(float progress, const Vector4& property)
- {
- return property;
- }
+private:
- virtual Quaternion operator()(float progress, const Quaternion& property)
+ /**
+ * Private constructor; see also Animator::New().
+ */
+ AnimatorTransformProperty( PropertyOwner* propertyOwner,
+ PropertyBase* property,
+ AnimatorFunctionBase* animatorFunction,
+ AlphaFunction alphaFunction,
+ const TimePeriod& timePeriod )
+ : AnimatorBase( propertyOwner, animatorFunction, alphaFunction, timePeriod ),
+ mPropertyAccessor( property )
{
- return property;
+ // WARNING - this object is created in the event-thread
+ // The scene-graph mPropertyOwner object cannot be observed here
}
-};
-// Update functions
+ // Undefined
+ AnimatorTransformProperty() = delete;
+ AnimatorTransformProperty( const AnimatorTransformProperty& ) = delete;
+ AnimatorTransformProperty& operator=( const AnimatorTransformProperty& ) = delete;
-struct AnimateByInteger : public AnimatorFunctionBase
-{
- AnimateByInteger(const int& relativeValue)
- : mRelative(relativeValue)
- {
- }
+protected:
- float operator()(float alpha, const int& property)
- {
- return int(property + mRelative * alpha + 0.5f );
- }
+ PropertyAccessorType mPropertyAccessor;
- int mRelative;
};
-struct AnimateToInteger : public AnimatorFunctionBase
-{
- AnimateToInteger(const int& targetValue)
- : mTarget(targetValue)
- {
- }
-
- float operator()(float alpha, const int& property)
- {
- return int(property + ((mTarget - property) * alpha) + 0.5f);
- }
+} // namespace SceneGraph
- int mTarget;
-};
+// Update functions
-struct AnimateByUnsignedInteger : public AnimatorFunctionBase
+struct AnimateByInteger : public AnimatorFunctionBase
{
- AnimateByUnsignedInteger(const unsigned int& relativeValue)
+ AnimateByInteger(const int& relativeValue)
: mRelative(relativeValue)
{
}
- float operator()(float alpha, const unsigned int& property)
+ using AnimatorFunctionBase::operator();
+ float operator()(float alpha, const int32_t& property)
{
- return static_cast<unsigned int>(property + mRelative * alpha + 0.5f );
+ // integers need to be correctly rounded
+ return roundf(static_cast<float>( property ) + static_cast<float>( mRelative ) * alpha );
}
- unsigned int mRelative;
+ int32_t mRelative;
};
-struct AnimateToUnsignedInteger : public AnimatorFunctionBase
+struct AnimateToInteger : public AnimatorFunctionBase
{
- AnimateToUnsignedInteger(const unsigned int& targetValue)
+ AnimateToInteger(const int& targetValue)
: mTarget(targetValue)
{
}
- float operator()(float alpha, const unsigned int& property)
+ using AnimatorFunctionBase::operator();
+ float operator()(float alpha, const int32_t& property)
{
- return static_cast<unsigned int>(property + ((mTarget - property) * alpha) + 0.5f);
+ // integers need to be correctly rounded
+ return roundf(static_cast<float>( property ) + (static_cast<float>(mTarget - property) * alpha) );
}
- unsigned int mTarget;
+ int32_t mTarget;
};
struct AnimateByFloat : public AnimatorFunctionBase
{
}
+ using AnimatorFunctionBase::operator();
float operator()(float alpha, const float& property)
{
return float(property + mRelative * alpha);
{
}
+ using AnimatorFunctionBase::operator();
float operator()(float alpha, const float& property)
{
return float(property + ((mTarget - property) * alpha));
{
}
+ using AnimatorFunctionBase::operator();
Vector2 operator()(float alpha, const Vector2& property)
{
return Vector2(property + mRelative * alpha);
{
}
+ using AnimatorFunctionBase::operator();
Vector2 operator()(float alpha, const Vector2& property)
{
return Vector2(property + ((mTarget - property) * alpha));
{
}
+ using AnimatorFunctionBase::operator();
Vector3 operator()(float alpha, const Vector3& property)
{
return Vector3(property + mRelative * alpha);
{
}
+ using AnimatorFunctionBase::operator();
Vector3 operator()(float alpha, const Vector3& property)
{
return Vector3(property + ((mTarget - property) * alpha));
{
}
+ using AnimatorFunctionBase::operator();
Vector4 operator()(float alpha, const Vector4& property)
{
return Vector4(property + mRelative * alpha);
{
}
+ using AnimatorFunctionBase::operator();
Vector4 operator()(float alpha, const Vector4& property)
{
return Vector4(property + ((mTarget - property) * alpha));
{
}
+ using AnimatorFunctionBase::operator();
Vector4 operator()(float alpha, const Vector4& property)
{
Vector4 result(property);
{
}
+ using AnimatorFunctionBase::operator();
Vector4 operator()(float alpha, const Vector4& property)
{
Vector4 result(property);
{
}
+ using AnimatorFunctionBase::operator();
bool operator()(float alpha, const bool& property)
{
// Alpha is not useful here, just keeping to the same template as other update functors
{
}
+ using AnimatorFunctionBase::operator();
bool operator()(float alpha, const bool& property)
{
// Alpha is not useful here, just keeping to the same template as other update functors
{
}
+ using AnimatorFunctionBase::operator();
Quaternion operator()(float alpha, const Quaternion& rotation)
{
if (alpha > 0.0f)
{
}
+ using AnimatorFunctionBase::operator();
Quaternion operator()(float alpha, const Quaternion& rotation)
{
return Quaternion::Slerp(rotation, mTarget, alpha);
{
}
+ using AnimatorFunctionBase::operator();
bool operator()(float progress, const bool& property)
{
if(mKeyFrames->IsActive(progress))
{
}
- float operator()(float progress, const int& property)
+ using AnimatorFunctionBase::operator();
+ float operator()(float progress, const int32_t& property)
{
if(mKeyFrames->IsActive(progress))
{
- return mKeyFrames->GetValue(progress, mInterpolation);
+ return static_cast<float>( mKeyFrames->GetValue(progress, mInterpolation) );
}
- return property;
+ return static_cast<float>( property );
}
KeyFrameIntegerPtr mKeyFrames;
Interpolation mInterpolation;
};
-struct KeyFrameUnsignedIntegerFunctor : public AnimatorFunctionBase
-{
- KeyFrameUnsignedIntegerFunctor(KeyFrameUnsignedIntegerPtr keyFrames, Interpolation interpolation)
- : mKeyFrames(keyFrames),mInterpolation(interpolation)
- {
- }
-
- float operator()(float progress, const unsigned int& property)
- {
- if(mKeyFrames->IsActive(progress))
- {
- return mKeyFrames->GetValue(progress, mInterpolation);
- }
- return property;
- }
-
- KeyFrameUnsignedIntegerPtr mKeyFrames;
- Interpolation mInterpolation;
-};
-
struct KeyFrameNumberFunctor : public AnimatorFunctionBase
{
KeyFrameNumberFunctor(KeyFrameNumberPtr keyFrames, Interpolation interpolation)
{
}
+ using AnimatorFunctionBase::operator();
float operator()(float progress, const float& property)
{
if(mKeyFrames->IsActive(progress))
{
}
+ using AnimatorFunctionBase::operator();
Vector2 operator()(float progress, const Vector2& property)
{
if(mKeyFrames->IsActive(progress))
{
}
+ using AnimatorFunctionBase::operator();
Vector3 operator()(float progress, const Vector3& property)
{
if(mKeyFrames->IsActive(progress))
{
}
+ using AnimatorFunctionBase::operator();
Vector4 operator()(float progress, const Vector4& property)
{
if(mKeyFrames->IsActive(progress))
{
}
+ using AnimatorFunctionBase::operator();
Quaternion operator()(float progress, const Quaternion& property)
{
if(mKeyFrames->IsActive(progress))
{
}
+ using AnimatorFunctionBase::operator();
Vector3 operator()(float progress, const Vector3& property)
{
- return mPath->SamplePosition(progress );
+ Vector3 position(property);
+ static_cast<void>( mPath->SamplePosition(progress, position) );
+ return position;
}
PathPtr mPath;
mForward.Normalize();
}
+ using AnimatorFunctionBase::operator();
Quaternion operator()(float progress, const Quaternion& property)
{
- Vector3 tangent( mPath->SampleTangent(progress) );
- return Quaternion( mForward, tangent );
+ Vector3 tangent;
+ if( mPath->SampleTangent(progress, tangent) )
+ {
+ return Quaternion( mForward, tangent );
+ }
+ else
+ {
+ return property;
+ }
}
PathPtr mPath;
Vector3 mForward;
};
-
} // namespace Internal
} // namespace Dali
-#endif // __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__
+#endif // DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H