Make some camera actor animatable & constraint input 09/296609/8
authorseungho baek <sbsh.baek@samsung.com>
Wed, 2 Aug 2023 05:03:24 +0000 (14:03 +0900)
committerseungho baek <sbsh.baek@samsung.com>
Fri, 4 Aug 2023 06:33:49 +0000 (15:33 +0900)
Change-Id: I7b164c6885dc3225a0ba13e560a71c13ec23e88c
Signed-off-by: seungho baek <sbsh.baek@samsung.com>
automated-tests/src/dali/utc-Dali-CameraActor.cpp
dali/internal/event/actors/camera-actor-impl.cpp
dali/internal/event/actors/camera-actor-impl.h
dali/internal/update/manager/render-instruction-processor.cpp
dali/internal/update/render-tasks/scene-graph-camera-messages.h
dali/internal/update/render-tasks/scene-graph-camera.cpp
dali/internal/update/render-tasks/scene-graph-camera.h
dali/public-api/actors/camera-actor.h

index d74172168f26543bf3de6d067cb8d798f73b0056..4ea403a53a545ba5841413ab4da049abbd9eb414 100644 (file)
@@ -1318,7 +1318,7 @@ int UtcDaliCameraActorDefaultProperties(void)
   {
     DALI_TEST_EQUALS(*iter, actor.GetPropertyIndex(actor.GetPropertyName(*iter)), TEST_LOCATION);
 
-    if(*iter == CameraActor::Property::FIELD_OF_VIEW || *iter == CameraActor::Property::ASPECT_RATIO || *iter == DevelCameraActor::Property::ORTHOGRAPHIC_SIZE)
+    if(*iter == CameraActor::Property::FIELD_OF_VIEW || *iter == CameraActor::Property::ASPECT_RATIO || *iter == DevelCameraActor::Property::ORTHOGRAPHIC_SIZE || *iter == CameraActor::Property::NEAR_PLANE_DISTANCE || *iter == CameraActor::Property::FAR_PLANE_DISTANCE)
     {
       DALI_TEST_CHECK(actor.IsPropertyAnimatable(*iter));
     }
@@ -1454,8 +1454,8 @@ int UtcDaliCameraActorDefaultPropertiesInherited(void)
       {"projectionMode", Property::INTEGER, true, false, true, Dali::CameraActor::Property::PROJECTION_MODE},
       {"fieldOfView", Property::FLOAT, true, true, true, Dali::CameraActor::Property::FIELD_OF_VIEW},
       {"aspectRatio", Property::FLOAT, true, true, true, Dali::CameraActor::Property::ASPECT_RATIO},
-      {"nearPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::NEAR_PLANE_DISTANCE},
-      {"farPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::FAR_PLANE_DISTANCE},
+      {"nearPlaneDistance", Property::FLOAT, true, true, true, Dali::CameraActor::Property::NEAR_PLANE_DISTANCE},
+      {"farPlaneDistance", Property::FLOAT, true, true, true, Dali::CameraActor::Property::FAR_PLANE_DISTANCE},
       {"leftPlaneDistance", Property::FLOAT, false, false, true, Dali::CameraActor::Property::LEFT_PLANE_DISTANCE},
       {"rightPlaneDistance", Property::FLOAT, false, false, true, Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE},
       {"topPlaneDistance", Property::FLOAT, false, false, true, Dali::CameraActor::Property::TOP_PLANE_DISTANCE},
@@ -1640,38 +1640,45 @@ int UtcDaliCameraActorAnimatedProperties03(void)
 
   Radian sourceFoV    = Radian(0.6f);
   float  sourceAspect = 0.7f;
+  float  sourceNearDistance = 0.5f;
+  float  sourceFarDistance  = 1000.0f;
 
   Radian targetFoV    = Radian(0.1f);
   float  targetAspect = 1.3f;
+  float  targetNearDistance = 20.5f;
+  float  targetFarDistance  = 30.0f;
 
   Matrix expectedProjectionMatrix1;
   Matrix expectedProjectionMatrix2;
   Matrix expectedProjectionMatrix3;
 
-  // Reduce near-far value for projection matrix epsilon
-  camera.SetNearClippingPlane(1.0f);
-  camera.SetFarClippingPlane(3.0f);
-
   // Build expect projection matrix
   camera.SetFieldOfView(sourceFoV.radian);
   camera.SetAspectRatio(sourceAspect);
+  camera.SetNearClippingPlane(sourceNearDistance);
+  camera.SetFarClippingPlane(sourceFarDistance);
   application.SendNotification();
   application.Render();
   camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(expectedProjectionMatrix1);
 
   camera.SetFieldOfView(sourceFoV.radian * 0.6f + targetFoV.radian * 0.4f);
   camera.SetAspectRatio(sourceAspect * 0.6f + targetAspect * 0.4f);
+  camera.SetNearClippingPlane(sourceNearDistance * 0.6f + targetNearDistance * 0.4f);
+  camera.SetFarClippingPlane(sourceFarDistance * 0.6f + targetFarDistance * 0.4f);
   application.SendNotification();
   application.Render();
   camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(expectedProjectionMatrix2);
 
   camera.SetFieldOfView(targetFoV.radian);
   camera.SetAspectRatio(targetAspect);
+  camera.SetNearClippingPlane(targetNearDistance);
+  camera.SetFarClippingPlane(targetFarDistance);
   application.SendNotification();
   application.Render();
   camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(expectedProjectionMatrix3);
 
-  auto TestAnimationProgress = [&]() {
+  auto TestAnimationProgress = [&]()
+  {
     Matrix projectionMatrix;
 
     application.SendNotification();
@@ -1680,6 +1687,8 @@ int UtcDaliCameraActorAnimatedProperties03(void)
     // progress 0.0
     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::FIELD_OF_VIEW), sourceFoV.radian, TEST_LOCATION);
     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::ASPECT_RATIO), sourceAspect, TEST_LOCATION);
+    DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::NEAR_PLANE_DISTANCE), sourceNearDistance, TEST_LOCATION);
+    DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::FAR_PLANE_DISTANCE), sourceFarDistance, TEST_LOCATION);
 
     camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
     DALI_TEST_EQUALS(projectionMatrix, expectedProjectionMatrix1, Epsilon<100000>::value, TEST_LOCATION);
