[Tizen] Make TransformManager check WorldMatrix dirty, instead local matrix dirty
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Tue, 13 Aug 2024 04:51:38 +0000 (13:51 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Tue, 13 Aug 2024 04:51:40 +0000 (13:51 +0900)
This reverts commit 1836241cef5a8a2c13563c819cd335faa2a4725f.

dali/internal/update/manager/transform-manager.cpp
dali/internal/update/manager/transform-manager.h
dali/internal/update/manager/update-algorithms.cpp
dali/internal/update/nodes/node.h
dali/internal/update/render-tasks/scene-graph-camera.cpp

index 4375ad8..cdee80f 100644 (file)
@@ -114,7 +114,7 @@ TransformId TransformManager::CreateTransform()
     mTxComponentAnimatableBaseValue.PushBack(TransformComponentAnimatable());
     mSizeBase.PushBack(Vector3(0.0f, 0.0f, 0.0f));
     mComponentDirty.PushBack(CLEAN_FLAG);
-    mLocalMatrixDirty.PushBack(false);
+    mWorldMatrixDirty.PushBack(false);
   }
   else
   {
@@ -131,7 +131,7 @@ TransformId TransformManager::CreateTransform()
     mBoundingSpheres[mComponentCount]  = Vector4(0.0f, 0.0f, 0.0f, 0.0f);
     mSizeBase[mComponentCount]         = Vector3(0.0f, 0.0f, 0.0f);
     mComponentDirty[mComponentCount]   = CLEAN_FLAG;
-    mLocalMatrixDirty[mComponentCount] = false;
+    mWorldMatrixDirty[mComponentCount] = false;
   }
 
   mComponentCount++;
@@ -153,7 +153,7 @@ void TransformManager::RemoveTransform(TransformId id)
   mTxComponentAnimatableBaseValue[index] = mTxComponentAnimatableBaseValue[mComponentCount];
   mSizeBase[index]                       = mSizeBase[mComponentCount];
   mComponentDirty[index]                 = mComponentDirty[mComponentCount];
-  mLocalMatrixDirty[index]               = mLocalMatrixDirty[mComponentCount];
+  mWorldMatrixDirty[index]               = mWorldMatrixDirty[mComponentCount];
   mBoundingSpheres[index]                = mBoundingSpheres[mComponentCount];
 
   TransformId lastItemId = mComponentId[mComponentCount];
@@ -250,7 +250,7 @@ void TransformManager::ResetToBaseValue()
 
     if(mUpdated)
     {
-      memset(&mLocalMatrixDirty[0], false, sizeof(bool) * mComponentCount);
+      memset(&mWorldMatrixDirty[0], false, sizeof(bool) * mComponentCount);
     }
   }
 }
@@ -290,9 +290,10 @@ bool TransformManager::Update()
       const TransformId& parentIndex = mIds[mParent[i]];
       if(DALI_LIKELY(mInheritanceMode[i] == INHERIT_ALL))
       {
-        if(mComponentDirty[i] || mLocalMatrixDirty[parentIndex])
+        if(mComponentDirty[i] || mWorldMatrixDirty[parentIndex])
         {
-          mLocalMatrixDirty[i] = true;
+          // TODO : Skip world matrix comparision. Is it improve performance?
+          mWorldMatrixDirty[i] = true;
 
           //Full transform inherited
           CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, mSize[i], half, topLeft);
@@ -305,8 +306,8 @@ bool TransformManager::Update()
       }
       else
       {
-        // Keep previous localMatrix for comparison.
-        Matrix previousLocalMatrix = mLocal[i];
+        // Keep previous worldMatrix for comparison.
+        Matrix previousWorldMatrix = mWorld[i];
 
         // Get Parent information.
         Vector3       parentPosition, parentScale;
@@ -368,14 +369,18 @@ bool TransformManager::Update()
         inverseParentMatrix.SetInverseTransformComponents(parentScale, parentOrientation, parentPosition);
         mLocal[i] = inverseParentMatrix * mWorld[i];
 
-        mLocalMatrixDirty[i] = mComponentDirty[i] || (previousLocalMatrix != mLocal[i]);
+        // TODO : We need to check mComponentDirty since we have to check the size changeness.
+        //        Could we check size changeness only?
+        mWorldMatrixDirty[i] = mComponentDirty[i] || (previousWorldMatrix != mWorld[i]);
       }
     }
     else //Component has no parent or doesn't inherit transform
     {
       if(mComponentDirty[i])
       {
-        mLocalMatrixDirty[i] = true;
+        // TODO : We need to check mComponentDirty since we have to check the size changeness.
+        //        Could we check size changeness only?
+        mWorldMatrixDirty[i] = true;
 
         CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, mSize[i], half, topLeft);
         localPosition = mTxComponentAnimatable[i].mPosition + centerPosition;
@@ -392,7 +397,7 @@ bool TransformManager::Update()
     mBoundingSpheres[i]   = mWorld[i].GetTranslation();
     mBoundingSpheres[i].w = Length(centerToEdgeWorldSpace);
 
-    mUpdated = mUpdated || mLocalMatrixDirty[i];
+    mUpdated = mUpdated || mWorldMatrixDirty[i];
 
     mComponentDirty[i] >>= 1u; ///< age down.
   }
