Revert "[Tizen] Add screen and client rotation itself function"
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / camera-actor-impl.cpp
index 273c2dd..ae63c9f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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>
+#include <cstring> // for strcmp
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/stage.h>
 #include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/actor-attachments/camera-attachment-impl.h>
+#include <dali/integration-api/debug.h>
 #include <dali/internal/event/common/property-helper.h>
 #include <dali/internal/event/common/stage-impl.h>
+#include <dali/internal/event/common/scene-impl.h>
 #include <dali/internal/event/render-tasks/render-task-impl.h>
 #include <dali/internal/event/render-tasks/render-task-list-impl.h>
 #include <dali/internal/event/common/projection.h>
-#include <dali/integration-api/debug.h>
+#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/internal/update/render-tasks/scene-graph-camera.h>
 
 namespace Dali
 {
@@ -49,21 +52,21 @@ namespace
  *              Name                     Type   writable animatable constraint-input  enum for index-checking
  */
 DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "type",                   STRING,   true,    false,   true,   Dali::CameraActor::Property::Type                 )
-DALI_PROPERTY( "projection-mode",        STRING,   true,    false,   true,   Dali::CameraActor::Property::ProjectionMode       )
-DALI_PROPERTY( "field-of-view",          FLOAT,    true,    false,   true,   Dali::CameraActor::Property::FieldOfView          )
-DALI_PROPERTY( "aspect-ratio",           FLOAT,    true,    false,   true,   Dali::CameraActor::Property::AspectRatio          )
-DALI_PROPERTY( "near-plane-distance",    FLOAT,    true,    false,   true,   Dali::CameraActor::Property::NearPlaneDistance    )
-DALI_PROPERTY( "far-plane-distance",     FLOAT,    true,    false,   true,   Dali::CameraActor::Property::FarPlaneDistance     )
-DALI_PROPERTY( "left-plane-distance",    FLOAT,    true,    false,   true,   Dali::CameraActor::Property::LeftPlaneDistance    )
-DALI_PROPERTY( "right-plane-distance",   FLOAT,    true,    false,   true,   Dali::CameraActor::Property::RightPlaneDistance   )
-DALI_PROPERTY( "top-plane-distance",     FLOAT,    true,    false,   true,   Dali::CameraActor::Property::TopPlaneDistance     )
-DALI_PROPERTY( "bottom-plane-distance",  FLOAT,    true,    false,   true,   Dali::CameraActor::Property::BottomPlaneDistance  )
-DALI_PROPERTY( "target-position",        VECTOR3,  true,    false,   true,   Dali::CameraActor::Property::TargetPosition       )
-DALI_PROPERTY( "projection-matrix",      MATRIX,   false,   false,   true,   Dali::CameraActor::Property::ProjectionMatrix     )
-DALI_PROPERTY( "view-matrix",            MATRIX,   false,   false,   true,   Dali::CameraActor::Property::ViewMatrix           )
-DALI_PROPERTY( "invert-y-axis",          BOOLEAN,  true,    false,   true,   Dali::CameraActor::Property::InvertYAxis          )
-DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX )
+DALI_PROPERTY( "type",                   STRING,   true,    false,   true,   Dali::CameraActor::Property::TYPE                  )
+DALI_PROPERTY( "projectionMode",         STRING,   true,    false,   true,   Dali::CameraActor::Property::PROJECTION_MODE       )
+DALI_PROPERTY( "fieldOfView",            FLOAT,    true,    false,   true,   Dali::CameraActor::Property::FIELD_OF_VIEW         )
+DALI_PROPERTY( "aspectRatio",            FLOAT,    true,    false,   true,   Dali::CameraActor::Property::ASPECT_RATIO          )
+DALI_PROPERTY( "nearPlaneDistance",      FLOAT,    true,    false,   true,   Dali::CameraActor::Property::NEAR_PLANE_DISTANCE   )
+DALI_PROPERTY( "farPlaneDistance",       FLOAT,    true,    false,   true,   Dali::CameraActor::Property::FAR_PLANE_DISTANCE    )
+DALI_PROPERTY( "leftPlaneDistance",      FLOAT,    true,    false,   true,   Dali::CameraActor::Property::LEFT_PLANE_DISTANCE   )
+DALI_PROPERTY( "rightPlaneDistance",     FLOAT,    true,    false,   true,   Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE  )
+DALI_PROPERTY( "topPlaneDistance",       FLOAT,    true,    false,   true,   Dali::CameraActor::Property::TOP_PLANE_DISTANCE    )
+DALI_PROPERTY( "bottomPlaneDistance",    FLOAT,    true,    false,   true,   Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE )
+DALI_PROPERTY( "targetPosition",         VECTOR3,  true,    false,   true,   Dali::CameraActor::Property::TARGET_POSITION       )
+DALI_PROPERTY( "projectionMatrix",       MATRIX,   false,   false,   true,   Dali::CameraActor::Property::PROJECTION_MATRIX     )
+DALI_PROPERTY( "viewMatrix",             MATRIX,   false,   false,   true,   Dali::CameraActor::Property::VIEW_MATRIX           )
+DALI_PROPERTY( "invertYAxis",            BOOLEAN,  true,    false,   true,   Dali::CameraActor::Property::INVERT_Y_AXIS         )
+DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, CameraDefaultProperties )
 
 // calculate the far plane distance for a 16bit depth buffer with 4 bits per unit precision
 void CalculateClippingAndZ( float width, float height, float& nearClippingPlane, float& farClippingPlane, float& cameraZ )