@@ -1690,6 +1699,8 @@ int UtcDaliCameraActorAnimatedProperties03(void)
     // progress 0.4
     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::FIELD_OF_VIEW), sourceFoV.radian * 0.6f + targetFoV.radian * 0.4f, TEST_LOCATION);
     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::ASPECT_RATIO), sourceAspect * 0.6f + targetAspect * 0.4f, TEST_LOCATION);
+    DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::NEAR_PLANE_DISTANCE), sourceNearDistance * 0.6f + targetNearDistance * 0.4f, TEST_LOCATION);
+    DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::FAR_PLANE_DISTANCE), sourceFarDistance * 0.6f + targetFarDistance * 0.4f, TEST_LOCATION);
 
     camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
     DALI_TEST_EQUALS(projectionMatrix, expectedProjectionMatrix2, Epsilon<100000>::value, TEST_LOCATION);
@@ -1700,6 +1711,8 @@ int UtcDaliCameraActorAnimatedProperties03(void)
     // progress 1.0
     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::FIELD_OF_VIEW), targetFoV.radian, TEST_LOCATION);
     DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::ASPECT_RATIO), targetAspect, TEST_LOCATION);
+    DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::NEAR_PLANE_DISTANCE), targetNearDistance, TEST_LOCATION);
+    DALI_TEST_EQUALS(camera.GetCurrentProperty<float>(CameraActor::Property::FAR_PLANE_DISTANCE), targetFarDistance, TEST_LOCATION);
 
     camera.GetProperty(CameraActor::Property::PROJECTION_MATRIX).Get(projectionMatrix);
     DALI_TEST_EQUALS(projectionMatrix, expectedProjectionMatrix3, Epsilon<100000>::value, TEST_LOCATION);
@@ -1714,9 +1727,13 @@ int UtcDaliCameraActorAnimatedProperties03(void)
     tet_printf("AnimateTo\n");
     camera.SetProperty(CameraActor::Property::FIELD_OF_VIEW, sourceFoV.radian);
     camera.SetProperty(CameraActor::Property::ASPECT_RATIO, sourceAspect);
+    camera.SetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE, sourceNearDistance);
+    camera.SetProperty(CameraActor::Property::FAR_PLANE_DISTANCE, sourceFarDistance);
     Animation animation = Animation::New(1.0f);
     animation.AnimateTo(Property(camera, CameraActor::Property::FIELD_OF_VIEW), targetFoV.radian);
     animation.AnimateTo(Property(camera, CameraActor::Property::ASPECT_RATIO), targetAspect);
+    animation.AnimateTo(Property(camera, CameraActor::Property::NEAR_PLANE_DISTANCE), targetNearDistance);
+    animation.AnimateTo(Property(camera, CameraActor::Property::FAR_PLANE_DISTANCE), targetFarDistance);
     animation.AnimateTo(Property(camera, Actor::Property::POSITION_X), 0.0f); ///< For line coverage.
     animation.Play();
 
@@ -1736,8 +1753,18 @@ int UtcDaliCameraActorAnimatedProperties03(void)
     keyFrames2.Add(0.0f, sourceAspect);
     keyFrames2.Add(1.0f, targetAspect);
 
+    KeyFrames keyFrames3 = KeyFrames::New();
+    keyFrames3.Add(0.0f, sourceNearDistance);
+    keyFrames3.Add(1.0f, targetNearDistance);
+
+    KeyFrames keyFrames4 = KeyFrames::New();
+    keyFrames4.Add(0.0f, sourceFarDistance);
+    keyFrames4.Add(1.0f, targetFarDistance);
+
     animation.AnimateBetween(Property(camera, CameraActor::Property::FIELD_OF_VIEW), keyFrames1);
     animation.AnimateBetween(Property(camera, CameraActor::Property::ASPECT_RATIO), keyFrames2);
+    animation.AnimateBetween(Property(camera, CameraActor::Property::NEAR_PLANE_DISTANCE), keyFrames3);
+    animation.AnimateBetween(Property(camera, CameraActor::Property::FAR_PLANE_DISTANCE), keyFrames4);
 
     animation.Play();
 
@@ -1749,9 +1776,13 @@ int UtcDaliCameraActorAnimatedProperties03(void)
     tet_printf("AnimateBy\n");
     camera.SetProperty(CameraActor::Property::FIELD_OF_VIEW, sourceFoV.radian);
     camera.SetProperty(CameraActor::Property::ASPECT_RATIO, sourceAspect);
