Multiply only for Transform Matrix + NEON comment clean up
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / transform-manager.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/update/manager/transform-manager.h>
20
21 //EXTERNAL INCLUDES
22 #include <algorithm>
23 #include <cstring>
24 #include <type_traits>
25
26 //INTERNAL INCLUDES
27 #include <dali/internal/common/math.h>
28 #include <dali/internal/common/matrix-utils.h>
29 #include <dali/public-api/common/constants.h>
30
31 #include <dali/integration-api/debug.h>
32
33 namespace Dali
34 {
35 namespace Internal
36 {
37 namespace SceneGraph
38 {
39 namespace
40 {
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};
43
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};
46
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");
49
50 /**
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
59  */
60 inline void CalculateCenterPosition(
61   Vector3&                        centerPosition,
62   const TransformComponentStatic& transformComponentStatic,
63   const Vector3&                  scale,
64   const Quaternion&               orientation,
65   const Vector3&                  size,
66   const Vector3&                  half,
67   const Vector3&                  topLeft)
68 {
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;
72
73   // If the position is ignoring the anchor-point, then remove the anchor-point shift from the position.
74   if(!transformComponentStatic.mPositionUsesAnchorPoint)
75   {
76     centerPosition -= (topLeft - transformComponentStatic.mAnchorPoint) * size;
77   }
78 }
79
80 } // unnamed namespace
81
82 TransformManager::TransformManager()
83 : mComponentCount(0),
84   mReorder(false)
85 {
86 }
87
88 TransformManager::~TransformManager() = default;
89
90 TransformId TransformManager::CreateTransform()
91 {
92   //Get id for the new component
93   TransformId id = mIds.Add(mComponentCount);
94
95   if(mTxComponentAnimatable.Size() <= mComponentCount)
96   {
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);
111   }
112   else
113   {
114     //Set default values
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;
128   }
129
130   mComponentCount++;
131   return id;
132 }
133
134 void TransformManager::RemoveTransform(TransformId id)
135 {
136   //Move the last element to the gap
137   mComponentCount--;
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];
151
152   TransformId lastItemId = mComponentId[mComponentCount];
153   mIds[lastItemId]       = index;
154   mComponentId[index]    = lastItemId;
155   mIds.Remove(id);
156
157   mReorder = true;
158 }
159
160 void TransformManager::SetParent(TransformId id, TransformId parentId)
161 {
162   DALI_ASSERT_ALWAYS(id != parentId);
163   TransformId index      = mIds[id];
164   mParent[index]         = parentId;
165   mComponentDirty[index] = true;
166   mReorder               = true;
167 }
168
169 const Matrix& TransformManager::GetWorldMatrix(TransformId id) const
170 {
171   return mWorld[mIds[id]];
172 }
173
174 Matrix& TransformManager::GetWorldMatrix(TransformId id)
175 {
176   return mWorld[mIds[id]];
177 }
178
179 void TransformManager::SetInheritPosition(TransformId id, bool inherit)
180 {
181   TransformId index = mIds[id];
182   if(inherit)
183   {
184     mInheritanceMode[index] |= INHERIT_POSITION;
185   }
186   else
187   {
188     mInheritanceMode[index] &= ~INHERIT_POSITION;
189   }
190
191   mComponentDirty[index] = true;
192 }
193
194 void TransformManager::SetInheritScale(TransformId id, bool inherit)
195 {
196   TransformId index = mIds[id];
197   if(inherit)
198   {
199     mInheritanceMode[index] |= INHERIT_SCALE;
200   }
201   else
202   {
203     mInheritanceMode[index] &= ~INHERIT_SCALE;
204   }
205
206   mComponentDirty[index] = true;
207 }
208
209 void TransformManager::SetInheritOrientation(TransformId id, bool inherit)
210 {
211   TransformId index = mIds[id];
212   if(inherit)
213   {
214     mInheritanceMode[index] |= INHERIT_ORIENTATION;
215   }
216   else
217   {
218     mInheritanceMode[index] &= ~INHERIT_ORIENTATION;
219   }
220
221   mComponentDirty[index] = true;
222 }
223
224 void TransformManager::ResetToBaseValue()
225 {
226   if(mComponentCount)
227   {
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);
231   }
232 }
233
234 bool TransformManager::Update()
235 {
236   bool componentsChanged = false;
237
238   if(mReorder)
239   {
240     //If some transform component has change its parent or has been removed since last update
241     //we need to reorder the vectors
242     ReorderComponents();
243     mReorder = false;
244   }
245
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)
252   {
253     if(DALI_LIKELY(mInheritanceMode[i] != DONT_INHERIT_TRANSFORM && mParent[i] != INVALID_TRANSFORM_ID))
254     {
255       const TransformId& parentIndex = mIds[mParent[i]];
256       if(DALI_LIKELY(mInheritanceMode[i] == INHERIT_ALL))
257       {
258         if(mComponentDirty[i] || mLocalMatrixDirty[parentIndex])
259         {
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);
265         }
266
267         //Update the world matrix
268         MatrixUtils::MultiplyTransformMatrix(mWorld[i], mLocal[i], mWorld[parentIndex]);
269       }
270       else
271       {
272         // Keep previous localMatrix for comparison.
273         Matrix previousLocalMatrix = mLocal[i];
274
275         // Get Parent information.
276         Vector3       parentPosition, parentScale;
277         Quaternion    parentOrientation;
278         const Matrix& parentMatrix = mWorld[parentIndex];
279         parentMatrix.GetTransformComponents(parentPosition, parentOrientation, parentScale);
280
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);
286
287         // Compute intermediate world information
288         Matrix intermediateWorldMatrix;
289         MatrixUtils::MultiplyTransformMatrix(intermediateWorldMatrix, intermediateLocalMatrix, mWorld[parentIndex]);
290
291         Vector3       intermediateWorldPosition, intermediateWorldScale;
292         Quaternion    intermediateWorldOrientation;
293         intermediateWorldMatrix.GetTransformComponents(intermediateWorldPosition, intermediateWorldOrientation, intermediateWorldScale);
294
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)
303         {
304           finalWorldScale = mTxComponentAnimatable[i].mScale;
305         }
306
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)
310         {
311           finalWorldOrientation = mTxComponentAnimatable[i].mOrientation;
312         }
313
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)
323         {
324           Vector4 parentOriginPosition((mTxComponentStatic[i].mParentOrigin - half) * mSize[parentIndex]);
325           parentOriginPosition.w = 1.0f;
326           finalWorldPosition += Vector3(parentMatrix * parentOriginPosition);
327         }
328
329         mWorld[i].SetTransformComponents(finalWorldScale, finalWorldOrientation, finalWorldPosition);
330
331         Matrix inverseParentMatrix;
332         inverseParentMatrix.SetInverseTransformComponents(parentScale, parentOrientation, parentPosition);
333         mLocal[i] = inverseParentMatrix * mWorld[i];
334
335         mLocalMatrixDirty[i] = mComponentDirty[i] || (previousLocalMatrix != mLocal[i]);
336       }
337     }
338     else //Component has no parent or doesn't inherit transform
339     {
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]);
346     }
347
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);
352
353     mBoundingSpheres[i]   = mWorld[i].GetTranslation();
354     mBoundingSpheres[i].w = Length(centerToEdgeWorldSpace);
355
356     componentsChanged  = componentsChanged || mComponentDirty[i];
357     mComponentDirty[i] = false;
358   }
359
360   return componentsChanged;
361 }
362
363 void TransformManager::SwapComponents(unsigned int i, unsigned int j)
364 {
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]);
377
378   mIds[mComponentId[i]] = i;
379   mIds[mComponentId[j]] = j;
380 }
381
382 void TransformManager::ReorderComponents()
383 {
384   mOrderedComponents.Resize(mComponentCount);
385
386   uint16_t    sceneId = 0u;
387   TransformId parentId;
388
389   // Create sceneId first
390   for(TransformId i = 0; i < mComponentCount; ++i)
391   {
392     mOrderedComponents[i].id    = mComponentId[i];
393     mOrderedComponents[i].level = 0u;
394
395     parentId = mParent[i];
396     if(parentId == INVALID_TRANSFORM_ID)
397     {
398       mOrderedComponents[i].sceneId = sceneId++;
399     }
400   }
401
402   // Propagate sceneId and level
403   for(TransformId i = 0; i < mComponentCount; ++i)
404   {
405     parentId = mParent[i];
406     while(parentId != INVALID_TRANSFORM_ID)
407     {
408       const uint32_t parentIndex = mIds[parentId];
409       ++mOrderedComponents[i].level;
410       mOrderedComponents[i].sceneId = mOrderedComponents[parentIndex].sceneId;
411       if(parentIndex < i)
412       {
413         // Parent information update done. We can reuse it.
414         mOrderedComponents[i].level += mOrderedComponents[parentIndex].level;
415         break;
416       }
417       else
418       {
419         parentId = mParent[parentIndex];
420       }
421     }
422   }
423
424   std::stable_sort(mOrderedComponents.Begin(), mOrderedComponents.End());
425   TransformId previousIndex = 0;
426   for(TransformId newIndex = 0; newIndex < mComponentCount - 1; ++newIndex)
427   {
428     previousIndex = mIds[mOrderedComponents[newIndex].id];
429     if(previousIndex != newIndex)
430     {
431       SwapComponents(previousIndex, newIndex);
432     }
433   }
434 }
435
436 Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property)
437 {
438   switch(property)
439   {
440     case TRANSFORM_PROPERTY_POSITION:
441     {
442       TransformId index(mIds[id]);
443       return mTxComponentAnimatable[index].mPosition;
444     }
445     case TRANSFORM_PROPERTY_SCALE:
446     {
447       TransformId index(mIds[id]);
448       return mTxComponentAnimatable[index].mScale;
449     }
450     case TRANSFORM_PROPERTY_PARENT_ORIGIN:
451     {
452       TransformId index(mIds[id]);
453       return mTxComponentStatic[index].mParentOrigin;
454     }
455     case TRANSFORM_PROPERTY_ANCHOR_POINT:
456     {
457       TransformId index(mIds[id]);
458       return mTxComponentStatic[index].mAnchorPoint;
459     }
460     case TRANSFORM_PROPERTY_SIZE:
461     {
462       TransformId index(mIds[id]);
463       return mSize[index];
464     }
465     default:
466     {
467       DALI_ASSERT_ALWAYS(false);
468       return mTxComponentAnimatable[mIds[id]].mPosition;
469     }
470   }
471 }
472
473 const Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property) const
474 {
475   switch(property)
476   {
477     case TRANSFORM_PROPERTY_POSITION:
478     {
479       return mTxComponentAnimatable[mIds[id]].mPosition;
480     }
481     case TRANSFORM_PROPERTY_SCALE:
482     {
483       return mTxComponentAnimatable[mIds[id]].mScale;
484     }
485     case TRANSFORM_PROPERTY_PARENT_ORIGIN:
486     {
487       return mTxComponentStatic[mIds[id]].mParentOrigin;
488     }
489     case TRANSFORM_PROPERTY_ANCHOR_POINT:
490     {
491       return mTxComponentStatic[mIds[id]].mAnchorPoint;
492     }
493     case TRANSFORM_PROPERTY_SIZE:
494     {
495       return mSize[mIds[id]];
496     }
497     default:
498     {
499       DALI_ASSERT_ALWAYS(false);
500       return mTxComponentAnimatable[mIds[id]].mPosition;
501     }
502   }
503 }
504
505 const float& TransformManager::GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, unsigned int component) const
506 {
507   switch(property)
508   {
509     case TRANSFORM_PROPERTY_POSITION:
510     {
511       return mTxComponentAnimatable[mIds[id]].mPosition[component];
512     }
513     case TRANSFORM_PROPERTY_SCALE:
514     {
515       return mTxComponentAnimatable[mIds[id]].mScale[component];
516     }
517     case TRANSFORM_PROPERTY_PARENT_ORIGIN:
518     {
519       return mTxComponentStatic[mIds[id]].mParentOrigin[component];
520     }
521     case TRANSFORM_PROPERTY_ANCHOR_POINT:
522     {
523       return mTxComponentStatic[mIds[id]].mAnchorPoint[component];
524     }
525     case TRANSFORM_PROPERTY_SIZE:
526     {
527       return mSize[mIds[id]][component];
528     }
529     default:
530     {
531       DALI_ASSERT_ALWAYS(false);
532       return mTxComponentAnimatable[mIds[id]].mPosition[component];
533     }
534   }
535 }
536
537 void TransformManager::SetVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
538 {
539   TransformId index(mIds[id]);
540   mComponentDirty[index] = true;
541
542   switch(property)
543   {
544     case TRANSFORM_PROPERTY_POSITION:
545     {
546       mTxComponentAnimatable[index].mPosition = value;
547       break;
548     }
549     case TRANSFORM_PROPERTY_SCALE:
550     {
551       mTxComponentAnimatable[index].mScale = value;
552       break;
553     }
554     case TRANSFORM_PROPERTY_PARENT_ORIGIN:
555     {
556       mTxComponentStatic[index].mParentOrigin = value;
557       break;
558     }
559     case TRANSFORM_PROPERTY_ANCHOR_POINT:
560     {
561       mTxComponentStatic[index].mAnchorPoint = value;
562       break;
563     }
564     case TRANSFORM_PROPERTY_SIZE:
565     {
566       mSize[index] = value;
567       break;
568     }
569     default:
570     {
571       DALI_ASSERT_ALWAYS(false);
572     }
573   }
574 }
575
576 void TransformManager::SetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
577 {
578   TransformId index(mIds[id]);
579   mComponentDirty[index] = true;
580
581   switch(property)
582   {
583     case TRANSFORM_PROPERTY_POSITION:
584     {
585       mTxComponentAnimatable[index].mPosition[component] = value;
586       break;
587     }
588     case TRANSFORM_PROPERTY_SCALE:
589     {
590       mTxComponentAnimatable[index].mScale[component] = value;
591       break;
592     }
593     case TRANSFORM_PROPERTY_PARENT_ORIGIN:
594     {
595       mTxComponentStatic[index].mParentOrigin[component] = value;
596       break;
597     }
598     case TRANSFORM_PROPERTY_ANCHOR_POINT:
599     {
600       mTxComponentStatic[index].mAnchorPoint[component] = value;
601       break;
602     }
603     case TRANSFORM_PROPERTY_SIZE:
604     {
605       mSize[index][component] = value;
606       break;
607     }
608     default:
609     {
610       DALI_ASSERT_ALWAYS(false);
611     }
612   }
613 }
614
615 void TransformManager::BakeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
616 {
617   TransformId index(mIds[id]);
618   mComponentDirty[index] = true;
619
620   switch(property)
621   {
622     case TRANSFORM_PROPERTY_POSITION:
623     {
624       mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = value;
625       break;
626     }
627     case TRANSFORM_PROPERTY_SCALE:
628     {
629       mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = value;
630       break;
631     }
632     case TRANSFORM_PROPERTY_PARENT_ORIGIN:
633     {
634       mTxComponentStatic[index].mParentOrigin = value;
635       break;
636     }
637     case TRANSFORM_PROPERTY_ANCHOR_POINT:
638     {
639       mTxComponentStatic[index].mAnchorPoint = value;
640       break;
641     }
642     case TRANSFORM_PROPERTY_SIZE:
643     {
644       mSize[index] = mSizeBase[index] = value;
645       break;
646     }
647     default:
648     {
649       DALI_ASSERT_ALWAYS(false);
650     }
651   }
652 }
653
654 void TransformManager::BakeRelativeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
655 {
656   TransformId index(mIds[id]);
657   mComponentDirty[index] = true;
658
659   switch(property)
660   {
661     case TRANSFORM_PROPERTY_POSITION:
662     {
663       mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition + value;
664       break;
665     }
666     case TRANSFORM_PROPERTY_SCALE:
667     {
668       mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale + value;
669       break;
670     }
671     case TRANSFORM_PROPERTY_PARENT_ORIGIN:
672     {
673       mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin + value;
674       break;
675     }
676     case TRANSFORM_PROPERTY_ANCHOR_POINT:
677     {
678       mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint + value;
679       break;
680     }
681     case TRANSFORM_PROPERTY_SIZE:
682     {
683       mSize[index] = mSizeBase[index] = mSize[index] + value;
684       break;
685     }
686     default:
687     {
688       DALI_ASSERT_ALWAYS(false);
689     }
690   }
691 }
692
693 void TransformManager::BakeMultiplyVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
694 {
695   TransformId index(mIds[id]);
696   mComponentDirty[index] = true;
697
698   switch(property)
699   {
700     case TRANSFORM_PROPERTY_POSITION:
701     {
702       mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition * value;
703       break;
704     }
705     case TRANSFORM_PROPERTY_SCALE:
706     {
707       mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale * value;
708       break;
709     }
710     case TRANSFORM_PROPERTY_PARENT_ORIGIN:
711     {
712       mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin * value;
713       break;
714     }
715     case TRANSFORM_PROPERTY_ANCHOR_POINT:
716     {
717       mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint * value;
718       break;
719     }
720     case TRANSFORM_PROPERTY_SIZE:
721     {
722       mSize[index] = mSizeBase[index] = mSize[index] * value;
723       break;
724     }
725     default:
726     {
727       DALI_ASSERT_ALWAYS(false);
728     }
729   }
730 }
731
732 void TransformManager::BakeVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
733 {
734   TransformId index(mIds[id]);
735   mComponentDirty[index] = true;
736
737   switch(property)
738   {
739     case TRANSFORM_PROPERTY_POSITION:
740     {
741       mTxComponentAnimatable[index].mPosition[component] = mTxComponentAnimatableBaseValue[index].mPosition[component] = value;
742       break;
743     }
744     case TRANSFORM_PROPERTY_SCALE:
745     {
746       mTxComponentAnimatable[index].mScale[component] = mTxComponentAnimatableBaseValue[index].mScale[component] = value;
747       break;
748     }
749     case TRANSFORM_PROPERTY_PARENT_ORIGIN:
750     {
751       mTxComponentStatic[index].mParentOrigin[component] = value;
752       break;
753     }
754     case TRANSFORM_PROPERTY_ANCHOR_POINT:
755     {
756       mTxComponentStatic[index].mAnchorPoint[component] = value;
757       break;
758     }
759     case TRANSFORM_PROPERTY_SIZE:
760     {
761       mSize[index][component] = mSizeBase[index][component] = value;
762       break;
763     }
764     default:
765     {
766       DALI_ASSERT_ALWAYS(false);
767     }
768   }
769 }
770
771 void TransformManager::BakeXVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
772 {
773   TransformId index(mIds[id]);
774   mComponentDirty[index] = true;
775
776   switch(property)
777   {
778     case TRANSFORM_PROPERTY_POSITION:
779     {
780       mTxComponentAnimatable[index].mPosition.x = mTxComponentAnimatableBaseValue[index].mPosition.x = value;
781       break;
782     }
783     case TRANSFORM_PROPERTY_SCALE:
784     {
785       mTxComponentAnimatable[index].mScale.x = mTxComponentAnimatableBaseValue[index].mScale.x = value;
786       break;
787     }
788     case TRANSFORM_PROPERTY_PARENT_ORIGIN:
789     {
790       mTxComponentStatic[index].mParentOrigin.x = value;
791       break;
792     }
793     case TRANSFORM_PROPERTY_ANCHOR_POINT:
794     {
795       mTxComponentStatic[index].mAnchorPoint.x = value;
796       break;
797     }
798     case TRANSFORM_PROPERTY_SIZE:
799     {
800       mSize[index].x = mSizeBase[index].x = value;
801       break;
802     }
803     default:
804     {
805       DALI_ASSERT_ALWAYS(false);
806     }
807   }
808 }
809
810 void TransformManager::BakeYVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
811 {
812   TransformId index(mIds[id]);
813   mComponentDirty[index] = true;
814
815   switch(property)
816   {
817     case TRANSFORM_PROPERTY_POSITION:
818     {
819       mTxComponentAnimatable[index].mPosition.y = mTxComponentAnimatableBaseValue[index].mPosition.y = value;
820       break;
821     }
822     case TRANSFORM_PROPERTY_SCALE:
823     {
824       mTxComponentAnimatable[index].mScale.y = mTxComponentAnimatableBaseValue[index].mScale.y = value;
825       break;
826     }
827     case TRANSFORM_PROPERTY_PARENT_ORIGIN:
828     {
829       mTxComponentStatic[index].mParentOrigin.y = value;
830       break;
831     }
832     case TRANSFORM_PROPERTY_ANCHOR_POINT:
833     {
834       mTxComponentStatic[index].mAnchorPoint.y = value;
835       break;
836     }
837     case TRANSFORM_PROPERTY_SIZE:
838     {
839       mSize[index].y = mSizeBase[index].y = value;
840       break;
841     }
842     default:
843     {
844       DALI_ASSERT_ALWAYS(false);
845     }
846   }
847 }
848
849 void TransformManager::BakeZVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
850 {
851   TransformId index(mIds[id]);
852   mComponentDirty[index] = true;
853
854   switch(property)
855   {
856     case TRANSFORM_PROPERTY_POSITION:
857     {
858       mTxComponentAnimatable[index].mPosition.z = mTxComponentAnimatableBaseValue[index].mPosition.z = value;
859       break;
860     }
861     case TRANSFORM_PROPERTY_SCALE:
862     {
863       mTxComponentAnimatable[index].mScale.z = mTxComponentAnimatableBaseValue[index].mScale.z = value;
864       break;
865     }
866     case TRANSFORM_PROPERTY_PARENT_ORIGIN:
867     {
868       mTxComponentStatic[index].mParentOrigin.z = value;
869       break;
870     }
871     case TRANSFORM_PROPERTY_ANCHOR_POINT:
872     {
873       mTxComponentStatic[index].mAnchorPoint.z = value;
874       break;
875     }
876     case TRANSFORM_PROPERTY_SIZE:
877     {
878       mSize[index].z = mSizeBase[index].z = value;
879       break;
880     }
881     default:
882     {
883       DALI_ASSERT_ALWAYS(false);
884     }
885   }
886 }
887
888 Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id)
889 {
890   TransformId index(mIds[id]);
891   return mTxComponentAnimatable[index].mOrientation;
892 }
893
894 const Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id) const
895 {
896   return mTxComponentAnimatable[mIds[id]].mOrientation;
897 }
898
899 void TransformManager::SetQuaternionPropertyValue(TransformId id, const Quaternion& q)
900 {
901   TransformId index(mIds[id]);
902   mTxComponentAnimatable[index].mOrientation = q;
903   mComponentDirty[index]                     = true;
904 }
905
906 void TransformManager::BakeQuaternionPropertyValue(TransformId id, const Quaternion& q)
907 {
908   TransformId index(mIds[id]);
909   mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
910   mComponentDirty[index]                                                                           = true;
911 }
912
913 void TransformManager::BakeRelativeQuaternionPropertyValue(TransformId id, const Quaternion& q)
914 {
915   TransformId index(mIds[id]);
916   mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[index].mOrientation * q;
917   mComponentDirty[index]                                                                           = true;
918 }
919
920 const Vector4& TransformManager::GetBoundingSphere(TransformId id) const
921 {
922   return mBoundingSpheres[mIds[id]];
923 }
924
925 void TransformManager::GetWorldMatrixAndSize(TransformId id, Matrix& worldMatrix, Vector3& size) const
926 {
927   TransformId index = mIds[id];
928   worldMatrix       = mWorld[index];
929   size              = mSize[index];
930 }
931
932 void TransformManager::SetPositionUsesAnchorPoint(TransformId id, bool value)
933 {
934   TransformId index(mIds[id]);
935   mComponentDirty[index]                             = true;
936   mTxComponentStatic[index].mPositionUsesAnchorPoint = value;
937 }
938
939 } //namespace SceneGraph
940 } //namespace Internal
941 } //namespace Dali