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);
109 mComponentChanged.PushBack(false);
110 mPrevWorld.PushBack(Matrix::IDENTITY);
111 mUpdateSizeHint.PushBack(Vector3(0.0f,0.0f,0.0f));
112 mUpdateSizeHintBase.PushBack(Vector3(0.0f,0.0f,0.0f));
117 memcpy( &mTxComponentAnimatable[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof( TransformComponentAnimatable ) );
118 memcpy( &mTxComponentStatic[mComponentCount], &gDefaultTransformComponentStaticData, sizeof( TransformComponentStatic ) );
119 memcpy( &mTxComponentAnimatableBaseValue[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof( TransformComponentAnimatable ) );
120 mInheritanceMode[mComponentCount] = INHERIT_ALL;
121 mComponentId[mComponentCount] = id;
122 mSize[mComponentCount] = Vector3(0.0f,0.0f,0.0f);
123 mParent[mComponentCount] = INVALID_TRANSFORM_ID;
124 mLocal[mComponentCount].SetIdentity();
125 mWorld[mComponentCount].SetIdentity();
126 mBoundingSpheres[mComponentCount] = Vector4(0.0f,0.0f,0.0f,0.0f);
127 mSizeBase[mComponentCount] = Vector3(0.0f,0.0f,0.0f);
128 mComponentDirty[mComponentCount] = false;
129 mLocalMatrixDirty[mComponentCount] = false;
130 mComponentChanged[mComponentCount] = false;
131 mPrevWorld[mComponentCount].SetIdentity();
132 mUpdateSizeHint[mComponentCount] = Vector3(0.0f,0.0f,0.0f);
133 mUpdateSizeHintBase[mComponentCount] = Vector3(0.0f,0.0f,0.0f);
140 void TransformManager::RemoveTransform(TransformId id)
142 //Move the last element to the gap
144 TransformId index = mIds[id];
145 mTxComponentAnimatable[index] = mTxComponentAnimatable[mComponentCount];
146 mTxComponentStatic[index] = mTxComponentStatic[mComponentCount];
147 mInheritanceMode[index] = mInheritanceMode[mComponentCount];
148 mSize[index] = mSize[mComponentCount];
149 mParent[index] = mParent[mComponentCount];
150 mWorld[index] = mWorld[mComponentCount];
151 mLocal[index] = mLocal[mComponentCount];
152 mTxComponentAnimatableBaseValue[index] = mTxComponentAnimatableBaseValue[mComponentCount];
153 mSizeBase[index] = mSizeBase[mComponentCount];
154 mComponentDirty[index] = mComponentDirty[mComponentCount];
155 mLocalMatrixDirty[index] = mLocalMatrixDirty[mComponentCount];
156 mBoundingSpheres[index] = mBoundingSpheres[mComponentCount];
157 mComponentChanged[index] = mComponentChanged[mComponentCount];
158 mPrevWorld[index] = mPrevWorld[mComponentCount];
159 mUpdateSizeHint[index] = mUpdateSizeHint[mComponentCount];
160 mUpdateSizeHintBase[index] = mUpdateSizeHintBase[mComponentCount];
162 TransformId lastItemId = mComponentId[mComponentCount];
163 mIds[ lastItemId ] = index;
164 mComponentId[index] = lastItemId;
170 void TransformManager::SetParent( TransformId id, TransformId parentId )
172 DALI_ASSERT_ALWAYS( id != parentId );
173 TransformId index = mIds[id];
174 mParent[ index ] = parentId;
175 mComponentDirty[ index ] = true;
179 const Matrix& TransformManager::GetWorldMatrix( TransformId id ) const
181 return mWorld[ mIds[id] ];
184 Matrix& TransformManager::GetWorldMatrix( TransformId id )
186 return mWorld[ mIds[id] ];
189 void TransformManager::SetInheritPosition( TransformId id, bool inherit )
191 TransformId index = mIds[id];
194 mInheritanceMode[ index ] |= INHERIT_POSITION;
198 mInheritanceMode[ index ] &= ~INHERIT_POSITION;
201 mComponentDirty[index] = true;
204 void TransformManager::SetInheritScale( TransformId id, bool inherit )
206 TransformId index = mIds[id];
209 mInheritanceMode[ index ] |= INHERIT_SCALE;
213 mInheritanceMode[ index ] &= ~INHERIT_SCALE;
216 mComponentDirty[index] = true;
219 void TransformManager::SetInheritOrientation( TransformId id, bool inherit )
221 TransformId index = mIds[id];
224 mInheritanceMode[ index ] |= INHERIT_ORIENTATION;
228 mInheritanceMode[ index ] &= ~INHERIT_ORIENTATION;
230 mComponentDirty[index] = true;
233 void TransformManager::ResetToBaseValue()
235 if( mComponentCount )
237 memcpy( &mTxComponentAnimatable[0], &mTxComponentAnimatableBaseValue[0], sizeof(TransformComponentAnimatable)*mComponentCount );
238 memcpy( &mSize[0], &mSizeBase[0], sizeof(Vector3)*mComponentCount );
239 memset( &mLocalMatrixDirty[0], false, sizeof(bool)*mComponentCount );
240 memcpy( &mUpdateSizeHint[0], &mUpdateSizeHintBase[0], sizeof(Vector3)*mComponentCount );
244 void TransformManager::Update()
248 //If some transform component has change its parent or has been removed since last update
249 //we need to reorder the vectors
254 //Iterate through all components to compute its world matrix
255 Vector3 centerPosition;
256 Vector3 localPosition;
257 const Vector3 half( 0.5f,0.5f,0.5f );
258 const Vector3 topLeft( 0.0f, 0.0f, 0.5f );
259 for( unsigned int i(0); i<mComponentCount; ++i )
261 mPrevWorld[i] = mWorld[i];
263 if( DALI_LIKELY( mInheritanceMode[i] != DONT_INHERIT_TRANSFORM && mParent[i] != INVALID_TRANSFORM_ID ) )
265 const TransformId& parentIndex = mIds[mParent[i] ];
266 if( DALI_LIKELY( mInheritanceMode[i] == INHERIT_ALL ) )
268 if( mComponentDirty[i] || mLocalMatrixDirty[parentIndex])
270 //Full transform inherited
271 mLocalMatrixDirty[i] = true;
272 CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
273 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + ( mTxComponentStatic[i].mParentOrigin - half ) * mSize[parentIndex];
274 mLocal[i].SetTransformComponents( mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition );
277 //Update the world matrix
278 Matrix::Multiply( mWorld[i], mLocal[i], mWorld[parentIndex]);
282 //Some components are not inherited
283 Vector3 parentPosition, parentScale;
284 Quaternion parentOrientation;
285 const Matrix& parentMatrix = mWorld[parentIndex];
286 parentMatrix.GetTransformComponents( parentPosition, parentOrientation, parentScale );
288 Vector3 localScale = mTxComponentAnimatable[i].mScale;
289 if( (mInheritanceMode[i] & INHERIT_SCALE) == 0 )
291 //Don't inherit scale
292 localScale /= parentScale;
295 Quaternion localOrientation( mTxComponentAnimatable[i].mOrientation );
296 if( (mInheritanceMode[i] & INHERIT_ORIENTATION) == 0 )
298 //Don't inherit orientation
299 parentOrientation.Invert();
300 localOrientation = parentOrientation * mTxComponentAnimatable[i].mOrientation;
303 if( (mInheritanceMode[i] & INHERIT_POSITION) == 0 )
305 //Don't inherit position
306 CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
307 mLocal[i].SetTransformComponents( localScale, localOrientation, Vector3::ZERO );
308 Matrix::Multiply( mWorld[i], mLocal[i], parentMatrix );
309 mWorld[i].SetTranslation( mTxComponentAnimatable[i].mPosition + centerPosition );
313 CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
314 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + ( mTxComponentStatic[i].mParentOrigin - half ) * mSize[parentIndex];
315 mLocal[i].SetTransformComponents( localScale, localOrientation, localPosition );
316 Matrix::Multiply( mWorld[i], mLocal[i], parentMatrix );
319 mLocalMatrixDirty[i] = true;
322 else //Component has no parent or doesn't inherit transform
324 CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
325 localPosition = mTxComponentAnimatable[i].mPosition + centerPosition;
326 mLocal[i].SetTransformComponents( mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition );
327 mWorld[i] = mLocal[i];
328 mLocalMatrixDirty[i] = true;
331 //Update the bounding sphere
332 Vec3 centerToEdge = { mSize[i].Length() * 0.5f, 0.0f, 0.0f };
333 Vec3 centerToEdgeWorldSpace;
334 TransformVector3( centerToEdgeWorldSpace, mWorld[i].AsFloat(), centerToEdge );
336 mBoundingSpheres[i] = mWorld[i].GetTranslation();
337 mBoundingSpheres[i].w = Length( centerToEdgeWorldSpace );
339 mComponentChanged[i] = false;
341 // Due to parent transformation child transformation could be changed
342 if( mComponentDirty[i] ||
343 mPrevWorld[i] != mWorld[i] )
345 mComponentChanged[i] = true;
348 mComponentDirty[i] = false;
353 void TransformManager::SwapComponents( unsigned int i, unsigned int j )
355 std::swap( mTxComponentAnimatable[i], mTxComponentAnimatable[j] );
356 std::swap( mTxComponentStatic[i], mTxComponentStatic[j] );
357 std::swap( mInheritanceMode[i], mInheritanceMode[j] );
358 std::swap( mSize[i], mSize[j] );
359 std::swap( mParent[i], mParent[j] );
360 std::swap( mComponentId[i], mComponentId[j] );
361 std::swap( mTxComponentAnimatableBaseValue[i], mTxComponentAnimatableBaseValue[j] );
362 std::swap( mSizeBase[i], mSizeBase[j] );
363 std::swap( mLocal[i], mLocal[j] );
364 std::swap( mComponentDirty[i], mComponentDirty[j] );
365 std::swap( mBoundingSpheres[i], mBoundingSpheres[j] );
366 std::swap( mWorld[i], mWorld[j] );
367 std::swap( mComponentChanged[i], mComponentChanged[j] );
368 std::swap( mPrevWorld[i], mPrevWorld[j] );
369 std::swap( mUpdateSizeHint[i], mUpdateSizeHint[j] );
370 std::swap( mUpdateSizeHintBase[i], mUpdateSizeHintBase[j] );
372 mIds[ mComponentId[i] ] = i;
373 mIds[ mComponentId[j] ] = j;
376 void TransformManager::ReorderComponents()
378 mOrderedComponents.Resize(mComponentCount);
380 TransformId parentId;
381 for( TransformId i = 0; i<mComponentCount; ++i )
383 mOrderedComponents[i].id = mComponentId[i];
384 mOrderedComponents[i].level = 0u;
386 parentId = mParent[i];
387 while( parentId != INVALID_TRANSFORM_ID )
389 mOrderedComponents[i].level++;
390 parentId = mParent[ mIds[parentId] ];
394 std::stable_sort( mOrderedComponents.Begin(), mOrderedComponents.End());
395 TransformId previousIndex = 0;
396 for( TransformId newIndex = 0; newIndex < mComponentCount-1; ++newIndex )
398 previousIndex = mIds[mOrderedComponents[newIndex].id];
399 if( previousIndex != newIndex )
401 SwapComponents( previousIndex, newIndex);
406 Vector3& TransformManager::GetVector3PropertyValue( TransformId id, TransformManagerProperty property )
410 case TRANSFORM_PROPERTY_POSITION:
412 TransformId index( mIds[id] );
413 mComponentDirty[ index ] = true;
414 return mTxComponentAnimatable[ index ].mPosition;
416 case TRANSFORM_PROPERTY_SCALE:
418 TransformId index( mIds[id] );
419 mComponentDirty[ index ] = true;
420 return mTxComponentAnimatable[ index ].mScale;
422 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
424 TransformId index( mIds[id] );
425 mComponentDirty[ index ] = true;
426 return mTxComponentStatic[ index ].mParentOrigin;
428 case TRANSFORM_PROPERTY_ANCHOR_POINT:
430 TransformId index( mIds[id] );
431 mComponentDirty[ index ] = true;
432 return mTxComponentStatic[ index ].mAnchorPoint;
434 case TRANSFORM_PROPERTY_SIZE:
436 TransformId index( mIds[id] );
437 mComponentDirty[ index ] = true;
438 return mSize[ index ];
440 case TRANSFORM_PROPERTY_UPDATE_SIZE_HINT:
442 TransformId index( mIds[id] );
443 mComponentDirty[ index ] = true;
444 return mUpdateSizeHint[ index ];
448 DALI_ASSERT_ALWAYS(false);
449 return mTxComponentAnimatable[ mIds[id] ].mPosition;
454 const Vector3& TransformManager::GetVector3PropertyValue( TransformId id, TransformManagerProperty property ) const
458 case TRANSFORM_PROPERTY_POSITION:
460 return mTxComponentAnimatable[ mIds[id] ].mPosition;
462 case TRANSFORM_PROPERTY_SCALE:
464 return mTxComponentAnimatable[ mIds[id] ].mScale;
466 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
468 return mTxComponentStatic[ mIds[id] ].mParentOrigin;
470 case TRANSFORM_PROPERTY_ANCHOR_POINT:
472 return mTxComponentStatic[ mIds[id] ].mAnchorPoint;
474 case TRANSFORM_PROPERTY_SIZE:
476 return mSize[ mIds[id] ];
478 case TRANSFORM_PROPERTY_UPDATE_SIZE_HINT:
480 return mUpdateSizeHint[ mIds[id] ];
484 DALI_ASSERT_ALWAYS(false);
485 return mTxComponentAnimatable[ mIds[id] ].mPosition;
490 const float& TransformManager::GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, unsigned int component ) const
494 case TRANSFORM_PROPERTY_POSITION:
496 return mTxComponentAnimatable[ mIds[id] ].mPosition[component];
498 case TRANSFORM_PROPERTY_SCALE:
500 return mTxComponentAnimatable[ mIds[id] ].mScale[component];
502 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
504 return mTxComponentStatic[ mIds[id] ].mParentOrigin[component];
506 case TRANSFORM_PROPERTY_ANCHOR_POINT:
508 return mTxComponentStatic[ mIds[id] ].mAnchorPoint[component];
510 case TRANSFORM_PROPERTY_SIZE:
512 return mSize[ mIds[id] ][component];
514 case TRANSFORM_PROPERTY_UPDATE_SIZE_HINT:
516 return mUpdateSizeHint[ mIds[id] ][component];
520 DALI_ASSERT_ALWAYS(false);
521 return mTxComponentAnimatable[ mIds[id] ].mPosition[component];
526 void TransformManager::SetVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
528 TransformId index( mIds[id] );
529 mComponentDirty[ index ] = true;
533 case TRANSFORM_PROPERTY_POSITION:
535 mTxComponentAnimatable[ index ].mPosition = value;
538 case TRANSFORM_PROPERTY_SCALE:
540 mTxComponentAnimatable[ index ].mScale = value;
543 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
545 mTxComponentStatic[ index ].mParentOrigin = value;
548 case TRANSFORM_PROPERTY_ANCHOR_POINT:
550 mTxComponentStatic[ index ].mAnchorPoint = value;
553 case TRANSFORM_PROPERTY_SIZE:
555 mSize[ index ] = value;
558 case TRANSFORM_PROPERTY_UPDATE_SIZE_HINT:
560 mUpdateSizeHint[ index ] = value;
565 DALI_ASSERT_ALWAYS(false);
570 void TransformManager::SetVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, unsigned int component )
572 TransformId index( mIds[id] );
573 mComponentDirty[ index ] = true;
577 case TRANSFORM_PROPERTY_POSITION:
579 mTxComponentAnimatable[ index ].mPosition[component] = value;
582 case TRANSFORM_PROPERTY_SCALE:
584 mTxComponentAnimatable[ index ].mScale[component] = value;
587 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
589 mTxComponentStatic[ index ].mParentOrigin[component] = value;
592 case TRANSFORM_PROPERTY_ANCHOR_POINT:
594 mTxComponentStatic[ index ].mAnchorPoint[component] = value;
597 case TRANSFORM_PROPERTY_SIZE:
599 mSize[ index ][component] = value;
602 case TRANSFORM_PROPERTY_UPDATE_SIZE_HINT:
604 mUpdateSizeHint[ index ][component] = value;
609 DALI_ASSERT_ALWAYS(false);
614 void TransformManager::BakeVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
616 TransformId index( mIds[id] );
617 mComponentDirty[ index ] = true;
621 case TRANSFORM_PROPERTY_POSITION:
623 mTxComponentAnimatable[ index ].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = value;
626 case TRANSFORM_PROPERTY_SCALE:
628 mTxComponentAnimatable[ index ].mScale = mTxComponentAnimatableBaseValue[index].mScale = value;
631 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
633 mTxComponentStatic[ index ].mParentOrigin = value;
636 case TRANSFORM_PROPERTY_ANCHOR_POINT:
638 mTxComponentStatic[ index ].mAnchorPoint = value;
641 case TRANSFORM_PROPERTY_SIZE:
643 mSize[ index ] = mSizeBase[index] = value;
646 case TRANSFORM_PROPERTY_UPDATE_SIZE_HINT:
648 mUpdateSizeHint[ index ] = mUpdateSizeHintBase[index] = value;
653 DALI_ASSERT_ALWAYS(false);
658 void TransformManager::BakeRelativeVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
660 TransformId index( mIds[id] );
661 mComponentDirty[ index ] = true;
665 case TRANSFORM_PROPERTY_POSITION:
667 mTxComponentAnimatable[ index ].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[ index ].mPosition + value;
670 case TRANSFORM_PROPERTY_SCALE:
672 mTxComponentAnimatable[ index ].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[ index ].mScale + value;
675 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
677 mTxComponentStatic[ index ].mParentOrigin = mTxComponentStatic[ index ].mParentOrigin + value;
680 case TRANSFORM_PROPERTY_ANCHOR_POINT:
682 mTxComponentStatic[ index ].mAnchorPoint = mTxComponentStatic[ index ].mAnchorPoint + value;
685 case TRANSFORM_PROPERTY_SIZE:
687 mSize[ index ] = mSizeBase[index] = mSize[ index ] + value;
690 case TRANSFORM_PROPERTY_UPDATE_SIZE_HINT:
692 mUpdateSizeHint[ index ] = mUpdateSizeHintBase[index] = mUpdateSizeHint[ index ] + value;
697 DALI_ASSERT_ALWAYS(false);
702 void TransformManager::BakeMultiplyVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
704 TransformId index( mIds[id] );
705 mComponentDirty[ index ] = true;
709 case TRANSFORM_PROPERTY_POSITION:
711 mTxComponentAnimatable[ index ].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[ index ].mPosition * value;
714 case TRANSFORM_PROPERTY_SCALE:
716 mTxComponentAnimatable[ index ].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[ index ].mScale * value;
719 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
721 mTxComponentStatic[ index ].mParentOrigin = mTxComponentStatic[ index ].mParentOrigin * value;
724 case TRANSFORM_PROPERTY_ANCHOR_POINT:
726 mTxComponentStatic[ index ].mAnchorPoint = mTxComponentStatic[ index ].mAnchorPoint * value;
729 case TRANSFORM_PROPERTY_SIZE:
731 mSize[ index ] = mSizeBase[index] = mSize[ index ] * value;
734 case TRANSFORM_PROPERTY_UPDATE_SIZE_HINT:
736 mUpdateSizeHint[ index ] = mUpdateSizeHintBase[index] = mUpdateSizeHint[ index ] * value;
741 DALI_ASSERT_ALWAYS(false);
746 void TransformManager::BakeVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, unsigned int component )
748 TransformId index( mIds[id] );
749 mComponentDirty[ index ] = true;
753 case TRANSFORM_PROPERTY_POSITION:
755 mTxComponentAnimatable[ index ].mPosition[component] = mTxComponentAnimatableBaseValue[index].mPosition[component] = value;
758 case TRANSFORM_PROPERTY_SCALE:
760 mTxComponentAnimatable[ index ].mScale[component] = mTxComponentAnimatableBaseValue[index].mScale[component] = value;
763 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
765 mTxComponentStatic[ index ].mParentOrigin[component] = value;
768 case TRANSFORM_PROPERTY_ANCHOR_POINT:
770 mTxComponentStatic[ index ].mAnchorPoint[component] = value;
773 case TRANSFORM_PROPERTY_SIZE:
775 mSize[ index ][component] = mSizeBase[index][component] = value;
778 case TRANSFORM_PROPERTY_UPDATE_SIZE_HINT:
780 mUpdateSizeHint[ index ][component] = mUpdateSizeHintBase[index][component] = value;
785 DALI_ASSERT_ALWAYS(false);
790 void TransformManager::BakeXVector3PropertyValue( TransformId id, TransformManagerProperty property, float value )
792 TransformId index( mIds[id] );
793 mComponentDirty[ index ] = true;
797 case TRANSFORM_PROPERTY_POSITION:
799 mTxComponentAnimatable[ index ].mPosition.x = mTxComponentAnimatableBaseValue[index].mPosition.x = value;
802 case TRANSFORM_PROPERTY_SCALE:
804 mTxComponentAnimatable[ index ].mScale.x = mTxComponentAnimatableBaseValue[index].mScale.x = value;
807 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
809 mTxComponentStatic[ index ].mParentOrigin.x = value;
812 case TRANSFORM_PROPERTY_ANCHOR_POINT:
814 mTxComponentStatic[ index ].mAnchorPoint.x = value;
817 case TRANSFORM_PROPERTY_SIZE:
819 mSize[ index ].x = mSizeBase[index].x = value;
822 case TRANSFORM_PROPERTY_UPDATE_SIZE_HINT:
824 mUpdateSizeHint[ index ].x = mUpdateSizeHintBase[index].x = value;
829 DALI_ASSERT_ALWAYS(false);
834 void TransformManager::BakeYVector3PropertyValue( TransformId id, TransformManagerProperty property, float value )
836 TransformId index( mIds[id] );
837 mComponentDirty[ index ] = true;
841 case TRANSFORM_PROPERTY_POSITION:
843 mTxComponentAnimatable[ index ].mPosition.y = mTxComponentAnimatableBaseValue[index].mPosition.y = value;
846 case TRANSFORM_PROPERTY_SCALE:
848 mTxComponentAnimatable[ index ].mScale.y = mTxComponentAnimatableBaseValue[index].mScale.y = value;
851 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
853 mTxComponentStatic[ index ].mParentOrigin.y = value;
856 case TRANSFORM_PROPERTY_ANCHOR_POINT:
858 mTxComponentStatic[ index ].mAnchorPoint.y = value;
861 case TRANSFORM_PROPERTY_SIZE:
863 mSize[ index ].y = mSizeBase[index].y = value;
866 case TRANSFORM_PROPERTY_UPDATE_SIZE_HINT:
868 mUpdateSizeHint[ index ].y = mUpdateSizeHintBase[index].y = value;
873 DALI_ASSERT_ALWAYS(false);
878 void TransformManager::BakeZVector3PropertyValue( TransformId id, TransformManagerProperty property, float value )
880 TransformId index( mIds[id] );
881 mComponentDirty[ index ] = true;
885 case TRANSFORM_PROPERTY_POSITION:
887 mTxComponentAnimatable[ index ].mPosition.z = mTxComponentAnimatableBaseValue[index].mPosition.z = value;
890 case TRANSFORM_PROPERTY_SCALE:
892 mTxComponentAnimatable[ index ].mScale.z = mTxComponentAnimatableBaseValue[index].mScale.z = value;
895 case TRANSFORM_PROPERTY_PARENT_ORIGIN:
897 mTxComponentStatic[ index ].mParentOrigin.z = value;
900 case TRANSFORM_PROPERTY_ANCHOR_POINT:
902 mTxComponentStatic[ index ].mAnchorPoint.z = value;
905 case TRANSFORM_PROPERTY_SIZE:
907 mSize[ index ].z = mSizeBase[index].z = value;
910 case TRANSFORM_PROPERTY_UPDATE_SIZE_HINT:
912 mUpdateSizeHint[ index ].z = mUpdateSizeHintBase[index].z = value;
917 DALI_ASSERT_ALWAYS(false);
922 Quaternion& TransformManager::GetQuaternionPropertyValue( TransformId id )
924 TransformId index( mIds[id] );
925 mComponentDirty[ index ] = true;
926 return mTxComponentAnimatable[ index ].mOrientation;
929 const Quaternion& TransformManager::GetQuaternionPropertyValue( TransformId id ) const
931 return mTxComponentAnimatable[ mIds[id] ].mOrientation;
934 void TransformManager::SetQuaternionPropertyValue( TransformId id, const Quaternion& q )
936 TransformId index( mIds[id] );
937 mTxComponentAnimatable[ index ].mOrientation = q;
938 mComponentDirty[ index ] = true;
941 void TransformManager::BakeQuaternionPropertyValue( TransformId id, const Quaternion& q )
943 TransformId index( mIds[id] );
944 mTxComponentAnimatable[ index ].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
945 mComponentDirty[ index ] = true;
948 void TransformManager::BakeRelativeQuaternionPropertyValue( TransformId id, const Quaternion& q )
950 TransformId index( mIds[id] );
951 mTxComponentAnimatable[ index ].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[ index ].mOrientation * q;
952 mComponentDirty[ index ] = true;
955 const Vector4& TransformManager::GetBoundingSphere( TransformId id ) const
957 return mBoundingSpheres[ mIds[id] ];
960 bool TransformManager::IsComponentChanged( TransformId id ) const
962 return mComponentChanged[ mIds[id]];
965 void TransformManager::GetWorldMatrixAndSize( TransformId id, Matrix& worldMatrix, Vector3& size ) const
967 TransformId index = mIds[id];
968 worldMatrix = mWorld[index];
972 void TransformManager::GetUpdateSizeHint( TransformId id, Vector3& updateSizeHint ) const
974 updateSizeHint = mUpdateSizeHint[ mIds[id] ] * mTxComponentAnimatable[mIds[ id ] ].mScale;
977 void TransformManager::SetPositionUsesAnchorPoint( TransformId id, bool value )
979 TransformId index( mIds[ id ] );
980 mComponentDirty[ index ] = true;
981 mTxComponentStatic[ index ].mPositionUsesAnchorPoint = value;
984 } //namespace SceneGraph
985 } //namespace Internal