Since ResetToBaseValue for TransfromProperty doesn't use basic
AnimatableProperty logic, the dirty flag is not match with common sence.
To match it as frame-by-frame, let we make component dirty as 2 bit,
and age-down every frame.
And after we allow to use dirty flag feature for transform,
we can determine whether we need to re-calculate matrix or not.
If that flag be used, we can 'skip' heavy matrix multiply operation.
Change-Id: Icf51e0be37962bee5147c08bb0cd3302bf203f89
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
*/
virtual void OnSet()
{
*/
virtual void OnSet()
{
- mDirtyFlags |= SET_FLAG;
+ mDirtyFlags = SET_FLAG;
*/
virtual void OnBake()
{
*/
virtual void OnBake()
{
- mDirtyFlags |= BAKED_FLAG;
+ mDirtyFlags = BAKED_FLAG;
- mDirtyFlags |= RESET_FLAG;
+ mDirtyFlags = RESET_FLAG;
}
public: // From PropertyBase
}
public: // From PropertyBase
//INTERNAL INCLUDES
#include <dali/internal/common/math.h>
#include <dali/internal/common/matrix-utils.h>
//INTERNAL INCLUDES
#include <dali/internal/common/math.h>
#include <dali/internal/common/matrix-utils.h>
+#include <dali/internal/update/common/animatable-property.h> ///< for SET_FLAG and BAKE_FLAG
#include <dali/public-api/common/constants.h>
#include <dali/integration-api/debug.h>
#include <dali/public-api/common/constants.h>
#include <dali/integration-api/debug.h>
//Default values for anchor point (CENTER) and parent origin (TOP_LEFT)
static const float gDefaultTransformComponentStaticData[] = {0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.5f, true};
//Default values for anchor point (CENTER) and parent origin (TOP_LEFT)
static const float gDefaultTransformComponentStaticData[] = {0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.5f, true};
+static const uint32_t STATIC_COMPONENT_FLAG = 0x01; ///< Indicates that the value when we change static transform components, so need to update at least 1 frame.
+
static_assert(sizeof(gDefaultTransformComponentAnimatableData) == sizeof(TransformComponentAnimatable), "gDefaultTransformComponentAnimatableData should have the same number of floats as specified in TransformComponentAnimatable");
static_assert(sizeof(gDefaultTransformComponentStaticData) == sizeof(TransformComponentStatic), "gDefaultTransformComponentStaticData should have the same number of floats as specified in TransformComponentStatic");
static_assert(sizeof(gDefaultTransformComponentAnimatableData) == sizeof(TransformComponentAnimatable), "gDefaultTransformComponentAnimatableData should have the same number of floats as specified in TransformComponentAnimatable");
static_assert(sizeof(gDefaultTransformComponentStaticData) == sizeof(TransformComponentStatic), "gDefaultTransformComponentStaticData should have the same number of floats as specified in TransformComponentStatic");
mBoundingSpheres.PushBack(Vector4(0.0f, 0.0f, 0.0f, 0.0f));
mTxComponentAnimatableBaseValue.PushBack(TransformComponentAnimatable());
mSizeBase.PushBack(Vector3(0.0f, 0.0f, 0.0f));
mBoundingSpheres.PushBack(Vector4(0.0f, 0.0f, 0.0f, 0.0f));
mTxComponentAnimatableBaseValue.PushBack(TransformComponentAnimatable());
mSizeBase.PushBack(Vector3(0.0f, 0.0f, 0.0f));
- mComponentDirty.PushBack(false);
+ mComponentDirty.PushBack(CLEAN_FLAG);
mLocalMatrixDirty.PushBack(false);
}
else
mLocalMatrixDirty.PushBack(false);
}
else
mWorld[mComponentCount].SetIdentity();
mBoundingSpheres[mComponentCount] = Vector4(0.0f, 0.0f, 0.0f, 0.0f);
mSizeBase[mComponentCount] = Vector3(0.0f, 0.0f, 0.0f);
mWorld[mComponentCount].SetIdentity();
mBoundingSpheres[mComponentCount] = Vector4(0.0f, 0.0f, 0.0f, 0.0f);
mSizeBase[mComponentCount] = Vector3(0.0f, 0.0f, 0.0f);
- mComponentDirty[mComponentCount] = false;
+ mComponentDirty[mComponentCount] = CLEAN_FLAG;
mLocalMatrixDirty[mComponentCount] = false;
}
mLocalMatrixDirty[mComponentCount] = false;
}
void TransformManager::SetParent(TransformId id, TransformId parentId)
{
DALI_ASSERT_ALWAYS(id != parentId);
void TransformManager::SetParent(TransformId id, TransformId parentId)
{
DALI_ASSERT_ALWAYS(id != parentId);
- TransformId index = mIds[id];
- mParent[index] = parentId;
- mComponentDirty[index] = true;
- mReorder = true;
+
+ TransformId index = mIds[id];
+ mParent[index] = parentId;
+ mComponentDirty[index] |= STATIC_COMPONENT_FLAG; ///< Need to calculate local matrix, at least 1 frame.
+
+ mReorder = true;
}
const Matrix& TransformManager::GetWorldMatrix(TransformId id) const
}
const Matrix& TransformManager::GetWorldMatrix(TransformId id) const
mInheritanceMode[index] &= ~INHERIT_POSITION;
}
mInheritanceMode[index] &= ~INHERIT_POSITION;
}
- mComponentDirty[index] = true;
+ mComponentDirty[index] |= STATIC_COMPONENT_FLAG;
}
void TransformManager::SetInheritScale(TransformId id, bool inherit)
}
void TransformManager::SetInheritScale(TransformId id, bool inherit)
mInheritanceMode[index] &= ~INHERIT_SCALE;
}
mInheritanceMode[index] &= ~INHERIT_SCALE;
}
- mComponentDirty[index] = true;
+ mComponentDirty[index] |= STATIC_COMPONENT_FLAG;
}
void TransformManager::SetInheritOrientation(TransformId id, bool inherit)
}
void TransformManager::SetInheritOrientation(TransformId id, bool inherit)
mInheritanceMode[index] &= ~INHERIT_ORIENTATION;
}
mInheritanceMode[index] &= ~INHERIT_ORIENTATION;
}
- mComponentDirty[index] = true;
+ mComponentDirty[index] |= STATIC_COMPONENT_FLAG;
}
void TransformManager::ResetToBaseValue()
}
void TransformManager::ResetToBaseValue()
mBoundingSpheres[i] = mWorld[i].GetTranslation();
mBoundingSpheres[i].w = Length(centerToEdgeWorldSpace);
mBoundingSpheres[i] = mWorld[i].GetTranslation();
mBoundingSpheres[i].w = Length(centerToEdgeWorldSpace);
- componentsChanged = componentsChanged || mComponentDirty[i];
- mComponentDirty[i] = false;
+ componentsChanged = componentsChanged || mComponentDirty[i];
+ mComponentDirty[i] >>= 1u; ///< age down.
}
DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_TRANSFORM_UPDATE", [&](std::ostringstream& oss) {
}
DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_TRANSFORM_UPDATE", [&](std::ostringstream& oss) {
void TransformManager::SetVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
{
TransformId index(mIds[id]);
void TransformManager::SetVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
{
TransformId index(mIds[id]);
- mComponentDirty[index] = true;
switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
+ mComponentDirty[index] = SET_FLAG;
mTxComponentAnimatable[index].mPosition = value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
mTxComponentAnimatable[index].mPosition = value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
+ mComponentDirty[index] = SET_FLAG;
mTxComponentAnimatable[index].mScale = value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
mTxComponentAnimatable[index].mScale = value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
+ mComponentDirty[index] |= STATIC_COMPONENT_FLAG;
mTxComponentStatic[index].mParentOrigin = value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
mTxComponentStatic[index].mParentOrigin = value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
+ mComponentDirty[index] |= STATIC_COMPONENT_FLAG;
mTxComponentStatic[index].mAnchorPoint = value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
mTxComponentStatic[index].mAnchorPoint = value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
+ mComponentDirty[index] = SET_FLAG;
+ mSize[index] = value;
void TransformManager::SetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
{
TransformId index(mIds[id]);
void TransformManager::SetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
{
TransformId index(mIds[id]);
- mComponentDirty[index] = true;
switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
+ mComponentDirty[index] = SET_FLAG;
mTxComponentAnimatable[index].mPosition[component] = value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
mTxComponentAnimatable[index].mPosition[component] = value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
+ mComponentDirty[index] = SET_FLAG;
mTxComponentAnimatable[index].mScale[component] = value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
mTxComponentAnimatable[index].mScale[component] = value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
+ mComponentDirty[index] |= STATIC_COMPONENT_FLAG;
mTxComponentStatic[index].mParentOrigin[component] = value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
mTxComponentStatic[index].mParentOrigin[component] = value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
+ mComponentDirty[index] |= STATIC_COMPONENT_FLAG;
mTxComponentStatic[index].mAnchorPoint[component] = value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
mTxComponentStatic[index].mAnchorPoint[component] = value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
+ mComponentDirty[index] = SET_FLAG;
mSize[index][component] = value;
break;
}
mSize[index][component] = value;
break;
}
void TransformManager::BakeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
{
TransformId index(mIds[id]);
void TransformManager::BakeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
{
TransformId index(mIds[id]);
- mComponentDirty[index] = true;
+ mComponentDirty[index] |= BAKED_FLAG;
void TransformManager::BakeRelativeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
{
TransformId index(mIds[id]);
void TransformManager::BakeRelativeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
{
TransformId index(mIds[id]);
- mComponentDirty[index] = true;
+ mComponentDirty[index] |= BAKED_FLAG;
void TransformManager::BakeMultiplyVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
{
TransformId index(mIds[id]);
void TransformManager::BakeMultiplyVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
{
TransformId index(mIds[id]);
- mComponentDirty[index] = true;
+ mComponentDirty[index] |= BAKED_FLAG;
void TransformManager::BakeVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
{
TransformId index(mIds[id]);
void TransformManager::BakeVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
{
TransformId index(mIds[id]);
- mComponentDirty[index] = true;
+ mComponentDirty[index] |= BAKED_FLAG;
void TransformManager::BakeXVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
{
TransformId index(mIds[id]);
void TransformManager::BakeXVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
{
TransformId index(mIds[id]);
- mComponentDirty[index] = true;
+ mComponentDirty[index] |= BAKED_FLAG;
void TransformManager::BakeYVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
{
TransformId index(mIds[id]);
void TransformManager::BakeYVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
{
TransformId index(mIds[id]);
- mComponentDirty[index] = true;
+ mComponentDirty[index] |= BAKED_FLAG;
void TransformManager::BakeZVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
{
TransformId index(mIds[id]);
void TransformManager::BakeZVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
{
TransformId index(mIds[id]);
- mComponentDirty[index] = true;
+ mComponentDirty[index] |= BAKED_FLAG;
void TransformManager::SetQuaternionPropertyValue(TransformId id, const Quaternion& q)
{
TransformId index(mIds[id]);
void TransformManager::SetQuaternionPropertyValue(TransformId id, const Quaternion& q)
{
TransformId index(mIds[id]);
+ mComponentDirty[index] = SET_FLAG;
+
mTxComponentAnimatable[index].mOrientation = q;
mTxComponentAnimatable[index].mOrientation = q;
- mComponentDirty[index] = true;
}
void TransformManager::BakeQuaternionPropertyValue(TransformId id, const Quaternion& q)
{
TransformId index(mIds[id]);
}
void TransformManager::BakeQuaternionPropertyValue(TransformId id, const Quaternion& q)
{
TransformId index(mIds[id]);
+ mComponentDirty[index] |= BAKED_FLAG;
+
mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
- mComponentDirty[index] = true;
}
void TransformManager::BakeRelativeQuaternionPropertyValue(TransformId id, const Quaternion& q)
{
TransformId index(mIds[id]);
}
void TransformManager::BakeRelativeQuaternionPropertyValue(TransformId id, const Quaternion& q)
{
TransformId index(mIds[id]);
+ mComponentDirty[index] |= BAKED_FLAG;
+
mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[index].mOrientation * q;
mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[index].mOrientation * q;
- mComponentDirty[index] = true;
}
const Vector4& TransformManager::GetBoundingSphere(TransformId id) const
}
const Vector4& TransformManager::GetBoundingSphere(TransformId id) const
void TransformManager::SetPositionUsesAnchorPoint(TransformId id, bool value)
{
TransformId index(mIds[id]);
void TransformManager::SetPositionUsesAnchorPoint(TransformId id, bool value)
{
TransformId index(mIds[id]);
- mComponentDirty[index] = true;
+ mComponentDirty[index] |= STATIC_COMPONENT_FLAG;
+
mTxComponentStatic[index].mPositionUsesAnchorPoint = value;
}
mTxComponentStatic[index].mPositionUsesAnchorPoint = value;
}
#define DALI_INTERNAL_TRANSFORM_MANAGER_H
/*
#define DALI_INTERNAL_TRANSFORM_MANAGER_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Vector<Vector4> mBoundingSpheres; ///< Bounding spheres. xyz is the center and w is the radius
Vector<TransformComponentAnimatable> mTxComponentAnimatableBaseValue; ///< Base values for the animatable part of the components
Vector<Vector3> mSizeBase; ///< Base value for the size of the components
Vector<Vector4> mBoundingSpheres; ///< Bounding spheres. xyz is the center and w is the radius
Vector<TransformComponentAnimatable> mTxComponentAnimatableBaseValue; ///< Base values for the animatable part of the components
Vector<Vector3> mSizeBase; ///< Base value for the size of the components
- Vector<bool> mComponentDirty; ///< 1u if some of the parts of the component has changed in this frame, 0 otherwise
- Vector<bool> mLocalMatrixDirty; ///< 1u if the local matrix has been updated in this frame, 0 otherwise
- Vector<SOrderItem> mOrderedComponents; ///< Used to reorder components when hierarchy changes
- bool mReorder; ///< Flag to determine if the components have to reordered in the next Update
+ Vector<uint8_t> mComponentDirty; ///< Dirty flags for each component. Follow as animatable property's dirty flag.
+ ///< 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<SOrderItem> mOrderedComponents; ///< Used to reorder components when hierarchy changes
+
+ bool mReorder : 1; ///< Flag to determine if the components have to reordered in the next Update
};
} //namespace SceneGraph
};
} //namespace SceneGraph