@@ -78,7 +81,7 @@ BaseHandle Create()
   return Dali::CameraActor::New();
 }
 
-TypeRegistration mType( typeid( Dali::CameraActor ), typeid( Dali::Actor ), Create );
+TypeRegistration mType( typeid( Dali::CameraActor ), typeid( Dali::Actor ), Create, CameraDefaultProperties );
 
 /**
  * Builds the picking ray in the world reference system from an orthographic camera
@@ -111,8 +114,10 @@ void BuildOrthoPickingRay( const Matrix& viewMatrix,
     DALI_ASSERT_DEBUG( false );
   }
 
-  Vector4 near( screenX - viewport.x, viewport.height - (screenY - viewport.y), 0.f, 1.f );
-  if( !Unproject( near, invViewProjection, viewport.width, viewport.height, rayOrigin ) )
+  Vector4 near( screenX - static_cast<float>( viewport.x ),
+                static_cast<float>( viewport.height ) - (screenY - static_cast<float>( viewport.y ) ),
+                0.f, 1.f );
+  if( !Unproject( near, invViewProjection, static_cast<float>( viewport.width ), static_cast<float>( viewport.height ), rayOrigin ) )
   {
     DALI_ASSERT_DEBUG( false );
   }
@@ -137,144 +142,246 @@ void BuildOrthoPickingRay( const Matrix& viewMatrix,
 
 CameraActorPtr CameraActor::New( const Size& size )
 {
-  CameraActorPtr actor(new CameraActor());
+  CameraActorPtr actor( new CameraActor( *CreateNode() ) );
 
   // Second-phase construction
-
   actor->Initialize();
 
-  actor->SetName("DefaultCamera");
-
-  // Create the attachment
-  actor->mCameraAttachment = CameraAttachment::New( *actor->mNode );
-
-  actor->Attach(*actor->mCameraAttachment);
-
+  actor->SetName( "DefaultCamera" );
   actor->SetPerspectiveProjection( size );
 
   // By default Actors face in the positive Z direction in world space
   // CameraActors should face in the negative Z direction, towards the other actors
-  actor->SetRotation( Quaternion( Math::PI, Vector3::YAXIS ) );
+  actor->SetOrientation( Quaternion( Dali::ANGLE_180, Vector3::YAXIS ) );
 
   return actor;
 }
 
+CameraActor::CameraActor( const SceneGraph::Node& node )
+: Actor( Actor::BASIC, node ),
+  mSceneObject( NULL ),
+  mTarget( SceneGraph::Camera::DEFAULT_TARGET_POSITION ),
+  mType( SceneGraph::Camera::DEFAULT_TYPE ),
+  mProjectionMode( SceneGraph::Camera::DEFAULT_MODE ),
+  mFieldOfView( SceneGraph::Camera::DEFAULT_FIELD_OF_VIEW ),
+  mAspectRatio( SceneGraph::Camera::DEFAULT_ASPECT_RATIO ),
+  mNearClippingPlane( SceneGraph::Camera::DEFAULT_NEAR_CLIPPING_PLANE ),
+  mFarClippingPlane( SceneGraph::Camera::DEFAULT_FAR_CLIPPING_PLANE ),
+  mLeftClippingPlane( SceneGraph::Camera::DEFAULT_LEFT_CLIPPING_PLANE ),
+  mRightClippingPlane( SceneGraph::Camera::DEFAULT_RIGHT_CLIPPING_PLANE ),
+  mTopClippingPlane( SceneGraph::Camera::DEFAULT_TOP_CLIPPING_PLANE ),
+  mBottomClippingPlane( SceneGraph::Camera::DEFAULT_BOTTOM_CLIPPING_PLANE ),
+  mInvertYAxis( SceneGraph::Camera::DEFAULT_INVERT_Y_AXIS )
+{
+}
+
+CameraActor::~CameraActor()
+{
+  if( EventThreadServices::IsCoreRunning() )
+  {
+    // Create scene-object and transfer ownership through message
+    RemoveCameraMessage( GetEventThreadServices().GetUpdateManager(), mSceneObject );
+  }
+}
+
 void CameraActor::OnInitialize()
 {
+  // Create scene-object and keep raw pointer for message passing.
+  SceneGraph::Camera* sceneGraphCamera = SceneGraph::Camera::New();
+
+  // Store a pointer to this camera node inside the scene-graph camera.
+  sceneGraphCamera->SetNode( &GetNode() );
+
+  mSceneObject = sceneGraphCamera;
+  OwnerPointer< SceneGraph::Camera > sceneGraphCameraOwner( sceneGraphCamera );
+
+  // Send message to inform update of this camera (and move ownership).
+  AddCameraMessage( GetEventThreadServices().GetUpdateManager(), sceneGraphCameraOwner );
 }
 
-CameraActor::CameraActor()
-: Actor( Actor::BASIC )
+void CameraActor::SetTarget( const Vector3& target )
 {
+  if( target != mTarget ) // using range epsilon
+  {
+    mTarget = target;
+
+    SetTargetPositionMessage( GetEventThreadServices(),  *mSceneObject, mTarget );
+  }
 }
 
-CameraActor::~CameraActor()
+Vector3 CameraActor::GetTarget() const
 {
+  return mTarget;
 }
 
 void CameraActor::SetType( Dali::Camera::Type type )
 {
-  mCameraAttachment->SetType(type);
+  if( type != mType )
+  {
+    mType = type;
+
+    // sceneObject is being used in a separate thread; queue a message to set
+    SetTypeMessage( GetEventThreadServices(), *mSceneObject, mType );
+  }
 }
 
 Dali::Camera::Type CameraActor::GetType() const
 {
-  return mCameraAttachment->GetType();
+  return mType;
 }
 
 void CameraActor::SetProjectionMode( Dali::Camera::ProjectionMode mode )
 {
-  mCameraAttachment->SetProjectionMode(mode);
+  if( mode != mProjectionMode )
+  {
+    mProjectionMode = mode;
+
+    // sceneObject is being used in a separate thread; queue a message to set
+    SetProjectionModeMessage( GetEventThreadServices(), *mSceneObject, mProjectionMode );
+  }
 }
 
 Dali::Camera::ProjectionMode CameraActor::GetProjectionMode() const
 {
-  return mCameraAttachment->GetProjectionMode();
+  return mProjectionMode;
 }
 
 void CameraActor::SetFieldOfView( float fieldOfView )
 {
-  mCameraAttachment->SetFieldOfView(fieldOfView);
+  if( ! Equals( fieldOfView, mFieldOfView ) )
+  {
+    mFieldOfView = fieldOfView;
+
+    // sceneObject is being used in a separate thread; queue a message to set
+    SetFieldOfViewMessage( GetEventThreadServices(), *mSceneObject, mFieldOfView );
+  }
 }
 
-float CameraActor::GetFieldOfView( ) const
+float CameraActor::GetFieldOfView() const
 {
-  return mCameraAttachment->GetFieldOfView();
+  return mFieldOfView;
 }
 
 void CameraActor::SetAspectRatio( float aspectRatio )
 {
-  mCameraAttachment->SetAspectRatio(aspectRatio);
+  if( ! Equals( aspectRatio, mAspectRatio ) )
+  {
+    mAspectRatio = aspectRatio;
+
+    // sceneObject is being used in a separate thread; queue a message to set
+    SetAspectRatioMessage( GetEventThreadServices(), *mSceneObject, mAspectRatio );
+  }
 }
 
-float CameraActor::GetAspectRatio( ) const
+float CameraActor::GetAspectRatio() const
 {
-  return mCameraAttachment->GetAspectRatio();
+  return mAspectRatio;
 }
 
 void CameraActor::SetNearClippingPlane( float nearClippingPlane )
 {
-  mCameraAttachment->SetNearClippingPlane(nearClippingPlane);
+  if( ! Equals( nearClippingPlane, mNearClippingPlane ) )
+  {
+    mNearClippingPlane = nearClippingPlane;
+
+    // sceneObject is being used in a separate thread; queue a message to set
+    SetNearClippingPlaneMessage( GetEventThreadServices(), *mSceneObject, mNearClippingPlane );
+  }
 }
 
-float CameraActor::GetNearClippingPlane( ) const
+float CameraActor::GetNearClippingPlane() const
 {
-  return mCameraAttachment->GetNearClippingPlane();
+  return mNearClippingPlane;
 }
 
 void CameraActor::SetFarClippingPlane( float farClippingPlane )
 {
-  mCameraAttachment->SetFarClippingPlane(farClippingPlane);
+  if( ! Equals( farClippingPlane, mFarClippingPlane ) )
+  {
+    mFarClippingPlane = farClippingPlane;
+
+    // sceneObject is being used in a separate thread; queue a message to set
+    SetFarClippingPlaneMessage( GetEventThreadServices(), *mSceneObject, mFarClippingPlane );
+  }
 }
 
-float CameraActor::GetFarClippingPlane( ) const
+float CameraActor::GetFarClippingPlane() const
 {
-  return mCameraAttachment->GetFarClippingPlane();
+  return mFarClippingPlane;
 }
 
-void CameraActor::SetTargetPosition(const Vector3& target)
+void CameraActor::SetLeftClippingPlane( float leftClippingPlane )
 {
-  mCameraAttachment->SetTargetPosition(target);
+  if( ! Equals( leftClippingPlane, mLeftClippingPlane ) )
+  {
+    mLeftClippingPlane = leftClippingPlane;
+
+    // sceneObject is being used in a separate thread; queue a message to set
+    SetLeftClippingPlaneMessage( GetEventThreadServices(), *mSceneObject, mLeftClippingPlane );
+  }
 }
 
-Vector3 CameraActor::GetTargetPosition() const
+void CameraActor::SetRightClippingPlane( float rightClippingPlane )
 {
-  return mCameraAttachment->GetTargetPosition();
+  if( ! Equals( rightClippingPlane, mRightClippingPlane ) )
+  {
+    mRightClippingPlane = rightClippingPlane;
+
+    // sceneObject is being used in a separate thread; queue a message to set
+    SetRightClippingPlaneMessage( GetEventThreadServices(), *mSceneObject, mRightClippingPlane );
+  }
 }
 
-void CameraActor::SetInvertYAxis(bool invertYAxis)
+void CameraActor::SetTopClippingPlane( float topClippingPlane )
 {
-  mCameraAttachment->SetInvertYAxis(invertYAxis);
+  if( ! Equals( topClippingPlane, mTopClippingPlane ) )
+  {
+    mTopClippingPlane = topClippingPlane;
+
+    // sceneObject is being used in a separate thread; queue a message to set
+    SetTopClippingPlaneMessage( GetEventThreadServices(), *mSceneObject, mTopClippingPlane );
+  }
 }
 
-bool CameraActor::GetInvertYAxis() const
+void CameraActor::SetBottomClippingPlane( float bottomClippingPlane )
 {
-  return mCameraAttachment->GetInvertYAxis();
+  if( ! Equals( bottomClippingPlane, mBottomClippingPlane ) )
+  {
+    mBottomClippingPlane = bottomClippingPlane;
+
+    // sceneObject is being used in a separate thread; queue a message to set
+    SetBottomClippingPlaneMessage( GetEventThreadServices(), *mSceneObject, mBottomClippingPlane );
+  }
 }
 
-void CameraActor::SetPerspectiveProjection( const Size& size, const Vector2& stereoBias /* = Vector2::ZERO */ )
+void CameraActor::SetInvertYAxis(bool invertYAxis)
 {
-  float width = size.width;
-  float height = size.height;
-
-  if( Size::ZERO == size )
+  if( invertYAxis != mInvertYAxis )
   {
-    if( Stage::IsInstalled() )
-    {
-      const Size& stageSize = mStage->GetSize();
+    mInvertYAxis = invertYAxis;
 
-      width = stageSize.width;
-      height = stageSize.height;
-    }
+    // sceneObject is being used in a separate thread; queue a message to set
+    SetInvertYAxisMessage( GetEventThreadServices(), *mSceneObject, mInvertYAxis );
   }
+}
 
