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/public-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 > {};
49 template <> struct ParameterType< SizeMode > : public BasicType< SizeMode > {};
61 * Flag whether property has changed, during the Update phase.
63 enum NodePropertyFlags
66 TransformFlag = 0x001,
71 SortModifierFlag = 0x020,
72 ChildDeletedFlag = 0x040
75 static const int AllFlags = ( ChildDeletedFlag << 1 ) - 1; // all the flags
78 * Size is not inherited.
79 * VisibleFlag is inherited so that attachments can be synchronized with nodes after they become visible
81 static const int InheritedDirtyFlags = TransformFlag | VisibleFlag | ColorFlag | OverlayFlag;
83 // Flags which require the scene renderable lists to be updated
84 static const int RenderableUpdateFlags = TransformFlag | SortModifierFlag | ChildDeletedFlag;
87 * Node is the base class for all nodes in the Scene Graph.
89 * Each node provides a transformation which applies to the node and
90 * its children. Node data is double-buffered. This allows an update
91 * thread to modify node data, without interferring with another
92 * thread reading the values from the previous update traversal.
94 class Node : public PropertyOwner, public NodeDataProvider
99 static const PositionInheritanceMode DEFAULT_POSITION_INHERITANCE_MODE;
100 static const ColorMode DEFAULT_COLOR_MODE;
105 * Construct a new Node.
115 * When a Node is marked "active" it has been disconnected, but its properties have been modified.
116 * @note An inactive Node will be skipped during the UpdateManager ResetProperties stage.
117 * @param[in] isActive True if the Node is active.
119 void SetActive( bool isActive )
121 mIsActive = isActive;
125 * Query whether the Node is active.
126 * @return True if the Node is active.
128 bool IsActive() const
134 * Called during UpdateManager::DestroyNode shortly before Node is destroyed.
141 * Query whether the node is a layer.
142 * @return True if the node is a layer.
146 return (GetLayer() != NULL);
150 * Convert a node to a layer.
151 * @return A pointer to the layer, or NULL.
153 virtual Layer* GetLayer()
161 * Attach an object to this Node; This should only be done by UpdateManager::AttachToNode.
162 * @pre The Node does not already have an attachment.
163 * @param[in] attachment The object to attach.
165 void Attach( NodeAttachment& attachment );
168 * Query the node if it has an attachment.
169 * @return True if it has an attachment.
171 bool HasAttachment() const
177 * Retreive the object attached to this node.
178 * @return The attachment.
180 NodeAttachment& GetAttachment() const
185 // Containment methods
188 * Query whether a node is the root node. Root nodes cannot have a parent node.
189 * A node becomes a root node, when it is installed by UpdateManager.
190 * @return True if the node is a root node.
198 * Set whether a node is the root node. Root nodes cannot have a parent node.
199 * This method should only be called by UpdateManager.
200 * @pre When isRoot is true, the node must not have a parent.
201 * @param[in] isRoot Whether the node is now a root node.
203 void SetRoot(bool isRoot);
206 * Retrieve the parent of a Node.
207 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
215 * Retrieve the parent of a Node.
216 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
218 const Node* GetParent() const
224 * Connect a node to the scene-graph.
225 * @pre A node cannot be added to itself.
226 * @pre The parent node is connected to the scene-graph.
227 * @pre The childNode does not already have a parent.
228 * @pre The childNode is not a root node.
229 * @param[in] childNode The child to add.
230 * @param[in] index to insert at, if not supplied or -1 it will be appended
233 void ConnectChild( Node* childNode, int index = -1);
236 * Disconnect a child (& its children) from the scene-graph.
237 * @pre childNode is a child of this Node.
238 * @param[in] updateBufferIndex The current update buffer index.
239 * @param[in] childNode The node to disconnect.
240 * @param[in] connectedNodes Disconnected Node attachments should be removed from here.
241 * @param[in] disconnectedNodes Disconnected Node attachments should be added here.
243 void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes );
246 * Retrieve the children a Node.
247 * @return The container of children.
249 const NodeContainer& GetChildren() const
255 * Retrieve the children a Node.
256 * @return The container of children.
258 NodeContainer& GetChildren()
266 * Flag that one of the node values has changed in the current frame.
267 * @param[in] flag The flag to set.
269 void SetDirtyFlag(NodePropertyFlags flag)
275 * Flag that all of the node values are dirty.
277 void SetAllDirtyFlags()
279 mDirtyFlags = AllFlags;
283 * Query whether a node is dirty.
284 * @return The dirty flags
286 int GetDirtyFlags() const;
289 * Query whether a node is clean.
290 * @return True if the node is clean.
294 return ( NothingFlag == GetDirtyFlags() );
298 * Retrieve the parent-origin of the node.
299 * @return The parent-origin.
301 const Vector3& GetParentOrigin() const
303 return mParentOrigin.mValue;
307 * Sets both the local & base parent-origins of the node.
308 * @param[in] origin The new local & base parent-origins.
310 void SetParentOrigin(const Vector3& origin)
312 mParentOrigin.mValue = origin;
313 mParentOrigin.OnSet();
317 * Retrieve the anchor-point of the node.
318 * @return The anchor-point.
320 const Vector3& GetAnchorPoint() const
322 return mAnchorPoint.mValue;
326 * Sets both the local & base anchor-points of the node.
327 * @param[in] anchor The new local & base anchor-points.
329 void SetAnchorPoint(const Vector3& anchor)
331 mAnchorPoint.mValue = anchor;
332 mAnchorPoint.OnSet();
336 * Retrieve the local position of the node, relative to its parent.
337 * @param[in] bufferIndex The buffer to read from.
338 * @return The local position.
340 const Vector3& GetPosition(BufferIndex bufferIndex) const
342 return mPosition[bufferIndex];
346 * Sets both the local & base positions of the node.
347 * @param[in] updateBufferIndex The current update buffer index.
348 * @param[in] position The new local & base position.
350 void BakePosition(BufferIndex updateBufferIndex, const Vector3& position)
352 mPosition.Bake( updateBufferIndex, position );
356 * Sets the world of the node derived from the position of all its parents.
357 * @param[in] updateBufferIndex The current update buffer index.
358 * @param[in] position The world position.
360 void SetWorldPosition( BufferIndex updateBufferIndex, const Vector3& position )
362 mWorldPosition.Set( updateBufferIndex, position );
366 * Sets the position of the node derived from the position of all its parents.
367 * This method should only be called when the parent's world position is up-to-date.
368 * With a non-central anchor-point, the local orientation and scale affects the world position.
369 * Therefore the world orientation & scale must be updated before the world position.
370 * @pre The node has a parent.
371 * @param[in] updateBufferIndex The current update buffer index.
373 void InheritWorldPosition(BufferIndex updateBufferIndex)
375 DALI_ASSERT_DEBUG(mParent != NULL);
377 switch( mPositionInheritanceMode )
379 case INHERIT_PARENT_POSITION : ///@see Dali::PositionInheritanceMode for how these modes are expected to work
381 Vector3 finalPosition(-0.5f, -0.5f, -0.5f);
383 finalPosition += mParentOrigin.mValue;
384 finalPosition *= mParent->GetSize(updateBufferIndex);
385 finalPosition += mPosition[updateBufferIndex];
386 finalPosition *= mParent->GetWorldScale(updateBufferIndex);
387 const Quaternion& parentWorldOrientation = mParent->GetWorldOrientation(updateBufferIndex);
388 if(!parentWorldOrientation.IsIdentity())
390 finalPosition *= parentWorldOrientation;
393 // check if a node needs to be offsetted locally (only applies when AnchorPoint is not central)
394 // dont use operator== as that does a slower comparison (and involves function calls)
395 Vector3 localOffset(0.5f, 0.5f, 0.5f); // AnchorPoint::CENTER
396 localOffset -= mAnchorPoint.mValue;
398 if( ( fabsf( localOffset.x ) >= Math::MACHINE_EPSILON_0 ) ||
399 ( fabsf( localOffset.y ) >= Math::MACHINE_EPSILON_0 ) ||
400 ( fabsf( localOffset.z ) >= Math::MACHINE_EPSILON_0 ) )
402 localOffset *= mSize[updateBufferIndex];
404 Vector3 scale = mWorldScale[updateBufferIndex];
406 // Pick up sign of local scale
407 if (mScale[updateBufferIndex].x < 0.0f)
411 if (mScale[updateBufferIndex].y < 0.0f)
415 if (mScale[updateBufferIndex].z < 0.0f)
420 // If the anchor-point is not central, then position is affected by the local orientation & scale
421 localOffset *= scale;
422 const Quaternion& localWorldOrientation = mWorldOrientation[updateBufferIndex];
423 if(!localWorldOrientation.IsIdentity())
425 localOffset *= localWorldOrientation;
427 finalPosition += localOffset;
430 finalPosition += mParent->GetWorldPosition(updateBufferIndex);
431 mWorldPosition.Set( updateBufferIndex, finalPosition );
434 case USE_PARENT_POSITION_PLUS_LOCAL_POSITION :
436 // copy parents position plus local transform
437 mWorldPosition.Set( updateBufferIndex, mParent->GetWorldPosition(updateBufferIndex) + mPosition[updateBufferIndex] );
440 case USE_PARENT_POSITION :
442 // copy parents position
443 mWorldPosition.Set( updateBufferIndex, mParent->GetWorldPosition(updateBufferIndex) );
446 case DONT_INHERIT_POSITION :
448 // use local position as world position
449 mWorldPosition.Set( updateBufferIndex, mPosition[updateBufferIndex] );
456 * Copies the previous inherited position, if this changed in the previous frame.
457 * This method should be called instead of InheritWorldPosition i.e. if the inherited position
458 * does not need to be recalculated in the current frame.
459 * @param[in] updateBufferIndex The current update buffer index.
461 void CopyPreviousWorldPosition( BufferIndex updateBufferIndex )
463 mWorldPosition.CopyPrevious( updateBufferIndex );
467 * Retrieve the position of the node derived from the position of all its parents.
468 * @return The world position.
470 const Vector3& GetWorldPosition( BufferIndex bufferIndex ) const
472 return mWorldPosition[bufferIndex];
476 * Set the position inheritance mode.
477 * @see Dali::Actor::PositionInheritanceMode
478 * @param[in] mode The new position inheritance mode.
480 void SetPositionInheritanceMode( PositionInheritanceMode mode )
482 mPositionInheritanceMode = mode;
484 SetDirtyFlag(TransformFlag);
488 * @return The position inheritance mode.
490 PositionInheritanceMode GetPositionInheritanceMode() const
492 return mPositionInheritanceMode;
496 * Retrieve the local orientation of the node, relative to its parent.
497 * @param[in] bufferIndex The buffer to read from.
498 * @return The local orientation.
500 const Quaternion& GetOrientation(BufferIndex bufferIndex) const
502 return mOrientation[bufferIndex];
506 * Sets both the local & base orientations of the node.
507 * @param[in] updateBufferIndex The current update buffer index.
508 * @param[in] orientation The new local & base orientation.
510 void BakeOrientation(BufferIndex updateBufferIndex, const Quaternion& orientation)
512 mOrientation.Bake( updateBufferIndex, orientation );
516 * Sets the orientation of the node derived from the rotation of all its parents.
517 * @param[in] updateBufferIndex The current update buffer index.
518 * @param[in] orientation The world orientation.
520 void SetWorldOrientation( BufferIndex updateBufferIndex, const Quaternion& orientation )
522 mWorldOrientation.Set( updateBufferIndex, orientation );
526 * Sets the orientation of the node derived from the rotation of all its parents.
527 * This method should only be called when the parents world orientation is up-to-date.
528 * @pre The node has a parent.
529 * @param[in] updateBufferIndex The current update buffer index.
531 void InheritWorldOrientation( BufferIndex updateBufferIndex )
533 DALI_ASSERT_DEBUG(mParent != NULL);
535 const Quaternion& localOrientation = mOrientation[updateBufferIndex];
537 if(localOrientation.IsIdentity())
539 mWorldOrientation.Set( updateBufferIndex, mParent->GetWorldOrientation(updateBufferIndex) );
543 Quaternion finalOrientation( mParent->GetWorldOrientation(updateBufferIndex) );
544 finalOrientation *= localOrientation;
545 mWorldOrientation.Set( updateBufferIndex, finalOrientation );
550 * Copies the previous inherited orientation, if this changed in the previous frame.
551 * This method should be called instead of InheritWorldOrientation i.e. if the inherited orientation
552 * does not need to be recalculated in the current frame.
553 * @param[in] updateBufferIndex The current update buffer index.
555 void CopyPreviousWorldOrientation( BufferIndex updateBufferIndex )
557 mWorldOrientation.CopyPrevious( updateBufferIndex );
561 * Retrieve the orientation of the node derived from the rotation of all its parents.
562 * @param[in] bufferIndex The buffer to read from.
563 * @return The world rotation.
565 const Quaternion& GetWorldOrientation( BufferIndex bufferIndex ) const
567 return mWorldOrientation[bufferIndex];
571 * Set whether the Node inherits orientation.
572 * @param[in] inherit True if the parent orientation is inherited.
574 void SetInheritOrientation(bool inherit)
576 if (inherit != mInheritOrientation)
578 mInheritOrientation = inherit;
580 SetDirtyFlag(TransformFlag);
585 * Query whether the node inherits orientation from its parent.
586 * @return True if the parent orientation is inherited.
588 bool IsOrientationInherited() const
590 return mInheritOrientation;
594 * Retrieve the local scale of the node, relative to its parent.
595 * @param[in] bufferIndex The buffer to read from.
596 * @return The local scale.
598 const Vector3& GetScale(BufferIndex bufferIndex) const
600 return mScale[bufferIndex];
604 * Sets the scale of the node derived from the scale of all its parents and a pre-scale
605 * @param[in] updateBufferIndex The current update buffer index.
606 * @param[in] scale The world scale.
608 void SetWorldScale(BufferIndex updateBufferIndex, const Vector3& scale)
610 mWorldScale.Set( updateBufferIndex, scale );
614 * Sets the scale of the node derived from the scale of all its parents and a pre-scale.
615 * This method should only be called when the parents world scale is up-to-date.
616 * @pre The node has a parent.
617 * @param[in] updateBufferIndex The current update buffer index.
619 void InheritWorldScale(BufferIndex updateBufferIndex)
621 DALI_ASSERT_DEBUG(mParent != NULL);
623 mWorldScale.Set( updateBufferIndex, mParent->GetWorldScale(updateBufferIndex) * mScale[updateBufferIndex] );
627 * Copies the previous inherited scale, if this changed in the previous frame.
628 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
629 * does not need to be recalculated in the current frame.
630 * @param[in] updateBufferIndex The current update buffer index.
632 void CopyPreviousWorldScale( BufferIndex updateBufferIndex )
634 mWorldScale.CopyPrevious( updateBufferIndex );
638 * Retrieve the scale of the node derived from the scale of all its parents.
639 * @param[in] bufferIndex The buffer to read from.
640 * @return The world scale.
642 const Vector3& GetWorldScale( BufferIndex bufferIndex ) const
644 return mWorldScale[bufferIndex];
648 * Set whether the Node inherits scale.
649 * @param inherit True if the Node inherits scale.
651 void SetInheritScale( bool inherit )
653 if( inherit != mInheritScale )
655 mInheritScale = inherit;
657 SetDirtyFlag( TransformFlag );
662 * Query whether the Node inherits scale.
663 * @return if scale is inherited
665 bool IsScaleInherited() const
667 return mInheritScale;
671 * Copies the previously used size, if this changed in the previous frame.
672 * @param[in] updateBufferIndex The current update buffer index.
674 void CopyPreviousSize( BufferIndex updateBufferIndex )
676 SetSize( updateBufferIndex, GetSize( 1u - updateBufferIndex ) );
680 * Retrieve the visibility of the node.
681 * @param[in] bufferIndex The buffer to read from.
682 * @return True if the node is visible.
684 bool IsVisible(BufferIndex bufferIndex) const
686 return mVisible[bufferIndex];
690 * Retrieves whether a node is fully visible.
691 * A node is fully visible if is visible and all its ancestors are visible.
692 * @param[in] updateBufferIndex The current update buffer index.
693 * @return True if the node is fully visible.
695 bool IsFullyVisible( BufferIndex updateBufferIndex ) const;
698 * Retrieve the opacity of the node.
699 * @param[in] bufferIndex The buffer to read from.
700 * @return The opacity.
702 float GetOpacity(BufferIndex bufferIndex) const
704 return mColor[bufferIndex].a;
708 * Retrieve the color of the node.
709 * @param[in] bufferIndex The buffer to read from.
712 const Vector4& GetColor(BufferIndex bufferIndex) const
714 return mColor[bufferIndex];
718 * Sets the color of the node derived from the color of all its parents.
719 * @param[in] color The world color.
720 * @param[in] updateBufferIndex The current update buffer index.
722 void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
724 mWorldColor.Set( updateBufferIndex, color );
728 * Sets the color of the node derived from the color of all its parents.
729 * This method should only be called when the parents world color is up-to-date.
730 * @pre The node has a parent.
731 * @param[in] updateBufferIndex The current update buffer index.
733 void InheritWorldColor( BufferIndex updateBufferIndex )
735 DALI_ASSERT_DEBUG(mParent != NULL);
738 if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA )
740 const Vector4& ownColor = mColor[updateBufferIndex];
741 mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a );
743 else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR )
745 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] );
747 else if( mColorMode == USE_PARENT_COLOR )
749 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) );
751 else // USE_OWN_COLOR
753 mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] );
758 * Copies the previous inherited scale, if this changed in the previous frame.
759 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
760 * does not need to be recalculated in the current frame.
761 * @param[in] updateBufferIndex The current update buffer index.
763 void CopyPreviousWorldColor( BufferIndex updateBufferIndex )
765 mWorldColor.CopyPrevious( updateBufferIndex );
769 * Retrieve the color of the node, possibly derived from the color
770 * of all its parents, depending on the value of mColorMode.
771 * @param[in] bufferIndex The buffer to read from.
772 * @return The world color.
774 const Vector4& GetWorldColor(BufferIndex bufferIndex) const
776 return mWorldColor[bufferIndex];
780 * Set the color mode. This specifies whether the Node uses its own color,
781 * or inherits its parent color.
782 * @param[in] colorMode The new color mode.
784 void SetColorMode(ColorMode colorMode)
786 mColorMode = colorMode;
788 SetDirtyFlag(ColorFlag);
792 * Retrieve the color mode.
793 * @return The color mode.
795 ColorMode GetColorMode() const
801 * Sets the size of the node.
802 * @param[in] bufferIndex The buffer to write to.
803 * @param[in] size The size to write.
805 void SetSize( BufferIndex bufferIndex, const Vector3& size )
807 mSize[bufferIndex] = size;
811 * Retrieve the size of the node.
812 * @param[in] bufferIndex The buffer to read from.
815 const Vector3& GetSize(BufferIndex bufferIndex) const
817 return mSize[bufferIndex];
821 * Set the world-matrix of a node, with scale + rotation + translation.
822 * Scale and rotation are centered at the origin.
823 * Translation is applied independently of the scale or rotatation axis.
824 * @param[in] updateBufferIndex The current update buffer index.
825 * @param[in] scale The scale.
826 * @param[in] rotation The rotation.
827 * @param[in] translation The translation.
829 void SetWorldMatrix( BufferIndex updateBufferIndex, const Vector3& scale, const Quaternion& rotation, const Vector3& translation )
831 mWorldMatrix.Get( updateBufferIndex ).SetTransformComponents( scale, rotation, translation );
832 mWorldMatrix.SetDirty( updateBufferIndex );
836 * Retrieve the cached world-matrix of a node.
837 * @param[in] bufferIndex The buffer to read from.
838 * @return The world-matrix.
840 const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
842 return mWorldMatrix[ bufferIndex ];
846 * Copy previous frames world matrix
847 * @param[in] updateBufferIndex The current update buffer index.
849 void CopyPreviousWorldMatrix( BufferIndex updateBufferIndex )
851 mWorldMatrix.CopyPrevious( updateBufferIndex );
855 * Mark the node as exclusive to a single RenderTask.
856 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
858 void SetExclusiveRenderTask( RenderTask* renderTask )
860 mExclusiveRenderTask = renderTask;
864 * Query whether the node is exclusive to a single RenderTask.
865 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
867 RenderTask* GetExclusiveRenderTask() const
869 return mExclusiveRenderTask;
873 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
874 * @param[in] drawMode The new draw-mode to use.
876 void SetDrawMode( const DrawMode::Type& drawMode )
878 mDrawMode = drawMode;
882 * Returns whether node is an overlay or not.
883 * @return True if node is an overlay, false otherwise.
885 DrawMode::Type GetDrawMode() const
891 * Equality operator, checks for identity, not values.
894 bool operator==( const Node* rhs ) const
904 * Set the inhibit local transform flag.@n
905 * Setting this flag will stop the node's local transform (position, scale and orientation)
906 * being applied on top of its parents transformation.
907 * @param[in] flag When true, local transformation is inhibited when calculating the world matrix.
909 void SetInhibitLocalTransform( bool flag )
911 SetDirtyFlag( TransformFlag );
912 mInhibitLocalTransform = flag;
916 * Get the inhibit local transform flag.@n
917 * See @ref SetInhibitLocalTransform
918 * @result A flag, when true, local transformation is inhibited when calculating the world matrix.
920 bool GetInhibitLocalTransform() const
922 return mInhibitLocalTransform;
928 * Set the parent of a Node.
929 * @param[in] parentNode the new parent.
931 void SetParent(Node& parentNode);
934 * Protected constructor; See also Node::New()
938 private: // from NodeDataProvider
941 * @copydoc NodeDataProvider::GetModelMatrix
943 virtual const Matrix& GetModelMatrix( unsigned int bufferId )
945 return GetWorldMatrix( bufferId );
949 * @copydoc NodeDataProvider::GetRenderColor
951 virtual const Vector4& GetRenderColor( unsigned int bufferId )
953 return GetWorldColor( bufferId );
956 virtual const Vector3& GetRenderSize( unsigned int bufferId )
958 return GetSize( bufferId );
968 Node& operator=(const Node& rhs);
971 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
973 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
976 * Recursive helper to disconnect a Node and its children.
977 * Disconnected Nodes have no parent or children.
978 * @param[in] updateBufferIndex The current update buffer index.
979 * @param[in] connectedNodes Disconnected Node attachments should be removed from here.
980 * @param[in] disconnectedNodes Disconnected Node attachments should be added here.
982 void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes );
984 public: // Default properties
986 PropertyVector3 mParentOrigin; ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
987 PropertyVector3 mAnchorPoint; ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
989 AnimatableProperty<Vector3> mSize; ///< Size is provided for layouting
990 AnimatableProperty<Vector3> mPosition; ///< Local transform; distance between parent-origin & anchor-point
991 AnimatableProperty<Quaternion> mOrientation; ///< Local transform; rotation relative to parent node
992 AnimatableProperty<Vector3> mScale; ///< Local transform; scale relative to parent node
993 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
994 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
996 // Inherited properties; read-only from public API
998 InheritedVector3 mWorldPosition; ///< Full inherited position
999 InheritedQuaternion mWorldOrientation; ///< Full inherited orientation
1000 InheritedVector3 mWorldScale; ///< Full inherited scale
1001 InheritedMatrix mWorldMatrix; ///< Full inherited world matrix
1002 InheritedColor mWorldColor; ///< Full inherited color
1006 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
1007 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
1009 NodeAttachmentOwner mAttachment; ///< Optional owned attachment
1010 NodeContainer mChildren; ///< Container of children; not owned
1013 // flags, compressed to bitfield
1014 int mDirtyFlags:10; ///< A composite set of flags for each of the Node properties
1016 bool mIsRoot:1; ///< True if the node cannot have a parent
1017 bool mInheritOrientation:1; ///< Whether the parent's orientation should be inherited.
1018 bool mInheritScale:1; ///< Whether the parent's scale should be inherited.
1019 bool mInhibitLocalTransform:1; ///< whether local transform should be applied.
1020 bool mIsActive:1; ///< When a Node is marked "active" it has been disconnected, and its properties have not been modified
1022 DrawMode::Type mDrawMode:2; ///< How the Node and its children should be drawn
1023 PositionInheritanceMode mPositionInheritanceMode:2;///< Determines how position is inherited, 2 bits is enough
1024 ColorMode mColorMode:2; ///< Determines whether mWorldColor is inherited, 2 bits is enough
1026 // Changes scope, should be at end of class
1027 DALI_LOG_OBJECT_STRING_DECLARATION;
1030 // Messages for Node
1032 inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1034 typedef MessageValue1< Node, bool > LocalType;
1036 // Reserve some memory inside the message queue
1037 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1039 // Construct message in the message queue memory; note that delete should not be called on the return value
1040 new (slot) LocalType( &node, &Node::SetInheritOrientation, inherit );
1045 inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
1047 typedef MessageValue1< Node, Vector3 > LocalType;
1049 // Reserve some memory inside the message queue
1050 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1052 // Construct message in the message queue memory; note that delete should not be called on the return value
1053 new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
1056 inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
1058 typedef MessageValue1< Node, Vector3 > LocalType;
1060 // Reserve some memory inside the message queue
1061 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1063 // Construct message in the message queue memory; note that delete should not be called on the return value
1064 new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
1067 inline void SetPositionInheritanceModeMessage( EventThreadServices& eventThreadServices, const Node& node, PositionInheritanceMode mode )
1069 typedef MessageValue1< Node, PositionInheritanceMode > LocalType;
1071 // Reserve some memory inside the message queue
1072 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1074 // Construct message in the message queue memory; note that delete should not be called on the return value
1075 new (slot) LocalType( &node, &Node::SetPositionInheritanceMode, mode );
1078 inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1080 typedef MessageValue1< Node, bool > LocalType;
1082 // Reserve some memory inside the message queue
1083 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1085 // Construct message in the message queue memory; note that delete should not be called on the return value
1086 new (slot) LocalType( &node, &Node::SetInheritScale, inherit );
1089 inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
1091 typedef MessageValue1< Node, ColorMode > LocalType;
1093 // Reserve some memory inside the message queue
1094 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1096 // Construct message in the message queue memory; note that delete should not be called on the return value
1097 new (slot) LocalType( &node, &Node::SetColorMode, colorMode );
1100 inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
1102 typedef MessageValue1< Node, DrawMode::Type > LocalType;
1104 // Reserve some memory inside the message queue
1105 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1107 // Construct message in the message queue memory; note that delete should not be called on the return value
1108 new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
1111 } // namespace SceneGraph
1113 } // namespace Internal
1117 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_H_