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>
31 #include <dali/integration-api/debug.h>
41 //Default values for scale (1.0,1.0,1.0), orientation (Identity) and position (0.0,0.0,0.0)
42 static const float gDefaultTransformComponentAnimatableData[] = {1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f};
44 //Default values for anchor point (CENTER) and parent origin (TOP_LEFT)
45 static const float gDefaultTransformComponentStaticData[] = {0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.5f, true};
47 static_assert(sizeof(gDefaultTransformComponentAnimatableData) == sizeof(TransformComponentAnimatable), "gDefaultTransformComponentAnimatableData should have the same number of floats as specified in TransformComponentAnimatable");
48 static_assert(sizeof(gDefaultTransformComponentStaticData) == sizeof(TransformComponentStatic), "gDefaultTransformComponentStaticData should have the same number of floats as specified in TransformComponentStatic");
51 * @brief Calculates the center position for the transform component
52 * @param[out] centerPosition The calculated center-position of the transform component
53 * @param[in] transformComponentStatic A const reference to the static component transform struct
54 * @param[in] scale scale factor to be applied to the center position.
55 * @param[in] orientation orientation factor to be applied to the center position.
56 * @param[in] size The size of the current transform component
57 * @param[in] half Halfway point of the transform
58 * @param[in] topLeft The top-left coords of the transform
60 inline void CalculateCenterPosition(
61 Vector3& centerPosition,
62 const TransformComponentStatic& transformComponentStatic,
64 const Quaternion& orientation,
67 const Vector3& topLeft)
69 // Calculate the center-point by applying the scale and rotation on the anchor point.
70 centerPosition = (half - transformComponentStatic.mAnchorPoint) * size * scale;
71 centerPosition *= orientation;
73 // If the position is ignoring the anchor-point, then remove the anchor-point shift from the position.
74 if(!transformComponentStatic.mPositionUsesAnchorPoint)
76 centerPosition -= (topLeft - transformComponentStatic.mAnchorPoint) * size;
80 } // unnamed namespace
82 TransformManager::TransformManager()
88 TransformManager::~TransformManager() = default;
90 TransformId TransformManager::CreateTransform()
92 //Get id for the new component
93 TransformId id = mIds.Add(mComponentCount);
95 if(mTxComponentAnimatable.Size() <= mComponentCount)
97 //Make room for another component
98 mTxComponentAnimatable.PushBack(TransformComponentAnimatable());
99 mTxComponentStatic.PushBack(TransformComponentStatic());
100 mInheritanceMode.PushBack(INHERIT_ALL);
101 mComponentId.PushBack(id);
102 mSize.PushBack(Vector3(0.0f, 0.0f, 0.0f));
103 mParent.PushBack(INVALID_TRANSFORM_ID);
104 mWorld.PushBack(Matrix::IDENTITY);
105 mLocal.PushBack(Matrix::IDENTITY);
106 mBoundingSpheres.PushBack(Vector4(0.0f, 0.0f, 0.0f, 0.0f));
107 mTxComponentAnimatableBaseValue.PushBack(TransformComponentAnimatable());
108 mSizeBase.PushBack(Vector3(0.0f, 0.0f, 0.0f));
109 mComponentDirty.PushBack(false);
110 mLocalMatrixDirty.PushBack(false);
115 memcpy(&mTxComponentAnimatable[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof(TransformComponentAnimatable));
116 memcpy(&mTxComponentStatic[mComponentCount], &gDefaultTransformComponentStaticData, sizeof(TransformComponentStatic));
117 memcpy(&mTxComponentAnimatableBaseValue[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof(TransformComponentAnimatable));
118 mInheritanceMode[mComponentCount] = INHERIT_ALL;
119 mComponentId[mComponentCount] = id;
120 mSize[mComponentCount] = Vector3(0.0f, 0.0f, 0.0f);
121 mParent[mComponentCount] = INVALID_TRANSFORM_ID;
122 mLocal[mComponentCount].SetIdentity();
123 mWorld[mComponentCount].SetIdentity();
124 mBoundingSpheres[mComponentCount] = Vector4(0.0f, 0.0f, 0.0f, 0.0f);
125 mSizeBase[mComponentCount] = Vector3(0.0f, 0.0f, 0.0f);
126 mComponentDirty[mComponentCount] = false;
127 mLocalMatrixDirty[mComponentCount] = false;
134 void TransformManager::RemoveTransform(TransformId id)
136 //Move the last element to the gap
138 TransformId index = mIds[id];
139 mTxComponentAnimatable[index] = mTxComponentAnimatable[mComponentCount];
140 mTxComponentStatic[index] = mTxComponentStatic[mComponentCount];
141 mInheritanceMode[index] = mInheritanceMode[mComponentCount];
142 mSize[index] = mSize[mComponentCount];
143 mParent[index] = mParent[mComponentCount];
144 mWorld[index] = mWorld[mComponentCount];
145 mLocal[index] = mLocal[mComponentCount];
146 mTxComponentAnimatableBaseValue[index] = mTxComponentAnimatableBaseValue[mComponentCount];
147 mSizeBase[index] = mSizeBase[mComponentCount];
148 mComponentDirty[index] = mComponentDirty[mComponentCount];
149 mLocalMatrixDirty[index] = mLocalMatrixDirty[mComponentCount];
150 mBoundingSpheres[index] = mBoundingSpheres[mComponentCount];
152 TransformId lastItemId = mComponentId[mComponentCount];
153 mIds[lastItemId] = index;
154 mComponentId[index] = lastItemId;
160 void TransformManager::SetParent(TransformId id, TransformId parentId)
162 DALI_ASSERT_ALWAYS(id != parentId);
163 TransformId index = mIds[id];
164 mParent[index] = parentId;
165 mComponentDirty[index] = true;
169 const Matrix& TransformManager::GetWorldMatrix(TransformId id) const
171 return mWorld[mIds[id]];
174 Matrix& TransformManager::GetWorldMatrix(TransformId id)
176 return mWorld[mIds[id]];
179 void TransformManager::SetInheritPosition(TransformId id, bool inherit)
181 TransformId index = mIds[id];
184 mInheritanceMode[index] |= INHERIT_POSITION;
188 mInheritanceMode[index] &= ~INHERIT_POSITION;
191 mComponentDirty[index] = true;
194 void TransformManager::SetInheritScale(TransformId id, bool inherit)
196 TransformId index = mIds[id];
199 mInheritanceMode[index] |= INHERIT_SCALE;
203 mInheritanceMode[index] &= ~INHERIT_SCALE;
206 mComponentDirty[index] = true;
209 void TransformManager::SetInheritOrientation(TransformId id, bool inherit)
211 TransformId index = mIds[id];
214 mInheritanceMode[index] |= INHERIT_ORIENTATION;
218 mInheritanceMode[index] &= ~INHERIT_ORIENTATION;
221 mComponentDirty[index] = true;
224 void TransformManager::ResetToBaseValue()
228 memcpy(&mTxComponentAnimatable[0], &mTxComponentAnimatableBaseValue[0], sizeof(TransformComponentAnimatable) * mComponentCount);
229 memcpy(&mSize[0], &mSizeBase[0], sizeof(Vector3) * mComponentCount);
230 memset(&mLocalMatrixDirty[0], false, sizeof(bool) * mComponentCount);
234 bool TransformManager::Update()
236 bool componentsChanged = false;
240 //If some transform component has change its parent or has been removed since last update
241 //we need to reorder the vectors
246 //Iterate through all components to compute its world matrix
247 Vector3 centerPosition;
248 Vector3 localPosition;
249 const Vector3 half(0.5f, 0.5f, 0.5f);
250 const Vector3 topLeft(0.0f, 0.0f, 0.5f);
251 for(unsigned int i(0); i < mComponentCount; ++i)
253 if(DALI_LIKELY(mInheritanceMode[i] != DONT_INHERIT_TRANSFORM && mParent[i] != INVALID_TRANSFORM_ID))
255 const TransformId& parentIndex = mIds[mParent[i]];
256 if(DALI_LIKELY(mInheritanceMode[i] == INHERIT_ALL))
258 if(mComponentDirty[i] || mLocalMatrixDirty[parentIndex])
260 //Full transform inherited
261 mLocalMatrixDirty[i] = true;
262 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, mSize[i], half, topLeft);
263 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + (mTxComponentStatic[i].mParentOrigin - half) * mSize[parentIndex];
264 mLocal[i].SetTransformComponents(mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition);
267 //Update the world matrix
268 MatrixUtils::MultiplyTransformMatrix(mWorld[i], mLocal[i], mWorld[parentIndex]);
272 // Keep previous localMatrix for comparison.
273 Matrix previousLocalMatrix = mLocal[i];
275 // Get Parent information.
276 Vector3 parentPosition, parentScale;
277 Quaternion parentOrientation;
278 const Matrix& parentMatrix = mWorld[parentIndex];
279 parentMatrix.GetTransformComponents(parentPosition, parentOrientation, parentScale);
281 // Compute intermediate Local information
282 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, mSize[i], half, topLeft);
283 Vector3 intermediateLocalPosition = mTxComponentAnimatable[i].mPosition + centerPosition + (mTxComponentStatic[i].mParentOrigin - half) * mSize[parentIndex];
284 Matrix intermediateLocalMatrix;
285 intermediateLocalMatrix.SetTransformComponents(mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, intermediateLocalPosition);
287 // Compute intermediate world information
288 Matrix intermediateWorldMatrix;
289 MatrixUtils::MultiplyTransformMatrix(intermediateWorldMatrix, intermediateLocalMatrix, mWorld[parentIndex]);
291 Vector3 intermediateWorldPosition, intermediateWorldScale;
292 Quaternion intermediateWorldOrientation;
293 intermediateWorldMatrix.GetTransformComponents(intermediateWorldPosition, intermediateWorldOrientation, intermediateWorldScale);
295 // Compute final world information
296 Vector3 finalWorldPosition = intermediateWorldPosition;
297 Vector3 finalWorldScale = intermediateWorldScale;
298 Quaternion finalWorldOrientation = intermediateWorldOrientation;
299 // worldScale includes the influence of local scale, local rotation, and parent scale.
300 // So, for the final world matrix, if this node inherits its parent scale, use worldScale.
301 // If not, use local scale for the final world matrix.
302 if((mInheritanceMode[i] & INHERIT_SCALE) == 0)
304 finalWorldScale = mTxComponentAnimatable[i].mScale;
307 // For the final world matrix, if this node inherits its parent orientation, use worldOrientation.
308 // If not, use local orientation for the final world matrix.
309 if((mInheritanceMode[i] & INHERIT_ORIENTATION) == 0)
311 finalWorldOrientation = mTxComponentAnimatable[i].mOrientation;
314 // The final world position of this node is computed as a sum of
315 // parent origin position in world space and relative position of center from parent origin.
316 // If this node doesn't inherit its parent position, simply use the relative position as a final world position.
317 Vector3 localCenterPosition;
318 CalculateCenterPosition(localCenterPosition, mTxComponentStatic[i], finalWorldScale, finalWorldOrientation, mSize[i], half, topLeft);
319 finalWorldPosition = mTxComponentAnimatable[i].mPosition * finalWorldScale;
320 finalWorldPosition *= finalWorldOrientation;
321 finalWorldPosition += localCenterPosition;
322 if((mInheritanceMode[i] & INHERIT_POSITION) != 0)
324 Vector4 parentOriginPosition((mTxComponentStatic[i].mParentOrigin - half) * mSize[parentIndex]);
325 parentOriginPosition.w = 1.0f;
326 finalWorldPosition += Vector3(parentMatrix * parentOriginPosition);
329 mWorld[i].SetTransformComponents(finalWorldScale, finalWorldOrientation, finalWorldPosition);
331 Matrix inverseParentMatrix;
332 inverseParentMatrix.SetInverseTransformComponents(parentScale, parentOrientation, parentPosition);
333 mLocal[i] = inverseParentMatrix * mWorld[i];
335 mLocalMatrixDirty[i] = mComponentDirty[i] || (previousLocalMatrix != mLocal[i]);
338 else //Component has no parent or doesn't inherit transform
340 Matrix localMatrix = mLocal[i];
341 CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, mSize[i], half, topLeft);
342 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition;
343 mLocal[i].SetTransformComponents(mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition);
344 mWorld[i] = mLocal[i];
345 mLocalMatrixDirty[i] = mComponentDirty[i] || (localMatrix != mLocal[i]);
348 //Update the bounding sphere
349 Vec3 centerToEdge = {mSize[i].Length() * 0.5f, 0.0f, 0.0f};
350 Vec3 centerToEdgeWorldSpace;
351 TransformVector3(centerToEdgeWorldSpace, mWorld[i].AsFloat(), centerToEdge);
353 mBoundingSpheres[i] = mWorld[i].GetTranslation();
354 mBoundingSpheres[i].w = Length(centerToEdgeWorldSpace);
356 componentsChanged = componentsChanged || mComponentDirty[i];
357 mComponentDirty[i] = false;
360 return componentsChanged;
363 void TransformManager::SwapComponents(unsigned int i, unsigned int j)
365 std::swap(mTxComponentAnimatable[i], mTxComponentAnimatable[j]);
366 std::swap(mTxComponentStatic[i], mTxComponentStatic[j]);
367 std::swap(mInheritanceMode[i], mInheritanceMode[j]);
368 std::swap(mSize[i], mSize[j]);
369 std::swap(mParent[i], mParent[j]);
370 std::swap(mComponentId[i], mComponentId[j]);
371 std::swap(mTxComponentAnimatableBaseValue[i], mTxComponentAnimatableBaseValue[j]);
372 std::swap(mSizeBase[i], mSizeBase[j]);
373 std::swap(mLocal[i], mLocal[j]);
374 std::swap(mComponentDirty[i], mComponentDirty[j]);
375 std::swap(mBoundingSpheres[i], mBoundingSpheres[j]);
376 std::swap(mWorld[i], mWorld[j]);
378 mIds[mComponentId[i]] = i;
379 mIds[mComponentId[j]] = j;
382 void TransformManager::ReorderComponents()
384 mOrderedComponents.Resize(mComponentCount);
386 uint16_t sceneId = 0u;
387 TransformId parentId;
389 // Create sceneId first
390 for(TransformId i = 0; i < mComponentCount; ++i)
392 mOrderedComponents[i].id = mComponentId[i];
393 mOrderedComponents[i].level = 0u;
395 parentId = mParent[i];
396 if(parentId == INVALID_TRANSFORM_ID)
398 mOrderedComponents[i].sceneId = sceneId++;
402 // Propagate sceneId and level
403 for(TransformId i = 0; i < mComponentCount; ++i)
405 parentId = mParent[i];
406 while(parentId != INVALID_TRANSFORM_ID)
408 const uint32_t parentIndex = mIds[parentId];
409 ++mOrderedComponents[i].level;
410 mOrderedComponents[i].sceneId = mOrderedComponents[parentIndex].sceneId;
413 // Parent information update done. We can reuse it.
414 mOrderedComponents[i].level += mOrderedComponents[parentIndex].level;
419 parentId = mParent[parentIndex];
424 std::stable_sort(mOrderedComponents.Begin(), mOrderedComponents.End());
425 TransformId previousIndex = 0;
426 for(TransformId newIndex = 0; newIndex < mComponentCount - 1; ++newIndex)
428 previousIndex = mIds[mOrderedComponents[newIndex].id];
429 if(previousIndex != newIndex)
431 SwapComponents(previousIndex, newIndex);
436 Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property)
440 case TRANSFORM_PROPERTY_POSITION:
442 TransformId index(mIds[id]);
443 return mTxComponentAnimatable[index].mPosition;
445 case TRANSFORM_PROPERTY_SCALE:
447 TransformId index(mIds[id]);
448 return mTxComponentAnimatable[index].mScale;
450 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
452 TransformId index(mIds[id]);
453 return mTxComponentStatic[index].mParentOrigin;
455 case TRANSFORM_PROPERTY_ANCHOR_POINT:
457 TransformId index(mIds[id]);
458 return mTxComponentStatic[index].mAnchorPoint;
460 case TRANSFORM_PROPERTY_SIZE:
462 TransformId index(mIds[id]);
467 DALI_ASSERT_ALWAYS(false);
468 return mTxComponentAnimatable[mIds[id]].mPosition;
473 const Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property) const
477 case TRANSFORM_PROPERTY_POSITION:
479 return mTxComponentAnimatable[mIds[id]].mPosition;
481 case TRANSFORM_PROPERTY_SCALE:
483 return mTxComponentAnimatable[mIds[id]].mScale;
485 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
487 return mTxComponentStatic[mIds[id]].mParentOrigin;
489 case TRANSFORM_PROPERTY_ANCHOR_POINT:
491 return mTxComponentStatic[mIds[id]].mAnchorPoint;
493 case TRANSFORM_PROPERTY_SIZE:
495 return mSize[mIds[id]];
499 DALI_ASSERT_ALWAYS(false);
500 return mTxComponentAnimatable[mIds[id]].mPosition;
505 const float& TransformManager::GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, unsigned int component) const
509 case TRANSFORM_PROPERTY_POSITION:
511 return mTxComponentAnimatable[mIds[id]].mPosition[component];
513 case TRANSFORM_PROPERTY_SCALE:
515 return mTxComponentAnimatable[mIds[id]].mScale[component];
517 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
519 return mTxComponentStatic[mIds[id]].mParentOrigin[component];
521 case TRANSFORM_PROPERTY_ANCHOR_POINT:
523 return mTxComponentStatic[mIds[id]].mAnchorPoint[component];
525 case TRANSFORM_PROPERTY_SIZE:
527 return mSize[mIds[id]][component];
531 DALI_ASSERT_ALWAYS(false);
532 return mTxComponentAnimatable[mIds[id]].mPosition[component];
537 void TransformManager::SetVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
539 TransformId index(mIds[id]);
540 mComponentDirty[index] = true;
544 case TRANSFORM_PROPERTY_POSITION:
546 mTxComponentAnimatable[index].mPosition = value;
549 case TRANSFORM_PROPERTY_SCALE:
551 mTxComponentAnimatable[index].mScale = value;
554 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
556 mTxComponentStatic[index].mParentOrigin = value;
559 case TRANSFORM_PROPERTY_ANCHOR_POINT:
561 mTxComponentStatic[index].mAnchorPoint = value;
564 case TRANSFORM_PROPERTY_SIZE:
566 mSize[index] = value;
571 DALI_ASSERT_ALWAYS(false);
576 void TransformManager::SetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
578 TransformId index(mIds[id]);
579 mComponentDirty[index] = true;
583 case TRANSFORM_PROPERTY_POSITION:
585 mTxComponentAnimatable[index].mPosition[component] = value;
588 case TRANSFORM_PROPERTY_SCALE:
590 mTxComponentAnimatable[index].mScale[component] = value;
593 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
595 mTxComponentStatic[index].mParentOrigin[component] = value;
598 case TRANSFORM_PROPERTY_ANCHOR_POINT:
600 mTxComponentStatic[index].mAnchorPoint[component] = value;
603 case TRANSFORM_PROPERTY_SIZE:
605 mSize[index][component] = value;
610 DALI_ASSERT_ALWAYS(false);
615 void TransformManager::BakeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
617 TransformId index(mIds[id]);
618 mComponentDirty[index] = true;
622 case TRANSFORM_PROPERTY_POSITION:
624 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = value;
627 case TRANSFORM_PROPERTY_SCALE:
629 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = value;
632 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
634 mTxComponentStatic[index].mParentOrigin = value;
637 case TRANSFORM_PROPERTY_ANCHOR_POINT:
639 mTxComponentStatic[index].mAnchorPoint = value;
642 case TRANSFORM_PROPERTY_SIZE:
644 mSize[index] = mSizeBase[index] = value;
649 DALI_ASSERT_ALWAYS(false);
654 void TransformManager::BakeRelativeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
656 TransformId index(mIds[id]);
657 mComponentDirty[index] = true;
661 case TRANSFORM_PROPERTY_POSITION:
663 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition + value;
666 case TRANSFORM_PROPERTY_SCALE:
668 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale + value;
671 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
673 mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin + value;
676 case TRANSFORM_PROPERTY_ANCHOR_POINT:
678 mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint + value;
681 case TRANSFORM_PROPERTY_SIZE:
683 mSize[index] = mSizeBase[index] = mSize[index] + value;
688 DALI_ASSERT_ALWAYS(false);
693 void TransformManager::BakeMultiplyVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
695 TransformId index(mIds[id]);
696 mComponentDirty[index] = true;
700 case TRANSFORM_PROPERTY_POSITION:
702 mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition * value;
705 case TRANSFORM_PROPERTY_SCALE:
707 mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale * value;
710 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
712 mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin * value;
715 case TRANSFORM_PROPERTY_ANCHOR_POINT:
717 mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint * value;
720 case TRANSFORM_PROPERTY_SIZE:
722 mSize[index] = mSizeBase[index] = mSize[index] * value;
727 DALI_ASSERT_ALWAYS(false);
732 void TransformManager::BakeVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
734 TransformId index(mIds[id]);
735 mComponentDirty[index] = true;
739 case TRANSFORM_PROPERTY_POSITION:
741 mTxComponentAnimatable[index].mPosition[component] = mTxComponentAnimatableBaseValue[index].mPosition[component] = value;
744 case TRANSFORM_PROPERTY_SCALE:
746 mTxComponentAnimatable[index].mScale[component] = mTxComponentAnimatableBaseValue[index].mScale[component] = value;
749 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
751 mTxComponentStatic[index].mParentOrigin[component] = value;
754 case TRANSFORM_PROPERTY_ANCHOR_POINT:
756 mTxComponentStatic[index].mAnchorPoint[component] = value;
759 case TRANSFORM_PROPERTY_SIZE:
761 mSize[index][component] = mSizeBase[index][component] = value;
766 DALI_ASSERT_ALWAYS(false);
771 void TransformManager::BakeXVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
773 TransformId index(mIds[id]);
774 mComponentDirty[index] = true;
778 case TRANSFORM_PROPERTY_POSITION:
780 mTxComponentAnimatable[index].mPosition.x = mTxComponentAnimatableBaseValue[index].mPosition.x = value;
783 case TRANSFORM_PROPERTY_SCALE:
785 mTxComponentAnimatable[index].mScale.x = mTxComponentAnimatableBaseValue[index].mScale.x = value;
788 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
790 mTxComponentStatic[index].mParentOrigin.x = value;
793 case TRANSFORM_PROPERTY_ANCHOR_POINT:
795 mTxComponentStatic[index].mAnchorPoint.x = value;
798 case TRANSFORM_PROPERTY_SIZE:
800 mSize[index].x = mSizeBase[index].x = value;
805 DALI_ASSERT_ALWAYS(false);
810 void TransformManager::BakeYVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
812 TransformId index(mIds[id]);
813 mComponentDirty[index] = true;
817 case TRANSFORM_PROPERTY_POSITION:
819 mTxComponentAnimatable[index].mPosition.y = mTxComponentAnimatableBaseValue[index].mPosition.y = value;
822 case TRANSFORM_PROPERTY_SCALE:
824 mTxComponentAnimatable[index].mScale.y = mTxComponentAnimatableBaseValue[index].mScale.y = value;
827 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
829 mTxComponentStatic[index].mParentOrigin.y = value;
832 case TRANSFORM_PROPERTY_ANCHOR_POINT:
834 mTxComponentStatic[index].mAnchorPoint.y = value;
837 case TRANSFORM_PROPERTY_SIZE:
839 mSize[index].y = mSizeBase[index].y = value;
844 DALI_ASSERT_ALWAYS(false);
849 void TransformManager::BakeZVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
851 TransformId index(mIds[id]);
852 mComponentDirty[index] = true;
856 case TRANSFORM_PROPERTY_POSITION:
858 mTxComponentAnimatable[index].mPosition.z = mTxComponentAnimatableBaseValue[index].mPosition.z = value;
861 case TRANSFORM_PROPERTY_SCALE:
863 mTxComponentAnimatable[index].mScale.z = mTxComponentAnimatableBaseValue[index].mScale.z = value;
866 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
868 mTxComponentStatic[index].mParentOrigin.z = value;
871 case TRANSFORM_PROPERTY_ANCHOR_POINT:
873 mTxComponentStatic[index].mAnchorPoint.z = value;
876 case TRANSFORM_PROPERTY_SIZE:
878 mSize[index].z = mSizeBase[index].z = value;
883 DALI_ASSERT_ALWAYS(false);
888 Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id)
890 TransformId index(mIds[id]);
891 return mTxComponentAnimatable[index].mOrientation;
894 const Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id) const
896 return mTxComponentAnimatable[mIds[id]].mOrientation;
899 void TransformManager::SetQuaternionPropertyValue(TransformId id, const Quaternion& q)
901 TransformId index(mIds[id]);
902 mTxComponentAnimatable[index].mOrientation = q;
903 mComponentDirty[index] = true;
906 void TransformManager::BakeQuaternionPropertyValue(TransformId id, const Quaternion& q)
908 TransformId index(mIds[id]);
909 mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
910 mComponentDirty[index] = true;
913 void TransformManager::BakeRelativeQuaternionPropertyValue(TransformId id, const Quaternion& q)
915 TransformId index(mIds[id]);
916 mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[index].mOrientation * q;
917 mComponentDirty[index] = true;
920 const Vector4& TransformManager::GetBoundingSphere(TransformId id) const
922 return mBoundingSpheres[mIds[id]];
925 void TransformManager::GetWorldMatrixAndSize(TransformId id, Matrix& worldMatrix, Vector3& size) const
927 TransformId index = mIds[id];
928 worldMatrix = mWorld[index];
932 void TransformManager::SetPositionUsesAnchorPoint(TransformId id, bool value)
934 TransformId index(mIds[id]);
935 mComponentDirty[index] = true;
936 mTxComponentStatic[index].mPositionUsesAnchorPoint = value;
939 } //namespace SceneGraph
940 } //namespace Internal