2 * Copyright (c) 2020 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/public-api/common/constants.h>
28 #include <dali/internal/common/math.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] transformComponentAnimatable A const reference to the animatable component transform struct
55 * @param[in] size The size of the current transform component
56 * @param[in] half Halfway point of the transform
57 * @param[in] topLeft The top-left coords of the transform
59 inline void CalculateCenterPosition(
60 Vector3& centerPosition,
61 const TransformComponentStatic& transformComponentStatic,
62 const TransformComponentAnimatable& transformComponentAnimatable,
65 const Vector3& topLeft )
67 // Calculate the center-point by applying the scale and rotation on the anchor point.
68 centerPosition = ( half - transformComponentStatic.mAnchorPoint ) * size * transformComponentAnimatable.mScale;
69 centerPosition *= transformComponentAnimatable.mOrientation;
71 // If the position is ignoring the anchor-point, then remove the anchor-point shift from the position.
72 if( ! transformComponentStatic.mPositionUsesAnchorPoint )
74 centerPosition -= ( topLeft - transformComponentStatic.mAnchorPoint ) * size;
78 } // unnamed namespace
80 TransformManager::TransformManager()
85 TransformManager::~TransformManager() = default;
87 TransformId TransformManager::CreateTransform()
89 //Get id for the new component
90 TransformId id = mIds.Add(mComponentCount);
92 if( mTxComponentAnimatable.Size() <= mComponentCount )
94 //Make room for another component
95 mTxComponentAnimatable.PushBack(TransformComponentAnimatable());
96 mTxComponentStatic.PushBack(TransformComponentStatic());
97 mInheritanceMode.PushBack(INHERIT_ALL);
98 mComponentId.PushBack(id);
99 mSize.PushBack(Vector3(0.0f,0.0f,0.0f));
100 mParent.PushBack(INVALID_TRANSFORM_ID);
101 mWorld.PushBack(Matrix::IDENTITY);
102 mLocal.PushBack(Matrix::IDENTITY);
103 mBoundingSpheres.PushBack( Vector4(0.0f,0.0f,0.0f,0.0f) );
104 mTxComponentAnimatableBaseValue.PushBack(TransformComponentAnimatable());
105 mSizeBase.PushBack(Vector3(0.0f,0.0f,0.0f));
106 mComponentDirty.PushBack(false);
107 mLocalMatrixDirty.PushBack(false);
112 memcpy( &mTxComponentAnimatable[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof( TransformComponentAnimatable ) );
113 memcpy( &mTxComponentStatic[mComponentCount], &gDefaultTransformComponentStaticData, sizeof( TransformComponentStatic ) );
114 memcpy( &mTxComponentAnimatableBaseValue[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof( TransformComponentAnimatable ) );
115 mInheritanceMode[mComponentCount] = INHERIT_ALL;
116 mComponentId[mComponentCount] = id;
117 mSize[mComponentCount] = Vector3(0.0f,0.0f,0.0f);
118 mParent[mComponentCount] = INVALID_TRANSFORM_ID;
119 mLocal[mComponentCount].SetIdentity();
120 mWorld[mComponentCount].SetIdentity();
121 mBoundingSpheres[mComponentCount] = Vector4(0.0f,0.0f,0.0f,0.0f);
122 mSizeBase[mComponentCount] = Vector3(0.0f,0.0f,0.0f);
123 mComponentDirty[mComponentCount] = false;
124 mLocalMatrixDirty[mComponentCount] = false;
131 void TransformManager::RemoveTransform(TransformId id)
133 //Move the last element to the gap
135 TransformId index = mIds[id];
136 mTxComponentAnimatable[index] = mTxComponentAnimatable[mComponentCount];
137 mTxComponentStatic[index] = mTxComponentStatic[mComponentCount];
138 mInheritanceMode[index] = mInheritanceMode[mComponentCount];
139 mSize[index] = mSize[mComponentCount];
140 mParent[index] = mParent[mComponentCount];
141 mWorld[index] = mWorld[mComponentCount];
142 mLocal[index] = mLocal[mComponentCount];
143 mTxComponentAnimatableBaseValue[index] = mTxComponentAnimatableBaseValue[mComponentCount];
144 mSizeBase[index] = mSizeBase[mComponentCount];
145 mComponentDirty[index] = mComponentDirty[mComponentCount];
146 mLocalMatrixDirty[index] = mLocalMatrixDirty[mComponentCount];
147 mBoundingSpheres[index] = mBoundingSpheres[mComponentCount];
149 TransformId lastItemId = mComponentId[mComponentCount];
150 mIds[ lastItemId ] = index;
151 mComponentId[index] = lastItemId;
157 void TransformManager::SetParent( TransformId id, TransformId parentId )
159 DALI_ASSERT_ALWAYS( id != parentId );
160 TransformId index = mIds[id];
161 mParent[ index ] = parentId;
162 mComponentDirty[ index ] = true;
166 const Matrix& TransformManager::GetWorldMatrix( TransformId id ) const
168 return mWorld[ mIds[id] ];
171 Matrix& TransformManager::GetWorldMatrix( TransformId id )
173 return mWorld[ mIds[id] ];
176 void TransformManager::SetInheritPosition( TransformId id, bool inherit )
178 TransformId index = mIds[id];
181 mInheritanceMode[ index ] |= INHERIT_POSITION;
185 mInheritanceMode[ index ] &= ~INHERIT_POSITION;
188 mComponentDirty[index] = true;
191 void TransformManager::SetInheritScale( TransformId id, bool inherit )
193 TransformId index = mIds[id];
196 mInheritanceMode[ index ] |= INHERIT_SCALE;
200 mInheritanceMode[ index ] &= ~INHERIT_SCALE;
203 mComponentDirty[index] = true;
206 void TransformManager::SetInheritOrientation( TransformId id, bool inherit )
208 TransformId index = mIds[id];
211 mInheritanceMode[ index ] |= INHERIT_ORIENTATION;
215 mInheritanceMode[ index ] &= ~INHERIT_ORIENTATION;
218 mComponentDirty[index] = true;
221 void TransformManager::ResetToBaseValue()
223 if( mComponentCount )
225 memcpy( &mTxComponentAnimatable[0], &mTxComponentAnimatableBaseValue[0], sizeof(TransformComponentAnimatable)*mComponentCount );
226 memcpy( &mSize[0], &mSizeBase[0], sizeof(Vector3)*mComponentCount );
227 memset( &mLocalMatrixDirty[0], false, sizeof(bool)*mComponentCount );
231 bool TransformManager::Update()
233 bool componentsChanged = false;
237 //If some transform component has change its parent or has been removed since last update
238 //we need to reorder the vectors
243 //Iterate through all components to compute its world matrix
244 Vector3 centerPosition;
245 Vector3 localPosition;
246 const Vector3 half( 0.5f,0.5f,0.5f );
247 const Vector3 topLeft( 0.0f, 0.0f, 0.5f );
248 for( unsigned int i(0); i<mComponentCount; ++i )
250 if( DALI_LIKELY( mInheritanceMode[i] != DONT_INHERIT_TRANSFORM && mParent[i] != INVALID_TRANSFORM_ID ) )
252 const TransformId& parentIndex = mIds[mParent[i] ];
253 if( DALI_LIKELY( mInheritanceMode[i] == INHERIT_ALL ) )
255 if( mComponentDirty[i] || mLocalMatrixDirty[parentIndex])
257 //Full transform inherited
258 mLocalMatrixDirty[i] = true;
259 CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
260 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + ( mTxComponentStatic[i].mParentOrigin - half ) * mSize[parentIndex];
261 mLocal[i].SetTransformComponents( mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition );
264 //Update the world matrix
265 Matrix::Multiply( mWorld[i], mLocal[i], mWorld[parentIndex]);
269 //Some components are not inherited
270 Vector3 parentPosition, parentScale;
271 Quaternion parentOrientation;
272 const Matrix& parentMatrix = mWorld[parentIndex];
273 parentMatrix.GetTransformComponents( parentPosition, parentOrientation, parentScale );
275 Vector3 localScale = mTxComponentAnimatable[i].mScale;
276 if( (mInheritanceMode[i] & INHERIT_SCALE) == 0 )
278 //Don't inherit scale
279 localScale /= parentScale;
282 Quaternion localOrientation( mTxComponentAnimatable[i].mOrientation );
283 if( (mInheritanceMode[i] & INHERIT_ORIENTATION) == 0 )
285 //Don't inherit orientation
286 parentOrientation.Invert();
287 localOrientation = parentOrientation * mTxComponentAnimatable[i].mOrientation;
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] = true;
309 else //Component has no parent or doesn't inherit transform
311 CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
312 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition;
313 mLocal[i].SetTransformComponents( mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition );
314 mWorld[i] = mLocal[i];
315 mLocalMatrixDirty[i] = true;
318 //Update the bounding sphere
319 Vec3 centerToEdge = { mSize[i].Length() * 0.5f, 0.0f, 0.0f };
320 Vec3 centerToEdgeWorldSpace;
321 TransformVector3( centerToEdgeWorldSpace, mWorld[i].AsFloat(), centerToEdge );
323 mBoundingSpheres[i] = mWorld[i].GetTranslation();
324 mBoundingSpheres[i].w = Length( centerToEdgeWorldSpace );
326 componentsChanged = componentsChanged || mComponentDirty[i];
327 mComponentDirty[i] = false;
330 return componentsChanged;
333 void TransformManager::SwapComponents( unsigned int i, unsigned int j )
335 std::swap( mTxComponentAnimatable[i], mTxComponentAnimatable[j] );
336 std::swap( mTxComponentStatic[i], mTxComponentStatic[j] );
337 std::swap( mInheritanceMode[i], mInheritanceMode[j] );
338 std::swap( mSize[i], mSize[j] );
339 std::swap( mParent[i], mParent[j] );
340 std::swap( mComponentId[i], mComponentId[j] );
341 std::swap( mTxComponentAnimatableBaseValue[i], mTxComponentAnimatableBaseValue[j] );
342 std::swap( mSizeBase[i], mSizeBase[j] );
343 std::swap( mLocal[i], mLocal[j] );
344 std::swap( mComponentDirty[i], mComponentDirty[j] );
345 std::swap( mBoundingSpheres[i], mBoundingSpheres[j] );
346 std::swap( mWorld[i], mWorld[j] );
348 mIds[ mComponentId[i] ] = i;
349 mIds[ mComponentId[j] ] = j;
352 void TransformManager::ReorderComponents()
354 mOrderedComponents.Resize(mComponentCount);
356 TransformId parentId;
357 for( TransformId i = 0; i<mComponentCount; ++i )
359 mOrderedComponents[i].id = mComponentId[i];
360 mOrderedComponents[i].level = 0u;
362 parentId = mParent[i];
363 while( parentId != INVALID_TRANSFORM_ID )
365 mOrderedComponents[i].level++;
366 parentId = mParent[ mIds[parentId] ];
370 std::stable_sort( mOrderedComponents.Begin(), mOrderedComponents.End());
371 TransformId previousIndex = 0;
372 for( TransformId newIndex = 0; newIndex < mComponentCount-1; ++newIndex )
374 previousIndex = mIds[mOrderedComponents[newIndex].id];
375 if( previousIndex != newIndex )
377 SwapComponents( previousIndex, newIndex);
382 Vector3& TransformManager::GetVector3PropertyValue( TransformId id, TransformManagerProperty property )
386 case TRANSFORM_PROPERTY_POSITION:
388 TransformId index( mIds[id] );
389 return mTxComponentAnimatable[ index ].mPosition;
391 case TRANSFORM_PROPERTY_SCALE:
393 TransformId index( mIds[id] );
394 return mTxComponentAnimatable[ index ].mScale;
396 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
398 TransformId index( mIds[id] );
399 return mTxComponentStatic[ index ].mParentOrigin;
401 case TRANSFORM_PROPERTY_ANCHOR_POINT:
403 TransformId index( mIds[id] );
404 return mTxComponentStatic[ index ].mAnchorPoint;
406 case TRANSFORM_PROPERTY_SIZE:
408 TransformId index( mIds[id] );
409 return mSize[ index ];
413 DALI_ASSERT_ALWAYS(false);
414 return mTxComponentAnimatable[ mIds[id] ].mPosition;
419 const Vector3& TransformManager::GetVector3PropertyValue( TransformId id, TransformManagerProperty property ) const
423 case TRANSFORM_PROPERTY_POSITION:
425 return mTxComponentAnimatable[ mIds[id] ].mPosition;
427 case TRANSFORM_PROPERTY_SCALE:
429 return mTxComponentAnimatable[ mIds[id] ].mScale;
431 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
433 return mTxComponentStatic[ mIds[id] ].mParentOrigin;
435 case TRANSFORM_PROPERTY_ANCHOR_POINT:
437 return mTxComponentStatic[ mIds[id] ].mAnchorPoint;
439 case TRANSFORM_PROPERTY_SIZE:
441 return mSize[ mIds[id] ];
445 DALI_ASSERT_ALWAYS(false);
446 return mTxComponentAnimatable[ mIds[id] ].mPosition;
451 const float& TransformManager::GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, unsigned int component ) const
455 case TRANSFORM_PROPERTY_POSITION:
457 return mTxComponentAnimatable[ mIds[id] ].mPosition[component];
459 case TRANSFORM_PROPERTY_SCALE:
461 return mTxComponentAnimatable[ mIds[id] ].mScale[component];
463 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
465 return mTxComponentStatic[ mIds[id] ].mParentOrigin[component];
467 case TRANSFORM_PROPERTY_ANCHOR_POINT:
469 return mTxComponentStatic[ mIds[id] ].mAnchorPoint[component];
471 case TRANSFORM_PROPERTY_SIZE:
473 return mSize[ mIds[id] ][component];
477 DALI_ASSERT_ALWAYS(false);
478 return mTxComponentAnimatable[ mIds[id] ].mPosition[component];
483 void TransformManager::SetVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
485 TransformId index( mIds[id] );
486 mComponentDirty[ index ] = true;
490 case TRANSFORM_PROPERTY_POSITION:
492 mTxComponentAnimatable[ index ].mPosition = value;
495 case TRANSFORM_PROPERTY_SCALE:
497 mTxComponentAnimatable[ index ].mScale = value;
500 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
502 mTxComponentStatic[ index ].mParentOrigin = value;
505 case TRANSFORM_PROPERTY_ANCHOR_POINT:
507 mTxComponentStatic[ index ].mAnchorPoint = value;
510 case TRANSFORM_PROPERTY_SIZE:
512 mSize[ index ] = value;
517 DALI_ASSERT_ALWAYS(false);
522 void TransformManager::SetVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, unsigned int component )
524 TransformId index( mIds[id] );
525 mComponentDirty[ index ] = true;
529 case TRANSFORM_PROPERTY_POSITION:
531 mTxComponentAnimatable[ index ].mPosition[component] = value;
534 case TRANSFORM_PROPERTY_SCALE:
536 mTxComponentAnimatable[ index ].mScale[component] = value;
539 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
541 mTxComponentStatic[ index ].mParentOrigin[component] = value;
544 case TRANSFORM_PROPERTY_ANCHOR_POINT:
546 mTxComponentStatic[ index ].mAnchorPoint[component] = value;
549 case TRANSFORM_PROPERTY_SIZE:
551 mSize[ index ][component] = value;
556 DALI_ASSERT_ALWAYS(false);
561 void TransformManager::BakeVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
563 TransformId index( mIds[id] );
564 mComponentDirty[ index ] = true;
568 case TRANSFORM_PROPERTY_POSITION:
570 mTxComponentAnimatable[ index ].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = value;
573 case TRANSFORM_PROPERTY_SCALE:
575 mTxComponentAnimatable[ index ].mScale = mTxComponentAnimatableBaseValue[index].mScale = value;
578 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
580 mTxComponentStatic[ index ].mParentOrigin = value;
583 case TRANSFORM_PROPERTY_ANCHOR_POINT:
585 mTxComponentStatic[ index ].mAnchorPoint = value;
588 case TRANSFORM_PROPERTY_SIZE:
590 mSize[ index ] = mSizeBase[index] = value;
595 DALI_ASSERT_ALWAYS(false);
600 void TransformManager::BakeRelativeVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
602 TransformId index( mIds[id] );
603 mComponentDirty[ index ] = true;
607 case TRANSFORM_PROPERTY_POSITION:
609 mTxComponentAnimatable[ index ].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[ index ].mPosition + value;
612 case TRANSFORM_PROPERTY_SCALE:
614 mTxComponentAnimatable[ index ].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[ index ].mScale + value;
617 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
619 mTxComponentStatic[ index ].mParentOrigin = mTxComponentStatic[ index ].mParentOrigin + value;
622 case TRANSFORM_PROPERTY_ANCHOR_POINT:
624 mTxComponentStatic[ index ].mAnchorPoint = mTxComponentStatic[ index ].mAnchorPoint + value;
627 case TRANSFORM_PROPERTY_SIZE:
629 mSize[ index ] = mSizeBase[index] = mSize[ index ] + value;
634 DALI_ASSERT_ALWAYS(false);
639 void TransformManager::BakeMultiplyVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
641 TransformId index( mIds[id] );
642 mComponentDirty[ index ] = true;
646 case TRANSFORM_PROPERTY_POSITION:
648 mTxComponentAnimatable[ index ].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[ index ].mPosition * value;
651 case TRANSFORM_PROPERTY_SCALE:
653 mTxComponentAnimatable[ index ].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[ index ].mScale * value;
656 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
658 mTxComponentStatic[ index ].mParentOrigin = mTxComponentStatic[ index ].mParentOrigin * value;
661 case TRANSFORM_PROPERTY_ANCHOR_POINT:
663 mTxComponentStatic[ index ].mAnchorPoint = mTxComponentStatic[ index ].mAnchorPoint * value;
666 case TRANSFORM_PROPERTY_SIZE:
668 mSize[ index ] = mSizeBase[index] = mSize[ index ] * value;
673 DALI_ASSERT_ALWAYS(false);
678 void TransformManager::BakeVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, unsigned int component )
680 TransformId index( mIds[id] );
681 mComponentDirty[ index ] = true;
685 case TRANSFORM_PROPERTY_POSITION:
687 mTxComponentAnimatable[ index ].mPosition[component] = mTxComponentAnimatableBaseValue[index].mPosition[component] = value;
690 case TRANSFORM_PROPERTY_SCALE:
692 mTxComponentAnimatable[ index ].mScale[component] = mTxComponentAnimatableBaseValue[index].mScale[component] = value;
695 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
697 mTxComponentStatic[ index ].mParentOrigin[component] = value;
700 case TRANSFORM_PROPERTY_ANCHOR_POINT:
702 mTxComponentStatic[ index ].mAnchorPoint[component] = value;
705 case TRANSFORM_PROPERTY_SIZE:
707 mSize[ index ][component] = mSizeBase[index][component] = value;
712 DALI_ASSERT_ALWAYS(false);
717 void TransformManager::BakeXVector3PropertyValue( TransformId id, TransformManagerProperty property, float value )
719 TransformId index( mIds[id] );
720 mComponentDirty[ index ] = true;
724 case TRANSFORM_PROPERTY_POSITION:
726 mTxComponentAnimatable[ index ].mPosition.x = mTxComponentAnimatableBaseValue[index].mPosition.x = value;
729 case TRANSFORM_PROPERTY_SCALE:
731 mTxComponentAnimatable[ index ].mScale.x = mTxComponentAnimatableBaseValue[index].mScale.x = value;
734 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
736 mTxComponentStatic[ index ].mParentOrigin.x = value;
739 case TRANSFORM_PROPERTY_ANCHOR_POINT:
741 mTxComponentStatic[ index ].mAnchorPoint.x = value;
744 case TRANSFORM_PROPERTY_SIZE:
746 mSize[ index ].x = mSizeBase[index].x = value;
751 DALI_ASSERT_ALWAYS(false);
756 void TransformManager::BakeYVector3PropertyValue( TransformId id, TransformManagerProperty property, float value )
758 TransformId index( mIds[id] );
759 mComponentDirty[ index ] = true;
763 case TRANSFORM_PROPERTY_POSITION:
765 mTxComponentAnimatable[ index ].mPosition.y = mTxComponentAnimatableBaseValue[index].mPosition.y = value;
768 case TRANSFORM_PROPERTY_SCALE:
770 mTxComponentAnimatable[ index ].mScale.y = mTxComponentAnimatableBaseValue[index].mScale.y = value;
773 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
775 mTxComponentStatic[ index ].mParentOrigin.y = value;
778 case TRANSFORM_PROPERTY_ANCHOR_POINT:
780 mTxComponentStatic[ index ].mAnchorPoint.y = value;
783 case TRANSFORM_PROPERTY_SIZE:
785 mSize[ index ].y = mSizeBase[index].y = value;
790 DALI_ASSERT_ALWAYS(false);
795 void TransformManager::BakeZVector3PropertyValue( TransformId id, TransformManagerProperty property, float value )
797 TransformId index( mIds[id] );
798 mComponentDirty[ index ] = true;
802 case TRANSFORM_PROPERTY_POSITION:
804 mTxComponentAnimatable[ index ].mPosition.z = mTxComponentAnimatableBaseValue[index].mPosition.z = value;
807 case TRANSFORM_PROPERTY_SCALE:
809 mTxComponentAnimatable[ index ].mScale.z = mTxComponentAnimatableBaseValue[index].mScale.z = value;
812 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
814 mTxComponentStatic[ index ].mParentOrigin.z = value;
817 case TRANSFORM_PROPERTY_ANCHOR_POINT:
819 mTxComponentStatic[ index ].mAnchorPoint.z = value;
822 case TRANSFORM_PROPERTY_SIZE:
824 mSize[ index ].z = mSizeBase[index].z = value;
829 DALI_ASSERT_ALWAYS(false);
834 Quaternion& TransformManager::GetQuaternionPropertyValue( TransformId id )
836 TransformId index( mIds[id] );
837 return mTxComponentAnimatable[ index ].mOrientation;
840 const Quaternion& TransformManager::GetQuaternionPropertyValue( TransformId id ) const
842 return mTxComponentAnimatable[ mIds[id] ].mOrientation;
845 void TransformManager::SetQuaternionPropertyValue( TransformId id, const Quaternion& q )
847 TransformId index( mIds[id] );
848 mTxComponentAnimatable[ index ].mOrientation = q;
849 mComponentDirty[ index ] = true;
852 void TransformManager::BakeQuaternionPropertyValue( TransformId id, const Quaternion& q )
854 TransformId index( mIds[id] );
855 mTxComponentAnimatable[ index ].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
856 mComponentDirty[ index ] = true;
859 void TransformManager::BakeRelativeQuaternionPropertyValue( TransformId id, const Quaternion& q )
861 TransformId index( mIds[id] );
862 mTxComponentAnimatable[ index ].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[ index ].mOrientation * q;
863 mComponentDirty[ index ] = true;
866 const Vector4& TransformManager::GetBoundingSphere( TransformId id ) const
868 return mBoundingSpheres[ mIds[id] ];
871 void TransformManager::GetWorldMatrixAndSize( TransformId id, Matrix& worldMatrix, Vector3& size ) const
873 TransformId index = mIds[id];
874 worldMatrix = mWorld[index];
878 void TransformManager::SetPositionUsesAnchorPoint( TransformId id, bool value )
880 TransformId index( mIds[ id ] );
881 mComponentDirty[ index ] = true;
882 mTxComponentStatic[ index ].mPositionUsesAnchorPoint = value;
885 } //namespace SceneGraph
886 } //namespace Internal