-  if( ( width < Math::MACHINE_EPSILON_1000 ) || ( height < Math::MACHINE_EPSILON_1000 ) )
+bool CameraActor::GetInvertYAxis() const
+{
+  return mInvertYAxis;
+}
+
+void CameraActor::SetPerspectiveProjection( const Size& size )
+{
+  if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
   {
-    // On the stage initialization this method is called but the size has not been set.
-    // There is no point to set any value if width or height is zero.
+    // Not allowed to set the canvas size to be 0.
+    DALI_LOG_ERROR( "Canvas size can not be 0\n" );
     return;
   }
 
+  float width = size.width;
+  float height = size.height;
+
   float nearClippingPlane;
   float farClippingPlane;
   float cameraZ;
@@ -292,12 +399,12 @@ void CameraActor::SetPerspectiveProjection( const Size& size, const Vector2& ste
 
   const float aspectRatio = width / height;
 
+  // sceneObject is being used in a separate thread; queue a message to set
   SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
   SetFieldOfView( fieldOfView );
   SetNearClippingPlane( nearClippingPlane );
   SetFarClippingPlane( farClippingPlane );
   SetAspectRatio( aspectRatio );
-  mCameraAttachment->SetStereoBias( stereoBias );
   SetZ( cameraZ );
 }
 
@@ -316,13 +423,13 @@ void CameraActor::SetOrthographicProjection( const Vector2& size )
 
 void CameraActor::SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far )
 {
-  mCameraAttachment->SetLeftClippingPlane(left);
-  mCameraAttachment->SetRightClippingPlane(right);
-  mCameraAttachment->SetTopClippingPlane(top);
-  mCameraAttachment->SetBottomClippingPlane(bottom);
+  SetLeftClippingPlane( left );
+  SetRightClippingPlane( right );
+  SetTopClippingPlane( top );
+  SetBottomClippingPlane( bottom );
   SetNearClippingPlane( near );
   SetFarClippingPlane( far );
-  SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
+  SetProjectionMode( Dali::Camera::ORTHOGRAPHIC_PROJECTION );
 }
 
 bool CameraActor::BuildPickingRay( const Vector2& screenCoordinates,
@@ -331,20 +438,19 @@ bool CameraActor::BuildPickingRay( const Vector2& screenCoordinates,
                                    Vector4& rayDirection )
 {
   bool success = true;
-  if( GetProjectionMode() == Dali::Camera::PERSPECTIVE_PROJECTION )
+  if( mProjectionMode == Dali::Camera::PERSPECTIVE_PROJECTION )
   {
     // Build a picking ray in the world reference system.
     // ray starts from the camera world position
-    rayOrigin = mNode->GetWorldPosition( mStage->GetEventBufferIndex() );
+    rayOrigin = GetNode().GetWorldMatrix(0).GetTranslation();
     rayOrigin.w = 1.0f;
 
     // Transform the touch point from the screen coordinate system to the world coordinates system.
-    Vector4 near( screenCoordinates.x - viewport.x, viewport.height - (screenCoordinates.y - viewport.y), 0.f, 1.f );
-    if( !Unproject( near, mCameraAttachment->GetInverseViewProjectionMatrix(), viewport.width, viewport.height, near ) )
-    {
-      // unproject failed so no picking ray possible
-      success = false;
-    }
+    Vector4 near( screenCoordinates.x - static_cast<float>(viewport.x),
+                  static_cast<float>( viewport.height ) - (screenCoordinates.y - static_cast<float>( viewport.y ) ),
+                  0.f, 1.f );
+    const Matrix& inverseViewProjection = mSceneObject->GetInverseViewProjectionMatrix( GetEventThreadServices().GetEventBufferIndex() );
+    success = Unproject( near, inverseViewProjection, static_cast<float>( viewport.width ), static_cast<float>( viewport.height ), near );
 
     // Compute the ray's director vector.
     rayDirection.x = near.x - rayOrigin.x;
@@ -372,7 +478,7 @@ const Matrix& CameraActor::GetViewMatrix() const
 {
   if ( OnStage() )
   {
-    return mCameraAttachment->GetViewMatrix();
+    return mSceneObject->GetViewMatrix( GetEventThreadServices().GetEventBufferIndex() );
   }
   else
   {
@@ -384,123 +490,16 @@ const Matrix& CameraActor::GetProjectionMatrix() const
 {
   if ( OnStage() )
   {
-    return mCameraAttachment->GetProjectionMatrix();
+    return mSceneObject->GetProjectionMatrix( GetEventThreadServices().GetEventBufferIndex() );
   }
   else
   {
     return Matrix::IDENTITY;
   }
 }
-
-unsigned int CameraActor::GetDefaultPropertyCount() const
-{
-  return Actor::GetDefaultPropertyCount() + DEFAULT_PROPERTY_COUNT;
-}
-
-void CameraActor::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
-  Actor::GetDefaultPropertyIndices( indices ); // Actor class properties
-
-  indices.reserve( indices.size() + DEFAULT_PROPERTY_COUNT );
-
-  int index = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
-  for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i, ++index )
-  {
-    indices.push_back( index );
-  }
-}
-
-bool CameraActor::IsDefaultPropertyWritable( Property::Index index ) const
-{
-  if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
-  {
-    return Actor::IsDefaultPropertyWritable( index );
-  }
-
-  return DEFAULT_PROPERTY_DETAILS[index - DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX].writable;
-}
-
-bool CameraActor::IsDefaultPropertyAnimatable( Property::Index index ) const
-{
-  if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
-  {
-    return Actor::IsDefaultPropertyAnimatable( index );
-  }
-
-  return DEFAULT_PROPERTY_DETAILS[index - DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX].animatable;
-}
-
-bool CameraActor::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
-  if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
-  {
-    return Actor::IsDefaultPropertyAConstraintInput( index );
-  }
-
-  return DEFAULT_PROPERTY_DETAILS[index - DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX].constraintInput;
-}
-
-Property::Type CameraActor::GetDefaultPropertyType( Property::Index index ) const
-{
-  if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
-  {
-    return Actor::GetDefaultPropertyType( index );
-  }
-  else
-  {
-    index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
-
-    if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
-    {
-      return DEFAULT_PROPERTY_DETAILS[index].type;
-    }
-    else
-    {
-      // index out-of-bounds
-      return Property::NONE;
-    }
-  }
-}
-
-const char* CameraActor::GetDefaultPropertyName( Property::Index index ) const
+const SceneGraph::Camera* CameraActor::GetCamera() const
 {
-  if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
-  {
-    return Actor::GetDefaultPropertyName(index);
-  }
-  else
-  {
-    index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
-
-    if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
-    {
-      return DEFAULT_PROPERTY_DETAILS[index].name;
-    }
-    return NULL;
-  }
-}
-
-Property::Index CameraActor::GetDefaultPropertyIndex(const std::string& name) const
-{
-  Property::Index index = Property::INVALID_INDEX;
-
-  // Look for name in current class' default properties
-  for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
-  {
-    if( 0 == strcmp( name.c_str(), DEFAULT_PROPERTY_DETAILS[i].name ) ) // dont want to convert rhs to string
-    {
-      index = i + DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
-      break;
-    }
-  }
-
-  // If not found, check in base class
-  if( Property::INVALID_INDEX == index )
-  {
-    index = Actor::GetDefaultPropertyIndex( name );
-  }
-
-  return index;
+  return mSceneObject;
 }
 
 void CameraActor::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
@@ -511,106 +510,97 @@ void CameraActor::SetDefaultProperty( Property::Index index, const Property::Val
   }
   else
   {
-    DALI_ASSERT_DEBUG(mCameraAttachment && "where is the camera?");
     switch(index)
     {
-      case Dali::CameraActor::Property::Type:
+      case Dali::CameraActor::Property::TYPE:
       {
         std::string s( propertyValue.Get<std::string>() );
         if(s == "LOOK_AT_TARGET")
         {
-          mCameraAttachment->SetType(Dali::Camera::LOOK_AT_TARGET);
+          SetType( Dali::Camera::LOOK_AT_TARGET );
         }
         else if(s == "FREE_LOOK")
         {
-          mCameraAttachment->SetType(Dali::Camera::FREE_LOOK);
-        }
-        else
-        {
-          DALI_LOG_WARNING("Unknown camera type\n");
+          SetType( Dali::Camera::FREE_LOOK );
         }
         break;
       }
-      case Dali::CameraActor::Property::ProjectionMode:
+      case Dali::CameraActor::Property::PROJECTION_MODE:
       {
-        std::string s(propertyValue.Get<std::string>());
-        if(s == "PERSPECTIVE_PROJECTION")
-        {
-          mCameraAttachment->SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
-        }
-        else if(s == "ORTHOGRAPHIC_PROJECTION")
+        std::string s( propertyValue.Get<std::string>() );
+        if( s == "PERSPECTIVE_PROJECTION" )
         {
-          mCameraAttachment->SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
+          SetProjectionMode( Dali::Camera::PERSPECTIVE_PROJECTION );
         }
-        else
+        else if( s == "ORTHOGRAPHIC_PROJECTION" )
         {
-          DALI_LOG_WARNING("Unknown projection mode\n");
+          SetProjectionMode( Dali::Camera::ORTHOGRAPHIC_PROJECTION );
         }
         break;
       }
-      case Dali::CameraActor::Property::FieldOfView:
+      case Dali::CameraActor::Property::FIELD_OF_VIEW:
       {
-        mCameraAttachment->SetFieldOfView(propertyValue.Get<float>());
+        SetFieldOfView( propertyValue.Get<float>() ); // set to 0 in case property is not float
         break;
       }
-      case Dali::CameraActor::Property::AspectRatio:
+      case Dali::CameraActor::Property::ASPECT_RATIO:
       {
-        mCameraAttachment->SetAspectRatio(propertyValue.Get<float>());
+        SetAspectRatio( propertyValue.Get<float>() ); // set to 0 in case property is not float
         break;
       }
-      case Dali::CameraActor::Property::LeftPlaneDistance:
+      case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
       {
-        mCameraAttachment->SetLeftClippingPlane(propertyValue.Get<float>());
+        SetNearClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
         break;
       }
-      case Dali::CameraActor::Property::RightPlaneDistance:
+      case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
       {
-        mCameraAttachment->SetRightClippingPlane(propertyValue.Get<float>());
+        SetFarClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
         break;
       }
-      case Dali::CameraActor::Property::TopPlaneDistance:
+      case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
       {
-        mCameraAttachment->SetTopClippingPlane(propertyValue.Get<float>());
+        SetLeftClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
         break;
       }
-      case Dali::CameraActor::Property::BottomPlaneDistance:
+      case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
       {
-        mCameraAttachment->SetBottomClippingPlane(propertyValue.Get<float>());
+        SetRightClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
         break;
       }
-      case Dali::CameraActor::Property::NearPlaneDistance:
+      case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
       {
-        mCameraAttachment->SetNearClippingPlane(propertyValue.Get<float>());
+        SetTopClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
         break;
       }
-      case Dali::CameraActor::Property::FarPlaneDistance:
+      case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
       {
-        mCameraAttachment->SetFarClippingPlane(propertyValue.Get<float>());
+        SetBottomClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
         break;
       }
-      case Dali::CameraActor::Property::TargetPosition:
+      case Dali::CameraActor::Property::TARGET_POSITION:
       {
-        mCameraAttachment->SetTargetPosition(propertyValue.Get<Vector3>());
+        SetTarget( propertyValue.Get<Vector3>() ); // set to 0 in case property is not Vector3
         break;
       }
-      case Dali::CameraActor::Property::ProjectionMatrix:
+      case Dali::CameraActor::Property::PROJECTION_MATRIX:
       {
-        DALI_LOG_WARNING("projection-matrix property is not animatable \n");
+        DALI_LOG_WARNING( "projection-matrix is read-only\n" );
         break;
       }
-      case Dali::CameraActor::Property::ViewMatrix:
+      case Dali::CameraActor::Property::VIEW_MATRIX:
       {
-        DALI_LOG_WARNING("view-matrix property is not animatable \n");
+        DALI_LOG_WARNING( "view-matrix is read-only\n" );
         break;
       }
-      case Dali::CameraActor::Property::InvertYAxis:
+      case Dali::CameraActor::Property::INVERT_Y_AXIS:
       {
-        mCameraAttachment->SetInvertYAxis(propertyValue.Get<bool>());
+        SetInvertYAxis( propertyValue.Get<bool>() ); // set to false in case property is not bool
         break;
       }
       default:
       {
-        DALI_LOG_WARNING("Unknown property (%d)\n", index);
+        DALI_LOG_WARNING( "Unknown property (%d)\n", index );
         break;
       }
     } // switch(index)
@@ -621,112 +611,96 @@ void CameraActor::SetDefaultProperty( Property::Index index, const Property::Val
 Property::Value CameraActor::GetDefaultProperty( Property::Index index ) const
 {
   Property::Value ret;
-  if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
+  if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
   {
     ret = Actor::GetDefaultProperty(index);
   }
   else
   {
-    DALI_ASSERT_DEBUG(mCameraAttachment && "where is the camera?");
     switch(index)
     {
-      case Dali::CameraActor::Property::Type:
+      case Dali::CameraActor::Property::TYPE:
       {
-        if(mCameraAttachment->GetType() == Dali::Camera::LOOK_AT_TARGET)
+        if( Dali::Camera::LOOK_AT_TARGET == mType )
         {
           ret = "LOOK_AT_TARGET";
         }
-        else if(mCameraAttachment->GetType() == Dali::Camera::FREE_LOOK)
+        else if( Dali::Camera::FREE_LOOK == mType )
         {
           ret = "FREE_LOOK";
         }
-        else
-        {
-          ret = "";
-          DALI_ASSERT_DEBUG("Unknown camera type\n");
-        }
         break;
       }
-      case Dali::CameraActor::Property::ProjectionMode:
+      case Dali::CameraActor::Property::PROJECTION_MODE:
       {
-        if(mCameraAttachment->GetProjectionMode() == Dali::Camera::PERSPECTIVE_PROJECTION)
+        if( Dali::Camera::PERSPECTIVE_PROJECTION == mProjectionMode )
         {
           ret = "PERSPECTIVE_PROJECTION";
         }
-        else if(mCameraAttachment->GetProjectionMode() == Dali::Camera::ORTHOGRAPHIC_PROJECTION)
+        else if( Dali::Camera::ORTHOGRAPHIC_PROJECTION == mProjectionMode )
         {
           ret = "ORTHOGRAPHIC_PROJECTION";
         }
-        else
-        {
-          ret = "";
-          DALI_ASSERT_DEBUG("Unknown projection mode\n");
-        }
         break;
       }
-      case Dali::CameraActor::Property::FieldOfView:
+      case Dali::CameraActor::Property::FIELD_OF_VIEW:
       {
-        ret = mCameraAttachment->GetFieldOfView();
+        ret = mFieldOfView;
         break;
       }
-      case Dali::CameraActor::Property::AspectRatio:
+      case Dali::CameraActor::Property::ASPECT_RATIO:
       {
-        ret = mCameraAttachment->GetAspectRatio();
+        ret = mAspectRatio;
         break;
       }
-      case Dali::CameraActor::Property::LeftPlaneDistance:
+      case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
       {
-        ret = mCameraAttachment->GetLeftClippingPlane();
+        ret = mNearClippingPlane;
         break;
       }
-      case Dali::CameraActor::Property::RightPlaneDistance:
+      case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
       {
-        ret = mCameraAttachment->GetRightClippingPlane();
+        ret = mFarClippingPlane;
         break;
       }
-      case Dali::CameraActor::Property::TopPlaneDistance:
+      case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
       {
-        ret = mCameraAttachment->GetTopClippingPlane();
+        ret = mLeftClippingPlane;
         break;
       }
-      case Dali::CameraActor::Property::BottomPlaneDistance:
+      case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
       {
-        ret = mCameraAttachment->GetBottomClippingPlane();
+        ret = mRightClippingPlane;
         break;
       }
-      case Dali::CameraActor::Property::NearPlaneDistance:
+      case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
       {
-        ret = mCameraAttachment->GetNearClippingPlane();
+        ret = mTopClippingPlane;
         break;
       }
-      case Dali::CameraActor::Property::FarPlaneDistance:
+      case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
       {
-        ret = mCameraAttachment->GetFarClippingPlane();
+        ret = mBottomClippingPlane;
         break;
       }
-      case Dali::CameraActor::Property::TargetPosition:
+      case Dali::CameraActor::Property::TARGET_POSITION:
       {
-        ret = mCameraAttachment->GetTargetPosition();
+        ret = mTarget;
         break;
       }
-      case Dali::CameraActor::Property::ProjectionMatrix:
+      case Dali::CameraActor::Property::PROJECTION_MATRIX:
       {
-        ret = mCameraAttachment->GetProjectionMatrix();
+        ret = GetProjectionMatrix(); // Only on scene-graph
         break;
       }
-      case Dali::CameraActor::Property::ViewMatrix:
+      case Dali::CameraActor::Property::VIEW_MATRIX:
       {
-        ret = mCameraAttachment->GetViewMatrix();
+        ret = GetViewMatrix(); // Only on scene-graph
         break;
       }
-      case Dali::CameraActor::Property::InvertYAxis:
+      case Dali::CameraActor::Property::INVERT_Y_AXIS:
       {
-        ret = mCameraAttachment->GetInvertYAxis();
-        break;
-      }
-      default:
-      {
-        DALI_LOG_WARNING("Unknown property (%d)\n", index);
+        ret = mInvertYAxis;
         break;
       }
     } // switch(index)
@@ -735,66 +709,47 @@ Property::Value CameraActor::GetDefaultProperty( Property::Index index ) const
   return ret;
 }
 
-const SceneGraph::PropertyBase* CameraActor::GetSceneObjectAnimatableProperty( Property::Index index ) const
+Property::Value CameraActor::GetDefaultPropertyCurrentValue( Property::Index index ) const
 {
-  DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
-
-  const SceneGraph::PropertyBase* property( NULL );
-
-  // This method should only return a property of an object connected to the scene-graph
-  if ( !OnStage() )
+  Property::Value ret;
+  if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
   {
-    return property;
+    ret = Actor::GetDefaultPropertyCurrentValue(index);
   }
-
-  // let actor handle animatable properties, we have no animatable properties
-  if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
+  else
   {
-    property = Actor::GetSceneObjectAnimatableProperty(index);
+    ret = GetDefaultProperty( index ); // Most are event-side properties, the scene-graph properties are only on the scene-graph
   }
 
-  return property;
+  return ret;
 }
 
 const PropertyInputImpl* CameraActor::GetSceneObjectInputProperty( Property::Index index ) const
 {
   const PropertyInputImpl* property( NULL );
 
-  // This method should only return a property of an object connected to the scene-graph
-  if ( !OnStage() )
-  {
-    return property;
-  }
-
-  // if its an actor default property or a custom property (actor already handles custom properties)
-  if( ( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) || ( index >= DEFAULT_PROPERTY_MAX_COUNT ) )
-  {
-    property = Actor::GetSceneObjectInputProperty(index);
-  }
-  else
+  switch( index )
   {
-    switch( index )
+    case Dali::CameraActor::Property::PROJECTION_MATRIX:
     {
-      case Dali::CameraActor::Property::ProjectionMatrix:
-      {
-        property = mCameraAttachment->GetProjectionMatrixProperty();
-        break;
-      }
-      case Dali::CameraActor::Property::ViewMatrix:
-      {
-        property = mCameraAttachment->GetViewMatrixProperty();
-        break;
-      }
-      default:
-        DALI_LOG_WARNING("Not an input property (%d)\n", index);
-        break;
+      property = mSceneObject->GetProjectionMatrix();
+      break;
     }
+    case Dali::CameraActor::Property::VIEW_MATRIX:
+    {
+      property = mSceneObject->GetViewMatrix();
+      break;
+    }
+    // no default on purpose as we chain method up to actor
+  }
+  if( !property )
+  {
+    property = Actor::GetSceneObjectInputProperty( index );
   }
 
   return property;
 }
 
-
 } // namespace Internal
 
 } // namespace Dali