2 * Copyright (c) 2018 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()
88 TransformId TransformManager::CreateTransform()
90 //Get id for the new component
91 TransformId id = mIds.Add(mComponentCount);
93 if( mTxComponentAnimatable.Size() <= mComponentCount )
95 //Make room for another component
96 mTxComponentAnimatable.PushBack(TransformComponentAnimatable());
97 mTxComponentStatic.PushBack(TransformComponentStatic());
98 mInheritanceMode.PushBack(INHERIT_ALL);
99 mComponentId.PushBack(id);
100 mSize.PushBack(Vector3(0.0f,0.0f,0.0f));
101 mParent.PushBack(INVALID_TRANSFORM_ID);
102 mWorld.PushBack(Matrix::IDENTITY);
103 mLocal.PushBack(Matrix::IDENTITY);
104 mBoundingSpheres.PushBack( Vector4(0.0f,0.0f,0.0f,0.0f) );
105 mTxComponentAnimatableBaseValue.PushBack(TransformComponentAnimatable());
106 mSizeBase.PushBack(Vector3(0.0f,0.0f,0.0f));
107 mComponentDirty.PushBack(false);
108 mLocalMatrixDirty.PushBack(false);
113 memcpy( &mTxComponentAnimatable[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof( TransformComponentAnimatable ) );
114 memcpy( &mTxComponentStatic[mComponentCount], &gDefaultTransformComponentStaticData, sizeof( TransformComponentStatic ) );
115 memcpy( &mTxComponentAnimatableBaseValue[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof( TransformComponentAnimatable ) );
116 mInheritanceMode[mComponentCount] = INHERIT_ALL;
117 mComponentId[mComponentCount] = id;
118 mSize[mComponentCount] = Vector3(0.0f,0.0f,0.0f);
119 mParent[mComponentCount] = INVALID_TRANSFORM_ID;
120 mLocal[mComponentCount].SetIdentity();
121 mWorld[mComponentCount].SetIdentity();
122 mBoundingSpheres[mComponentCount] = Vector4(0.0f,0.0f,0.0f,0.0f);
123 mSizeBase[mComponentCount] = Vector3(0.0f,0.0f,0.0f);
124 mComponentDirty[mComponentCount] = false;
125 mLocalMatrixDirty[mComponentCount] = false;
132 void TransformManager::RemoveTransform(TransformId id)
134 //Move the last element to the gap
136 TransformId index = mIds[id];
137 mTxComponentAnimatable[index] = mTxComponentAnimatable[mComponentCount];
138 mTxComponentStatic[index] = mTxComponentStatic[mComponentCount];
139 mInheritanceMode[index] = mInheritanceMode[mComponentCount];
140 mSize[index] = mSize[mComponentCount];
141 mParent[index] = mParent[mComponentCount];
142 mWorld[index] = mWorld[mComponentCount];
143 mLocal[index] = mLocal[mComponentCount];
144 mTxComponentAnimatableBaseValue[index] = mTxComponentAnimatableBaseValue[mComponentCount];
145 mSizeBase[index] = mSizeBase[mComponentCount];
146 mComponentDirty[index] = mComponentDirty[mComponentCount];
147 mLocalMatrixDirty[index] = mLocalMatrixDirty[mComponentCount];
148 mBoundingSpheres[index] = mBoundingSpheres[mComponentCount];
150 TransformId lastItemId = mComponentId[mComponentCount];
151 mIds[ lastItemId ] = index;
152 mComponentId[index] = lastItemId;
158 void TransformManager::SetParent( TransformId id, TransformId parentId )
160 DALI_ASSERT_ALWAYS( id != parentId );
161 TransformId index = mIds[id];
162 mParent[ index ] = parentId;
163 mComponentDirty[ index ] = true;
167 const Matrix& TransformManager::GetWorldMatrix( TransformId id ) const
169 return mWorld[ mIds[id] ];
172 Matrix& TransformManager::GetWorldMatrix( TransformId id )
174 return mWorld[ mIds[id] ];
177 void TransformManager::SetInheritPosition( TransformId id, bool inherit )
179 TransformId index = mIds[id];
182 mInheritanceMode[ index ] |= INHERIT_POSITION;
186 mInheritanceMode[ index ] &= ~INHERIT_POSITION;
189 mComponentDirty[index] = true;
192 void TransformManager::SetInheritScale( TransformId id, bool inherit )
194 TransformId index = mIds[id];
197 mInheritanceMode[ index ] |= INHERIT_SCALE;
201 mInheritanceMode[ index ] &= ~INHERIT_SCALE;
204 mComponentDirty[index] = true;
207 void TransformManager::SetInheritOrientation( TransformId id, bool inherit )
209 TransformId index = mIds[id];
212 mInheritanceMode[ index ] |= INHERIT_ORIENTATION;
216 mInheritanceMode[ index ] &= ~INHERIT_ORIENTATION;
219 mComponentDirty[index] = true;
222 void TransformManager::ResetToBaseValue()
224 if( mComponentCount )
226 memcpy( &mTxComponentAnimatable[0], &mTxComponentAnimatableBaseValue[0], sizeof(TransformComponentAnimatable)*mComponentCount );
227 memcpy( &mSize[0], &mSizeBase[0], sizeof(Vector3)*mComponentCount );
228 memset( &mLocalMatrixDirty[0], false, sizeof(bool)*mComponentCount );
232 void TransformManager::Update()
236 //If some transform component has change its parent or has been removed since last update
237 //we need to reorder the vectors
242 //Iterate through all components to compute its world matrix
243 Vector3 centerPosition;
244 Vector3 localPosition;
245 const Vector3 half( 0.5f,0.5f,0.5f );
246 const Vector3 topLeft( 0.0f, 0.0f, 0.5f );
247 for( unsigned int i(0); i<mComponentCount; ++i )
249 if( DALI_LIKELY( mInheritanceMode[i] != DONT_INHERIT_TRANSFORM && mParent[i] != INVALID_TRANSFORM_ID ) )
251 const TransformId& parentIndex = mIds[mParent[i] ];
252 if( DALI_LIKELY( mInheritanceMode[i] == INHERIT_ALL ) )
254 if( mComponentDirty[i] || mLocalMatrixDirty[parentIndex])
256 //Full transform inherited
257 mLocalMatrixDirty[i] = true;
258 CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
259 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + ( mTxComponentStatic[i].mParentOrigin - half ) * mSize[parentIndex];
260 mLocal[i].SetTransformComponents( mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition );
263 //Update the world matrix
264 Matrix::Multiply( mWorld[i], mLocal[i], mWorld[parentIndex]);
268 //Some components are not inherited
269 Vector3 parentPosition, parentScale;
270 Quaternion parentOrientation;
271 const Matrix& parentMatrix = mWorld[parentIndex];
272 parentMatrix.GetTransformComponents( parentPosition, parentOrientation, parentScale );
274 Vector3 localScale = mTxComponentAnimatable[i].mScale;
275 if( (mInheritanceMode[i] & INHERIT_SCALE) == 0 )
277 //Don't inherit scale
278 localScale /= parentScale;
281 Quaternion localOrientation( mTxComponentAnimatable[i].mOrientation );
282 if( (mInheritanceMode[i] & INHERIT_ORIENTATION) == 0 )
284 //Don't inherit orientation
285 parentOrientation.Invert();
286 localOrientation = parentOrientation * mTxComponentAnimatable[i].mOrientation;
289 if( (mInheritanceMode[i] & INHERIT_POSITION) == 0 )
291 //Don't inherit position
292 CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
293 mLocal[i].SetTransformComponents( localScale, localOrientation, Vector3::ZERO );
294 Matrix::Multiply( mWorld[i], mLocal[i], parentMatrix );
295 mWorld[i].SetTranslation( mTxComponentAnimatable[i].mPosition + centerPosition );
299 CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
300 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + ( mTxComponentStatic[i].mParentOrigin - half ) * mSize[parentIndex];
301 mLocal[i].SetTransformComponents( localScale, localOrientation, localPosition );
302 Matrix::Multiply( mWorld[i], mLocal[i], parentMatrix );
305 mLocalMatrixDirty[i] = true;
308 else //Component has no parent or doesn't inherit transform
310 CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
311 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition;
312 mLocal[i].SetTransformComponents( mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition );
313 mWorld[i] = mLocal[i];
314 mLocalMatrixDirty[i] = true;
317 //Update the bounding sphere
318 Vec3 centerToEdge = { mSize[i].Length() * 0.5f, 0.0f, 0.0f };
319 Vec3 centerToEdgeWorldSpace;
320 TransformVector3( centerToEdgeWorldSpace, mWorld[i].AsFloat(), centerToEdge );
322 mBoundingSpheres[i] = mWorld[i].GetTranslation();
323 mBoundingSpheres[i].w = Length( centerToEdgeWorldSpace );
325 mComponentDirty[i] = false;
329 void TransformManager::SwapComponents( unsigned int i, unsigned int j )
331 std::swap( mTxComponentAnimatable[i], mTxComponentAnimatable[j] );
332 std::swap( mTxComponentStatic[i], mTxComponentStatic[j] );
333 std::swap( mInheritanceMode[i], mInheritanceMode[j] );
334 std::swap( mSize[i], mSize[j] );
335 std::swap( mParent[i], mParent[j] );
336 std::swap( mComponentId[i], mComponentId[j] );
337 std::swap( mTxComponentAnimatableBaseValue[i], mTxComponentAnimatableBaseValue[j] );
338 std::swap( mSizeBase[i], mSizeBase[j] );
339 std::swap( mLocal[i], mLocal[j] );
340 std::swap( mComponentDirty[i], mComponentDirty[j] );
341 std::swap( mBoundingSpheres[i], mBoundingSpheres[j] );
342 std::swap( mWorld[i], mWorld[j] );
344 mIds[ mComponentId[i] ] = i;
345 mIds[ mComponentId[j] ] = j;
348 void TransformManager::ReorderComponents()
350 mOrderedComponents.Resize(mComponentCount);
352 TransformId parentId;
353 for( TransformId i = 0; i<mComponentCount; ++i )
355 mOrderedComponents[i].id = mComponentId[i];
356 mOrderedComponents[i].level = 0u;
358 parentId = mParent[i];
359 while( parentId != INVALID_TRANSFORM_ID )
361 mOrderedComponents[i].level++;
362 parentId = mParent[ mIds[parentId] ];
366 std::stable_sort( mOrderedComponents.Begin(), mOrderedComponents.End());
367 TransformId previousIndex = 0;
368 for( TransformId newIndex = 0; newIndex < mComponentCount-1; ++newIndex )
370 previousIndex = mIds[mOrderedComponents[newIndex].id];
371 if( previousIndex != newIndex )
373 SwapComponents( previousIndex, newIndex);
378 Vector3& TransformManager::GetVector3PropertyValue( TransformId id, TransformManagerProperty property )
382 case TRANSFORM_PROPERTY_POSITION:
384 TransformId index( mIds[id] );
385 mComponentDirty[ index ] = true;
386 return mTxComponentAnimatable[ index ].mPosition;
388 case TRANSFORM_PROPERTY_SCALE:
390 TransformId index( mIds[id] );
391 mComponentDirty[ index ] = true;
392 return mTxComponentAnimatable[ index ].mScale;
394 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
396 TransformId index( mIds[id] );
397 mComponentDirty[ index ] = true;
398 return mTxComponentStatic[ index ].mParentOrigin;
400 case TRANSFORM_PROPERTY_ANCHOR_POINT:
402 TransformId index( mIds[id] );
403 mComponentDirty[ index ] = true;
404 return mTxComponentStatic[ index ].mAnchorPoint;
406 case TRANSFORM_PROPERTY_SIZE:
408 TransformId index( mIds[id] );
409 mComponentDirty[ index ] = true;
410 return mSize[ index ];
414 DALI_ASSERT_ALWAYS(false);
415 return mTxComponentAnimatable[ mIds[id] ].mPosition;
420 const Vector3& TransformManager::GetVector3PropertyValue( TransformId id, TransformManagerProperty property ) const
424 case TRANSFORM_PROPERTY_POSITION:
426 return mTxComponentAnimatable[ mIds[id] ].mPosition;
428 case TRANSFORM_PROPERTY_SCALE:
430 return mTxComponentAnimatable[ mIds[id] ].mScale;
432 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
434 return mTxComponentStatic[ mIds[id] ].mParentOrigin;
436 case TRANSFORM_PROPERTY_ANCHOR_POINT:
438 return mTxComponentStatic[ mIds[id] ].mAnchorPoint;
440 case TRANSFORM_PROPERTY_SIZE:
442 return mSize[ mIds[id] ];
446 DALI_ASSERT_ALWAYS(false);
447 return mTxComponentAnimatable[ mIds[id] ].mPosition;
452 const float& TransformManager::GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, unsigned int component ) const
456 case TRANSFORM_PROPERTY_POSITION:
458 return mTxComponentAnimatable[ mIds[id] ].mPosition[component];
460 case TRANSFORM_PROPERTY_SCALE:
462 return mTxComponentAnimatable[ mIds[id] ].mScale[component];
464 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
466 return mTxComponentStatic[ mIds[id] ].mParentOrigin[component];
468 case TRANSFORM_PROPERTY_ANCHOR_POINT:
470 return mTxComponentStatic[ mIds[id] ].mAnchorPoint[component];
472 case TRANSFORM_PROPERTY_SIZE:
474 return mSize[ mIds[id] ][component];
478 DALI_ASSERT_ALWAYS(false);
479 return mTxComponentAnimatable[ mIds[id] ].mPosition[component];
484 void TransformManager::SetVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
486 TransformId index( mIds[id] );
487 mComponentDirty[ index ] = true;
491 case TRANSFORM_PROPERTY_POSITION:
493 mTxComponentAnimatable[ index ].mPosition = value;
496 case TRANSFORM_PROPERTY_SCALE:
498 mTxComponentAnimatable[ index ].mScale = value;
501 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
503 mTxComponentStatic[ index ].mParentOrigin = value;
506 case TRANSFORM_PROPERTY_ANCHOR_POINT:
508 mTxComponentStatic[ index ].mAnchorPoint = value;
511 case TRANSFORM_PROPERTY_SIZE:
513 mSize[ index ] = value;
518 DALI_ASSERT_ALWAYS(false);
523 void TransformManager::SetVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, unsigned int component )
525 TransformId index( mIds[id] );
526 mComponentDirty[ index ] = true;
530 case TRANSFORM_PROPERTY_POSITION:
532 mTxComponentAnimatable[ index ].mPosition[component] = value;
535 case TRANSFORM_PROPERTY_SCALE:
537 mTxComponentAnimatable[ index ].mScale[component] = value;
540 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
542 mTxComponentStatic[ index ].mParentOrigin[component] = value;
545 case TRANSFORM_PROPERTY_ANCHOR_POINT:
547 mTxComponentStatic[ index ].mAnchorPoint[component] = value;
550 case TRANSFORM_PROPERTY_SIZE:
552 mSize[ index ][component] = value;
557 DALI_ASSERT_ALWAYS(false);
562 void TransformManager::BakeVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
564 TransformId index( mIds[id] );
565 mComponentDirty[ index ] = true;
569 case TRANSFORM_PROPERTY_POSITION:
571 mTxComponentAnimatable[ index ].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = value;
574 case TRANSFORM_PROPERTY_SCALE:
576 mTxComponentAnimatable[ index ].mScale = mTxComponentAnimatableBaseValue[index].mScale = value;
579 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
581 mTxComponentStatic[ index ].mParentOrigin = value;
584 case TRANSFORM_PROPERTY_ANCHOR_POINT:
586 mTxComponentStatic[ index ].mAnchorPoint = value;
589 case TRANSFORM_PROPERTY_SIZE:
591 mSize[ index ] = mSizeBase[index] = value;
596 DALI_ASSERT_ALWAYS(false);
601 void TransformManager::BakeRelativeVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
603 TransformId index( mIds[id] );
604 mComponentDirty[ index ] = true;
608 case TRANSFORM_PROPERTY_POSITION:
610 mTxComponentAnimatable[ index ].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[ index ].mPosition + value;
613 case TRANSFORM_PROPERTY_SCALE:
615 mTxComponentAnimatable[ index ].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[ index ].mScale + value;
618 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
620 mTxComponentStatic[ index ].mParentOrigin = mTxComponentStatic[ index ].mParentOrigin + value;
623 case TRANSFORM_PROPERTY_ANCHOR_POINT:
625 mTxComponentStatic[ index ].mAnchorPoint = mTxComponentStatic[ index ].mAnchorPoint + value;
628 case TRANSFORM_PROPERTY_SIZE:
630 mSize[ index ] = mSizeBase[index] = mSize[ index ] + value;
635 DALI_ASSERT_ALWAYS(false);
640 void TransformManager::BakeMultiplyVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
642 TransformId index( mIds[id] );
643 mComponentDirty[ index ] = true;
647 case TRANSFORM_PROPERTY_POSITION:
649 mTxComponentAnimatable[ index ].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[ index ].mPosition * value;
652 case TRANSFORM_PROPERTY_SCALE:
654 mTxComponentAnimatable[ index ].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[ index ].mScale * value;
657 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
659 mTxComponentStatic[ index ].mParentOrigin = mTxComponentStatic[ index ].mParentOrigin * value;
662 case TRANSFORM_PROPERTY_ANCHOR_POINT:
664 mTxComponentStatic[ index ].mAnchorPoint = mTxComponentStatic[ index ].mAnchorPoint * value;
667 case TRANSFORM_PROPERTY_SIZE:
669 mSize[ index ] = mSizeBase[index] = mSize[ index ] * value;
674 DALI_ASSERT_ALWAYS(false);
679 void TransformManager::BakeVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, unsigned int component )
681 TransformId index( mIds[id] );
682 mComponentDirty[ index ] = true;
686 case TRANSFORM_PROPERTY_POSITION:
688 mTxComponentAnimatable[ index ].mPosition[component] = mTxComponentAnimatableBaseValue[index].mPosition[component] = value;
691 case TRANSFORM_PROPERTY_SCALE:
693 mTxComponentAnimatable[ index ].mScale[component] = mTxComponentAnimatableBaseValue[index].mScale[component] = value;
696 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
698 mTxComponentStatic[ index ].mParentOrigin[component] = value;
701 case TRANSFORM_PROPERTY_ANCHOR_POINT:
703 mTxComponentStatic[ index ].mAnchorPoint[component] = value;
706 case TRANSFORM_PROPERTY_SIZE:
708 mSize[ index ][component] = mSizeBase[index][component] = value;
713 DALI_ASSERT_ALWAYS(false);
718 void TransformManager::BakeXVector3PropertyValue( TransformId id, TransformManagerProperty property, float value )
720 TransformId index( mIds[id] );
721 mComponentDirty[ index ] = true;
725 case TRANSFORM_PROPERTY_POSITION:
727 mTxComponentAnimatable[ index ].mPosition.x = mTxComponentAnimatableBaseValue[index].mPosition.x = value;
730 case TRANSFORM_PROPERTY_SCALE:
732 mTxComponentAnimatable[ index ].mScale.x = mTxComponentAnimatableBaseValue[index].mScale.x = value;
735 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
737 mTxComponentStatic[ index ].mParentOrigin.x = value;
740 case TRANSFORM_PROPERTY_ANCHOR_POINT:
742 mTxComponentStatic[ index ].mAnchorPoint.x = value;
745 case TRANSFORM_PROPERTY_SIZE:
747 mSize[ index ].x = mSizeBase[index].x = value;
752 DALI_ASSERT_ALWAYS(false);
757 void TransformManager::BakeYVector3PropertyValue( TransformId id, TransformManagerProperty property, float value )
759 TransformId index( mIds[id] );
760 mComponentDirty[ index ] = true;
764 case TRANSFORM_PROPERTY_POSITION:
766 mTxComponentAnimatable[ index ].mPosition.y = mTxComponentAnimatableBaseValue[index].mPosition.y = value;
769 case TRANSFORM_PROPERTY_SCALE:
771 mTxComponentAnimatable[ index ].mScale.y = mTxComponentAnimatableBaseValue[index].mScale.y = value;
774 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
776 mTxComponentStatic[ index ].mParentOrigin.y = value;
779 case TRANSFORM_PROPERTY_ANCHOR_POINT:
781 mTxComponentStatic[ index ].mAnchorPoint.y = value;
784 case TRANSFORM_PROPERTY_SIZE:
786 mSize[ index ].y = mSizeBase[index].y = value;
791 DALI_ASSERT_ALWAYS(false);
796 void TransformManager::BakeZVector3PropertyValue( TransformId id, TransformManagerProperty property, float value )
798 TransformId index( mIds[id] );
799 mComponentDirty[ index ] = true;
803 case TRANSFORM_PROPERTY_POSITION:
805 mTxComponentAnimatable[ index ].mPosition.z = mTxComponentAnimatableBaseValue[index].mPosition.z = value;
808 case TRANSFORM_PROPERTY_SCALE:
810 mTxComponentAnimatable[ index ].mScale.z = mTxComponentAnimatableBaseValue[index].mScale.z = value;
813 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
815 mTxComponentStatic[ index ].mParentOrigin.z = value;
818 case TRANSFORM_PROPERTY_ANCHOR_POINT:
820 mTxComponentStatic[ index ].mAnchorPoint.z = value;
823 case TRANSFORM_PROPERTY_SIZE:
825 mSize[ index ].z = mSizeBase[index].z = value;
830 DALI_ASSERT_ALWAYS(false);
835 Quaternion& TransformManager::GetQuaternionPropertyValue( TransformId id )
837 TransformId index( mIds[id] );
838 mComponentDirty[ index ] = true;
839 return mTxComponentAnimatable[ index ].mOrientation;
842 const Quaternion& TransformManager::GetQuaternionPropertyValue( TransformId id ) const
844 return mTxComponentAnimatable[ mIds[id] ].mOrientation;
847 void TransformManager::SetQuaternionPropertyValue( TransformId id, const Quaternion& q )
849 TransformId index( mIds[id] );
850 mTxComponentAnimatable[ index ].mOrientation = q;
851 mComponentDirty[ index ] = true;
854 void TransformManager::BakeQuaternionPropertyValue( TransformId id, const Quaternion& q )
856 TransformId index( mIds[id] );
857 mTxComponentAnimatable[ index ].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
858 mComponentDirty[ index ] = true;
861 void TransformManager::BakeRelativeQuaternionPropertyValue( TransformId id, const Quaternion& q )
863 TransformId index( mIds[id] );
864 mTxComponentAnimatable[ index ].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[ index ].mOrientation * q;
865 mComponentDirty[ index ] = true;
868 const Vector4& TransformManager::GetBoundingSphere( TransformId id ) const
870 return mBoundingSpheres[ mIds[id] ];
873 void TransformManager::GetWorldMatrixAndSize( TransformId id, Matrix& worldMatrix, Vector3& size ) const
875 TransformId index = mIds[id];
876 worldMatrix = mWorld[index];
880 void TransformManager::SetPositionUsesAnchorPoint( TransformId id, bool value )
882 TransformId index( mIds[ id ] );
883 mComponentDirty[ index ] = true;
884 mTxComponentStatic[ index ].mPositionUsesAnchorPoint = value;
887 } //namespace SceneGraph
888 } //namespace Internal