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/common/event-to-update.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/renderers/render-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.
88 * Each node provides a transformation which applies to the node and its children.
89 * Node data is double-buffered. This allows an update thread to modify node data, without interferring
90 * with another thread reading the values from the previous update traversal.
92 class Node : public PropertyOwner, public RenderDataProvider
97 static const PositionInheritanceMode DEFAULT_POSITION_INHERITANCE_MODE;
98 static const ColorMode DEFAULT_COLOR_MODE;
99 static const SizeMode DEFAULT_SIZE_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.
229 * @param[in] index to insert at, if not supplied or -1 it will be appended
232 void ConnectChild( Node* childNode, int index = -1);
235 * Disconnect a child (& its children) from the scene-graph.
236 * @pre childNode is a child of this Node.
237 * @param[in] updateBufferIndex The current update buffer index.
238 * @param[in] childNode The node to disconnect.
239 * @param[in] connectedNodes Disconnected Node attachments should be removed from here.
240 * @param[in] disconnectedNodes Disconnected Node attachments should be added here.
242 void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes );
245 * Retrieve the children a Node.
246 * @return The container of children.
248 const NodeContainer& GetChildren() const
254 * Retrieve the children a Node.
255 * @return The container of children.
257 NodeContainer& GetChildren()
265 * Flag that one of the node values has changed in the current frame.
266 * @param[in] flag The flag to set.
268 void SetDirtyFlag(NodePropertyFlags flag)
274 * Flag that all of the node values are dirty.
276 void SetAllDirtyFlags()
278 mDirtyFlags = AllFlags;
282 * Query whether a node is dirty.
283 * @return The dirty flags
285 int GetDirtyFlags() const;
288 * Query whether a node is clean.
289 * @return True if the node is clean.
293 return ( NothingFlag == GetDirtyFlags() );
297 * Retrieve the parent-origin of the node.
298 * @return The parent-origin.
300 const Vector3& GetParentOrigin() const
302 return mParentOrigin.mValue;
306 * Sets both the local & base parent-origins of the node.
307 * @param[in] origin The new local & base parent-origins.
309 void SetParentOrigin(const Vector3& origin)
311 mParentOrigin.mValue = origin;
312 mParentOrigin.OnSet();
316 * Retrieve the anchor-point of the node.
317 * @return The anchor-point.
319 const Vector3& GetAnchorPoint() const
321 return mAnchorPoint.mValue;
325 * Sets both the local & base anchor-points of the node.
326 * @param[in] anchor The new local & base anchor-points.
328 void SetAnchorPoint(const Vector3& anchor)
330 mAnchorPoint.mValue = anchor;
331 mAnchorPoint.OnSet();
335 * Retrieve the local position of the node, relative to its parent.
336 * @param[in] bufferIndex The buffer to read from.
337 * @return The local position.
339 const Vector3& GetPosition(BufferIndex bufferIndex) const
341 return mPosition[bufferIndex];
345 * Sets both the local & base positions of the node.
346 * @param[in] updateBufferIndex The current update buffer index.
347 * @param[in] position The new local & base position.
349 void BakePosition(BufferIndex updateBufferIndex, const Vector3& position)
351 mPosition.Bake( updateBufferIndex, position );
355 * Sets the world of the node derived from the position of all its parents.
356 * @param[in] updateBufferIndex The current update buffer index.
357 * @param[in] position The world position.
359 void SetWorldPosition( BufferIndex updateBufferIndex, const Vector3& position )
361 mWorldPosition.Set( updateBufferIndex, position );
365 * Sets the position of the node derived from the position of all its parents.
366 * This method should only be called when the parent's world position is up-to-date.
367 * With a non-central anchor-point, the local rotation and scale affects the world position.
368 * Therefore the world rotation & scale must be updated before the world position.
369 * @pre The node has a parent.
370 * @param[in] updateBufferIndex The current update buffer index.
372 void InheritWorldPosition(BufferIndex updateBufferIndex)
374 DALI_ASSERT_DEBUG(mParent != NULL);
376 switch( mPositionInheritanceMode )
378 case INHERIT_PARENT_POSITION : ///@see Dali::PositionInheritanceMode for how these modes are expected to work
380 Vector3 finalPosition(-0.5f, -0.5f, -0.5f);
382 finalPosition += mParentOrigin.mValue;
383 finalPosition *= mParent->GetSize(updateBufferIndex);
384 finalPosition += mPosition[updateBufferIndex];
385 finalPosition *= mParent->GetWorldScale(updateBufferIndex);
386 const Quaternion& parentWorldRotation = mParent->GetWorldRotation(updateBufferIndex);
387 if(!parentWorldRotation.IsIdentity())
389 finalPosition *= parentWorldRotation;
392 // check if a node needs to be offsetted locally (only applies when AnchorPoint is not central)
393 // dont use operator== as that does a slower comparison (and involves function calls)
394 Vector3 localOffset(0.5f, 0.5f, 0.5f); // AnchorPoint::CENTER
395 localOffset -= mAnchorPoint.mValue;
397 if( ( fabsf( localOffset.x ) >= Math::MACHINE_EPSILON_0 ) ||
398 ( fabsf( localOffset.y ) >= Math::MACHINE_EPSILON_0 ) ||
399 ( fabsf( localOffset.z ) >= Math::MACHINE_EPSILON_0 ) )
401 localOffset *= mSize[updateBufferIndex];
403 Vector3 scale = mWorldScale[updateBufferIndex];
405 // Pick up sign of local scale
406 if (mScale[updateBufferIndex].x < 0.0f)
410 if (mScale[updateBufferIndex].y < 0.0f)
414 if (mScale[updateBufferIndex].z < 0.0f)
419 // If the anchor-point is not central, then position is affected by the local rotation & scale
420 localOffset *= scale;
421 const Quaternion& localWorldRotation = mWorldRotation[updateBufferIndex];
422 if(!localWorldRotation.IsIdentity())
424 localOffset *= localWorldRotation;
426 finalPosition += localOffset;
429 finalPosition += mParent->GetWorldPosition(updateBufferIndex);
430 mWorldPosition.Set( updateBufferIndex, finalPosition );
433 case USE_PARENT_POSITION_PLUS_LOCAL_POSITION :
435 // copy parents position plus local transform
436 mWorldPosition.Set( updateBufferIndex, mParent->GetWorldPosition(updateBufferIndex) + mPosition[updateBufferIndex] );
439 case USE_PARENT_POSITION :
441 // copy parents position
442 mWorldPosition.Set( updateBufferIndex, mParent->GetWorldPosition(updateBufferIndex) );
445 case DONT_INHERIT_POSITION :
447 // use local position as world position
448 mWorldPosition.Set( updateBufferIndex, mPosition[updateBufferIndex] );
455 * Copies the previous inherited position, if this changed in the previous frame.
456 * This method should be called instead of InheritWorldPosition i.e. if the inherited position
457 * does not need to be recalculated in the current frame.
458 * @param[in] updateBufferIndex The current update buffer index.
460 void CopyPreviousWorldPosition( BufferIndex updateBufferIndex )
462 mWorldPosition.CopyPrevious( updateBufferIndex );
466 * Retrieve the position of the node derived from the position of all its parents.
467 * @return The world position.
469 const Vector3& GetWorldPosition( BufferIndex bufferIndex ) const
471 return mWorldPosition[bufferIndex];
475 * Set the position inheritance mode.
476 * @see Dali::Actor::PositionInheritanceMode
477 * @param[in] mode The new position inheritance mode.
479 void SetPositionInheritanceMode( PositionInheritanceMode mode )
481 mPositionInheritanceMode = mode;
483 SetDirtyFlag(TransformFlag);
487 * @return The position inheritance mode.
489 PositionInheritanceMode GetPositionInheritanceMode() const
491 return mPositionInheritanceMode;
495 * Retrieve the local rotation of the node, relative to its parent.
496 * @param[in] bufferIndex The buffer to read from.
497 * @return The local rotation.
499 const Quaternion& GetRotation(BufferIndex bufferIndex) const
501 return mRotation[bufferIndex];
505 * Sets both the local & base rotations of the node.
506 * @param[in] updateBufferIndex The current update buffer index.
507 * @param[in] rotation The new local & base rotation.
509 void BakeRotation(BufferIndex updateBufferIndex, const Quaternion& rotation)
511 mRotation.Bake( updateBufferIndex, rotation );
515 * Sets the rotation of the node derived from the rotation of all its parents.
516 * @param[in] updateBufferIndex The current update buffer index.
517 * @param[in] rotation The world rotation.
519 void SetWorldRotation( BufferIndex updateBufferIndex, const Quaternion& rotation )
521 mWorldRotation.Set( updateBufferIndex, rotation );
525 * Sets the rotation of the node derived from the rotation of all its parents.
526 * This method should only be called when the parents world rotation is up-to-date.
527 * @pre The node has a parent.
528 * @param[in] updateBufferIndex The current update buffer index.
530 void InheritWorldRotation( BufferIndex updateBufferIndex )
532 DALI_ASSERT_DEBUG(mParent != NULL);
534 const Quaternion& localRotation = mRotation[updateBufferIndex];
536 if(localRotation.IsIdentity())
538 mWorldRotation.Set( updateBufferIndex, mParent->GetWorldRotation(updateBufferIndex) );
542 Quaternion finalRotation( mParent->GetWorldRotation(updateBufferIndex) );
543 finalRotation *= localRotation;
544 mWorldRotation.Set( updateBufferIndex, finalRotation );
549 * Copies the previous inherited rotation, if this changed in the previous frame.
550 * This method should be called instead of InheritWorldRotation i.e. if the inherited rotation
551 * does not need to be recalculated in the current frame.
552 * @param[in] updateBufferIndex The current update buffer index.
554 void CopyPreviousWorldRotation( BufferIndex updateBufferIndex )
556 mWorldRotation.CopyPrevious( updateBufferIndex );
560 * Retrieve the rotation of the node derived from the rotation of all its parents.
561 * @param[in] bufferIndex The buffer to read from.
562 * @return The world rotation.
564 const Quaternion& GetWorldRotation( BufferIndex bufferIndex ) const
566 return mWorldRotation[bufferIndex];
570 * Set whether the Node inherits rotation.
571 * @param[in] inherit True if the parent rotation is inherited.
573 void SetInheritRotation(bool inherit)
575 if (inherit != mInheritRotation)
577 mInheritRotation = inherit;
579 SetDirtyFlag(TransformFlag);
584 * Query whether the node inherits rotation from its parent.
585 * @return True if the parent rotation is inherited.
587 bool IsRotationInherited() const
589 return mInheritRotation;
593 * @brief Defines how a child actor's size is affected by its parent's size.
594 * @param[in] mode The size relative to parent mode to use.
596 void SetSizeMode( SizeMode mode )
598 if ( mode != mSizeMode )
602 SetDirtyFlag( TransformFlag );
607 * Query how the child actor's size is affected by its parent's size.
608 * @return The size relative to parent mode in use.
610 SizeMode GetSizeMode() const
616 * Sets the factor of the parents size used for the child actor.
617 * Note: Only used for certain SizeModes.
618 * @param[in] factor The vector to multiply the parents size by to get the childs size.
620 void SetSizeModeFactor( const Vector3& factor )
622 mSizeModeFactor = factor;
624 SetDirtyFlag( TransformFlag );
628 * Gets the factor of the parents size used for the child actor.
629 * Note: Only used for certain SizeModes.
630 * @return The vector being used to multiply the parents size by to get the childs size.
632 const Vector3& GetSizeModeFactor() const
634 return mSizeModeFactor;
638 * Retrieve the local scale of the node, relative to its parent.
639 * @param[in] bufferIndex The buffer to read from.
640 * @return The local scale.
642 const Vector3& GetScale(BufferIndex bufferIndex) const
644 return mScale[bufferIndex];
648 * Sets the scale of the node derived from the scale of all its parents and a pre-scale
649 * @param[in] updateBufferIndex The current update buffer index.
650 * @param[in] scale The world scale.
652 void SetWorldScale(BufferIndex updateBufferIndex, const Vector3& scale)
654 mWorldScale.Set( updateBufferIndex, scale );
658 * Sets the scale of the node derived from the scale of all its parents and a pre-scale.
659 * This method should only be called when the parents world scale is up-to-date.
660 * @pre The node has a parent.
661 * @param[in] updateBufferIndex The current update buffer index.
663 void InheritWorldScale(BufferIndex updateBufferIndex)
665 DALI_ASSERT_DEBUG(mParent != NULL);
667 mWorldScale.Set( updateBufferIndex, mParent->GetWorldScale(updateBufferIndex) * mScale[updateBufferIndex] );
671 * Copies the previous inherited scale, if this changed in the previous frame.
672 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
673 * does not need to be recalculated in the current frame.
674 * @param[in] updateBufferIndex The current update buffer index.
676 void CopyPreviousWorldScale( BufferIndex updateBufferIndex )
678 mWorldScale.CopyPrevious( updateBufferIndex );
682 * Retrieve the scale of the node derived from the scale of all its parents.
683 * @param[in] bufferIndex The buffer to read from.
684 * @return The world scale.
686 const Vector3& GetWorldScale( BufferIndex bufferIndex ) const
688 return mWorldScale[bufferIndex];
692 * Set whether the Node inherits scale.
693 * @param inherit True if the Node inherits scale.
695 void SetInheritScale( bool inherit )
697 if( inherit != mInheritScale )
699 mInheritScale = inherit;
701 SetDirtyFlag( TransformFlag );
706 * Query whether the Node inherits scale.
707 * @return if scale is inherited
709 bool IsScaleInherited() const
711 return mInheritScale;
715 * Copies the previously used size, if this changed in the previous frame.
716 * @param[in] updateBufferIndex The current update buffer index.
718 void CopyPreviousSize( BufferIndex updateBufferIndex )
720 SetSize( updateBufferIndex, GetSize( 1u - updateBufferIndex ) );
724 * Retrieve the visibility of the node.
725 * @param[in] bufferIndex The buffer to read from.
726 * @return True if the node is visible.
728 bool IsVisible(BufferIndex bufferIndex) const
730 return mVisible[bufferIndex];
734 * Retrieves whether a node is fully visible.
735 * A node is fully visible if is visible and all its ancestors are visible.
736 * @param[in] updateBufferIndex The current update buffer index.
737 * @return True if the node is fully visible.
739 bool IsFullyVisible( BufferIndex updateBufferIndex ) const;
742 * Retrieve the opacity of the node.
743 * @param[in] bufferIndex The buffer to read from.
744 * @return The opacity.
746 float GetOpacity(BufferIndex bufferIndex) const
748 return mColor[bufferIndex].a;
752 * Retrieve the color of the node.
753 * @param[in] bufferIndex The buffer to read from.
756 const Vector4& GetColor(BufferIndex bufferIndex) const
758 return mColor[bufferIndex];
762 * Sets the color of the node derived from the color of all its parents.
763 * @param[in] color The world color.
764 * @param[in] updateBufferIndex The current update buffer index.
766 void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
768 mWorldColor.Set( updateBufferIndex, color );
772 * Sets the color of the node derived from the color of all its parents.
773 * This method should only be called when the parents world color is up-to-date.
774 * @pre The node has a parent.
775 * @param[in] updateBufferIndex The current update buffer index.
777 void InheritWorldColor( BufferIndex updateBufferIndex )
779 DALI_ASSERT_DEBUG(mParent != NULL);
782 if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA )
784 const Vector4& ownColor = mColor[updateBufferIndex];
785 mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a );
787 else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR )
789 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] );
791 else if( mColorMode == USE_PARENT_COLOR )
793 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) );
795 else // USE_OWN_COLOR
797 mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] );
802 * Copies the previous inherited scale, if this changed in the previous frame.
803 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
804 * does not need to be recalculated in the current frame.
805 * @param[in] updateBufferIndex The current update buffer index.
807 void CopyPreviousWorldColor( BufferIndex updateBufferIndex )
809 mWorldColor.CopyPrevious( updateBufferIndex );
813 * Retrieve the color of the node, possibly derived from the color
814 * of all its parents, depending on the value of mColorMode.
815 * @param[in] bufferIndex The buffer to read from.
816 * @return The world color.
818 const Vector4& GetWorldColor(BufferIndex bufferIndex) const
820 return mWorldColor[bufferIndex];
824 * Set the color mode. This specifies whether the Node uses its own color,
825 * or inherits its parent color.
826 * @param[in] colorMode The new color mode.
828 void SetColorMode(ColorMode colorMode)
830 mColorMode = colorMode;
832 SetDirtyFlag(ColorFlag);
836 * Retrieve the color mode.
837 * @return The color mode.
839 ColorMode GetColorMode() const
845 * Sets the size of the node.
846 * @param[in] bufferIndex The buffer to write to.
847 * @param[in] size The size to write.
849 void SetSize( BufferIndex bufferIndex, const Vector3& size )
851 mSize[bufferIndex] = size;
855 * Retrieve the size of the node.
856 * @param[in] bufferIndex The buffer to read from.
859 const Vector3& GetSize(BufferIndex bufferIndex) const
861 return mSize[bufferIndex];
865 * Set the world-matrix of a node, with scale + rotation + translation.
866 * Scale and rotation are centered at the origin.
867 * Translation is applied independently of the scale or rotatation axis.
868 * @param[in] updateBufferIndex The current update buffer index.
869 * @param[in] scale The scale.
870 * @param[in] rotation The rotation.
871 * @param[in] translation The translation.
873 void SetWorldMatrix( BufferIndex updateBufferIndex, const Vector3& scale, const Quaternion& rotation, const Vector3& translation )
875 mWorldMatrix.Get( updateBufferIndex ).SetTransformComponents( scale, rotation, translation );
876 mWorldMatrix.SetDirty( updateBufferIndex );
880 * Retrieve the cached world-matrix of a node.
881 * @param[in] bufferIndex The buffer to read from.
882 * @return The world-matrix.
884 const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
886 return mWorldMatrix[ bufferIndex ];
890 * Copy previous frames world matrix
891 * @param[in] updateBufferIndex The current update buffer index.
893 void CopyPreviousWorldMatrix( BufferIndex updateBufferIndex )
895 mWorldMatrix.CopyPrevious( updateBufferIndex );
899 * Mark the node as exclusive to a single RenderTask.
900 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
902 void SetExclusiveRenderTask( RenderTask* renderTask )
904 mExclusiveRenderTask = renderTask;
908 * Query whether the node is exclusive to a single RenderTask.
909 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
911 RenderTask* GetExclusiveRenderTask() const
913 return mExclusiveRenderTask;
917 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
918 * @param[in] drawMode The new draw-mode to use.
920 void SetDrawMode( const DrawMode::Type& drawMode )
922 mDrawMode = drawMode;
926 * Returns whether node is an overlay or not.
927 * @return True if node is an overlay, false otherwise.
929 DrawMode::Type GetDrawMode() const
935 * Equality operator, checks for identity, not values.
938 bool operator==( const Node* rhs ) const
948 * Set the inhibit local transform flag.@n
949 * Setting this flag will stop the node's local transform (position, scale and orientation)
950 * being applied on top of its parents transformation.
951 * @param[in] flag When true, local transformation is inhibited when calculating the world matrix.
953 void SetInhibitLocalTransform( bool flag )
955 SetDirtyFlag( TransformFlag );
956 mInhibitLocalTransform = flag;
960 * Get the inhibit local transform flag.@n
961 * See @ref SetInhibitLocalTransform
962 * @result A flag, when true, local transformation is inhibited when calculating the world matrix.
964 bool GetInhibitLocalTransform() const
966 return mInhibitLocalTransform;
972 * Set the parent of a Node.
973 * @param[in] parentNode the new parent.
975 void SetParent(Node& parentNode);
978 * Protected constructor; See also Node::New()
982 private: // from RenderDataProvider
985 * @copydoc RenderDataProvider::GetModelMatrix
987 virtual const Matrix& GetModelMatrix( unsigned int bufferId )
989 return GetWorldMatrix( bufferId );
993 * @copydoc RenderDataProvider::GetRenderColor
995 virtual const Vector4& GetRenderColor( unsigned int bufferId )
997 return GetWorldColor( bufferId );
1006 Node& operator=(const Node& rhs);
1009 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
1011 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
1014 * Recursive helper to disconnect a Node and its children.
1015 * Disconnected Nodes have no parent or children.
1016 * @param[in] updateBufferIndex The current update buffer index.
1017 * @param[in] connectedNodes Disconnected Node attachments should be removed from here.
1018 * @param[in] disconnectedNodes Disconnected Node attachments should be added here.
1020 void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes );
1022 public: // Default properties
1024 PropertyVector3 mParentOrigin; ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
1025 PropertyVector3 mAnchorPoint; ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
1027 AnimatableProperty<Vector3> mSize; ///< Size is provided for layouting
1028 AnimatableProperty<Vector3> mPosition; ///< Local transform; distance between parent-origin & anchor-point
1029 AnimatableProperty<Quaternion> mRotation; ///< Local transform; rotation relative to parent node
1030 AnimatableProperty<Vector3> mScale; ///< Local transform; scale relative to parent node
1031 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
1032 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
1034 // Inherited properties; read-only from public API
1036 InheritedVector3 mWorldPosition; ///< Full inherited position
1037 InheritedQuaternion mWorldRotation; ///< Full inherited rotation
1038 InheritedVector3 mWorldScale; ///< Full inherited scale
1039 InheritedMatrix mWorldMatrix; ///< Full inherited world matrix
1040 InheritedColor mWorldColor; ///< Full inherited color
1044 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
1045 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
1047 NodeAttachmentOwner mAttachment; ///< Optional owned attachment
1048 NodeContainer mChildren; ///< Container of children; not owned
1050 Vector3 mSizeModeFactor; ///< Factor of parent size. Used for certain SizeModes.
1052 // flags, compressed to bitfield
1053 int mDirtyFlags:10; ///< A composite set of flags for each of the Node properties
1055 bool mIsRoot:1; ///< True if the node cannot have a parent
1056 bool mInheritRotation:1; ///< Whether the parent's rotation should be inherited.
1057 bool mInheritScale:1; ///< Whether the parent's scale should be inherited.
1058 bool mInhibitLocalTransform:1; ///< whether local transform should be applied.
1059 bool mIsActive:1; ///< When a Node is marked "active" it has been disconnected, and its properties have not been modified
1061 DrawMode::Type mDrawMode:2; ///< How the Node and its children should be drawn
1062 PositionInheritanceMode mPositionInheritanceMode:2;///< Determines how position is inherited, 2 bits is enough
1063 ColorMode mColorMode:2; ///< Determines whether mWorldColor is inherited, 2 bits is enough
1064 SizeMode mSizeMode:2; ///< Determines how the actors parent affects the actors size.
1066 // Changes scope, should be at end of class
1067 DALI_LOG_OBJECT_STRING_DECLARATION;
1070 // Messages for Node
1072 inline void SetInheritRotationMessage( EventToUpdate& eventToUpdate, const Node& node, bool inherit )
1074 typedef MessageValue1< Node, bool > LocalType;
1076 // Reserve some memory inside the message queue
1077 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1079 // Construct message in the message queue memory; note that delete should not be called on the return value
1080 new (slot) LocalType( &node, &Node::SetInheritRotation, inherit );
1083 inline void SetSizeModeMessage( EventToUpdate& eventToUpdate, const Node& node, SizeMode mode )
1085 typedef MessageValue1< Node, SizeMode > LocalType;
1087 // Reserve some memory inside the message queue
1088 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1090 // Construct message in the message queue memory; note that delete should not be called on the return value
1091 new (slot) LocalType( &node, &Node::SetSizeMode, mode );
1094 inline void SetSizeModeFactorMessage( EventToUpdate& eventToUpdate, const Node& node, const Vector3& factor )
1096 typedef MessageValue1< Node, Vector3 > LocalType;
1098 // Reserve some memory inside the message queue
1099 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1101 // Construct message in the message queue memory; note that delete should not be called on the return value
1102 new (slot) LocalType( &node, &Node::SetSizeModeFactor, factor );
1105 inline void SetParentOriginMessage( EventToUpdate& eventToUpdate, const Node& node, const Vector3& origin )
1107 typedef MessageValue1< Node, Vector3 > LocalType;
1109 // Reserve some memory inside the message queue
1110 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1112 // Construct message in the message queue memory; note that delete should not be called on the return value
1113 new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
1116 inline void SetAnchorPointMessage( EventToUpdate& eventToUpdate, const Node& node, const Vector3& anchor )
1118 typedef MessageValue1< Node, Vector3 > LocalType;
1120 // Reserve some memory inside the message queue
1121 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1123 // Construct message in the message queue memory; note that delete should not be called on the return value
1124 new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
1127 inline void SetPositionInheritanceModeMessage( EventToUpdate& eventToUpdate, const Node& node, PositionInheritanceMode mode )
1129 typedef MessageValue1< Node, PositionInheritanceMode > LocalType;
1131 // Reserve some memory inside the message queue
1132 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1134 // Construct message in the message queue memory; note that delete should not be called on the return value
1135 new (slot) LocalType( &node, &Node::SetPositionInheritanceMode, mode );
1138 inline void SetInheritScaleMessage( EventToUpdate& eventToUpdate, const Node& node, bool inherit )
1140 typedef MessageValue1< Node, bool > LocalType;
1142 // Reserve some memory inside the message queue
1143 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1145 // Construct message in the message queue memory; note that delete should not be called on the return value
1146 new (slot) LocalType( &node, &Node::SetInheritScale, inherit );
1149 inline void SetColorModeMessage( EventToUpdate& eventToUpdate, const Node& node, ColorMode colorMode )
1151 typedef MessageValue1< Node, ColorMode > LocalType;
1153 // Reserve some memory inside the message queue
1154 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1156 // Construct message in the message queue memory; note that delete should not be called on the return value
1157 new (slot) LocalType( &node, &Node::SetColorMode, colorMode );
1160 inline void SetDrawModeMessage( EventToUpdate& eventToUpdate, const Node& node, DrawMode::Type drawMode )
1162 typedef MessageValue1< Node, DrawMode::Type > LocalType;
1164 // Reserve some memory inside the message queue
1165 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1167 // Construct message in the message queue memory; note that delete should not be called on the return value
1168 new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
1171 } // namespace SceneGraph
1173 } // namespace Internal
1177 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_H_