2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/update/manager/transform-manager.h>
24 #include <type_traits>
27 #include <dali/internal/common/math.h>
28 #include <dali/internal/common/matrix-utils.h>
29 #include <dali/public-api/common/constants.h>
39 //Default values for scale (1.0,1.0,1.0), orientation (Identity) and position (0.0,0.0,0.0)
40 static const float gDefaultTransformComponentAnimatableData[] = {1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f};
42 //Default values for anchor point (CENTER) and parent origin (TOP_LEFT)
43 static const float gDefaultTransformComponentStaticData[] = {0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.5f, true};
45 static_assert(sizeof(gDefaultTransformComponentAnimatableData) == sizeof(TransformComponentAnimatable), "gDefaultTransformComponentAnimatableData should have the same number of floats as specified in TransformComponentAnimatable");
46 static_assert(sizeof(gDefaultTransformComponentStaticData) == sizeof(TransformComponentStatic), "gDefaultTransformComponentStaticData should have the same number of floats as specified in TransformComponentStatic");
49 * @brief Calculates the center position for the transform component
50 * @param[out] centerPosition The calculated center-position of the transform component
51 * @param[in] transformComponentStatic A const reference to the static component transform struct
52 * @param[in] transformComponentAnimatable A const reference to the animatable component transform struct
53 * @param[in] size The size of the current transform component
54 * @param[in] half Halfway point of the transform
55 * @param[in] topLeft The top-left coords of the transform
57 inline void CalculateCenterPosition(
58 Vector3& centerPosition,
59 const TransformComponentStatic& transformComponentStatic,
60 const TransformComponentAnimatable& transformComponentAnimatable,
63 const Vector3& topLeft)
65 // Calculate the center-point by applying the scale and rotation on the anchor point.
66 centerPosition = (half - transformComponentStatic.mAnchorPoint) * size * transformComponentAnimatable.mScale;
67 centerPosition *= transformComponentAnimatable.mOrientation;
69 // If the position is ignoring the anchor-point, then remove the anchor-point shift from the position.
70 if(!transformComponentStatic.mPositionUsesAnchorPoint)
72 centerPosition -= (topLeft - transformComponentStatic.mAnchorPoint) * size;
76 } // unnamed namespace
78 TransformManager::TransformManager()
84 TransformManager::~TransformManager() = default;
86 TransformId TransformManager::CreateTransform()
88 //Get id for the new component
89 TransformId id = mIds.Add(mComponentCount);
91 if(mTxComponentAnimatable.Size() <= mComponentCount)
93 //Make room for another component
94 mTxComponentAnimatable.PushBack(TransformComponentAnimatable());
95 mTxComponentStatic.PushBack(TransformComponentStatic());
96 mInheritanceMode.PushBack(INHERIT_ALL);
97 mComponentId.PushBack(id);
98 mSize.PushBack(Vector3(0.0f, 0.0f, 0.0f));
99 mParent.PushBack(INVALID_TRANSFORM_ID);
100 mWorld.PushBack(Matrix::IDENTITY);
101 mLocal.PushBack(Matrix::IDENTITY);
102 mBoundingSpheres.PushBack(Vector4(0.0f, 0.0f, 0.0f, 0.0f));
103 mTxComponentAnimatableBaseValue.PushBack(TransformComponentAnimatable());
104 mSizeBase.PushBack(Vector3(0.0f, 0.0f, 0.0f));
105 mComponentDirty.PushBack(false);
106 mLocalMatrixDirty.PushBack(false);
111 memcpy(&mTxComponentAnimatable[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof(TransformComponentAnimatable));
112 memcpy(&mTxComponentStatic[mComponentCount], &gDefaultTransformComponentStaticData, sizeof(TransformComponentStatic));
113 memcpy(&mTxComponentAnimatableBaseValue[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof(TransformComponentAnimatable));
114 mInheritanceMode[mComponentCount] = INHERIT_ALL;
115 mComponentId[mComponentCount] = id;
116 mSize[mComponentCount] = Vector3(0.0f, 0.0f, 0.0f);
117 mParent[mComponentCount] = INVALID_TRANSFORM_ID;
118 mLocal[mComponentCount].SetIdentity();
119 mWorld[mComponentCount].SetIdentity();
120 mBoundingSpheres[mComponentCount] = Vector4(0.0f, 0.0f, 0.0f, 0.0f);
121 mSizeBase[mComponentCount] = Vector3(0.0f, 0.0f, 0.0f);
122 mComponentDirty[mComponentCount] = false;
123 mLocalMatrixDirty[mComponentCount] = false;
130 void TransformManager::RemoveTransform(TransformId id)
132 //Move the last element to the gap
134 TransformId index = mIds[id];
135 mTxComponentAnimatable[index] = mTxComponentAnimatable[mComponentCount];
136 mTxComponentStatic[index] = mTxComponentStatic[mComponentCount];
137 mInheritanceMode[index] = mInheritanceMode[mComponentCount];
138 mSize[index] = mSize[mComponentCount];
139 mParent[index] = mParent[mComponentCount];
140 mWorld[index] = mWorld[mComponentCount];
141 mLocal[index] = mLocal[mComponentCount];
142 mTxComponentAnimatableBaseValue[index] = mTxComponentAnimatableBaseValue[mComponentCount];
143 mSizeBase[index] = mSizeBase[mComponentCount];
144 mComponentDirty[index] = mComponentDirty[mComponentCount];
145 mLocalMatrixDirty[index] = mLocalMatrixDirty[mComponentCount];
146 mBoundingSpheres[index] = mBoundingSpheres[mComponentCount];
148 TransformId lastItemId = mComponentId[mComponentCount];
149 mIds[lastItemId] = index;
150 mComponentId[index] = lastItemId;
156 void TransformManager::SetParent(TransformId id, TransformId parentId)
158 DALI_ASSERT_ALWAYS(id != parentId);
159 TransformId index = mIds[id];
160 mParent[index] = parentId;
161 mComponentDirty[index] = true;
165 const Matrix& TransformManager::GetWorldMatrix(TransformId id) const
167 return mWorld[mIds[id]];
170 Matrix& TransformManager::GetWorldMatrix(TransformId id)
172 return mWorld[mIds[id]];
175 void TransformManager::SetInheritPosition(TransformId id, bool inherit)
177 TransformId index = mIds[id];
180 mInheritanceMode[index] |= INHERIT_POSITION;
184 mInheritanceMode[index] &= ~INHERIT_POSITION;
187 mComponentDirty[index] = true;
190 void TransformManager::SetInheritScale(TransformId id, bool inherit)
192 TransformId index = mIds[id];
195 mInheritanceMode[index] |= INHERIT_SCALE;
199 mInheritanceMode[index] &= ~INHERIT_SCALE;
202 mComponentDirty[index] = true;
205 void TransformManager::SetInheritOrientation(TransformId id, bool inherit)
207 TransformId index = mIds[id];
210 mInheritanceMode[index] |= INHERIT_ORIENTATION;
214 mInheritanceMode[index] &= ~INHERIT_ORIENTATION;
217 mComponentDirty[index] = true;
220 void TransformManager::ResetToBaseValue()
224 memcpy(&mTxComponentAnimatable[0], &mTxComponentAnimatableBaseValue[0], sizeof(TransformComponentAnimatable) * mComponentCount);
225 memcpy(&mSize[0], &mSizeBase[0], sizeof(Vector3) * mComponentCount);
226 memset(&mLocalMatrixDirty[0], false, sizeof(bool) * mComponentCount);
230 bool TransformManager::Update()
232 bool componentsChanged = false;
236 //If some transform component has change its parent or has been removed since last update
237 //we need to reorder the vectors
242 //Iterate through all components to compute its world matrix
243 Vector3 centerPosition;
244 Vector3 localPosition;
245 const Vector3 half(0.5f, 0.5f, 0.5f);
246 const Vector3 topLeft(0.0f, 0.0f, 0.5f);
247 for(unsigned int i(0); i < mComponentCount; ++i)
249 if(DALI_LIKELY(mInheritanceMode[i] != DONT_INHERIT_TRANSFORM && mParent[i] != INVALID_TRANSFORM_ID))
251 const TransformId& parentIndex = mIds[mParent[i]];
252 if(DALI_LIKELY(mInheritanceMode[i] == INHERIT_ALL))
254 if(mComponentDirty[i] || mLocalMatrixDirty[parentIndex])
256 //Full transform inherited
257 mLocalMatrixDirty[i] = true;
258 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
259 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + (mTxComponentStatic[i].mParentOrigin - half) * mSize[parentIndex];
260 mLocal[i].SetTransformComponents(mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition);
263 //Update the world matrix
264 MatrixUtils::Multiply(mWorld[i], mLocal[i], mWorld[parentIndex]);
268 //Some components are not inherited
269 Vector3 parentPosition, parentScale;
270 Quaternion parentOrientation;
271 const Matrix& parentMatrix = mWorld[parentIndex];
272 parentMatrix.GetTransformComponents(parentPosition, parentOrientation, parentScale);
274 Vector3 localScale = mTxComponentAnimatable[i].mScale;
275 if((mInheritanceMode[i] & INHERIT_SCALE) == 0)
277 //Don't inherit scale
278 localScale /= parentScale;
281 Quaternion localOrientation(mTxComponentAnimatable[i].mOrientation);
282 if((mInheritanceMode[i] & INHERIT_ORIENTATION) == 0)
284 //Don't inherit orientation
285 parentOrientation.Invert();
286 localOrientation = parentOrientation * mTxComponentAnimatable[i].mOrientation;
289 Matrix localMatrix = mLocal[i];
291 if((mInheritanceMode[i] & INHERIT_POSITION) == 0)
293 //Don't inherit position
294 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
295 mLocal[i].SetTransformComponents(localScale, localOrientation, Vector3::ZERO);
296 MatrixUtils::Multiply(mWorld[i], mLocal[i], parentMatrix);
297 mWorld[i].SetTranslation(mTxComponentAnimatable[i].mPosition + centerPosition);
301 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
302 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + (mTxComponentStatic[i].mParentOrigin - half) * mSize[parentIndex];
303 mLocal[i].SetTransformComponents(localScale, localOrientation, localPosition);
304 MatrixUtils::Multiply(mWorld[i], mLocal[i], parentMatrix);
307 mLocalMatrixDirty[i] = mComponentDirty[i] || (localMatrix != mLocal[i]);
310 else //Component has no parent or doesn't inherit transform
312 Matrix localMatrix = mLocal[i];
313 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
314 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition;
315 mLocal[i].SetTransformComponents(mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition);
316 mWorld[i] = mLocal[i];
317 mLocalMatrixDirty[i] = mComponentDirty[i] || (localMatrix != mLocal[i]);
320 //Update the bounding sphere
321 Vec3 centerToEdge = {mSize[i].Length() * 0.5f, 0.0f, 0.0f};
322 Vec3 centerToEdgeWorldSpace;
323 TransformVector3(centerToEdgeWorldSpace, mWorld[i].AsFloat(), centerToEdge);
325 mBoundingSpheres[i] = mWorld[i].GetTranslation();
326 mBoundingSpheres[i].w = Length(centerToEdgeWorldSpace);
328 componentsChanged = componentsChanged || mComponentDirty[i];
329 mComponentDirty[i] = false;
332 return componentsChanged;
335 void TransformManager::SwapComponents(unsigned int i, unsigned int j)
337 std::swap(mTxComponentAnimatable[i], mTxComponentAnimatable[j]);
338 std::swap(mTxComponentStatic[i], mTxComponentStatic[j]);
339 std::swap(mInheritanceMode[i], mInheritanceMode[j]);
340 std::swap(mSize[i], mSize[j]);
341 std::swap(mParent[i], mParent[j]);
342 std::swap(mComponentId[i], mComponentId[j]);
343 std::swap(mTxComponentAnimatableBaseValue[i], mTxComponentAnimatableBaseValue[j]);
344 std::swap(mSizeBase[i], mSizeBase[j]);
345 std::swap(mLocal[i], mLocal[j]);
346 std::swap(mComponentDirty[i], mComponentDirty[j]);
347 std::swap(mBoundingSpheres[i], mBoundingSpheres[j]);
348 std::swap(mWorld[i], mWorld[j]);
350 mIds[mComponentId[i]] = i;
351 mIds[mComponentId[j]] = j;
354 void TransformManager::ReorderComponents()
356 mOrderedComponents.Resize(mComponentCount);
358 uint16_t sceneId = 0u;
359 TransformId parentId;
361 // Create sceneId first
362 for(TransformId i = 0; i < mComponentCount; ++i)
364 mOrderedComponents[i].id = mComponentId[i];
365 mOrderedComponents[i].level = 0u;
367 parentId = mParent[i];
368 if(parentId == INVALID_TRANSFORM_ID)
370 mOrderedComponents[i].sceneId = sceneId++;
374 // Propagate sceneId and level
375 for(TransformId i = 0; i < mComponentCount; ++i)
377 parentId = mParent[i];
378 while(parentId != INVALID_TRANSFORM_ID)
380 const uint32_t parentIndex = mIds[parentId];
381 ++mOrderedComponents[i].level;
382 mOrderedComponents[i].sceneId = mOrderedComponents[parentIndex].sceneId;
385 // Parent information update done. We can reuse it.
386 mOrderedComponents[i].level += mOrderedComponents[parentIndex].level;
391 parentId = mParent[parentIndex];
396 std::stable_sort(mOrderedComponents.Begin(), mOrderedComponents.End());
397 TransformId previousIndex = 0;
398 for(TransformId newIndex = 0; newIndex < mComponentCount - 1; ++newIndex)
400 previousIndex = mIds[mOrderedComponents[newIndex].id];
401 if(previousIndex != newIndex)
403 SwapComponents(previousIndex, newIndex);
408 Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property)
412 case TRANSFORM_PROPERTY_POSITION:
414 TransformId index(mIds[id]);
415 return mTxComponentAnimatable[index].mPosition;
417 case TRANSFORM_PROPERTY_SCALE:
419 TransformId index(mIds[id]);
420 return mTxComponentAnimatable[index].mScale;
422 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
424 TransformId index(mIds[id]);
425 return mTxComponentStatic[index].mParentOrigin;
427 case TRANSFORM_PROPERTY_ANCHOR_POINT:
429 TransformId index(mIds[id]);
430 return mTxComponentStatic[index].mAnchorPoint;
432 case TRANSFORM_PROPERTY_SIZE:
434 TransformId index(mIds[id]);
439 DALI_ASSERT_ALWAYS(false);
440 return mTxComponentAnimatable[mIds[id]].mPosition;
445 const Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property) const
449 case TRANSFORM_PROPERTY_POSITION:
451 return mTxComponentAnimatable[mIds[id]].mPosition;
453 case TRANSFORM_PROPERTY_SCALE:
455 return mTxComponentAnimatable[mIds[id]].mScale;
457 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
459 return mTxComponentStatic[mIds[id]].mParentOrigin;
461 case TRANSFORM_PROPERTY_ANCHOR_POINT:
463 return mTxComponentStatic[mIds[id]].mAnchorPoint;
465 case TRANSFORM_PROPERTY_SIZE:
467 return mSize[mIds[id]];
471 DALI_ASSERT_ALWAYS(false);
472 return mTxComponentAnimatable[mIds[id]].mPosition;
477 const float& TransformManager::GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, unsigned int component) const
481 case TRANSFORM_PROPERTY_POSITION:
483 return mTxComponentAnimatable[mIds[id]].mPosition[component];
485 case TRANSFORM_PROPERTY_SCALE:
487 return mTxComponentAnimatable[mIds[id]].mScale[component];
489 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
491 return mTxComponentStatic[mIds[id]].mParentOrigin[component];
493 case TRANSFORM_PROPERTY_ANCHOR_POINT:
495 return mTxComponentStatic[mIds[id]].mAnchorPoint[component];
497 case TRANSFORM_PROPERTY_SIZE:
499 return mSize[mIds[id]][component];
503 DALI_ASSERT_ALWAYS(false);
504 return mTxComponentAnimatable[mIds[id]].mPosition[component];
509 void TransformManager::SetVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
511 TransformId index(mIds[id]);
512 mComponentDirty[index] = true;
516 case TRANSFORM_PROPERTY_POSITION:
518 mTxComponentAnimatable[index].mPosition = value;
521 case TRANSFORM_PROPERTY_SCALE:
523 mTxComponentAnimatable[index].mScale = value;
526 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
528 mTxComponentStatic[index].mParentOrigin = value;
531 case TRANSFORM_PROPERTY_ANCHOR_POINT:
533 mTxComponentStatic[index].mAnchorPoint = value;
536 case TRANSFORM_PROPERTY_SIZE:
538 mSize[index] = value;
543 DALI_ASSERT_ALWAYS(false);
548 void TransformManager::SetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
550 TransformId index(mIds[id]);
551 mComponentDirty[index] = true;
555 case TRANSFORM_PROPERTY_POSITION:
557 mTxComponentAnimatable[index].mPosition[component] = value;
560 case TRANSFORM_PROPERTY_SCALE:
562 mTxComponentAnimatable[index].mScale[component] = value;
565 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
567 mTxComponentStatic[index].mParentOrigin[component] = value;
570 case TRANSFORM_PROPERTY_ANCHOR_POINT:
572 mTxComponentStatic[index].mAnchorPoint[component] = value;
575 case TRANSFORM_PROPERTY_SIZE:
577 mSize[index][component] = value;
582 DALI_ASSERT_ALWAYS(false);
587 void TransformManager::BakeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
589 TransformId index(mIds[id]);
590 mComponentDirty[index] = true;
594 case TRANSFORM_PROPERTY_POSITION:
596 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = value;
599 case TRANSFORM_PROPERTY_SCALE:
601 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = value;
604 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
606 mTxComponentStatic[index].mParentOrigin = value;
609 case TRANSFORM_PROPERTY_ANCHOR_POINT:
611 mTxComponentStatic[index].mAnchorPoint = value;
614 case TRANSFORM_PROPERTY_SIZE:
616 mSize[index] = mSizeBase[index] = value;
621 DALI_ASSERT_ALWAYS(false);
626 void TransformManager::BakeRelativeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
628 TransformId index(mIds[id]);
629 mComponentDirty[index] = true;
633 case TRANSFORM_PROPERTY_POSITION:
635 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition + value;
638 case TRANSFORM_PROPERTY_SCALE:
640 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale + value;
643 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
645 mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin + value;
648 case TRANSFORM_PROPERTY_ANCHOR_POINT:
650 mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint + value;
653 case TRANSFORM_PROPERTY_SIZE:
655 mSize[index] = mSizeBase[index] = mSize[index] + value;
660 DALI_ASSERT_ALWAYS(false);
665 void TransformManager::BakeMultiplyVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
667 TransformId index(mIds[id]);
668 mComponentDirty[index] = true;
672 case TRANSFORM_PROPERTY_POSITION:
674 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition * value;
677 case TRANSFORM_PROPERTY_SCALE:
679 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale * value;
682 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
684 mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin * value;
687 case TRANSFORM_PROPERTY_ANCHOR_POINT:
689 mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint * value;
692 case TRANSFORM_PROPERTY_SIZE:
694 mSize[index] = mSizeBase[index] = mSize[index] * value;
699 DALI_ASSERT_ALWAYS(false);
704 void TransformManager::BakeVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
706 TransformId index(mIds[id]);
707 mComponentDirty[index] = true;
711 case TRANSFORM_PROPERTY_POSITION:
713 mTxComponentAnimatable[index].mPosition[component] = mTxComponentAnimatableBaseValue[index].mPosition[component] = value;
716 case TRANSFORM_PROPERTY_SCALE:
718 mTxComponentAnimatable[index].mScale[component] = mTxComponentAnimatableBaseValue[index].mScale[component] = value;
721 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
723 mTxComponentStatic[index].mParentOrigin[component] = value;
726 case TRANSFORM_PROPERTY_ANCHOR_POINT:
728 mTxComponentStatic[index].mAnchorPoint[component] = value;
731 case TRANSFORM_PROPERTY_SIZE:
733 mSize[index][component] = mSizeBase[index][component] = value;
738 DALI_ASSERT_ALWAYS(false);
743 void TransformManager::BakeXVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
745 TransformId index(mIds[id]);
746 mComponentDirty[index] = true;
750 case TRANSFORM_PROPERTY_POSITION:
752 mTxComponentAnimatable[index].mPosition.x = mTxComponentAnimatableBaseValue[index].mPosition.x = value;
755 case TRANSFORM_PROPERTY_SCALE:
757 mTxComponentAnimatable[index].mScale.x = mTxComponentAnimatableBaseValue[index].mScale.x = value;
760 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
762 mTxComponentStatic[index].mParentOrigin.x = value;
765 case TRANSFORM_PROPERTY_ANCHOR_POINT:
767 mTxComponentStatic[index].mAnchorPoint.x = value;
770 case TRANSFORM_PROPERTY_SIZE:
772 mSize[index].x = mSizeBase[index].x = value;
777 DALI_ASSERT_ALWAYS(false);
782 void TransformManager::BakeYVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
784 TransformId index(mIds[id]);
785 mComponentDirty[index] = true;
789 case TRANSFORM_PROPERTY_POSITION:
791 mTxComponentAnimatable[index].mPosition.y = mTxComponentAnimatableBaseValue[index].mPosition.y = value;
794 case TRANSFORM_PROPERTY_SCALE:
796 mTxComponentAnimatable[index].mScale.y = mTxComponentAnimatableBaseValue[index].mScale.y = value;
799 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
801 mTxComponentStatic[index].mParentOrigin.y = value;
804 case TRANSFORM_PROPERTY_ANCHOR_POINT:
806 mTxComponentStatic[index].mAnchorPoint.y = value;
809 case TRANSFORM_PROPERTY_SIZE:
811 mSize[index].y = mSizeBase[index].y = value;
816 DALI_ASSERT_ALWAYS(false);
821 void TransformManager::BakeZVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
823 TransformId index(mIds[id]);
824 mComponentDirty[index] = true;
828 case TRANSFORM_PROPERTY_POSITION:
830 mTxComponentAnimatable[index].mPosition.z = mTxComponentAnimatableBaseValue[index].mPosition.z = value;
833 case TRANSFORM_PROPERTY_SCALE:
835 mTxComponentAnimatable[index].mScale.z = mTxComponentAnimatableBaseValue[index].mScale.z = value;
838 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
840 mTxComponentStatic[index].mParentOrigin.z = value;
843 case TRANSFORM_PROPERTY_ANCHOR_POINT:
845 mTxComponentStatic[index].mAnchorPoint.z = value;
848 case TRANSFORM_PROPERTY_SIZE:
850 mSize[index].z = mSizeBase[index].z = value;
855 DALI_ASSERT_ALWAYS(false);
860 Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id)
862 TransformId index(mIds[id]);
863 return mTxComponentAnimatable[index].mOrientation;
866 const Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id) const
868 return mTxComponentAnimatable[mIds[id]].mOrientation;
871 void TransformManager::SetQuaternionPropertyValue(TransformId id, const Quaternion& q)
873 TransformId index(mIds[id]);
874 mTxComponentAnimatable[index].mOrientation = q;
875 mComponentDirty[index] = true;
878 void TransformManager::BakeQuaternionPropertyValue(TransformId id, const Quaternion& q)
880 TransformId index(mIds[id]);
881 mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
882 mComponentDirty[index] = true;
885 void TransformManager::BakeRelativeQuaternionPropertyValue(TransformId id, const Quaternion& q)
887 TransformId index(mIds[id]);
888 mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[index].mOrientation * q;
889 mComponentDirty[index] = true;
892 const Vector4& TransformManager::GetBoundingSphere(TransformId id) const
894 return mBoundingSpheres[mIds[id]];
897 void TransformManager::GetWorldMatrixAndSize(TransformId id, Matrix& worldMatrix, Vector3& size) const
899 TransformId index = mIds[id];
900 worldMatrix = mWorld[index];
904 void TransformManager::SetPositionUsesAnchorPoint(TransformId id, bool value)
906 TransformId index(mIds[id]);
907 mComponentDirty[index] = true;
908 mTxComponentStatic[index].mPositionUsesAnchorPoint = value;
911 } //namespace SceneGraph
912 } //namespace Internal