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/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 Matrix localMatrix = mLocal[i];
290 if((mInheritanceMode[i] & INHERIT_POSITION) == 0)
292 //Don't inherit position
293 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
294 mLocal[i].SetTransformComponents(localScale, localOrientation, Vector3::ZERO);
295 Matrix::Multiply(mWorld[i], mLocal[i], parentMatrix);
296 mWorld[i].SetTranslation(mTxComponentAnimatable[i].mPosition + centerPosition);
300 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
301 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + (mTxComponentStatic[i].mParentOrigin - half) * mSize[parentIndex];
302 mLocal[i].SetTransformComponents(localScale, localOrientation, localPosition);
303 Matrix::Multiply(mWorld[i], mLocal[i], parentMatrix);
306 mLocalMatrixDirty[i] = mComponentDirty[i] || (localMatrix != mLocal[i]);
309 else //Component has no parent or doesn't inherit transform
311 Matrix localMatrix = mLocal[i];
312 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
313 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition;
314 mLocal[i].SetTransformComponents(mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition);
315 mWorld[i] = mLocal[i];
316 mLocalMatrixDirty[i] = mComponentDirty[i] || (localMatrix != mLocal[i]);
319 //Update the bounding sphere
320 Vec3 centerToEdge = {mSize[i].Length() * 0.5f, 0.0f, 0.0f};
321 Vec3 centerToEdgeWorldSpace;
322 TransformVector3(centerToEdgeWorldSpace, mWorld[i].AsFloat(), centerToEdge);
324 mBoundingSpheres[i] = mWorld[i].GetTranslation();
325 mBoundingSpheres[i].w = Length(centerToEdgeWorldSpace);
327 componentsChanged = componentsChanged || mComponentDirty[i];
328 mComponentDirty[i] = false;
331 return componentsChanged;
334 void TransformManager::SwapComponents(unsigned int i, unsigned int j)
336 std::swap(mTxComponentAnimatable[i], mTxComponentAnimatable[j]);
337 std::swap(mTxComponentStatic[i], mTxComponentStatic[j]);
338 std::swap(mInheritanceMode[i], mInheritanceMode[j]);
339 std::swap(mSize[i], mSize[j]);
340 std::swap(mParent[i], mParent[j]);
341 std::swap(mComponentId[i], mComponentId[j]);
342 std::swap(mTxComponentAnimatableBaseValue[i], mTxComponentAnimatableBaseValue[j]);
343 std::swap(mSizeBase[i], mSizeBase[j]);
344 std::swap(mLocal[i], mLocal[j]);
345 std::swap(mComponentDirty[i], mComponentDirty[j]);
346 std::swap(mBoundingSpheres[i], mBoundingSpheres[j]);
347 std::swap(mWorld[i], mWorld[j]);
349 mIds[mComponentId[i]] = i;
350 mIds[mComponentId[j]] = j;
353 void TransformManager::ReorderComponents()
355 mOrderedComponents.Resize(mComponentCount);
357 uint16_t sceneId = 0u;
358 TransformId parentId;
360 // Create sceneId first
361 for(TransformId i = 0; i < mComponentCount; ++i)
363 mOrderedComponents[i].id = mComponentId[i];
364 mOrderedComponents[i].level = 0u;
366 parentId = mParent[i];
367 if(parentId == INVALID_TRANSFORM_ID)
369 mOrderedComponents[i].sceneId = sceneId++;
373 // Propagate sceneId and level
374 for(TransformId i = 0; i < mComponentCount; ++i)
376 parentId = mParent[i];
377 while(parentId != INVALID_TRANSFORM_ID)
379 const uint32_t parentIndex = mIds[parentId];
380 ++mOrderedComponents[i].level;
381 mOrderedComponents[i].sceneId = mOrderedComponents[parentIndex].sceneId;
384 // Parent information update done. We can reuse it.
385 mOrderedComponents[i].level += mOrderedComponents[parentIndex].level;
390 parentId = mParent[parentIndex];
395 std::stable_sort(mOrderedComponents.Begin(), mOrderedComponents.End());
396 TransformId previousIndex = 0;
397 for(TransformId newIndex = 0; newIndex < mComponentCount - 1; ++newIndex)
399 previousIndex = mIds[mOrderedComponents[newIndex].id];
400 if(previousIndex != newIndex)
402 SwapComponents(previousIndex, newIndex);
407 Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property)
411 case TRANSFORM_PROPERTY_POSITION:
413 TransformId index(mIds[id]);
414 return mTxComponentAnimatable[index].mPosition;
416 case TRANSFORM_PROPERTY_SCALE:
418 TransformId index(mIds[id]);
419 return mTxComponentAnimatable[index].mScale;
421 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
423 TransformId index(mIds[id]);
424 return mTxComponentStatic[index].mParentOrigin;
426 case TRANSFORM_PROPERTY_ANCHOR_POINT:
428 TransformId index(mIds[id]);
429 return mTxComponentStatic[index].mAnchorPoint;
431 case TRANSFORM_PROPERTY_SIZE:
433 TransformId index(mIds[id]);
438 DALI_ASSERT_ALWAYS(false);
439 return mTxComponentAnimatable[mIds[id]].mPosition;
444 const Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property) const
448 case TRANSFORM_PROPERTY_POSITION:
450 return mTxComponentAnimatable[mIds[id]].mPosition;
452 case TRANSFORM_PROPERTY_SCALE:
454 return mTxComponentAnimatable[mIds[id]].mScale;
456 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
458 return mTxComponentStatic[mIds[id]].mParentOrigin;
460 case TRANSFORM_PROPERTY_ANCHOR_POINT:
462 return mTxComponentStatic[mIds[id]].mAnchorPoint;
464 case TRANSFORM_PROPERTY_SIZE:
466 return mSize[mIds[id]];
470 DALI_ASSERT_ALWAYS(false);
471 return mTxComponentAnimatable[mIds[id]].mPosition;
476 const float& TransformManager::GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, unsigned int component) const
480 case TRANSFORM_PROPERTY_POSITION:
482 return mTxComponentAnimatable[mIds[id]].mPosition[component];
484 case TRANSFORM_PROPERTY_SCALE:
486 return mTxComponentAnimatable[mIds[id]].mScale[component];
488 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
490 return mTxComponentStatic[mIds[id]].mParentOrigin[component];
492 case TRANSFORM_PROPERTY_ANCHOR_POINT:
494 return mTxComponentStatic[mIds[id]].mAnchorPoint[component];
496 case TRANSFORM_PROPERTY_SIZE:
498 return mSize[mIds[id]][component];
502 DALI_ASSERT_ALWAYS(false);
503 return mTxComponentAnimatable[mIds[id]].mPosition[component];
508 void TransformManager::SetVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
510 TransformId index(mIds[id]);
511 mComponentDirty[index] = true;
515 case TRANSFORM_PROPERTY_POSITION:
517 mTxComponentAnimatable[index].mPosition = value;
520 case TRANSFORM_PROPERTY_SCALE:
522 mTxComponentAnimatable[index].mScale = value;
525 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
527 mTxComponentStatic[index].mParentOrigin = value;
530 case TRANSFORM_PROPERTY_ANCHOR_POINT:
532 mTxComponentStatic[index].mAnchorPoint = value;
535 case TRANSFORM_PROPERTY_SIZE:
537 mSize[index] = value;
542 DALI_ASSERT_ALWAYS(false);
547 void TransformManager::SetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
549 TransformId index(mIds[id]);
550 mComponentDirty[index] = true;
554 case TRANSFORM_PROPERTY_POSITION:
556 mTxComponentAnimatable[index].mPosition[component] = value;
559 case TRANSFORM_PROPERTY_SCALE:
561 mTxComponentAnimatable[index].mScale[component] = value;
564 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
566 mTxComponentStatic[index].mParentOrigin[component] = value;
569 case TRANSFORM_PROPERTY_ANCHOR_POINT:
571 mTxComponentStatic[index].mAnchorPoint[component] = value;
574 case TRANSFORM_PROPERTY_SIZE:
576 mSize[index][component] = value;
581 DALI_ASSERT_ALWAYS(false);
586 void TransformManager::BakeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
588 TransformId index(mIds[id]);
589 mComponentDirty[index] = true;
593 case TRANSFORM_PROPERTY_POSITION:
595 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = value;
598 case TRANSFORM_PROPERTY_SCALE:
600 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = value;
603 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
605 mTxComponentStatic[index].mParentOrigin = value;
608 case TRANSFORM_PROPERTY_ANCHOR_POINT:
610 mTxComponentStatic[index].mAnchorPoint = value;
613 case TRANSFORM_PROPERTY_SIZE:
615 mSize[index] = mSizeBase[index] = value;
620 DALI_ASSERT_ALWAYS(false);
625 void TransformManager::BakeRelativeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
627 TransformId index(mIds[id]);
628 mComponentDirty[index] = true;
632 case TRANSFORM_PROPERTY_POSITION:
634 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition + value;
637 case TRANSFORM_PROPERTY_SCALE:
639 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale + value;
642 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
644 mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin + value;
647 case TRANSFORM_PROPERTY_ANCHOR_POINT:
649 mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint + value;
652 case TRANSFORM_PROPERTY_SIZE:
654 mSize[index] = mSizeBase[index] = mSize[index] + value;
659 DALI_ASSERT_ALWAYS(false);
664 void TransformManager::BakeMultiplyVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
666 TransformId index(mIds[id]);
667 mComponentDirty[index] = true;
671 case TRANSFORM_PROPERTY_POSITION:
673 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition * value;
676 case TRANSFORM_PROPERTY_SCALE:
678 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale * value;
681 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
683 mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin * value;
686 case TRANSFORM_PROPERTY_ANCHOR_POINT:
688 mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint * value;
691 case TRANSFORM_PROPERTY_SIZE:
693 mSize[index] = mSizeBase[index] = mSize[index] * value;
698 DALI_ASSERT_ALWAYS(false);
703 void TransformManager::BakeVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
705 TransformId index(mIds[id]);
706 mComponentDirty[index] = true;
710 case TRANSFORM_PROPERTY_POSITION:
712 mTxComponentAnimatable[index].mPosition[component] = mTxComponentAnimatableBaseValue[index].mPosition[component] = value;
715 case TRANSFORM_PROPERTY_SCALE:
717 mTxComponentAnimatable[index].mScale[component] = mTxComponentAnimatableBaseValue[index].mScale[component] = value;
720 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
722 mTxComponentStatic[index].mParentOrigin[component] = value;
725 case TRANSFORM_PROPERTY_ANCHOR_POINT:
727 mTxComponentStatic[index].mAnchorPoint[component] = value;
730 case TRANSFORM_PROPERTY_SIZE:
732 mSize[index][component] = mSizeBase[index][component] = value;
737 DALI_ASSERT_ALWAYS(false);
742 void TransformManager::BakeXVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
744 TransformId index(mIds[id]);
745 mComponentDirty[index] = true;
749 case TRANSFORM_PROPERTY_POSITION:
751 mTxComponentAnimatable[index].mPosition.x = mTxComponentAnimatableBaseValue[index].mPosition.x = value;
754 case TRANSFORM_PROPERTY_SCALE:
756 mTxComponentAnimatable[index].mScale.x = mTxComponentAnimatableBaseValue[index].mScale.x = value;
759 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
761 mTxComponentStatic[index].mParentOrigin.x = value;
764 case TRANSFORM_PROPERTY_ANCHOR_POINT:
766 mTxComponentStatic[index].mAnchorPoint.x = value;
769 case TRANSFORM_PROPERTY_SIZE:
771 mSize[index].x = mSizeBase[index].x = value;
776 DALI_ASSERT_ALWAYS(false);
781 void TransformManager::BakeYVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
783 TransformId index(mIds[id]);
784 mComponentDirty[index] = true;
788 case TRANSFORM_PROPERTY_POSITION:
790 mTxComponentAnimatable[index].mPosition.y = mTxComponentAnimatableBaseValue[index].mPosition.y = value;
793 case TRANSFORM_PROPERTY_SCALE:
795 mTxComponentAnimatable[index].mScale.y = mTxComponentAnimatableBaseValue[index].mScale.y = value;
798 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
800 mTxComponentStatic[index].mParentOrigin.y = value;
803 case TRANSFORM_PROPERTY_ANCHOR_POINT:
805 mTxComponentStatic[index].mAnchorPoint.y = value;
808 case TRANSFORM_PROPERTY_SIZE:
810 mSize[index].y = mSizeBase[index].y = value;
815 DALI_ASSERT_ALWAYS(false);
820 void TransformManager::BakeZVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
822 TransformId index(mIds[id]);
823 mComponentDirty[index] = true;
827 case TRANSFORM_PROPERTY_POSITION:
829 mTxComponentAnimatable[index].mPosition.z = mTxComponentAnimatableBaseValue[index].mPosition.z = value;
832 case TRANSFORM_PROPERTY_SCALE:
834 mTxComponentAnimatable[index].mScale.z = mTxComponentAnimatableBaseValue[index].mScale.z = value;
837 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
839 mTxComponentStatic[index].mParentOrigin.z = value;
842 case TRANSFORM_PROPERTY_ANCHOR_POINT:
844 mTxComponentStatic[index].mAnchorPoint.z = value;
847 case TRANSFORM_PROPERTY_SIZE:
849 mSize[index].z = mSizeBase[index].z = value;
854 DALI_ASSERT_ALWAYS(false);
859 Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id)
861 TransformId index(mIds[id]);
862 return mTxComponentAnimatable[index].mOrientation;
865 const Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id) const
867 return mTxComponentAnimatable[mIds[id]].mOrientation;
870 void TransformManager::SetQuaternionPropertyValue(TransformId id, const Quaternion& q)
872 TransformId index(mIds[id]);
873 mTxComponentAnimatable[index].mOrientation = q;
874 mComponentDirty[index] = true;
877 void TransformManager::BakeQuaternionPropertyValue(TransformId id, const Quaternion& q)
879 TransformId index(mIds[id]);
880 mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
881 mComponentDirty[index] = true;
884 void TransformManager::BakeRelativeQuaternionPropertyValue(TransformId id, const Quaternion& q)
886 TransformId index(mIds[id]);
887 mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[index].mOrientation * q;
888 mComponentDirty[index] = true;
891 const Vector4& TransformManager::GetBoundingSphere(TransformId id) const
893 return mBoundingSpheres[mIds[id]];
896 void TransformManager::GetWorldMatrixAndSize(TransformId id, Matrix& worldMatrix, Vector3& size) const
898 TransformId index = mIds[id];
899 worldMatrix = mWorld[index];
903 void TransformManager::SetPositionUsesAnchorPoint(TransformId id, bool value)
905 TransformId index(mIds[id]);
906 mComponentDirty[index] = true;
907 mTxComponentStatic[index].mPositionUsesAnchorPoint = value;
910 } //namespace SceneGraph
911 } //namespace Internal