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 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 unsigned int sceneId = 0;
359 TransformId parentId;
360 for(TransformId i = 0; i < mComponentCount; ++i)
362 mOrderedComponents[i].id = mComponentId[i];
363 mOrderedComponents[i].level = 0u;
365 parentId = mParent[i];
366 if(parentId == INVALID_TRANSFORM_ID)
368 mOrderedComponents[i].sceneId = sceneId++;
371 while(parentId != INVALID_TRANSFORM_ID)
373 mOrderedComponents[i].level++;
374 parentId = mParent[mIds[parentId]];
375 mOrderedComponents[i].sceneId = mOrderedComponents[mIds[mParent[i]]].sceneId;
379 std::stable_sort(mOrderedComponents.Begin(), mOrderedComponents.End());
380 TransformId previousIndex = 0;
381 for(TransformId newIndex = 0; newIndex < mComponentCount - 1; ++newIndex)
383 previousIndex = mIds[mOrderedComponents[newIndex].id];
384 if(previousIndex != newIndex)
386 SwapComponents(previousIndex, newIndex);
391 Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property)
395 case TRANSFORM_PROPERTY_POSITION:
397 TransformId index(mIds[id]);
398 return mTxComponentAnimatable[index].mPosition;
400 case TRANSFORM_PROPERTY_SCALE:
402 TransformId index(mIds[id]);
403 return mTxComponentAnimatable[index].mScale;
405 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
407 TransformId index(mIds[id]);
408 return mTxComponentStatic[index].mParentOrigin;
410 case TRANSFORM_PROPERTY_ANCHOR_POINT:
412 TransformId index(mIds[id]);
413 return mTxComponentStatic[index].mAnchorPoint;
415 case TRANSFORM_PROPERTY_SIZE:
417 TransformId index(mIds[id]);
422 DALI_ASSERT_ALWAYS(false);
423 return mTxComponentAnimatable[mIds[id]].mPosition;
428 const Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property) const
432 case TRANSFORM_PROPERTY_POSITION:
434 return mTxComponentAnimatable[mIds[id]].mPosition;
436 case TRANSFORM_PROPERTY_SCALE:
438 return mTxComponentAnimatable[mIds[id]].mScale;
440 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
442 return mTxComponentStatic[mIds[id]].mParentOrigin;
444 case TRANSFORM_PROPERTY_ANCHOR_POINT:
446 return mTxComponentStatic[mIds[id]].mAnchorPoint;
448 case TRANSFORM_PROPERTY_SIZE:
450 return mSize[mIds[id]];
454 DALI_ASSERT_ALWAYS(false);
455 return mTxComponentAnimatable[mIds[id]].mPosition;
460 const float& TransformManager::GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, unsigned int component) const
464 case TRANSFORM_PROPERTY_POSITION:
466 return mTxComponentAnimatable[mIds[id]].mPosition[component];
468 case TRANSFORM_PROPERTY_SCALE:
470 return mTxComponentAnimatable[mIds[id]].mScale[component];
472 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
474 return mTxComponentStatic[mIds[id]].mParentOrigin[component];
476 case TRANSFORM_PROPERTY_ANCHOR_POINT:
478 return mTxComponentStatic[mIds[id]].mAnchorPoint[component];
480 case TRANSFORM_PROPERTY_SIZE:
482 return mSize[mIds[id]][component];
486 DALI_ASSERT_ALWAYS(false);
487 return mTxComponentAnimatable[mIds[id]].mPosition[component];
492 void TransformManager::SetVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
494 TransformId index(mIds[id]);
495 mComponentDirty[index] = true;
499 case TRANSFORM_PROPERTY_POSITION:
501 mTxComponentAnimatable[index].mPosition = value;
504 case TRANSFORM_PROPERTY_SCALE:
506 mTxComponentAnimatable[index].mScale = value;
509 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
511 mTxComponentStatic[index].mParentOrigin = value;
514 case TRANSFORM_PROPERTY_ANCHOR_POINT:
516 mTxComponentStatic[index].mAnchorPoint = value;
519 case TRANSFORM_PROPERTY_SIZE:
521 mSize[index] = value;
526 DALI_ASSERT_ALWAYS(false);
531 void TransformManager::SetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
533 TransformId index(mIds[id]);
534 mComponentDirty[index] = true;
538 case TRANSFORM_PROPERTY_POSITION:
540 mTxComponentAnimatable[index].mPosition[component] = value;
543 case TRANSFORM_PROPERTY_SCALE:
545 mTxComponentAnimatable[index].mScale[component] = value;
548 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
550 mTxComponentStatic[index].mParentOrigin[component] = value;
553 case TRANSFORM_PROPERTY_ANCHOR_POINT:
555 mTxComponentStatic[index].mAnchorPoint[component] = value;
558 case TRANSFORM_PROPERTY_SIZE:
560 mSize[index][component] = value;
565 DALI_ASSERT_ALWAYS(false);
570 void TransformManager::BakeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
572 TransformId index(mIds[id]);
573 mComponentDirty[index] = true;
577 case TRANSFORM_PROPERTY_POSITION:
579 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = value;
582 case TRANSFORM_PROPERTY_SCALE:
584 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = value;
587 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
589 mTxComponentStatic[index].mParentOrigin = value;
592 case TRANSFORM_PROPERTY_ANCHOR_POINT:
594 mTxComponentStatic[index].mAnchorPoint = value;
597 case TRANSFORM_PROPERTY_SIZE:
599 mSize[index] = mSizeBase[index] = value;
604 DALI_ASSERT_ALWAYS(false);
609 void TransformManager::BakeRelativeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
611 TransformId index(mIds[id]);
612 mComponentDirty[index] = true;
616 case TRANSFORM_PROPERTY_POSITION:
618 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition + value;
621 case TRANSFORM_PROPERTY_SCALE:
623 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale + value;
626 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
628 mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin + value;
631 case TRANSFORM_PROPERTY_ANCHOR_POINT:
633 mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint + value;
636 case TRANSFORM_PROPERTY_SIZE:
638 mSize[index] = mSizeBase[index] = mSize[index] + value;
643 DALI_ASSERT_ALWAYS(false);
648 void TransformManager::BakeMultiplyVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
650 TransformId index(mIds[id]);
651 mComponentDirty[index] = true;
655 case TRANSFORM_PROPERTY_POSITION:
657 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition * value;
660 case TRANSFORM_PROPERTY_SCALE:
662 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale * value;
665 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
667 mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin * value;
670 case TRANSFORM_PROPERTY_ANCHOR_POINT:
672 mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint * value;
675 case TRANSFORM_PROPERTY_SIZE:
677 mSize[index] = mSizeBase[index] = mSize[index] * value;
682 DALI_ASSERT_ALWAYS(false);
687 void TransformManager::BakeVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
689 TransformId index(mIds[id]);
690 mComponentDirty[index] = true;
694 case TRANSFORM_PROPERTY_POSITION:
696 mTxComponentAnimatable[index].mPosition[component] = mTxComponentAnimatableBaseValue[index].mPosition[component] = value;
699 case TRANSFORM_PROPERTY_SCALE:
701 mTxComponentAnimatable[index].mScale[component] = mTxComponentAnimatableBaseValue[index].mScale[component] = value;
704 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
706 mTxComponentStatic[index].mParentOrigin[component] = value;
709 case TRANSFORM_PROPERTY_ANCHOR_POINT:
711 mTxComponentStatic[index].mAnchorPoint[component] = value;
714 case TRANSFORM_PROPERTY_SIZE:
716 mSize[index][component] = mSizeBase[index][component] = value;
721 DALI_ASSERT_ALWAYS(false);
726 void TransformManager::BakeXVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
728 TransformId index(mIds[id]);
729 mComponentDirty[index] = true;
733 case TRANSFORM_PROPERTY_POSITION:
735 mTxComponentAnimatable[index].mPosition.x = mTxComponentAnimatableBaseValue[index].mPosition.x = value;
738 case TRANSFORM_PROPERTY_SCALE:
740 mTxComponentAnimatable[index].mScale.x = mTxComponentAnimatableBaseValue[index].mScale.x = value;
743 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
745 mTxComponentStatic[index].mParentOrigin.x = value;
748 case TRANSFORM_PROPERTY_ANCHOR_POINT:
750 mTxComponentStatic[index].mAnchorPoint.x = value;
753 case TRANSFORM_PROPERTY_SIZE:
755 mSize[index].x = mSizeBase[index].x = value;
760 DALI_ASSERT_ALWAYS(false);
765 void TransformManager::BakeYVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
767 TransformId index(mIds[id]);
768 mComponentDirty[index] = true;
772 case TRANSFORM_PROPERTY_POSITION:
774 mTxComponentAnimatable[index].mPosition.y = mTxComponentAnimatableBaseValue[index].mPosition.y = value;
777 case TRANSFORM_PROPERTY_SCALE:
779 mTxComponentAnimatable[index].mScale.y = mTxComponentAnimatableBaseValue[index].mScale.y = value;
782 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
784 mTxComponentStatic[index].mParentOrigin.y = value;
787 case TRANSFORM_PROPERTY_ANCHOR_POINT:
789 mTxComponentStatic[index].mAnchorPoint.y = value;
792 case TRANSFORM_PROPERTY_SIZE:
794 mSize[index].y = mSizeBase[index].y = value;
799 DALI_ASSERT_ALWAYS(false);
804 void TransformManager::BakeZVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
806 TransformId index(mIds[id]);
807 mComponentDirty[index] = true;
811 case TRANSFORM_PROPERTY_POSITION:
813 mTxComponentAnimatable[index].mPosition.z = mTxComponentAnimatableBaseValue[index].mPosition.z = value;
816 case TRANSFORM_PROPERTY_SCALE:
818 mTxComponentAnimatable[index].mScale.z = mTxComponentAnimatableBaseValue[index].mScale.z = value;
821 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
823 mTxComponentStatic[index].mParentOrigin.z = value;
826 case TRANSFORM_PROPERTY_ANCHOR_POINT:
828 mTxComponentStatic[index].mAnchorPoint.z = value;
831 case TRANSFORM_PROPERTY_SIZE:
833 mSize[index].z = mSizeBase[index].z = value;
838 DALI_ASSERT_ALWAYS(false);
843 Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id)
845 TransformId index(mIds[id]);
846 return mTxComponentAnimatable[index].mOrientation;
849 const Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id) const
851 return mTxComponentAnimatable[mIds[id]].mOrientation;
854 void TransformManager::SetQuaternionPropertyValue(TransformId id, const Quaternion& q)
856 TransformId index(mIds[id]);
857 mTxComponentAnimatable[index].mOrientation = q;
858 mComponentDirty[index] = true;
861 void TransformManager::BakeQuaternionPropertyValue(TransformId id, const Quaternion& q)
863 TransformId index(mIds[id]);
864 mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
865 mComponentDirty[index] = true;
868 void TransformManager::BakeRelativeQuaternionPropertyValue(TransformId id, const Quaternion& q)
870 TransformId index(mIds[id]);
871 mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[index].mOrientation * q;
872 mComponentDirty[index] = true;
875 const Vector4& TransformManager::GetBoundingSphere(TransformId id) const
877 return mBoundingSpheres[mIds[id]];
880 void TransformManager::GetWorldMatrixAndSize(TransformId id, Matrix& worldMatrix, Vector3& size) const
882 TransformId index = mIds[id];
883 worldMatrix = mWorld[index];
887 void TransformManager::SetPositionUsesAnchorPoint(TransformId id, bool value)
889 TransformId index(mIds[id]);
890 mComponentDirty[index] = true;
891 mTxComponentStatic[index].mPositionUsesAnchorPoint = value;
894 } //namespace SceneGraph
895 } //namespace Internal