+    camera.SetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE, sourceNearDistance);
+    camera.SetProperty(CameraActor::Property::FAR_PLANE_DISTANCE, sourceFarDistance);
     Animation animation = Animation::New(1.0f);
     animation.AnimateBy(Property(camera, CameraActor::Property::FIELD_OF_VIEW), targetFoV.radian - sourceFoV.radian);
     animation.AnimateBy(Property(camera, CameraActor::Property::ASPECT_RATIO), targetAspect - sourceAspect);
+    animation.AnimateBy(Property(camera, CameraActor::Property::NEAR_PLANE_DISTANCE), targetNearDistance - sourceNearDistance);
+    animation.AnimateBy(Property(camera, CameraActor::Property::FAR_PLANE_DISTANCE), targetFarDistance - sourceFarDistance);
     animation.Play();
 
     TestAnimationProgress();
@@ -2976,3 +3007,78 @@ int UtcDaliCameraActorSetProperty(void)
 
   END_TEST;
 }
+
+int UtcDaliCameraActorConstraintInputProperty(void)
+{
+  TestApplication application;
+  tet_infoline("Testing Constraint input properties");
+
+  CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
+  application.SendNotification();
+  application.Render(0);
+  application.Render();
+  application.SendNotification();
+  Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
+  Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
+  actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+  application.GetScene().Add(actor);
+
+  float projectionMode;
+  float projectionDirection;
+  float invertYAxis;
+  float nearClippingPlane;
+  float farClippingPlane;
+
+  camera.GetProperty(CameraActor::Property::PROJECTION_MODE).Get(projectionMode);
+  camera.GetProperty(DevelCameraActor::Property::PROJECTION_DIRECTION).Get(projectionDirection);
+  camera.GetProperty(CameraActor::Property::INVERT_Y_AXIS).Get(invertYAxis);
+  camera.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(nearClippingPlane);
+  camera.GetProperty(CameraActor::Property::FAR_PLANE_DISTANCE).Get(farClippingPlane);
+
+  Property::Index projectionModePropertyIndex      = actor.RegisterProperty("projectionMode", 100.0f);
+  Property::Index projectionDirectionPropertyIndex = actor.RegisterProperty("projectionDirection", 100.0f);
+  Property::Index invertYAxisPropertyIndex         = actor.RegisterProperty("invertYAxis", 100.0f);
+  Property::Index nearClippingPlanePropertyIndex   = actor.RegisterProperty("nearClippingPlane", 100.0f);
+  Property::Index farClippingPlanePropertyIndex    = actor.RegisterProperty("farClippingPlane", 100.0f);
+
+  application.SendNotification();
+  application.Render();
+
+  Constraint projectionModePropertyConstraint      = Constraint::New<float>(actor, projectionModePropertyIndex, [](float& output, const PropertyInputContainer& inputs)
+                                                                    { output = static_cast<float>(inputs[0]->GetInteger()); });
+  Constraint projectionDirectionPropertyConstraint = Constraint::New<float>(actor, projectionDirectionPropertyIndex, [](float& output, const PropertyInputContainer& inputs)
+                                                                    { output = static_cast<float>(inputs[0]->GetInteger()); });
+  Constraint invertYAxisPropertyConstraint         = Constraint::New<float>(actor, invertYAxisPropertyIndex, [](float& output, const PropertyInputContainer& inputs)
+                                                                    { output = static_cast<float>(inputs[0]->GetBoolean()); });
+  Constraint nearClippingPlanePropertyConstraint   = Constraint::New<float>(actor, nearClippingPlanePropertyIndex, EqualToConstraint());
+  Constraint farClippingPlanePropertyConstraint    = Constraint::New<float>(actor, farClippingPlanePropertyIndex, EqualToConstraint());
+
+  projectionModePropertyConstraint.AddSource(Source(camera, CameraActor::Property::PROJECTION_MODE));
+  projectionDirectionPropertyConstraint.AddSource(Source(camera, DevelCameraActor::Property::PROJECTION_DIRECTION));
+  invertYAxisPropertyConstraint.AddSource(Source(camera, CameraActor::Property::INVERT_Y_AXIS));
+  nearClippingPlanePropertyConstraint.AddSource(Source(camera, CameraActor::Property::NEAR_PLANE_DISTANCE));
+  farClippingPlanePropertyConstraint.AddSource(Source(camera, CameraActor::Property::FAR_PLANE_DISTANCE));
+
+  projectionModePropertyConstraint.Apply();
+  projectionDirectionPropertyConstraint.Apply();
+  invertYAxisPropertyConstraint.Apply();
+  nearClippingPlanePropertyConstraint.Apply();
+  farClippingPlanePropertyConstraint.Apply();
+
+  application.SendNotification();
+  application.Render();
+
+  float projectionModeResult      = actor.GetCurrentProperty<float>(projectionModePropertyIndex);
+  float projectionDirectionResult = actor.GetCurrentProperty<float>(projectionDirectionPropertyIndex);
+  float invertYAxisResult         = actor.GetCurrentProperty<float>(invertYAxisPropertyIndex);
+  float nearClippingPlaneResult   = actor.GetCurrentProperty<float>(nearClippingPlanePropertyIndex);
+  float farClippingPlaneResult    = actor.GetCurrentProperty<float>(farClippingPlanePropertyIndex);
+
+  DALI_TEST_EQUALS(projectionModeResult, projectionMode, TEST_LOCATION);
+  DALI_TEST_EQUALS(projectionDirectionResult, projectionDirection, TEST_LOCATION);
+  DALI_TEST_EQUALS(invertYAxisResult, invertYAxis, TEST_LOCATION);
+  DALI_TEST_EQUALS(nearClippingPlaneResult, nearClippingPlane, TEST_LOCATION);
+  DALI_TEST_EQUALS(farClippingPlaneResult, farClippingPlane, TEST_LOCATION);
+
+  END_TEST;
+}
index 883a28db269b71832f72b52610e9e24c3630369b..805ab2b583b0f02e83e5110d6763b5ce4e2fcf2d 100644 (file)
@@ -53,8 +53,8 @@ DALI_PROPERTY( "type",                   INTEGER,  true,    false,   true,   Dal
 DALI_PROPERTY( "projectionMode",         INTEGER,  true,    false,   true,   Dali::CameraActor::Property::PROJECTION_MODE           )
 DALI_PROPERTY( "fieldOfView",            FLOAT,    true,    true,    true,   Dali::CameraActor::Property::FIELD_OF_VIEW             )
 DALI_PROPERTY( "aspectRatio",            FLOAT,    true,    true,    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( "nearPlaneDistance",      FLOAT,    true,    true,    true,   Dali::CameraActor::Property::NEAR_PLANE_DISTANCE       )
+DALI_PROPERTY( "farPlaneDistance",       FLOAT,    true,    true,    true,   Dali::CameraActor::Property::FAR_PLANE_DISTANCE        )
 DALI_PROPERTY( "leftPlaneDistance",      FLOAT,    false,   false,   true,   Dali::CameraActor::Property::LEFT_PLANE_DISTANCE       )
 DALI_PROPERTY( "rightPlaneDistance",     FLOAT,    false,   false,   true,   Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE      )
 DALI_PROPERTY( "topPlaneDistance",       FLOAT,    false,   false,   true,   Dali::CameraActor::Property::TOP_PLANE_DISTANCE        )
@@ -426,7 +426,7 @@ void CameraActor::SetNearClippingPlane(float nearClippingPlane)
     mNearClippingPlane = nearClippingPlane;
 
     // sceneObject is being used in a separate thread; queue a message to set
-    SetNearClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mNearClippingPlane);
+    BakeNearClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mNearClippingPlane);
   }
 }
 