@@ -500,7 +505,7 @@ void TransformManager::ReorderComponents()
     mTxComponentAnimatableBaseValue.Resize(mComponentCount);
     mSizeBase.Resize(mComponentCount);
     mComponentDirty.Resize(mComponentCount);
-    mLocalMatrixDirty.Resize(mComponentCount);
+    mWorldMatrixDirty.Resize(mComponentCount);
     mOrderedComponents.Resize(mComponentCount);
 
     mTxComponentAnimatable.ShrinkToFit();
@@ -515,7 +520,7 @@ void TransformManager::ReorderComponents()
     mTxComponentAnimatableBaseValue.ShrinkToFit();
     mSizeBase.ShrinkToFit();
     mComponentDirty.ShrinkToFit();
-    mLocalMatrixDirty.ShrinkToFit();
+    mWorldMatrixDirty.ShrinkToFit();
     mOrderedComponents.ShrinkToFit();
   }
 #endif
index b304ba1..432399d 100644 (file)
@@ -179,13 +179,13 @@ public:
   Matrix& GetWorldMatrix(TransformId id);
 
   /**
-   * Checks if the local transform was updated in the last Update
+   * Checks if the world transform was updated in the last Update
    * @param[in] id Id of the transform
-   * @return true if local matrix changed in the last update, false otherwise
+   * @return true if world matrix changed in the last update, false otherwise
    */
-  bool IsLocalMatrixDirty(TransformId id) const
+  bool IsWorldMatrixDirty(TransformId id) const
   {
-    return mLocalMatrixDirty[mIds[id]];
+    return mWorldMatrixDirty[mIds[id]];
   }
 
   /**
@@ -422,7 +422,7 @@ private:
                                                                         ///< Or If we change static component changed, flag become non-zero. Age down at Update time.
                                                                         ///< Note that we don't replace dirty flag as BAKE even if we call Bake operation.
                                                                         ///< (Since single dirty flag controls multiple animatable properties ; Position, Size, Scale, Orientation.)
-  Vector<bool>       mLocalMatrixDirty;                                 ///< 1u if the local matrix has been updated in this frame, 0 otherwise
+  Vector<bool>       mWorldMatrixDirty;                                 ///< 1u if the local matrix has been updated in this frame, 0 otherwise
   Vector<SOrderItem> mOrderedComponents;                                ///< Used to reorder components when hierarchy changes
 
   uint8_t mDirtyFlags : 2; ///< Dirty flags for all transform components. Age down at Update time.
index d70bcaa..1873e30 100644 (file)
@@ -207,7 +207,7 @@ inline void UpdateLayers(Node&             node,
 {
   // Some dirty flags are inherited from parent
   NodePropertyFlags nodeDirtyFlags = node.GetDirtyFlags() | node.GetInheritedDirtyFlags(parentFlags);
-  nodeDirtyFlags |= (node.IsLocalMatrixDirty() ? NodePropertyFlags::TRANSFORM : NodePropertyFlags::NOTHING);
+  nodeDirtyFlags |= (node.IsWorldMatrixDirty() ? NodePropertyFlags::TRANSFORM : NodePropertyFlags::NOTHING);
 
   Layer* nodeIsLayer(node.GetLayer());
   Layer* layer = nodeIsLayer ? nodeIsLayer : &currentLayer;
@@ -255,7 +255,7 @@ void UpdateLayerTree(Layer&      layer,
                      BufferIndex updateBufferIndex)
 {
   NodePropertyFlags nodeDirtyFlags = layer.GetDirtyFlags();
-  nodeDirtyFlags |= (layer.IsLocalMatrixDirty() ? NodePropertyFlags::TRANSFORM : NodePropertyFlags::NOTHING);
+  nodeDirtyFlags |= (layer.IsWorldMatrixDirty() ? NodePropertyFlags::TRANSFORM : NodePropertyFlags::NOTHING);
 
   layer.SetReuseRenderers(updateBufferIndex, nodeDirtyFlags == NodePropertyFlags::NOTHING);
 
index 00c369a..f614456 100644 (file)
@@ -748,10 +748,10 @@ public:
    * Checks if local matrix has changed since last update
    * @return true if local matrix has changed, false otherwise
    */
-  bool IsLocalMatrixDirty() const
+  bool IsWorldMatrixDirty() const
   {
     return (mTransformManagerData.Id() != INVALID_TRANSFORM_ID) &&
-           (mTransformManagerData.Manager()->IsLocalMatrixDirty(mTransformManagerData.Id()));
+           (mTransformManagerData.Manager()->IsWorldMatrixDirty(mTransformManagerData.Id()));
   }
 
   /**
index 5fb143c..68e47ea 100644 (file)
@@ -556,7 +556,7 @@ const PropertyBase* Camera::GetProjectionDirection() const
 void Camera::Update(BufferIndex updateBufferIndex)
 {
   // if this has changes in world position we need to update camera for next 2 frames
-  if(IsLocalMatrixDirty())
+  if(IsWorldMatrixDirty())
   {
     mUpdateViewFlag = UPDATE_COUNT;
   }