[4.0] Changed Update to reset only target properties each frame
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / animator-connector.h
index 1c535c2..8119063 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_ANIMATOR_CONNECTOR_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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 <boost/function.hpp>
-
 // INTERNAL INCLUDES
-#include <dali/internal/event/common/proxy-object.h>
 #include <dali/internal/event/animation/animator-connector-base.h>
 #include <dali/internal/event/animation/animation-impl.h>
 #include <dali/internal/update/common/property-owner.h>
 #include <dali/internal/update/animation/property-accessor.h>
 #include <dali/internal/update/animation/property-component-accessor.h>
-#include <dali/internal/update/animation/scene-graph-animator.h>
+#include <dali/internal/update/common/property-resetter.h>
 #include <dali/internal/update/manager/update-manager.h>
 
 namespace Dali
@@ -38,26 +34,23 @@ namespace Internal
 {
 
 /**
- * AnimatorConnector is used to connect SceneGraph::Animators for newly created scene-graph objects.
- *
- * The scene-graph objects are created by a ProxyObject e.g. Actor is a proxy for SceneGraph::Node.
- * AnimatorConnector observes the proxy object, in order to detect when a scene-graph object is created.
+ * AnimatorConnector is used to connect SceneGraph::Animators and
+ * PropertyResetters for newly created scene-graph objects.
  *
  * SceneGraph::Animators weakly reference scene objects, and are automatically deleted when orphaned.
  * Therefore the AnimatorConnector is NOT responsible for disconnecting animators.
  */
 template < typename PropertyType >
-class AnimatorConnector : public AnimatorConnectorBase, public ProxyObject::Observer
+class AnimatorConnector : public AnimatorConnectorBase
 {
 public:
 
-  typedef boost::function< PropertyType (float, const PropertyType&) > AnimatorFunction;
   typedef SceneGraph::Animator< PropertyType, PropertyAccessor<PropertyType> > AnimatorType;
   typedef SceneGraph::AnimatableProperty< PropertyType > PropertyInterfaceType;
 
   /**
    * Construct a new animator connector.
-   * @param[in] proxy The proxy for a scene-graph object to animate.
+   * @param[in] object The object for a scene-graph object to animate.
    * @param[in] propertyIndex The index of a property provided by the object.
    * @param[in] componentIndex Index to a sub component of a property, for use with Vector2, Vector3 and Vector4 (INVALID_PROPERTY_COMPONENTINDEX to use the whole property)
    * @param[in] animatorFunction A function used to animate the property.
@@ -65,14 +58,14 @@ public:
    * @param[in] period The time period of the animator.
    * @return A pointer to a newly allocated animator connector.
    */
-  static AnimatorConnectorBase* New( ProxyObject& proxy,
+  static AnimatorConnectorBase* New( Object& object,
                                      Property::Index propertyIndex,
                                      int componentIndex,
-                                     const AnimatorFunction& animatorFunction,
+                                     AnimatorFunctionBase* animatorFunction,
                                      AlphaFunction alpha,
                                      const TimePeriod& period )
   {
-    return new AnimatorConnector< PropertyType >( proxy,
+    return new AnimatorConnector< PropertyType >( object,
                                                   propertyIndex,
                                                   componentIndex,
                                                   animatorFunction,
@@ -85,13 +78,18 @@ public:
    */
   virtual ~AnimatorConnector()
   {
-    if( mProxy )
+    if( mObject )
     {
-      mProxy->RemoveObserver( *this );
+      mObject->RemoveObserver( *this );
     }
 
-    // Removing animators via Animation is not necessary.
-    // The corresponding scene graph animation will destroy any animators that become disconnected.
+    // If there is not a SceneGraph::Animator, the AnimatorConnector is responsible for deleting the mAnimatorFunction
+    // otherwise, the animator function ownership is transferred to the SceneGraph::Animator
+    if( !mAnimator )
+    {
+      delete mAnimatorFunction;
+      mAnimatorFunction = 0;
+    }
   }
 
   /**
@@ -103,14 +101,9 @@ public:
     DALI_ASSERT_ALWAYS( mParent == NULL && "AnimationConnector already has a parent" );
     mParent = &parent;
 
-    if( mProxy )
+    if( mObject && mObject->GetSceneObject() )
     {
-      // Connect an animator, if the proxy has added an object to the scene-graph
-      const SceneGraph::PropertyOwner* object = mProxy->GetSceneObject();
-      if( object )
-      {
-        ConnectAnimator( *object );
-      }
+      CreateAnimator();
     }
   }
 
@@ -119,20 +112,16 @@ private:
   /**
    * Private constructor; see also AnimatorConnector::New().
    */
-  AnimatorConnector( ProxyObject& proxy,
+  AnimatorConnector( Object& object,
                      Property::Index propertyIndex,
                      int componentIndex,
-                     const AnimatorFunction& animatorFunction,
+                     Internal::AnimatorFunctionBase* animatorFunction,
                      AlphaFunction alpha,
                      const TimePeriod& period )
-  : AnimatorConnectorBase( alpha, period ),
-    mProxy( &proxy ),
-    mPropertyIndex( propertyIndex ),
-    mComponentIndex( componentIndex ),
-    mAnimatorFunction( animatorFunction ),
-    mConnected( false )
+  : AnimatorConnectorBase( object, propertyIndex, componentIndex, alpha, period ),
+    mAnimator(0),
+    mAnimatorFunction( animatorFunction )
   {
-    proxy.AddObserver( *this );
   }
 
   // Undefined
@@ -142,312 +131,276 @@ private:
   AnimatorConnector& operator=( const AnimatorConnector& rhs );
 
   /**
-   * From ProxyObject::Observer
-   */
-  virtual void SceneObjectAdded( ProxyObject& proxy )
-  {
-    const SceneGraph::PropertyOwner* object = mProxy->GetSceneObject();
-    DALI_ASSERT_DEBUG( NULL != object );
-
-    ConnectAnimator( *object );
-  }
-
-  /**
-   * From ProxyObject::Observer
-   */
-  virtual void SceneObjectRemoved( ProxyObject& proxy )
-  {
-    // Removing animators via Animation is not necessary.
-    // The corresponding scene graph animation will destroy any animators that become disconnected.
-    mConnected = false;
-  }
-
-  /**
-   * From ProxyObject::Observer
-   */
-  virtual void ProxyDestroyed( ProxyObject& proxy )
-  {
-    mConnected = false;
-    mProxy = NULL;
-  }
-
-  /**
-   * Create and connect an animator via update manager
-   */
-  void ConnectAnimator( const SceneGraph::PropertyOwner& object )
-  {
-    DALI_ASSERT_DEBUG( false == mConnected ); // Guard against double connections
-    DALI_ASSERT_DEBUG( NULL != mParent );
-
-    const SceneGraph::PropertyBase* base = mProxy->GetSceneObjectAnimatableProperty( mPropertyIndex );
-
-    const PropertyInterfaceType* sceneProperty = dynamic_cast< const PropertyInterfaceType* >( base );
-    DALI_ASSERT_DEBUG( NULL != sceneProperty && "Animating property with invalid type" );
-
-    SceneGraph::AnimatorBase* animator = AnimatorType::New( *sceneProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
-    DALI_ASSERT_DEBUG( NULL != animator );
-
-    const SceneGraph::Animation* animation = mParent->GetSceneObject();
-    DALI_ASSERT_DEBUG( NULL != animation );
-
-    AddAnimatorMessage( mParent->GetUpdateManager().GetEventToUpdate(), *animation, *animator, object );
-
-    mConnected = true; // not really necessary, but useful for asserts
-  }
-
-protected:
-
-  ProxyObject* mProxy; ///< Not owned by the animator connector. Valid until ProxyDestroyed() is called.
-
-  Property::Index mPropertyIndex;
-
-  int mComponentIndex;
-
-  AnimatorFunction mAnimatorFunction;
-
-  bool mConnected; ///< Used to guard against double connections
-};
-
-/**
- * Variant which allows float components to be animated individually.
- */
-template <>
-class AnimatorConnector<float> : public AnimatorConnectorBase, public ProxyObject::Observer
-{
-public:
-
-  typedef boost::function< float (float, const float&) > AnimatorFunction;
-  typedef SceneGraph::Animator< float, PropertyAccessor<float> > AnimatorType;
-
-  /**
-   * Construct a new animator connector.
-   * @param[in] proxy The proxy for a scene-graph object to animate.
-   * @param[in] propertyIndex The index of a property provided by the object.
-   * @param[in] componentIndex Index to a sub component of a property, for use with Vector2, Vector3 and Vector4
-   * @param[in] animatorFunction A function used to animate the property.
-   * @param[in] alpha The alpha function to apply.
-   * @param[in] period The time period of the animator.
-   * @return A pointer to a newly allocated animator connector.
-   */
-  static AnimatorConnectorBase* New( ProxyObject& proxy,
-                                     Property::Index propertyIndex,
-                                     int componentIndex,
-                                     const AnimatorFunction& animatorFunction,
-                                     AlphaFunction alpha,
-                                     const TimePeriod& period )
-  {
-    return new AnimatorConnector<float>( proxy,
-                                         propertyIndex,
-                                         componentIndex,
-                                         animatorFunction,
-                                         alpha,
-                                         period );
-  }
-
-  /**
-   * Virtual destructor.
-   */
-  virtual ~AnimatorConnector()
-  {
-    if( mProxy )
-    {
-      mProxy->RemoveObserver( *this );
-    }
-
-    // Removing animators via Animation is not necessary.
-    // The corresponding scene graph animation will destroy any animators that become disconnected.
-  }
-
-  /**
-   * From AnimatorConnectorBase.
-   * This is only expected to be called once, when added to an Animation.
+   * From Object::Observer
    */
-  void SetParent( Animation& parent )
+  virtual void SceneObjectAdded( Object& object )
   {
-    DALI_ASSERT_ALWAYS( mParent == NULL && "AnimationConnector already has a parent");
-    mParent = &parent;
-
-    if( mProxy )
+    //If the animator has not been created yet, create it now.
+    if( !mAnimator && mObject )
     {
-      // Connect an animator, if the proxy has added an object to the scene-graph
-      const SceneGraph::PropertyOwner* object = mProxy->GetSceneObject();
-      if( object )
-      {
-        ConnectAnimator( *object );
-      }
+      CreateAnimator();
     }
   }
 
-private:
-
-  /**
-   * Private constructor; see also AnimatorConnector::New().
+   /**
+   * Helper function to create a Scenegraph::Animator and PropertyResetter and add it to its correspondent
+   * SceneGraph::Animation.
+   *
+   * @note This function will only be called the first time the object is added to the scene or at creation time if
+   * the object was already in the scene
    */
-  AnimatorConnector( ProxyObject& proxy,
-                     Property::Index propertyIndex,
-                     int componentIndex,
-                     const AnimatorFunction& animatorFunction,
-                     AlphaFunction alpha,
-                     const TimePeriod& period )
-  : AnimatorConnectorBase( alpha, period ),
-    mProxy( &proxy ),
-    mPropertyIndex( propertyIndex ),
-    mComponentIndex( componentIndex ),
-    mAnimatorFunction( animatorFunction ),
-    mConnected( false )
+  void CreateAnimator()
   {
-    proxy.AddObserver( *this );
-  }
+    DALI_ASSERT_DEBUG( mAnimator == NULL );
+    DALI_ASSERT_DEBUG( mAnimatorFunction != NULL );
+    DALI_ASSERT_DEBUG( mParent != NULL );
 
-  // Undefined
-  AnimatorConnector( const AnimatorConnector& );
-
-  // Undefined
-  AnimatorConnector& operator=( const AnimatorConnector& rhs );
-
-  /**
-   * From ProxyObject::Observer
-   */
-  virtual void SceneObjectAdded( ProxyObject& proxy )
-  {
-    const SceneGraph::PropertyOwner* object = mProxy->GetSceneObject();
-    DALI_ASSERT_DEBUG( NULL != object );
+    //Get the PropertyOwner the animator is going to animate
+    const SceneGraph::PropertyOwner* propertyOwner = mObject->GetSceneObject();
 
-    ConnectAnimator( *object );
-  }
+    // Get SceneGraph::BaseProperty
+    const SceneGraph::PropertyBase* baseProperty = mObject->GetSceneObjectAnimatableProperty( mPropertyIndex );
 
-  /**
-   * From ProxyObject::Observer
-   */
-  virtual void SceneObjectRemoved( ProxyObject& proxy )
-  {
-    // Removing animators via Animation is not necessary.
-    // The corresponding scene graph animation will destroy any animators that become disconnected.
-    mConnected = false;
-  }
+    OwnerPointer<SceneGraph::PropertyResetterBase> resetter;
 
-  /**
-   * From ProxyObject::Observer
-   */
-  virtual void ProxyDestroyed( ProxyObject& proxy )
-  {
-    mConnected = false;
-    mProxy = NULL;
-  }
-
-  /**
-   * Create and connect an animator via update manager
-   */
-  void ConnectAnimator( const SceneGraph::PropertyOwner& object )
-  {
-    DALI_ASSERT_DEBUG( false == mConnected ); // Guard against double connections
-    DALI_ASSERT_DEBUG( NULL != mParent );
-
-    const SceneGraph::PropertyBase* base = mProxy->GetSceneObjectAnimatableProperty( mPropertyIndex );
-    DALI_ASSERT_DEBUG( NULL != base );
-
-    SceneGraph::AnimatorBase* animator( NULL );
-
-    const int componentIndex = mProxy->GetPropertyComponentIndex( mPropertyIndex );
+    // Check if property is a component of another property
+    const int componentIndex = mObject->GetPropertyComponentIndex( mPropertyIndex );
     if( componentIndex != Property::INVALID_COMPONENT_INDEX )
     {
       mComponentIndex = componentIndex;
     }
 
-    if ( Property::INVALID_COMPONENT_INDEX == mComponentIndex )
+    if( mComponentIndex == Property::INVALID_COMPONENT_INDEX )
     {
-      // Not a Vector3 or Vector4 component, expecting float type
-      DALI_ASSERT_DEBUG( PropertyTypes::Get< float >() == base->GetType() );
-
-      typedef SceneGraph::AnimatableProperty< float > PropertyInterfaceType;
+      // Animating the whole property
 
-      const PropertyInterfaceType* sceneProperty = dynamic_cast< const PropertyInterfaceType* >( base );
-      DALI_ASSERT_DEBUG( NULL != sceneProperty );
+      // Cast to AnimatableProperty
+      const PropertyInterfaceType* animatableProperty = dynamic_cast< const PropertyInterfaceType* >( baseProperty );
 
-      animator = AnimatorType::New( *sceneProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
-    }
-    else
-    {
-      // Expecting Vector3 or Vector4 type
-
-      if ( PropertyTypes::Get< Vector3 >() == base->GetType() )
+      if( animatableProperty == NULL )
       {
-        // Animate float component of Vector3 property
-        typedef SceneGraph::AnimatableProperty< Vector3 > PropertyInterfaceType;
-
-        const PropertyInterfaceType* sceneProperty = dynamic_cast< const PropertyInterfaceType* >( base );
-        DALI_ASSERT_DEBUG( NULL != sceneProperty );
-
-        if ( 0 == mComponentIndex )
-        {
-          typedef SceneGraph::Animator< float, PropertyComponentAccessorX<Vector3> > Vector3AnimatorType;
-          animator = Vector3AnimatorType::New( *sceneProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
-        }
-        else if ( 1 == mComponentIndex )
+        if( baseProperty->IsTransformManagerProperty() )
         {
-          typedef SceneGraph::Animator< float, PropertyComponentAccessorY<Vector3> > Vector3AnimatorType;
-          animator = Vector3AnimatorType::New( *sceneProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+          mAnimator = SceneGraph::AnimatorTransformProperty< PropertyType,TransformManagerPropertyAccessor<PropertyType> >::New( *propertyOwner, *baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+          // Don't reset transform manager properties - TransformManager will do it more efficiently
         }
-        else if ( 2 == mComponentIndex )
+        else
         {
-          typedef SceneGraph::Animator< float, PropertyComponentAccessorZ<Vector3> > Vector3AnimatorType;
-          animator = Vector3AnimatorType::New( *sceneProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+          DALI_ASSERT_DEBUG( animatableProperty != NULL && "Animating non-animatable property" );
         }
+
       }
-      else if ( PropertyTypes::Get< Vector4 >() == base->GetType() )
+      else
       {
-        // Animate float component of Vector4 property
-        typedef SceneGraph::AnimatableProperty< Vector4 > PropertyInterfaceType;
-
-        const PropertyInterfaceType* sceneProperty = dynamic_cast< const PropertyInterfaceType* >( base );
-        DALI_ASSERT_DEBUG( NULL != sceneProperty );
-
-        if ( 0 == mComponentIndex )
-        {
-          typedef SceneGraph::Animator< float, PropertyComponentAccessorX<Vector4> > Vector4AnimatorType;
-          animator = Vector4AnimatorType::New( *sceneProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
-        }
-        else if ( 1 == mComponentIndex )
+        // Create the animator and resetter
+        mAnimator = AnimatorType::New( *propertyOwner, *animatableProperty, mAnimatorFunction,
+                                       mAlphaFunction, mTimePeriod );
+        resetter = SceneGraph::AnimatorResetter::New( *propertyOwner, *baseProperty, *mAnimator );
+      }
+    }
+    else
+    {
+      {
+        // Animating a component of the property
+        if ( PropertyTypes::Get< Vector2 >() == baseProperty->GetType() )
         {
-          typedef SceneGraph::Animator< float, PropertyComponentAccessorY<Vector4> > Vector4AnimatorType;
-          animator = Vector4AnimatorType::New( *sceneProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+          // Animate float component of Vector2 property
+
+          // Cast to AnimatableProperty of type Vector2
+          const SceneGraph::AnimatableProperty<Vector2>* animatableProperty = dynamic_cast< const SceneGraph::AnimatableProperty<Vector2>* >( baseProperty );
+          DALI_ASSERT_DEBUG( animatableProperty != NULL && "Animating non-animatable property" );
+
+          switch( mComponentIndex )
+          {
+            case 0:
+            {
+              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector2> >::New( *propertyOwner,
+                                                                                                   *animatableProperty,
+                                                                                                   mAnimatorFunction,
+                                                                                                   mAlphaFunction,
+                                                                                                   mTimePeriod );
+              break;
+            }
+            case 1:
+            {
+              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector2> >::New( *propertyOwner,
+                                                                                                   *animatableProperty,
+                                                                                                   mAnimatorFunction,
+                                                                                                   mAlphaFunction,
+                                                                                                   mTimePeriod );
+              break;
+            }
+            default:
+            {
+              break;
+            }
+          }
+
+          if( mAnimator != nullptr )
+          {
+            resetter = SceneGraph::AnimatorResetter::New( *propertyOwner, *baseProperty, *mAnimator );
+          }
         }
-        else if ( 2 == mComponentIndex )
+
+        else if ( PropertyTypes::Get< Vector3 >() == baseProperty->GetType() )
         {
-          typedef SceneGraph::Animator< float, PropertyComponentAccessorZ<Vector4> > Vector4AnimatorType;
-          animator = Vector4AnimatorType::New( *sceneProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+          // Animate float component of Vector3 property
+          // Cast to AnimatableProperty of type Vector3
+          const SceneGraph::AnimatableProperty<Vector3>* animatableProperty = dynamic_cast< const SceneGraph::AnimatableProperty<Vector3>* >( baseProperty );
+
+          if( animatableProperty == NULL )
+          {
+            if( baseProperty->IsTransformManagerProperty() )
+            {
+              if( mComponentIndex == 0 )
+              {
+                mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,0> >::New( *propertyOwner, *baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+              }
+              else if( mComponentIndex == 1 )
+              {
+                mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,1> >::New( *propertyOwner, *baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+              }
+              else if( mComponentIndex == 2 )
+              {
+                mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,2> >::New( *propertyOwner, *baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+              }
+            }
+            else
+            {
+              DALI_ASSERT_DEBUG( animatableProperty != NULL && "Animating non-animatable property" );
+            }
+            // Don't manually reset transform property - TransformManager will do it more efficiently
+          }
+          else
+          {
+            // Dynamic cast will fail if BaseProperty is not a Vector3 AnimatableProperty
+            DALI_ASSERT_DEBUG( animatableProperty != NULL && "Animating non-animatable property" );
+
+            switch( mComponentIndex )
+            {
+              case 0:
+              {
+                mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector3> >::New( *propertyOwner,
+                                                                                                     *animatableProperty,
+                                                                                                     mAnimatorFunction,
+                                                                                                     mAlphaFunction,
+                                                                                                     mTimePeriod );
+                break;
+              }
+              case 1:
+              {
+                mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector3> >::New( *propertyOwner,
+                                                                                                     *animatableProperty,
+                                                                                                     mAnimatorFunction,
+                                                                                                     mAlphaFunction,
+                                                                                                     mTimePeriod );
+                break;
+              }
+              case 2:
+              {
+                mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ<Vector3> >::New( *propertyOwner,
+                                                                                                     *animatableProperty,
+                                                                                                     mAnimatorFunction,
+                                                                                                     mAlphaFunction,
+                                                                                                     mTimePeriod );
+                break;
+              }
+              default:
+              {
+                break;
+              }
+            }
+
+            if( mAnimator != nullptr )
+            {
+              resetter = SceneGraph::AnimatorResetter::New( *propertyOwner, *baseProperty, *mAnimator );
+            }
+          }
         }
-        else if ( 3 == mComponentIndex )
+        else if ( PropertyTypes::Get< Vector4 >() == baseProperty->GetType() )
         {
-          typedef SceneGraph::Animator< float, PropertyComponentAccessorW<Vector4> > Vector4AnimatorType;
-          animator = Vector4AnimatorType::New( *sceneProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+          // Animate float component of Vector4 property
+
+          // Cast to AnimatableProperty of type Vector4
+          const SceneGraph::AnimatableProperty<Vector4>* animatableProperty = dynamic_cast< const SceneGraph::AnimatableProperty<Vector4>* >( baseProperty );
+
+          //Dynamic cast will fail if BaseProperty is not a Vector4 AnimatableProperty
+          DALI_ASSERT_DEBUG( animatableProperty != NULL && "Animating non-animatable property" );
+
+          switch( mComponentIndex )
+          {
+            case 0:
+            {
+              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector4> >::New( *propertyOwner,
+                                                                                                   *animatableProperty,
+                                                                                                   mAnimatorFunction,
+                                                                                                   mAlphaFunction,
+                                                                                                   mTimePeriod );
+              break;
+            }
+            case 1:
+            {
+              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector4> >::New( *propertyOwner,
+                                                                                                   *animatableProperty,
+                                                                                                   mAnimatorFunction,
+                                                                                                   mAlphaFunction,
+                                                                                                   mTimePeriod );
+              break;
+            }
+            case 2:
+            {
+              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ<Vector4> >::New( *propertyOwner,
+                                                                                                   *animatableProperty,
+                                                                                                   mAnimatorFunction,
+                                                                                                   mAlphaFunction,
+                                                                                                   mTimePeriod );
+              break;
+            }
+            case 3:
+            {
+              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorW<Vector4> >::New( *propertyOwner,
+                                                                                                   *animatableProperty,
+                                                                                                   mAnimatorFunction,
+                                                                                                   mAlphaFunction,
+                                                                                                   mTimePeriod );
+              break;
+            }
+
+            default:
+            {
+              break;
+            }
+          }
+          if( mAnimator != nullptr )
+          {
+            resetter = SceneGraph::AnimatorResetter::New( *propertyOwner, *baseProperty, *mAnimator );
+          }
         }
       }
     }
 
-    DALI_ASSERT_DEBUG( NULL != animator && "Animating property with invalid type" );
+    DALI_ASSERT_DEBUG( mAnimator != NULL );
 
+    // Add the new SceneGraph::Animator to its correspondent SceneGraph::Animation via message
     const SceneGraph::Animation* animation = mParent->GetSceneObject();
     DALI_ASSERT_DEBUG( NULL != animation );
+    AddAnimatorMessage( mParent->GetEventThreadServices(), *animation, *mAnimator );
 
-    AddAnimatorMessage( mParent->GetUpdateManager().GetEventToUpdate(), *animation, *animator, object );
-
-    mConnected = true; // not really necessary, but useful for asserts
+    // Add the new SceneGraph::PropertyResetter to the update manager via message
+    if( resetter != nullptr )
+    {
+      AddResetterMessage( mParent->GetEventThreadServices().GetUpdateManager(), resetter );
+    }
   }
 
 protected:
 
-  ProxyObject* mProxy; ///< Not owned by the animator connector. Valid until ProxyDestroyed() is called.
+  SceneGraph::AnimatorBase* mAnimator;
 
-  Property::Index mPropertyIndex;
-
-  int mComponentIndex;
-
-  AnimatorFunction mAnimatorFunction;
-
-  bool mConnected; ///< Used to guard against double connections
+  Internal::AnimatorFunctionBase* mAnimatorFunction;  ///< Owned by the animator connector until an Scenegraph::Animator is created
 };
 
+
 } // namespace Internal
 
 } // namespace Dali