@@ -435,6 +435,11 @@ float CameraActor::GetNearClippingPlane() const
   return mNearClippingPlane;
 }
 
+float CameraActor::GetCurrentNearClippingPlane() const
+{
+  return GetCameraSceneObject().GetNearClippingPlane(GetEventThreadServices().GetEventBufferIndex());
+}
+
 void CameraActor::SetFarClippingPlane(float farClippingPlane)
 {
   mPropertyChanged = true;
@@ -443,7 +448,7 @@ void CameraActor::SetFarClippingPlane(float farClippingPlane)
     mFarClippingPlane = farClippingPlane;
 
     // sceneObject is being used in a separate thread; queue a message to set
-    SetFarClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mFarClippingPlane);
+    BakeFarClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mFarClippingPlane);
   }
 }
 
@@ -452,6 +457,11 @@ float CameraActor::GetFarClippingPlane() const
   return mFarClippingPlane;
 }
 
+float CameraActor::GetCurrentFarClippingPlane() const
+{
+  return GetCameraSceneObject().GetFarClippingPlane(GetEventThreadServices().GetEventBufferIndex());
+}
+
 void CameraActor::SetInvertYAxis(bool invertYAxis)
 {
   if(invertYAxis != mInvertYAxis)
@@ -860,6 +870,16 @@ Property::Value CameraActor::GetDefaultPropertyCurrentValue(Property::Index inde
         ret = GetCurrentAspectRatio();
         break;
       }
+      case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
+      {
+        ret = GetCurrentNearClippingPlane();
+        break;
+      }
+      case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
+      {
+        ret = GetCurrentFarClippingPlane();
+        break;
+      }
       case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
       {
         ret = OrthographicSizeConverter(GetCurrentOrthographicSize(), GetCurrentAspectRatio(), mProjectionDirection).LeftPlaneDistance();
@@ -920,6 +940,16 @@ void CameraActor::OnNotifyDefaultPropertyAnimation(Animation& animation, Propert
             value.Get(mAspectRatio);
             break;
           }
+          case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
+          {
+            value.Get(mNearClippingPlane);
+            break;
+          }
+          case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
+          {
+            value.Get(mFarClippingPlane);
+            break;
+          }
         }
         break;
       }
@@ -942,6 +972,16 @@ void CameraActor::OnNotifyDefaultPropertyAnimation(Animation& animation, Propert
             AdjustValue<float>(mAspectRatio, value);
             break;
           }
+          case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
+          {
+            AdjustValue<float>(mNearClippingPlane, value);
+            break;
+          }
+          case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
+          {
+            AdjustValue<float>(mFarClippingPlane, value);
+            break;
+          }
         }
         break;
       }
@@ -968,6 +1008,16 @@ const SceneGraph::PropertyBase* CameraActor::GetSceneObjectAnimatableProperty(Pr
     {
       property = GetCameraSceneObject().GetAspectRatio();
       break;
+    }
+    case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
+    {
+      property = GetCameraSceneObject().GetNearPlaneDistance();
+      break;
+    }
+    case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
+    {
+      property = GetCameraSceneObject().GetFarPlaneDistance();
+      break;
     }
       // no default on purpose as we chain method up to actor
   }
