2 * Copyright (c) 2021 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/public-api/common/constants.h>
38 //Default values for scale (1.0,1.0,1.0), orientation (Identity) and position (0.0,0.0,0.0)
39 static const float gDefaultTransformComponentAnimatableData[] = {1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f};
41 //Default values for anchor point (CENTER) and parent origin (TOP_LEFT)
42 static const float gDefaultTransformComponentStaticData[] = {0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.5f, true};
44 static_assert(sizeof(gDefaultTransformComponentAnimatableData) == sizeof(TransformComponentAnimatable), "gDefaultTransformComponentAnimatableData should have the same number of floats as specified in TransformComponentAnimatable");
45 static_assert(sizeof(gDefaultTransformComponentStaticData) == sizeof(TransformComponentStatic), "gDefaultTransformComponentStaticData should have the same number of floats as specified in TransformComponentStatic");
48 * @brief Calculates the center position for the transform component
49 * @param[out] centerPosition The calculated center-position of the transform component
50 * @param[in] transformComponentStatic A const reference to the static component transform struct
51 * @param[in] transformComponentAnimatable A const reference to the animatable component transform struct
52 * @param[in] size The size of the current transform component
53 * @param[in] half Halfway point of the transform
54 * @param[in] topLeft The top-left coords of the transform
56 inline void CalculateCenterPosition(
57 Vector3& centerPosition,
58 const TransformComponentStatic& transformComponentStatic,
59 const TransformComponentAnimatable& transformComponentAnimatable,
62 const Vector3& topLeft)
64 // Calculate the center-point by applying the scale and rotation on the anchor point.
65 centerPosition = (half - transformComponentStatic.mAnchorPoint) * size * transformComponentAnimatable.mScale;
66 centerPosition *= transformComponentAnimatable.mOrientation;
68 // If the position is ignoring the anchor-point, then remove the anchor-point shift from the position.
69 if(!transformComponentStatic.mPositionUsesAnchorPoint)
71 centerPosition -= (topLeft - transformComponentStatic.mAnchorPoint) * size;
75 } // unnamed namespace
77 TransformManager::TransformManager()
83 TransformManager::~TransformManager() = default;
85 TransformId TransformManager::CreateTransform()
87 //Get id for the new component
88 TransformId id = mIds.Add(mComponentCount);
90 if(mTxComponentAnimatable.Size() <= mComponentCount)
92 //Make room for another component
93 mTxComponentAnimatable.PushBack(TransformComponentAnimatable());
94 mTxComponentStatic.PushBack(TransformComponentStatic());
95 mInheritanceMode.PushBack(INHERIT_ALL);
96 mComponentId.PushBack(id);
97 mSize.PushBack(Vector3(0.0f, 0.0f, 0.0f));
98 mParent.PushBack(INVALID_TRANSFORM_ID);
99 mWorld.PushBack(Matrix::IDENTITY);
100 mLocal.PushBack(Matrix::IDENTITY);
101 mBoundingSpheres.PushBack(Vector4(0.0f, 0.0f, 0.0f, 0.0f));
102 mTxComponentAnimatableBaseValue.PushBack(TransformComponentAnimatable());
103 mSizeBase.PushBack(Vector3(0.0f, 0.0f, 0.0f));
104 mComponentDirty.PushBack(false);
105 mLocalMatrixDirty.PushBack(false);
110 memcpy(&mTxComponentAnimatable[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof(TransformComponentAnimatable));
111 memcpy(&mTxComponentStatic[mComponentCount], &gDefaultTransformComponentStaticData, sizeof(TransformComponentStatic));
112 memcpy(&mTxComponentAnimatableBaseValue[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof(TransformComponentAnimatable));
113 mInheritanceMode[mComponentCount] = INHERIT_ALL;
114 mComponentId[mComponentCount] = id;
115 mSize[mComponentCount] = Vector3(0.0f, 0.0f, 0.0f);
116 mParent[mComponentCount] = INVALID_TRANSFORM_ID;
117 mLocal[mComponentCount].SetIdentity();
118 mWorld[mComponentCount].SetIdentity();
119 mBoundingSpheres[mComponentCount] = Vector4(0.0f, 0.0f, 0.0f, 0.0f);
120 mSizeBase[mComponentCount] = Vector3(0.0f, 0.0f, 0.0f);
121 mComponentDirty[mComponentCount] = false;
122 mLocalMatrixDirty[mComponentCount] = false;
129 void TransformManager::RemoveTransform(TransformId id)
131 //Move the last element to the gap
133 TransformId index = mIds[id];
134 mTxComponentAnimatable[index] = mTxComponentAnimatable[mComponentCount];
135 mTxComponentStatic[index] = mTxComponentStatic[mComponentCount];
136 mInheritanceMode[index] = mInheritanceMode[mComponentCount];
137 mSize[index] = mSize[mComponentCount];
138 mParent[index] = mParent[mComponentCount];
139 mWorld[index] = mWorld[mComponentCount];
140 mLocal[index] = mLocal[mComponentCount];
141 mTxComponentAnimatableBaseValue[index] = mTxComponentAnimatableBaseValue[mComponentCount];
142 mSizeBase[index] = mSizeBase[mComponentCount];
143 mComponentDirty[index] = mComponentDirty[mComponentCount];
144 mLocalMatrixDirty[index] = mLocalMatrixDirty[mComponentCount];
145 mBoundingSpheres[index] = mBoundingSpheres[mComponentCount];
147 TransformId lastItemId = mComponentId[mComponentCount];
148 mIds[lastItemId] = index;
149 mComponentId[index] = lastItemId;
155 void TransformManager::SetParent(TransformId id, TransformId parentId)
157 DALI_ASSERT_ALWAYS(id != parentId);
158 TransformId index = mIds[id];
159 mParent[index] = parentId;
160 mComponentDirty[index] = true;
164 const Matrix& TransformManager::GetWorldMatrix(TransformId id) const
166 return mWorld[mIds[id]];
169 Matrix& TransformManager::GetWorldMatrix(TransformId id)
171 return mWorld[mIds[id]];
174 void TransformManager::SetInheritPosition(TransformId id, bool inherit)
176 TransformId index = mIds[id];
179 mInheritanceMode[index] |= INHERIT_POSITION;
183 mInheritanceMode[index] &= ~INHERIT_POSITION;
186 mComponentDirty[index] = true;
189 void TransformManager::SetInheritScale(TransformId id, bool inherit)
191 TransformId index = mIds[id];
194 mInheritanceMode[index] |= INHERIT_SCALE;
198 mInheritanceMode[index] &= ~INHERIT_SCALE;
201 mComponentDirty[index] = true;
204 void TransformManager::SetInheritOrientation(TransformId id, bool inherit)
206 TransformId index = mIds[id];
209 mInheritanceMode[index] |= INHERIT_ORIENTATION;
213 mInheritanceMode[index] &= ~INHERIT_ORIENTATION;
216 mComponentDirty[index] = true;
219 void TransformManager::ResetToBaseValue()
223 memcpy(&mTxComponentAnimatable[0], &mTxComponentAnimatableBaseValue[0], sizeof(TransformComponentAnimatable) * mComponentCount);
224 memcpy(&mSize[0], &mSizeBase[0], sizeof(Vector3) * mComponentCount);
225 memset(&mLocalMatrixDirty[0], false, sizeof(bool) * mComponentCount);
229 bool TransformManager::Update()
231 bool componentsChanged = false;
235 //If some transform component has change its parent or has been removed since last update
236 //we need to reorder the vectors
241 //Iterate through all components to compute its world matrix
242 Vector3 centerPosition;
243 Vector3 localPosition;
244 const Vector3 half(0.5f, 0.5f, 0.5f);
245 const Vector3 topLeft(0.0f, 0.0f, 0.5f);
246 for(unsigned int i(0); i < mComponentCount; ++i)
248 if(DALI_LIKELY(mInheritanceMode[i] != DONT_INHERIT_TRANSFORM && mParent[i] != INVALID_TRANSFORM_ID))
250 const TransformId& parentIndex = mIds[mParent[i]];
251 if(DALI_LIKELY(mInheritanceMode[i] == INHERIT_ALL))
253 if(mComponentDirty[i] || mLocalMatrixDirty[parentIndex])
255 //Full transform inherited
256 mLocalMatrixDirty[i] = true;
257 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
258 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + (mTxComponentStatic[i].mParentOrigin - half) * mSize[parentIndex];
259 mLocal[i].SetTransformComponents(mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition);
262 //Update the world matrix
263 Matrix::Multiply(mWorld[i], mLocal[i], mWorld[parentIndex]);
267 //Some components are not inherited
268 Vector3 parentPosition, parentScale;
269 Quaternion parentOrientation;
270 const Matrix& parentMatrix = mWorld[parentIndex];
271 parentMatrix.GetTransformComponents(parentPosition, parentOrientation, parentScale);
273 Vector3 localScale = mTxComponentAnimatable[i].mScale;
274 if((mInheritanceMode[i] & INHERIT_SCALE) == 0)
276 //Don't inherit scale
277 localScale /= parentScale;
280 Quaternion localOrientation(mTxComponentAnimatable[i].mOrientation);
281 if((mInheritanceMode[i] & INHERIT_ORIENTATION) == 0)
283 //Don't inherit orientation
284 parentOrientation.Invert();
285 localOrientation = parentOrientation * mTxComponentAnimatable[i].mOrientation;
288 if((mInheritanceMode[i] & INHERIT_POSITION) == 0)
290 //Don't inherit position
291 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
292 mLocal[i].SetTransformComponents(localScale, localOrientation, Vector3::ZERO);
293 Matrix::Multiply(mWorld[i], mLocal[i], parentMatrix);
294 mWorld[i].SetTranslation(mTxComponentAnimatable[i].mPosition + centerPosition);
298 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
299 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + (mTxComponentStatic[i].mParentOrigin - half) * mSize[parentIndex];
300 mLocal[i].SetTransformComponents(localScale, localOrientation, localPosition);
301 Matrix::Multiply(mWorld[i], mLocal[i], parentMatrix);
304 mLocalMatrixDirty[i] = true;
307 else //Component has no parent or doesn't inherit transform
309 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
310 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition;
311 mLocal[i].SetTransformComponents(mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition);
312 mWorld[i] = mLocal[i];
313 mLocalMatrixDirty[i] = true;
316 //Update the bounding sphere
317 Vec3 centerToEdge = {mSize[i].Length() * 0.5f, 0.0f, 0.0f};
318 Vec3 centerToEdgeWorldSpace;
319 TransformVector3(centerToEdgeWorldSpace, mWorld[i].AsFloat(), centerToEdge);
321 mBoundingSpheres[i] = mWorld[i].GetTranslation();
322 mBoundingSpheres[i].w = Length(centerToEdgeWorldSpace);
324 componentsChanged = componentsChanged || mComponentDirty[i];
325 mComponentDirty[i] = false;
328 return componentsChanged;
331 void TransformManager::SwapComponents(unsigned int i, unsigned int j)
333 std::swap(mTxComponentAnimatable[i], mTxComponentAnimatable[j]);
334 std::swap(mTxComponentStatic[i], mTxComponentStatic[j]);
335 std::swap(mInheritanceMode[i], mInheritanceMode[j]);
336 std::swap(mSize[i], mSize[j]);
337 std::swap(mParent[i], mParent[j]);
338 std::swap(mComponentId[i], mComponentId[j]);
339 std::swap(mTxComponentAnimatableBaseValue[i], mTxComponentAnimatableBaseValue[j]);
340 std::swap(mSizeBase[i], mSizeBase[j]);
341 std::swap(mLocal[i], mLocal[j]);
342 std::swap(mComponentDirty[i], mComponentDirty[j]);
343 std::swap(mBoundingSpheres[i], mBoundingSpheres[j]);
344 std::swap(mWorld[i], mWorld[j]);
346 mIds[mComponentId[i]] = i;
347 mIds[mComponentId[j]] = j;
350 void TransformManager::ReorderComponents()
352 mOrderedComponents.Resize(mComponentCount);
354 TransformId parentId;
355 for(TransformId i = 0; i < mComponentCount; ++i)
357 mOrderedComponents[i].id = mComponentId[i];
358 mOrderedComponents[i].level = 0u;
360 parentId = mParent[i];
361 while(parentId != INVALID_TRANSFORM_ID)
363 mOrderedComponents[i].level++;
364 parentId = mParent[mIds[parentId]];
368 std::stable_sort(mOrderedComponents.Begin(), mOrderedComponents.End());
369 TransformId previousIndex = 0;
370 for(TransformId newIndex = 0; newIndex < mComponentCount - 1; ++newIndex)
372 previousIndex = mIds[mOrderedComponents[newIndex].id];
373 if(previousIndex != newIndex)
375 SwapComponents(previousIndex, newIndex);
380 Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property)
384 case TRANSFORM_PROPERTY_POSITION:
386 TransformId index(mIds[id]);
387 return mTxComponentAnimatable[index].mPosition;
389 case TRANSFORM_PROPERTY_SCALE:
391 TransformId index(mIds[id]);
392 return mTxComponentAnimatable[index].mScale;
394 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
396 TransformId index(mIds[id]);
397 return mTxComponentStatic[index].mParentOrigin;
399 case TRANSFORM_PROPERTY_ANCHOR_POINT:
401 TransformId index(mIds[id]);
402 return mTxComponentStatic[index].mAnchorPoint;
404 case TRANSFORM_PROPERTY_SIZE:
406 TransformId index(mIds[id]);
411 DALI_ASSERT_ALWAYS(false);
412 return mTxComponentAnimatable[mIds[id]].mPosition;
417 const Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property) const
421 case TRANSFORM_PROPERTY_POSITION:
423 return mTxComponentAnimatable[mIds[id]].mPosition;
425 case TRANSFORM_PROPERTY_SCALE:
427 return mTxComponentAnimatable[mIds[id]].mScale;
429 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
431 return mTxComponentStatic[mIds[id]].mParentOrigin;
433 case TRANSFORM_PROPERTY_ANCHOR_POINT:
435 return mTxComponentStatic[mIds[id]].mAnchorPoint;
437 case TRANSFORM_PROPERTY_SIZE:
439 return mSize[mIds[id]];
443 DALI_ASSERT_ALWAYS(false);
444 return mTxComponentAnimatable[mIds[id]].mPosition;
449 const float& TransformManager::GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, unsigned int component) const
453 case TRANSFORM_PROPERTY_POSITION:
455 return mTxComponentAnimatable[mIds[id]].mPosition[component];
457 case TRANSFORM_PROPERTY_SCALE:
459 return mTxComponentAnimatable[mIds[id]].mScale[component];
461 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
463 return mTxComponentStatic[mIds[id]].mParentOrigin[component];
465 case TRANSFORM_PROPERTY_ANCHOR_POINT:
467 return mTxComponentStatic[mIds[id]].mAnchorPoint[component];
469 case TRANSFORM_PROPERTY_SIZE:
471 return mSize[mIds[id]][component];
475 DALI_ASSERT_ALWAYS(false);
476 return mTxComponentAnimatable[mIds[id]].mPosition[component];
481 void TransformManager::SetVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
483 TransformId index(mIds[id]);
484 mComponentDirty[index] = true;
488 case TRANSFORM_PROPERTY_POSITION:
490 mTxComponentAnimatable[index].mPosition = value;
493 case TRANSFORM_PROPERTY_SCALE:
495 mTxComponentAnimatable[index].mScale = value;
498 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
500 mTxComponentStatic[index].mParentOrigin = value;
503 case TRANSFORM_PROPERTY_ANCHOR_POINT:
505 mTxComponentStatic[index].mAnchorPoint = value;
508 case TRANSFORM_PROPERTY_SIZE:
510 mSize[index] = value;
515 DALI_ASSERT_ALWAYS(false);
520 void TransformManager::SetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
522 TransformId index(mIds[id]);
523 mComponentDirty[index] = true;
527 case TRANSFORM_PROPERTY_POSITION:
529 mTxComponentAnimatable[index].mPosition[component] = value;
532 case TRANSFORM_PROPERTY_SCALE:
534 mTxComponentAnimatable[index].mScale[component] = value;
537 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
539 mTxComponentStatic[index].mParentOrigin[component] = value;
542 case TRANSFORM_PROPERTY_ANCHOR_POINT:
544 mTxComponentStatic[index].mAnchorPoint[component] = value;
547 case TRANSFORM_PROPERTY_SIZE:
549 mSize[index][component] = value;
554 DALI_ASSERT_ALWAYS(false);
559 void TransformManager::BakeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
561 TransformId index(mIds[id]);
562 mComponentDirty[index] = true;
566 case TRANSFORM_PROPERTY_POSITION:
568 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = value;
571 case TRANSFORM_PROPERTY_SCALE:
573 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = value;
576 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
578 mTxComponentStatic[index].mParentOrigin = value;
581 case TRANSFORM_PROPERTY_ANCHOR_POINT:
583 mTxComponentStatic[index].mAnchorPoint = value;
586 case TRANSFORM_PROPERTY_SIZE:
588 mSize[index] = mSizeBase[index] = value;
593 DALI_ASSERT_ALWAYS(false);
598 void TransformManager::BakeRelativeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
600 TransformId index(mIds[id]);
601 mComponentDirty[index] = true;
605 case TRANSFORM_PROPERTY_POSITION:
607 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition + value;
610 case TRANSFORM_PROPERTY_SCALE:
612 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale + value;
615 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
617 mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin + value;
620 case TRANSFORM_PROPERTY_ANCHOR_POINT:
622 mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint + value;
625 case TRANSFORM_PROPERTY_SIZE:
627 mSize[index] = mSizeBase[index] = mSize[index] + value;
632 DALI_ASSERT_ALWAYS(false);
637 void TransformManager::BakeMultiplyVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
639 TransformId index(mIds[id]);
640 mComponentDirty[index] = true;
644 case TRANSFORM_PROPERTY_POSITION:
646 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition * value;
649 case TRANSFORM_PROPERTY_SCALE:
651 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale * value;
654 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
656 mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin * value;
659 case TRANSFORM_PROPERTY_ANCHOR_POINT:
661 mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint * value;
664 case TRANSFORM_PROPERTY_SIZE:
666 mSize[index] = mSizeBase[index] = mSize[index] * value;
671 DALI_ASSERT_ALWAYS(false);
676 void TransformManager::BakeVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
678 TransformId index(mIds[id]);
679 mComponentDirty[index] = true;
683 case TRANSFORM_PROPERTY_POSITION:
685 mTxComponentAnimatable[index].mPosition[component] = mTxComponentAnimatableBaseValue[index].mPosition[component] = value;
688 case TRANSFORM_PROPERTY_SCALE:
690 mTxComponentAnimatable[index].mScale[component] = mTxComponentAnimatableBaseValue[index].mScale[component] = value;
693 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
695 mTxComponentStatic[index].mParentOrigin[component] = value;
698 case TRANSFORM_PROPERTY_ANCHOR_POINT:
700 mTxComponentStatic[index].mAnchorPoint[component] = value;
703 case TRANSFORM_PROPERTY_SIZE:
705 mSize[index][component] = mSizeBase[index][component] = value;
710 DALI_ASSERT_ALWAYS(false);
715 void TransformManager::BakeXVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
717 TransformId index(mIds[id]);
718 mComponentDirty[index] = true;
722 case TRANSFORM_PROPERTY_POSITION:
724 mTxComponentAnimatable[index].mPosition.x = mTxComponentAnimatableBaseValue[index].mPosition.x = value;
727 case TRANSFORM_PROPERTY_SCALE:
729 mTxComponentAnimatable[index].mScale.x = mTxComponentAnimatableBaseValue[index].mScale.x = value;
732 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
734 mTxComponentStatic[index].mParentOrigin.x = value;
737 case TRANSFORM_PROPERTY_ANCHOR_POINT:
739 mTxComponentStatic[index].mAnchorPoint.x = value;
742 case TRANSFORM_PROPERTY_SIZE:
744 mSize[index].x = mSizeBase[index].x = value;
749 DALI_ASSERT_ALWAYS(false);
754 void TransformManager::BakeYVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
756 TransformId index(mIds[id]);
757 mComponentDirty[index] = true;
761 case TRANSFORM_PROPERTY_POSITION:
763 mTxComponentAnimatable[index].mPosition.y = mTxComponentAnimatableBaseValue[index].mPosition.y = value;
766 case TRANSFORM_PROPERTY_SCALE:
768 mTxComponentAnimatable[index].mScale.y = mTxComponentAnimatableBaseValue[index].mScale.y = value;
771 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
773 mTxComponentStatic[index].mParentOrigin.y = value;
776 case TRANSFORM_PROPERTY_ANCHOR_POINT:
778 mTxComponentStatic[index].mAnchorPoint.y = value;
781 case TRANSFORM_PROPERTY_SIZE:
783 mSize[index].y = mSizeBase[index].y = value;
788 DALI_ASSERT_ALWAYS(false);
793 void TransformManager::BakeZVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
795 TransformId index(mIds[id]);
796 mComponentDirty[index] = true;
800 case TRANSFORM_PROPERTY_POSITION:
802 mTxComponentAnimatable[index].mPosition.z = mTxComponentAnimatableBaseValue[index].mPosition.z = value;
805 case TRANSFORM_PROPERTY_SCALE:
807 mTxComponentAnimatable[index].mScale.z = mTxComponentAnimatableBaseValue[index].mScale.z = value;
810 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
812 mTxComponentStatic[index].mParentOrigin.z = value;
815 case TRANSFORM_PROPERTY_ANCHOR_POINT:
817 mTxComponentStatic[index].mAnchorPoint.z = value;
820 case TRANSFORM_PROPERTY_SIZE:
822 mSize[index].z = mSizeBase[index].z = value;
827 DALI_ASSERT_ALWAYS(false);
832 Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id)
834 TransformId index(mIds[id]);
835 return mTxComponentAnimatable[index].mOrientation;
838 const Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id) const
840 return mTxComponentAnimatable[mIds[id]].mOrientation;
843 void TransformManager::SetQuaternionPropertyValue(TransformId id, const Quaternion& q)
845 TransformId index(mIds[id]);
846 mTxComponentAnimatable[index].mOrientation = q;
847 mComponentDirty[index] = true;
850 void TransformManager::BakeQuaternionPropertyValue(TransformId id, const Quaternion& q)
852 TransformId index(mIds[id]);
853 mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
854 mComponentDirty[index] = true;
857 void TransformManager::BakeRelativeQuaternionPropertyValue(TransformId id, const Quaternion& q)
859 TransformId index(mIds[id]);
860 mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[index].mOrientation * q;
861 mComponentDirty[index] = true;
864 const Vector4& TransformManager::GetBoundingSphere(TransformId id) const
866 return mBoundingSpheres[mIds[id]];
869 void TransformManager::GetWorldMatrixAndSize(TransformId id, Matrix& worldMatrix, Vector3& size) const
871 TransformId index = mIds[id];
872 worldMatrix = mWorld[index];
876 void TransformManager::SetPositionUsesAnchorPoint(TransformId id, bool value)
878 TransformId index(mIds[id]);
879 mComponentDirty[index] = true;
880 mTxComponentStatic[index].mPositionUsesAnchorPoint = value;
883 } //namespace SceneGraph
884 } //namespace Internal