Fix SVACE issue
[platform/core/uifw/dali-core.git] / dali / internal / update / render-tasks / scene-graph-camera.cpp
index 158ed37..56e6b9e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -65,7 +65,7 @@ void Frustum(Matrix& result, float left, float right, float bottom, float top, f
   float deltaZ = far - near;
   if ((near <= 0.0f) || (far <= 0.0f) || Equals(right, left) || Equals(bottom, top) || (deltaZ <= 0.0f))
   {
-    DALI_LOG_ERROR("Invalid parameters passed into Frustum!");
+    DALI_LOG_ERROR("Invalid parameters passed into Frustum!\n");
     DALI_ASSERT_DEBUG("Invalid parameters passed into Frustum!");
     return;
   }
@@ -104,7 +104,7 @@ void Orthographic(Matrix& result, float left, float right, float bottom, float t
 {
   if ( Equals(right, left) || Equals(top, bottom) || Equals(far, near) )
   {
-    DALI_LOG_ERROR( "Cannot create orthographic projection matrix with a zero dimension." );
+    DALI_LOG_ERROR( "Cannot create orthographic projection matrix with a zero dimension.\n" );
     DALI_ASSERT_DEBUG( "Cannot create orthographic projection matrix with a zero dimension." );
     return;
   }
@@ -154,6 +154,7 @@ const Vector3 Camera::DEFAULT_TARGET_POSITION( 0.0f, 0.0f, 0.0f );
 Camera::Camera()
 : mUpdateViewFlag( UPDATE_COUNT ),
   mUpdateProjectionFlag( UPDATE_COUNT ),
+  mNode( NULL ),
   mType( DEFAULT_TYPE ),
   mProjectionMode( DEFAULT_MODE ),
   mInvertYAxis( DEFAULT_INVERT_Y_AXIS ),
@@ -182,6 +183,11 @@ Camera::~Camera()
 {
 }
 
+void Camera::SetNode( const Node* node )
+{
+  mNode = node;
+}
+
 void Camera::SetType( Dali::Camera::Type type )
 {
   mType = type;
@@ -284,14 +290,14 @@ const PropertyInputImpl* Camera::GetViewMatrix() const
   return &mViewMatrix;
 }
 
-void Camera::Update( BufferIndex updateBufferIndex, const Node& owningNode )
+void Camera::Update( BufferIndex updateBufferIndex )
 {
   // if owning node has changes in world position we need to update camera for next 2 frames
-  if( owningNode.IsLocalMatrixDirty() )
+  if( mNode->IsLocalMatrixDirty() )
   {
     mUpdateViewFlag = UPDATE_COUNT;
   }
-  if( owningNode.GetDirtyFlags() & VisibleFlag )
+  if( mNode->GetDirtyFlags() & VisibleFlag )
   {
     // If the visibility changes, the projection matrix needs to be re-calculated.
     // It may happen the first time an actor is rendered it's rendered only once and becomes invisible,
@@ -301,7 +307,7 @@ void Camera::Update( BufferIndex updateBufferIndex, const Node& owningNode )
   }
 
   // if either matrix changed, we need to recalculate the inverse matrix for hit testing to work
-  unsigned int viewUpdateCount = UpdateViewMatrix( updateBufferIndex, owningNode );
+  unsigned int viewUpdateCount = UpdateViewMatrix( updateBufferIndex );
   unsigned int projectionUpdateCount = UpdateProjection( updateBufferIndex );
 
   // if model or view matrix changed we need to either recalculate the inverse VP or copy previous
@@ -328,7 +334,7 @@ bool Camera::ViewMatrixUpdated()
   return 0u != mUpdateViewFlag;
 }
 
-unsigned int Camera::UpdateViewMatrix( BufferIndex updateBufferIndex, const Node& owningNode )
+unsigned int Camera::UpdateViewMatrix( BufferIndex updateBufferIndex )
 {
   unsigned int retval( mUpdateViewFlag );
   if( 0u != mUpdateViewFlag )
@@ -346,7 +352,7 @@ unsigned int Camera::UpdateViewMatrix( BufferIndex updateBufferIndex, const Node
         case Dali::Camera::FREE_LOOK:
         {
           Matrix& viewMatrix = mViewMatrix.Get( updateBufferIndex );
-          viewMatrix = owningNode.GetWorldMatrix( updateBufferIndex );
+          viewMatrix = mNode->GetWorldMatrix( updateBufferIndex );
           viewMatrix.Invert();
           mViewMatrix.SetDirty( updateBufferIndex );
           break;
@@ -354,7 +360,7 @@ unsigned int Camera::UpdateViewMatrix( BufferIndex updateBufferIndex, const Node
           // camera orientation constrained to look at a target
         case Dali::Camera::LOOK_AT_TARGET:
         {
-          const Matrix& owningNodeMatrix( owningNode.GetWorldMatrix( updateBufferIndex ) );
+          const Matrix& owningNodeMatrix( mNode->GetWorldMatrix( updateBufferIndex ) );
           Vector3 position, scale;
           Quaternion orientation;
           owningNodeMatrix.GetTransformComponents( position, orientation, scale );