@@ -986,14 +1036,14 @@ const PropertyInputImpl* CameraActor::GetSceneObjectInputProperty(Property::Inde
 
   switch(index)
   {
-    case Dali::CameraActor::Property::FIELD_OF_VIEW:
+    case Dali::CameraActor::Property::PROJECTION_MODE:
     {
-      property = GetCameraSceneObject().GetFieldOfView();
+      property = GetCameraSceneObject().GetProjectionMode();
       break;
     }
-    case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
+    case Dali::CameraActor::Property::FIELD_OF_VIEW:
     {
-      property = GetCameraSceneObject().GetOrthographicSize();
+      property = GetCameraSceneObject().GetFieldOfView();
       break;
     }
     case Dali::CameraActor::Property::ASPECT_RATIO:
@@ -1001,6 +1051,16 @@ const PropertyInputImpl* CameraActor::GetSceneObjectInputProperty(Property::Inde
       property = GetCameraSceneObject().GetAspectRatio();
       break;
     }
+    case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
+    {
+      property = GetCameraSceneObject().GetNearPlaneDistance();
+      break;
+    }
+    case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
+    {
+      property = GetCameraSceneObject().GetFarPlaneDistance();
+      break;
+    }
     case Dali::CameraActor::Property::PROJECTION_MATRIX:
     {
       property = GetCameraSceneObject().GetProjectionMatrix();
@@ -1010,6 +1070,21 @@ const PropertyInputImpl* CameraActor::GetSceneObjectInputProperty(Property::Inde
     {
       property = GetCameraSceneObject().GetViewMatrix();
       break;
+    }
+    case Dali::CameraActor::Property::INVERT_Y_AXIS:
+    {
+      property = GetCameraSceneObject().GetInvertYAxis();
+      break;
+    }
+    case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
+    {
+      property = GetCameraSceneObject().GetOrthographicSize();
+      break;
+    }
+    case Dali::DevelCameraActor::Property::PROJECTION_DIRECTION:
+    {
+      property = GetCameraSceneObject().GetProjectionDirection();
+      break;
     }
       // no default on purpose as we chain method up to actor
   }
index 74ccac5f9d66729ca0c5dbef2bd6e9767ff51cfb..3a20af0c6ba9078043057955a257717d4d5ecca1 100644 (file)
@@ -291,6 +291,22 @@ private:
    */
   float GetCurrentAspectRatio() const;
 
+  /**
+   * @brief Retrieve the CameraActor's near clipping plane distance from update side.
+   * This is either the last value set, or the currently animating value.
+   * It may be defferent to GetNearClippingPlane() if the set message hasn't been processed yet.
+   * @return Near clipping plane distance.
+   */
+  float GetCurrentNearClippingPlane() const;
+
+  /**
+   * @brief Retrieve the CameraActor's far clipping plane distance from update side.
+   * This is either the last value set, or the currently animating value.
+   * It may be defferent to GetFarClippingPlane() if the set message hasn't been processed yet.
+   * @return Far clipping plane distance.
+   */
+  float GetCurrentFarClippingPlane() const;
+
 private: // Data
   Vector3                                     mTarget;
   Vector2                                     mCanvasSize;
index f22fc11538f30ba24016187ff0cb9fa023b8410e..cb75c1beef3c06bc95b7fedf4f96008131963d10 100644 (file)
@@ -536,7 +536,7 @@ void RenderInstructionProcessor::Prepare(BufferIndex                 updateBuffe
 
   const Matrix&             viewMatrix           = renderTask.GetViewMatrix(updateBufferIndex);
   const SceneGraph::Camera& camera               = renderTask.GetCamera();
-  const bool                isOrthographicCamera = camera.mProjectionMode == Dali::Camera::ProjectionMode::ORTHOGRAPHIC_PROJECTION;
+  const bool                isOrthographicCamera = camera.mProjectionMode[0] == Dali::Camera::ProjectionMode::ORTHOGRAPHIC_PROJECTION;
 
   Viewport viewport;
   bool     viewportSet = renderTask.QueryViewport(updateBufferIndex, viewport);
index 5ff3e8dcd95158fe8887bcf4eb8c19370cdee9d6..af69f8804bea382eb8430f7ab9e4dd0e7897c72b 100644 (file)
@@ -124,26 +124,38 @@ inline void BakeAspectRatioMessage(EventThreadServices& eventThreadServices, con
   AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter);
 }
 
-inline void SetNearClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
+inline void BakeNearClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
 {
-  using LocalType = MessageValue1<Camera, float>;
+  using LocalType = MessageDoubleBuffered1<Camera, float>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new(slot) LocalType(&camera, &Camera::SetNearClippingPlane, parameter);
+  new(slot) LocalType(&camera, &Camera::BakeNearClippingPlane, parameter);
+
+  OwnerPointer<SceneGraph::PropertyResetterBase> resetter(
+    new SceneGraph::BakerResetter(const_cast<SceneGraph::Camera*>(&camera),
+                                  const_cast<SceneGraph::AnimatableProperty<float>*>(&camera.mNearClippingPlane),
+                                  BakerResetter::Lifetime::BAKE));
+  AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter);
 }
 
-inline void SetFarClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
+inline void BakeFarClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
 {
-  using LocalType = MessageValue1<Camera, float>;
+  using LocalType = MessageDoubleBuffered1<Camera, float>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new(slot) LocalType(&camera, &Camera::SetFarClippingPlane, parameter);
+  new(slot) LocalType(&camera, &Camera::BakeFarClippingPlane, parameter);
+
+  OwnerPointer<SceneGraph::PropertyResetterBase> resetter(
+    new SceneGraph::BakerResetter(const_cast<SceneGraph::Camera*>(&camera),
+                                  const_cast<SceneGraph::AnimatableProperty<float>*>(&camera.mFarClippingPlane),
+                                  BakerResetter::Lifetime::BAKE));
+  AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter);
 }
 
 inline void SetReflectByPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, const Vector4& plane)
