1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_NODE_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_NODE_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/actors/actor-enumerations.h>
23 #include <dali/public-api/actors/draw-mode.h>
24 #include <dali/devel-api/common/set-wrapper.h>
25 #include <dali/public-api/math/quaternion.h>
26 #include <dali/public-api/math/math-utils.h>
27 #include <dali/public-api/math/vector3.h>
28 #include <dali/internal/common/message.h>
29 #include <dali/internal/event/common/event-thread-services.h>
30 #include <dali/internal/update/common/animatable-property.h>
31 #include <dali/internal/update/common/property-owner.h>
32 #include <dali/internal/update/common/property-vector3.h>
33 #include <dali/internal/update/common/scene-graph-buffers.h>
34 #include <dali/internal/update/common/inherited-property.h>
35 #include <dali/integration-api/debug.h>
36 #include <dali/internal/update/nodes/node-declarations.h>
37 #include <dali/internal/update/node-attachments/node-attachment-declarations.h>
38 #include <dali/internal/render/data-providers/node-data-provider.h>
46 // value types used by messages
47 template <> struct ParameterType< ColorMode > : public BasicType< ColorMode > {};
48 template <> struct ParameterType< PositionInheritanceMode > : public BasicType< PositionInheritanceMode > {};
60 * Flag whether property has changed, during the Update phase.
62 enum NodePropertyFlags
65 TransformFlag = 0x001,
70 SortModifierFlag = 0x020,
71 ChildDeletedFlag = 0x040
74 static const int AllFlags = ( ChildDeletedFlag << 1 ) - 1; // all the flags
77 * Size is not inherited.
78 * VisibleFlag is inherited so that attachments can be synchronized with nodes after they become visible
80 static const int InheritedDirtyFlags = TransformFlag | VisibleFlag | ColorFlag | OverlayFlag;
82 // Flags which require the scene renderable lists to be updated
83 static const int RenderableUpdateFlags = TransformFlag | SortModifierFlag | ChildDeletedFlag;
86 * Node is the base class for all nodes in the Scene Graph.
88 * Each node provides a transformation which applies to the node and
89 * its children. Node data is double-buffered. This allows an update
90 * thread to modify node data, without interferring with another
91 * thread reading the values from the previous update traversal.
93 class Node : public PropertyOwner, public NodeDataProvider
98 static const PositionInheritanceMode DEFAULT_POSITION_INHERITANCE_MODE;
99 static const ColorMode DEFAULT_COLOR_MODE;
104 * Construct a new Node.
114 * When a Node is marked "active" it has been disconnected, but its properties have been modified.
115 * @note An inactive Node will be skipped during the UpdateManager ResetProperties stage.
116 * @param[in] isActive True if the Node is active.
118 void SetActive( bool isActive )
120 mIsActive = isActive;
124 * Query whether the Node is active.
125 * @return True if the Node is active.
127 bool IsActive() const
133 * Called during UpdateManager::DestroyNode shortly before Node is destroyed.
140 * Query whether the node is a layer.
141 * @return True if the node is a layer.
145 return (GetLayer() != NULL);
149 * Convert a node to a layer.
150 * @return A pointer to the layer, or NULL.
152 virtual Layer* GetLayer()
160 * Attach an object to this Node; This should only be done by UpdateManager::AttachToNode.
161 * @pre The Node does not already have an attachment.
162 * @param[in] attachment The object to attach.
164 void Attach( NodeAttachment& attachment );
167 * Query the node if it has an attachment.
168 * @return True if it has an attachment.
170 bool HasAttachment() const
176 * Retreive the object attached to this node.
177 * @return The attachment.
179 NodeAttachment& GetAttachment() const
184 // Containment methods
187 * Query whether a node is the root node. Root nodes cannot have a parent node.
188 * A node becomes a root node, when it is installed by UpdateManager.
189 * @return True if the node is a root node.
197 * Set whether a node is the root node. Root nodes cannot have a parent node.
198 * This method should only be called by UpdateManager.
199 * @pre When isRoot is true, the node must not have a parent.
200 * @param[in] isRoot Whether the node is now a root node.
202 void SetRoot(bool isRoot);
205 * Retrieve the parent of a Node.
206 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
214 * Retrieve the parent of a Node.
215 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
217 const Node* GetParent() const
223 * Connect a node to the scene-graph.
224 * @pre A node cannot be added to itself.
225 * @pre The parent node is connected to the scene-graph.
226 * @pre The childNode does not already have a parent.
227 * @pre The childNode is not a root node.
228 * @param[in] childNode The child to add.
230 void ConnectChild( Node* childNode );
233 * Disconnect a child (& its children) from the scene-graph.
234 * @pre childNode is a child of this Node.
235 * @param[in] updateBufferIndex The current update buffer index.
236 * @param[in] childNode The node to disconnect.
237 * @param[in] connectedNodes Disconnected Node attachments should be removed from here.
238 * @param[in] disconnectedNodes Disconnected Node attachments should be added here.
240 void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes );
243 * Retrieve the children a Node.
244 * @return The container of children.
246 const NodeContainer& GetChildren() const
252 * Retrieve the children a Node.
253 * @return The container of children.
255 NodeContainer& GetChildren()
263 * Flag that one of the node values has changed in the current frame.
264 * @param[in] flag The flag to set.
266 void SetDirtyFlag(NodePropertyFlags flag)
272 * Flag that all of the node values are dirty.
274 void SetAllDirtyFlags()
276 mDirtyFlags = AllFlags;
280 * Query whether a node is dirty.
281 * @return The dirty flags
283 int GetDirtyFlags() const;
286 * Query whether a node is clean.
287 * @return True if the node is clean.
291 return ( NothingFlag == GetDirtyFlags() );
295 * Retrieve the parent-origin of the node.
296 * @return The parent-origin.
298 const Vector3& GetParentOrigin() const
300 return mParentOrigin.mValue;
304 * Sets both the local & base parent-origins of the node.
305 * @param[in] origin The new local & base parent-origins.
307 void SetParentOrigin(const Vector3& origin)
309 mParentOrigin.mValue = origin;
310 mParentOrigin.OnSet();
314 * Retrieve the anchor-point of the node.
315 * @return The anchor-point.
317 const Vector3& GetAnchorPoint() const
319 return mAnchorPoint.mValue;
323 * Sets both the local & base anchor-points of the node.
324 * @param[in] anchor The new local & base anchor-points.
326 void SetAnchorPoint(const Vector3& anchor)
328 mAnchorPoint.mValue = anchor;
329 mAnchorPoint.OnSet();
333 * Retrieve the local position of the node, relative to its parent.
334 * @param[in] bufferIndex The buffer to read from.
335 * @return The local position.
337 const Vector3& GetPosition(BufferIndex bufferIndex) const
339 return mPosition[bufferIndex];
343 * Sets both the local & base positions of the node.
344 * @param[in] updateBufferIndex The current update buffer index.
345 * @param[in] position The new local & base position.
347 void BakePosition(BufferIndex updateBufferIndex, const Vector3& position)
349 mPosition.Bake( updateBufferIndex, position );
353 * Sets the world of the node derived from the position of all its parents.
354 * @param[in] updateBufferIndex The current update buffer index.
355 * @param[in] position The world position.
357 void SetWorldPosition( BufferIndex updateBufferIndex, const Vector3& position )
359 mWorldPosition.Set( updateBufferIndex, position );
363 * Sets the position of the node derived from the position of all its parents.
364 * This method should only be called when the parent's world position is up-to-date.
365 * With a non-central anchor-point, the local orientation and scale affects the world position.
366 * Therefore the world orientation & scale must be updated before the world position.
367 * @pre The node has a parent.
368 * @param[in] updateBufferIndex The current update buffer index.
370 void InheritWorldPosition(BufferIndex updateBufferIndex)
372 DALI_ASSERT_DEBUG(mParent != NULL);
374 switch( mPositionInheritanceMode )
376 case INHERIT_PARENT_POSITION : ///@see Dali::PositionInheritanceMode for how these modes are expected to work
378 Vector3 finalPosition(-0.5f, -0.5f, -0.5f);
380 finalPosition += mParentOrigin.mValue;
381 finalPosition *= mParent->GetSize(updateBufferIndex);
382 finalPosition += mPosition[updateBufferIndex];
383 finalPosition *= mParent->GetWorldScale(updateBufferIndex);
384 const Quaternion& parentWorldOrientation = mParent->GetWorldOrientation(updateBufferIndex);
385 if(!parentWorldOrientation.IsIdentity())
387 finalPosition *= parentWorldOrientation;
390 // check if a node needs to be offsetted locally (only applies when AnchorPoint is not central)
391 // dont use operator== as that does a slower comparison (and involves function calls)
392 Vector3 localOffset(0.5f, 0.5f, 0.5f); // AnchorPoint::CENTER
393 localOffset -= mAnchorPoint.mValue;
395 if( ( fabsf( localOffset.x ) >= Math::MACHINE_EPSILON_0 ) ||
396 ( fabsf( localOffset.y ) >= Math::MACHINE_EPSILON_0 ) ||
397 ( fabsf( localOffset.z ) >= Math::MACHINE_EPSILON_0 ) )
399 localOffset *= mSize[updateBufferIndex];
401 Vector3 scale = mWorldScale[updateBufferIndex];
403 // Pick up sign of local scale
404 if (mScale[updateBufferIndex].x < 0.0f)
408 if (mScale[updateBufferIndex].y < 0.0f)
412 if (mScale[updateBufferIndex].z < 0.0f)
417 // If the anchor-point is not central, then position is affected by the local orientation & scale
418 localOffset *= scale;
419 const Quaternion& localWorldOrientation = mWorldOrientation[updateBufferIndex];
420 if(!localWorldOrientation.IsIdentity())
422 localOffset *= localWorldOrientation;
424 finalPosition += localOffset;
427 finalPosition += mParent->GetWorldPosition(updateBufferIndex);
428 mWorldPosition.Set( updateBufferIndex, finalPosition );
431 case USE_PARENT_POSITION_PLUS_LOCAL_POSITION :
433 // copy parents position plus local transform
434 mWorldPosition.Set( updateBufferIndex, mParent->GetWorldPosition(updateBufferIndex) + mPosition[updateBufferIndex] );
437 case USE_PARENT_POSITION :
439 // copy parents position
440 mWorldPosition.Set( updateBufferIndex, mParent->GetWorldPosition(updateBufferIndex) );
443 case DONT_INHERIT_POSITION :
445 // use local position as world position
446 mWorldPosition.Set( updateBufferIndex, mPosition[updateBufferIndex] );
453 * Copies the previous inherited position, if this changed in the previous frame.
454 * This method should be called instead of InheritWorldPosition i.e. if the inherited position
455 * does not need to be recalculated in the current frame.
456 * @param[in] updateBufferIndex The current update buffer index.
458 void CopyPreviousWorldPosition( BufferIndex updateBufferIndex )
460 mWorldPosition.CopyPrevious( updateBufferIndex );
464 * Retrieve the position of the node derived from the position of all its parents.
465 * @return The world position.
467 const Vector3& GetWorldPosition( BufferIndex bufferIndex ) const
469 return mWorldPosition[bufferIndex];
473 * Set the position inheritance mode.
474 * @see Dali::Actor::PositionInheritanceMode
475 * @param[in] mode The new position inheritance mode.
477 void SetPositionInheritanceMode( PositionInheritanceMode mode )
479 mPositionInheritanceMode = mode;
481 SetDirtyFlag(TransformFlag);
485 * @return The position inheritance mode.
487 PositionInheritanceMode GetPositionInheritanceMode() const
489 return mPositionInheritanceMode;
493 * Retrieve the local orientation of the node, relative to its parent.
494 * @param[in] bufferIndex The buffer to read from.
495 * @return The local orientation.
497 const Quaternion& GetOrientation(BufferIndex bufferIndex) const
499 return mOrientation[bufferIndex];
503 * Sets both the local & base orientations of the node.
504 * @param[in] updateBufferIndex The current update buffer index.
505 * @param[in] orientation The new local & base orientation.
507 void BakeOrientation(BufferIndex updateBufferIndex, const Quaternion& orientation)
509 mOrientation.Bake( updateBufferIndex, orientation );
513 * Sets the orientation of the node derived from the rotation of all its parents.
514 * @param[in] updateBufferIndex The current update buffer index.
515 * @param[in] orientation The world orientation.
517 void SetWorldOrientation( BufferIndex updateBufferIndex, const Quaternion& orientation )
519 mWorldOrientation.Set( updateBufferIndex, orientation );
523 * Sets the orientation of the node derived from the rotation of all its parents.
524 * This method should only be called when the parents world orientation is up-to-date.
525 * @pre The node has a parent.
526 * @param[in] updateBufferIndex The current update buffer index.
528 void InheritWorldOrientation( BufferIndex updateBufferIndex )
530 DALI_ASSERT_DEBUG(mParent != NULL);
532 const Quaternion& localOrientation = mOrientation[updateBufferIndex];
534 if(localOrientation.IsIdentity())
536 mWorldOrientation.Set( updateBufferIndex, mParent->GetWorldOrientation(updateBufferIndex) );
540 Quaternion finalOrientation( mParent->GetWorldOrientation(updateBufferIndex) );
541 finalOrientation *= localOrientation;
542 mWorldOrientation.Set( updateBufferIndex, finalOrientation );
547 * Copies the previous inherited orientation, if this changed in the previous frame.
548 * This method should be called instead of InheritWorldOrientation i.e. if the inherited orientation
549 * does not need to be recalculated in the current frame.
550 * @param[in] updateBufferIndex The current update buffer index.
552 void CopyPreviousWorldOrientation( BufferIndex updateBufferIndex )
554 mWorldOrientation.CopyPrevious( updateBufferIndex );
558 * Retrieve the orientation of the node derived from the rotation of all its parents.
559 * @param[in] bufferIndex The buffer to read from.
560 * @return The world rotation.
562 const Quaternion& GetWorldOrientation( BufferIndex bufferIndex ) const
564 return mWorldOrientation[bufferIndex];
568 * Set whether the Node inherits orientation.
569 * @param[in] inherit True if the parent orientation is inherited.
571 void SetInheritOrientation(bool inherit)
573 if (inherit != mInheritOrientation)
575 mInheritOrientation = inherit;
577 SetDirtyFlag(TransformFlag);
582 * Query whether the node inherits orientation from its parent.
583 * @return True if the parent orientation is inherited.
585 bool IsOrientationInherited() const
587 return mInheritOrientation;
591 * Retrieve the local scale of the node, relative to its parent.
592 * @param[in] bufferIndex The buffer to read from.
593 * @return The local scale.
595 const Vector3& GetScale(BufferIndex bufferIndex) const
597 return mScale[bufferIndex];
601 * Sets the scale of the node derived from the scale of all its parents and a pre-scale
602 * @param[in] updateBufferIndex The current update buffer index.
603 * @param[in] scale The world scale.
605 void SetWorldScale(BufferIndex updateBufferIndex, const Vector3& scale)
607 mWorldScale.Set( updateBufferIndex, scale );
611 * Sets the scale of the node derived from the scale of all its parents and a pre-scale.
612 * This method should only be called when the parents world scale is up-to-date.
613 * @pre The node has a parent.
614 * @param[in] updateBufferIndex The current update buffer index.
616 void InheritWorldScale(BufferIndex updateBufferIndex)
618 DALI_ASSERT_DEBUG(mParent != NULL);
620 mWorldScale.Set( updateBufferIndex, mParent->GetWorldScale(updateBufferIndex) * mScale[updateBufferIndex] );
624 * Copies the previous inherited scale, if this changed in the previous frame.
625 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
626 * does not need to be recalculated in the current frame.
627 * @param[in] updateBufferIndex The current update buffer index.
629 void CopyPreviousWorldScale( BufferIndex updateBufferIndex )
631 mWorldScale.CopyPrevious( updateBufferIndex );
635 * Retrieve the scale of the node derived from the scale of all its parents.
636 * @param[in] bufferIndex The buffer to read from.
637 * @return The world scale.
639 const Vector3& GetWorldScale( BufferIndex bufferIndex ) const
641 return mWorldScale[bufferIndex];
645 * Set whether the Node inherits scale.
646 * @param inherit True if the Node inherits scale.
648 void SetInheritScale( bool inherit )
650 if( inherit != mInheritScale )
652 mInheritScale = inherit;
654 SetDirtyFlag( TransformFlag );
659 * Query whether the Node inherits scale.
660 * @return if scale is inherited
662 bool IsScaleInherited() const
664 return mInheritScale;
668 * Copies the previously used size, if this changed in the previous frame.
669 * @param[in] updateBufferIndex The current update buffer index.
671 void CopyPreviousSize( BufferIndex updateBufferIndex )
673 SetSize( updateBufferIndex, GetSize( 1u - updateBufferIndex ) );
677 * Retrieve the visibility of the node.
678 * @param[in] bufferIndex The buffer to read from.
679 * @return True if the node is visible.
681 bool IsVisible(BufferIndex bufferIndex) const
683 return mVisible[bufferIndex];
687 * Retrieves whether a node is fully visible.
688 * A node is fully visible if is visible and all its ancestors are visible.
689 * @param[in] updateBufferIndex The current update buffer index.
690 * @return True if the node is fully visible.
692 bool IsFullyVisible( BufferIndex updateBufferIndex ) const;
695 * Retrieve the opacity of the node.
696 * @param[in] bufferIndex The buffer to read from.
697 * @return The opacity.
699 float GetOpacity(BufferIndex bufferIndex) const
701 return mColor[bufferIndex].a;
705 * Retrieve the color of the node.
706 * @param[in] bufferIndex The buffer to read from.
709 const Vector4& GetColor(BufferIndex bufferIndex) const
711 return mColor[bufferIndex];
715 * Sets the color of the node derived from the color of all its parents.
716 * @param[in] color The world color.
717 * @param[in] updateBufferIndex The current update buffer index.
719 void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
721 mWorldColor.Set( updateBufferIndex, color );
725 * Sets the color of the node derived from the color of all its parents.
726 * This method should only be called when the parents world color is up-to-date.
727 * @pre The node has a parent.
728 * @param[in] updateBufferIndex The current update buffer index.
730 void InheritWorldColor( BufferIndex updateBufferIndex )
732 DALI_ASSERT_DEBUG(mParent != NULL);
735 if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA )
737 const Vector4& ownColor = mColor[updateBufferIndex];
738 mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a );
740 else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR )
742 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] );
744 else if( mColorMode == USE_PARENT_COLOR )
746 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) );
748 else // USE_OWN_COLOR
750 mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] );
755 * Copies the previous inherited scale, if this changed in the previous frame.
756 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
757 * does not need to be recalculated in the current frame.
758 * @param[in] updateBufferIndex The current update buffer index.
760 void CopyPreviousWorldColor( BufferIndex updateBufferIndex )
762 mWorldColor.CopyPrevious( updateBufferIndex );
766 * Retrieve the color of the node, possibly derived from the color
767 * of all its parents, depending on the value of mColorMode.
768 * @param[in] bufferIndex The buffer to read from.
769 * @return The world color.
771 const Vector4& GetWorldColor(BufferIndex bufferIndex) const
773 return mWorldColor[bufferIndex];
777 * Set the color mode. This specifies whether the Node uses its own color,
778 * or inherits its parent color.
779 * @param[in] colorMode The new color mode.
781 void SetColorMode(ColorMode colorMode)
783 mColorMode = colorMode;
785 SetDirtyFlag(ColorFlag);
789 * Retrieve the color mode.
790 * @return The color mode.
792 ColorMode GetColorMode() const
798 * Sets the size of the node.
799 * @param[in] bufferIndex The buffer to write to.
800 * @param[in] size The size to write.
802 void SetSize( BufferIndex bufferIndex, const Vector3& size )
804 mSize[bufferIndex] = size;
808 * Retrieve the size of the node.
809 * @param[in] bufferIndex The buffer to read from.
812 const Vector3& GetSize(BufferIndex bufferIndex) const
814 return mSize[bufferIndex];
818 * Set the world-matrix of a node, with scale + rotation + translation.
819 * Scale and rotation are centered at the origin.
820 * Translation is applied independently of the scale or rotatation axis.
821 * @param[in] updateBufferIndex The current update buffer index.
822 * @param[in] scale The scale.
823 * @param[in] rotation The rotation.
824 * @param[in] translation The translation.
826 void SetWorldMatrix( BufferIndex updateBufferIndex, const Vector3& scale, const Quaternion& rotation, const Vector3& translation )
828 mWorldMatrix.Get( updateBufferIndex ).SetTransformComponents( scale, rotation, translation );
829 mWorldMatrix.SetDirty( updateBufferIndex );
833 * Retrieve the cached world-matrix of a node.
834 * @param[in] bufferIndex The buffer to read from.
835 * @return The world-matrix.
837 const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
839 return mWorldMatrix[ bufferIndex ];
843 * Copy previous frames world matrix
844 * @param[in] updateBufferIndex The current update buffer index.
846 void CopyPreviousWorldMatrix( BufferIndex updateBufferIndex )
848 mWorldMatrix.CopyPrevious( updateBufferIndex );
852 * Mark the node as exclusive to a single RenderTask.
853 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
855 void SetExclusiveRenderTask( RenderTask* renderTask )
857 mExclusiveRenderTask = renderTask;
861 * Query whether the node is exclusive to a single RenderTask.
862 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
864 RenderTask* GetExclusiveRenderTask() const
866 return mExclusiveRenderTask;
870 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
871 * @param[in] drawMode The new draw-mode to use.
873 void SetDrawMode( const DrawMode::Type& drawMode )
875 mDrawMode = drawMode;
879 * Returns whether node is an overlay or not.
880 * @return True if node is an overlay, false otherwise.
882 DrawMode::Type GetDrawMode() const
888 * Equality operator, checks for identity, not values.
891 bool operator==( const Node* rhs ) const
901 * Set the inhibit local transform flag.@n
902 * Setting this flag will stop the node's local transform (position, scale and orientation)
903 * being applied on top of its parents transformation.
904 * @param[in] flag When true, local transformation is inhibited when calculating the world matrix.
906 void SetInhibitLocalTransform( bool flag )
908 SetDirtyFlag( TransformFlag );
909 mInhibitLocalTransform = flag;
913 * Get the inhibit local transform flag.@n
914 * See @ref SetInhibitLocalTransform
915 * @result A flag, when true, local transformation is inhibited when calculating the world matrix.
917 bool GetInhibitLocalTransform() const
919 return mInhibitLocalTransform;
922 unsigned short GetDepth() const
930 * Set the parent of a Node.
931 * @param[in] parentNode the new parent.
933 void SetParent(Node& parentNode);
936 * Protected constructor; See also Node::New()
940 private: // from NodeDataProvider
943 * @copydoc NodeDataProvider::GetModelMatrix
945 virtual const Matrix& GetModelMatrix( unsigned int bufferId )
947 return GetWorldMatrix( bufferId );
951 * @copydoc NodeDataProvider::GetRenderColor
953 virtual const Vector4& GetRenderColor( unsigned int bufferId )
955 return GetWorldColor( bufferId );
958 virtual const Vector3& GetRenderSize( unsigned int bufferId )
960 return GetSize( bufferId );
970 Node& operator=(const Node& rhs);
973 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
975 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
978 * Recursive helper to disconnect a Node and its children.
979 * Disconnected Nodes have no parent or children.
980 * @param[in] updateBufferIndex The current update buffer index.
981 * @param[in] connectedNodes Disconnected Node attachments should be removed from here.
982 * @param[in] disconnectedNodes Disconnected Node attachments should be added here.
984 void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes );
986 public: // Default properties
988 PropertyVector3 mParentOrigin; ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
989 PropertyVector3 mAnchorPoint; ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
991 AnimatableProperty<Vector3> mSize; ///< Size is provided for layouting
992 AnimatableProperty<Vector3> mPosition; ///< Local transform; distance between parent-origin & anchor-point
993 AnimatableProperty<Quaternion> mOrientation; ///< Local transform; rotation relative to parent node
994 AnimatableProperty<Vector3> mScale; ///< Local transform; scale relative to parent node
995 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
996 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
998 // Inherited properties; read-only from public API
1000 InheritedVector3 mWorldPosition; ///< Full inherited position
1001 InheritedQuaternion mWorldOrientation; ///< Full inherited orientation
1002 InheritedVector3 mWorldScale; ///< Full inherited scale
1003 InheritedMatrix mWorldMatrix; ///< Full inherited world matrix
1004 InheritedColor mWorldColor; ///< Full inherited color
1008 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
1009 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
1011 NodeAttachmentOwner mAttachment; ///< Optional owned attachment
1012 NodeContainer mChildren; ///< Container of children; not owned
1015 // flags, compressed to bitfield
1016 unsigned short mDepth: 12; ///< Depth in the hierarchy
1017 int mDirtyFlags:8; ///< A composite set of flags for each of the Node properties
1019 bool mIsRoot:1; ///< True if the node cannot have a parent
1020 bool mInheritOrientation:1; ///< Whether the parent's orientation should be inherited.
1021 bool mInheritScale:1; ///< Whether the parent's scale should be inherited.
1022 bool mInhibitLocalTransform:1; ///< whether local transform should be applied.
1023 bool mIsActive:1; ///< When a Node is marked "active" it has been disconnected, and its properties have not been modified
1025 DrawMode::Type mDrawMode:2; ///< How the Node and its children should be drawn
1026 PositionInheritanceMode mPositionInheritanceMode:2;///< Determines how position is inherited, 2 bits is enough
1027 ColorMode mColorMode:2; ///< Determines whether mWorldColor is inherited, 2 bits is enough
1029 // Changes scope, should be at end of class
1030 DALI_LOG_OBJECT_STRING_DECLARATION;
1033 // Messages for Node
1035 inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1037 typedef MessageValue1< Node, bool > LocalType;
1039 // Reserve some memory inside the message queue
1040 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1042 // Construct message in the message queue memory; note that delete should not be called on the return value
1043 new (slot) LocalType( &node, &Node::SetInheritOrientation, inherit );
1048 inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
1050 typedef MessageValue1< Node, Vector3 > LocalType;
1052 // Reserve some memory inside the message queue
1053 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1055 // Construct message in the message queue memory; note that delete should not be called on the return value
1056 new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
1059 inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
1061 typedef MessageValue1< Node, Vector3 > LocalType;
1063 // Reserve some memory inside the message queue
1064 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1066 // Construct message in the message queue memory; note that delete should not be called on the return value
1067 new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
1070 inline void SetPositionInheritanceModeMessage( EventThreadServices& eventThreadServices, const Node& node, PositionInheritanceMode mode )
1072 typedef MessageValue1< Node, PositionInheritanceMode > LocalType;
1074 // Reserve some memory inside the message queue
1075 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1077 // Construct message in the message queue memory; note that delete should not be called on the return value
1078 new (slot) LocalType( &node, &Node::SetPositionInheritanceMode, mode );
1081 inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1083 typedef MessageValue1< Node, bool > LocalType;
1085 // Reserve some memory inside the message queue
1086 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1088 // Construct message in the message queue memory; note that delete should not be called on the return value
1089 new (slot) LocalType( &node, &Node::SetInheritScale, inherit );
1092 inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
1094 typedef MessageValue1< Node, ColorMode > LocalType;
1096 // Reserve some memory inside the message queue
1097 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1099 // Construct message in the message queue memory; note that delete should not be called on the return value
1100 new (slot) LocalType( &node, &Node::SetColorMode, colorMode );
1103 inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
1105 typedef MessageValue1< Node, DrawMode::Type > LocalType;
1107 // Reserve some memory inside the message queue
1108 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1110 // Construct message in the message queue memory; note that delete should not be called on the return value
1111 new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
1114 } // namespace SceneGraph
1116 } // namespace Internal
1120 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_H_