index f714fb4acc10ac62ae3e609a10942ce0a4a59c33..d044c6cca98f14b90cb8cb917142c815b0387aff 100644 (file)
@@ -377,19 +377,19 @@ void Camera::SetType(Dali::Camera::Type type)
 
 void Camera::SetProjectionMode(Dali::Camera::ProjectionMode mode)
 {
-  mProjectionMode       = mode;
+  mProjectionMode.Bake(0, mode);
   mUpdateProjectionFlag = UPDATE_COUNT;
 }
 
 void Camera::SetProjectionDirection(Dali::DevelCameraActor::ProjectionDirection direction)
 {
-  mProjectionDirection  = direction;
+  mProjectionDirection.Bake(0, direction);
   mUpdateProjectionFlag = UPDATE_COUNT;
 }
 
 void Camera::SetInvertYAxis(bool invertYAxis)
 {
-  mInvertYAxis          = invertYAxis;
+  mInvertYAxis.Bake(0, invertYAxis);
   mUpdateProjectionFlag = UPDATE_COUNT;
 }
 
@@ -411,15 +411,15 @@ void Camera::BakeAspectRatio(BufferIndex updateBufferIndex, float aspectRatio)
   mUpdateProjectionFlag = UPDATE_COUNT;
 }
 
-void Camera::SetNearClippingPlane(float nearClippingPlane)
+void Camera::BakeNearClippingPlane(BufferIndex updateBufferIndex, float nearClippingPlane)
 {
-  mNearClippingPlane    = nearClippingPlane;
+  mNearClippingPlane.Bake(updateBufferIndex, nearClippingPlane);
   mUpdateProjectionFlag = UPDATE_COUNT;
 }
 
-void Camera::SetFarClippingPlane(float farClippingPlane)
+void Camera::BakeFarClippingPlane(BufferIndex updateBufferIndex, float farClippingPlane)
 {
-  mFarClippingPlane     = farClippingPlane;
+  mFarClippingPlane.Bake(updateBufferIndex, farClippingPlane);
   mUpdateProjectionFlag = UPDATE_COUNT;
 }
 
@@ -498,14 +498,14 @@ const Matrix& Camera::GetFinalProjectionMatrix(BufferIndex bufferIndex) const
   return mFinalProjection[bufferIndex];
 }
 
-const PropertyBase* Camera::GetFieldOfView() const
+const PropertyBase* Camera::GetProjectionMode() const
 {
-  return &mFieldOfView;
+  return &mProjectionMode;
 }
 
-const PropertyBase* Camera::GetOrthographicSize() const
+const PropertyBase* Camera::GetFieldOfView() const
 {
-  return &mOrthographicSize;
+  return &mFieldOfView;
 }
 
 const PropertyBase* Camera::GetAspectRatio() const
@@ -513,6 +513,16 @@ const PropertyBase* Camera::GetAspectRatio() const
   return &mAspectRatio;
 }
 
+const PropertyBase* Camera::GetNearPlaneDistance() const
+{
+  return &mNearClippingPlane;
+}
+
+const PropertyBase* Camera::GetFarPlaneDistance() const
+{
+  return &mFarClippingPlane;
+}
+
 const PropertyInputImpl* Camera::GetProjectionMatrix() const
 {
   return &mProjectionMatrix;
@@ -523,6 +533,21 @@ const PropertyInputImpl* Camera::GetViewMatrix() const
   return &mViewMatrix;
 }
 
+const PropertyBase* Camera::GetInvertYAxis() const
+{
+  return &mInvertYAxis;
+}
+
+const PropertyBase* Camera::GetOrthographicSize() const
+{
+  return &mOrthographicSize;
+}
+
+const PropertyBase* Camera::GetProjectionDirection() const
+{
+  return &mProjectionDirection;
+}
+
 void Camera::Update(BufferIndex updateBufferIndex)
 {
   // if this has changes in world position we need to update camera for next 2 frames
@@ -788,8 +813,8 @@ Dali::Rect<int32_t> Camera::GetOrthographicClippingBox(BufferIndex bufferIndex)
   const float orthographicSize = mOrthographicSize[bufferIndex];
   const float aspect           = mAspectRatio[bufferIndex];
 
-  const float halfWidth  = mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? orthographicSize * aspect : orthographicSize;
-  const float halfHeight = mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? orthographicSize : orthographicSize / aspect;
+  const float halfWidth  = mProjectionDirection[0] == DevelCameraActor::ProjectionDirection::VERTICAL ? orthographicSize * aspect : orthographicSize;
+  const float halfHeight = mProjectionDirection[0] == DevelCameraActor::ProjectionDirection::VERTICAL ? orthographicSize : orthographicSize / aspect;
 
   return Dali::Rect<int32_t>(-halfWidth, -halfHeight, halfWidth * 2.0f, halfHeight * 2.0f);
 }
@@ -812,18 +837,18 @@ uint32_t Camera::UpdateProjection(BufferIndex updateBufferIndex)
     }
     else // UPDATE_COUNT == mUpdateProjectionFlag
     {
-      switch(mProjectionMode)
+      switch(mProjectionMode[0])
       {
         case Dali::Camera::PERSPECTIVE_PROJECTION:
         {
           Matrix& projectionMatrix = mProjectionMatrix.Get(updateBufferIndex);
           Perspective(projectionMatrix,
-                      mProjectionDirection,
+                      static_cast<Dali::DevelCameraActor::ProjectionDirection>(mProjectionDirection[0]),
                       mFieldOfView[updateBufferIndex],
                       mAspectRatio[updateBufferIndex],
-                      mNearClippingPlane,
-                      mFarClippingPlane,
-                      mInvertYAxis);
+                      mNearClippingPlane[updateBufferIndex],
+                      mFarClippingPlane[updateBufferIndex],
+                      mInvertYAxis[0]);
 
           //need to apply custom clipping plane
           if(mUseReflectionClip)
@@ -842,7 +867,7 @@ uint32_t Camera::UpdateProjection(BufferIndex updateBufferIndex)
             }
 
             Vector4 customClipping = viewInv * adjReflectPlane;
-            AdjustNearPlaneForPerspective(projectionMatrix, customClipping, mFarClippingPlane);
+            AdjustNearPlaneForPerspective(projectionMatrix, customClipping, mFarClippingPlane[updateBufferIndex]);
           }
           break;
         }
@@ -850,12 +875,12 @@ uint32_t Camera::UpdateProjection(BufferIndex updateBufferIndex)
         {
           Matrix& projectionMatrix = mProjectionMatrix.Get(updateBufferIndex);
           Orthographic(projectionMatrix,
-                       mProjectionDirection,
+                      static_cast<Dali::DevelCameraActor::ProjectionDirection>(mProjectionDirection[0]),
                        mOrthographicSize[updateBufferIndex],
                        mAspectRatio[updateBufferIndex],
-                       mNearClippingPlane,
-                       mFarClippingPlane,
-                       mInvertYAxis);
+                       mNearClippingPlane[updateBufferIndex],
+                       mFarClippingPlane[updateBufferIndex],
+                       mInvertYAxis[0]);
 
           //need to apply custom clipping plane
           if(mUseReflectionClip)
@@ -874,7 +899,7 @@ uint32_t Camera::UpdateProjection(BufferIndex updateBufferIndex)
             }
 
             Vector4 customClipping = viewInv * adjReflectPlane;
-            AdjustNearPlaneForOrthographic(projectionMatrix, customClipping, mFarClippingPlane);
+            AdjustNearPlaneForOrthographic(projectionMatrix, customClipping, mFarClippingPlane[updateBufferIndex]);
           }
           break;
         }
index 016c80933919e8d3393efe2a02fc518614bcb913..ae51349f46e79203f6b38725f6f6d0ebcfac8025 100644 (file)
@@ -35,6 +35,25 @@ namespace SceneGraph
 {
 class SceneController;
 
+template<>
+class AnimatableProperty<Dali::Camera::ProjectionMode> : public AnimatableProperty<int>
+{
+public:
+  AnimatableProperty(Dali::Camera::ProjectionMode initialValue)
+  : AnimatableProperty<int>(static_cast<int>(initialValue))
+  {
+  }
+};
+template<>
+class AnimatableProperty<Dali::DevelCameraActor::ProjectionDirection> : public AnimatableProperty<int>
+{
+public:
+  AnimatableProperty(Dali::DevelCameraActor::ProjectionDirection initialValue)
+  : AnimatableProperty<int>(static_cast<int>(initialValue))
+  {
+  }
+};
+
 /**
  * Scene-graph camera object
  */
@@ -108,7 +127,7 @@ public:
    */
   bool IsYAxisInverted() const
   {
-    return mInvertYAxis;
+    return mInvertYAxis[0];
   }
 
   /**
@@ -141,16 +160,6 @@ public:
    */
   void SetBottomClippingPlane(float bottomClippingPlane);
 
-  /**
-   * @copydoc Dali::Internal::CameraActor::SetNearClippingPlane
-   */
-  void SetNearClippingPlane(float nearClippingPlane);
-
-  /**
-   * @copydoc Dali::Internal::CameraActor::SetFarClippingPlane
-   */
-  void SetFarClippingPlane(float farClippingPlane);
-
   /**
    * @copydoc Dali::Internal::CameraActor::RotateProjection
    */
@@ -212,6 +221,40 @@ public:
     return mAspectRatio[bufferIndex];
   }
 
+  /**
+   * @brief Bakes the near clipping plane distance.
+   * @param[in] updateBufferIndex The current update buffer index.
+   * @param[in] nearClippingPlane The near clipping plane distance.
+   */
+  void BakeNearClippingPlane(BufferIndex updateBufferIndex, float nearClippingPlane);
+
+  /**
+   * @brief Retrieve the near clipping plane distance.
+   * @param[in] bufferIndex The buffer to read from.
+   * @return The near clipping plane distance.
+   */
+  float GetNearClippingPlane(BufferIndex bufferIndex) const
+  {
+    return mNearClippingPlane[bufferIndex];
+  }
+
+  /**
+   * @brief Bakes the far clipping plane distance.
+   * @param[in] updateBufferIndex The current update buffer index.
+   * @param[in] farClippingPlane The far clipping plane distance.
+   */
+  void BakeFarClippingPlane(BufferIndex updateBufferIndex, float farClippingPlane);
+
+  /**
+   * @brief Retrieve the far clipping plane distance.
+   * @param[in] bufferIndex The buffer to read from.
+   * @return The far clipping plane distance.
+   */
+  float GetFarClippingPlane(BufferIndex bufferIndex) const
+  {
+    return mFarClippingPlane[bufferIndex];
+  }
+
   /**
    * Sets the reflection plane
    * @param[in] plane reflection plane
@@ -283,18 +326,18 @@ public:
   const Matrix& GetFinalProjectionMatrix(BufferIndex bufferIndex) const;
 
   /**
-   * Retrieve the field of view property querying interface.
+   * Retrieve the projection mode property querying interface.
    * @pre The camera is on-stage.
-   * @return The field of view property querying interface.
+   * @return The projection mode property querying interface.
    */
-  const PropertyBase* GetFieldOfView() const;
+  const PropertyBase* GetProjectionMode() const;
 
   /**
-   * Retrieve the orthographic size property querying interface.
+   * Retrieve the field of view property querying interface.
    * @pre The camera is on-stage.
-   * @return The orthographic size property querying interface.
+   * @return The field of view property querying interface.
    */
-  const PropertyBase* GetOrthographicSize() const;
+  const PropertyBase* GetFieldOfView() const;
 
   /**
    * Retrieve the aspect ratio property querying interface.
@@ -303,6 +346,20 @@ public:
    */
   const PropertyBase* GetAspectRatio() const;
 
+  /**
+   * Retrieve the near clipping plane distance property querying interface.
+   * @pre The camera is on-stage.
+   * @return The near clipping plane distance property querying interface.
+   */
+  const PropertyBase* GetNearPlaneDistance() const;
+
+  /**
+   * Retrieve the far clipping plane distance property querying interface.
+   * @pre The camera is on-stage.
+   * @return The far clipping plane distance property querying interface.
+   */
+  const PropertyBase* GetFarPlaneDistance() const;
+
   /**
    * Retrieve the projection-matrix property querying interface.
    * @pre The camera is on-stage.
@@ -317,6 +374,27 @@ public:
    */
   const PropertyInputImpl* GetViewMatrix() const;
 
+  /**
+   * Retrieve the value of InvertYAxis property querying interface.
+   * @pre The camera is on-stage.
+   * @return The InvertYAxis property value querying interface.
+   */
+  const PropertyBase* GetInvertYAxis() const;
+
+  /**
+   * Retrieve the orthographic size property querying interface.
+   * @pre The camera is on-stage.
+   * @return The orthographic size property querying interface.
+   */
+  const PropertyBase* GetOrthographicSize() const;
+
+  /**
+   * Retrieve the value of Projection Direction property querying interface.
+   * @pre The camera is on-stage.
+   * @return The Projection Direction property value querying interface.
+   */
+  const PropertyBase* GetProjectionDirection() const;
+
   /**
    * Updates view and projection matrices.
    * Called by the render task using the camera
@@ -379,18 +457,18 @@ private:
   uint32_t mUpdateProjectionFlag; ///< This is non-zero if the projection matrix requires an update
   int      mProjectionRotation;   ///< The rotaion angle of the projection
 
-public:                                                             // PROPERTIES
-  Dali::Camera::Type                          mType;                // Non-animatable
-  Dali::Camera::ProjectionMode                mProjectionMode;      // Non-animatable
-  Dali::DevelCameraActor::ProjectionDirection mProjectionDirection; // Non-animatable
-  bool                                        mInvertYAxis;         // Non-animatable
+public:                           // PROPERTIES
+  Dali::Camera::Type                                              mType;                // Non-animatable
+  AnimatableProperty<Dali::Camera::ProjectionMode>                mProjectionMode;      // Non-animatable, constraint_input
+  AnimatableProperty<Dali::DevelCameraActor::ProjectionDirection> mProjectionDirection; // Non-animatable, constraint_input
+  AnimatableProperty<bool>                                        mInvertYAxis;         // Non-animatable, constraint_input
 
-  AnimatableProperty<float> mFieldOfView;      // Animatable
-  AnimatableProperty<float> mOrthographicSize; // Animatable
-  AnimatableProperty<float> mAspectRatio;      // Animatable
+  AnimatableProperty<float> mFieldOfView;                                               // Animatable
+  AnimatableProperty<float> mOrthographicSize;                                          // Animatable
+  AnimatableProperty<float> mAspectRatio;                                               // Animatable
+  AnimatableProperty<float> mNearClippingPlane;                                         // Animatable
+  AnimatableProperty<float> mFarClippingPlane;                                          // Animatable
 
-  float   mNearClippingPlane;
-  float   mFarClippingPlane;
   Vector3 mTargetPosition;
 
   Dali::Matrix  mReflectionMtx;
index 5f5268b21480e66ed5b2b108758faab9bfa41cf6..3c3fb33d44399ea4b1acf90a71e5c12402d91868 100644 (file)
@@ -106,8 +106,8 @@ public:
      */
     enum
     {
-      TYPE = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, ///< name "type",                  type std::string @SINCE_1_0.0
-      PROJECTION_MODE,                                   ///< name "projectionMode",        type std::string @SINCE_1_0.0
+      TYPE = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, ///< name "type",                  type int @SINCE_1_0.0
+      PROJECTION_MODE,                                   ///< name "projectionMode",        type int @SINCE_1_0.0
       FIELD_OF_VIEW,                                     ///< name "fieldOfView",           type float @SINCE_1_0.0
       ASPECT_RATIO,                                      ///< name "aspectRatio",           type float @SINCE_1_0.0
       NEAR_PLANE_DISTANCE,                               ///< name "nearPlaneDistance",     type float @SINCE_1_0.0