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/update/common/animatable-property.h>
30 #include <dali/internal/update/common/property-owner.h>
31 #include <dali/internal/update/common/property-vector3.h>
32 #include <dali/internal/update/common/scene-graph-buffers.h>
33 #include <dali/internal/update/common/inherited-property.h>
34 #include <dali/integration-api/debug.h>
35 #include <dali/internal/update/nodes/node-declarations.h>
36 #include <dali/internal/update/node-attachments/node-attachment-declarations.h>
37 #include <dali/internal/render/renderers/render-data-provider.h>
45 // value types used by messages
46 template <> struct ParameterType< ColorMode > : public BasicType< ColorMode > {};
47 template <> struct ParameterType< PositionInheritanceMode > : public BasicType< PositionInheritanceMode > {};
59 * Flag whether property has changed, during the Update phase.
61 enum NodePropertyFlags
64 TransformFlag = 0x001,
69 SortModifierFlag = 0x020,
70 ChildDeletedFlag = 0x040
73 static const int AllFlags = ( ChildDeletedFlag << 1 ) - 1; // all the flags
76 * Size is not inherited.
77 * VisibleFlag is inherited so that attachments can be synchronized with nodes after they become visible
79 static const int InheritedDirtyFlags = TransformFlag | VisibleFlag | ColorFlag | OverlayFlag;
81 // Flags which require the scene renderable lists to be updated
82 static const int RenderableUpdateFlags = TransformFlag | SortModifierFlag | ChildDeletedFlag;
85 * Node is the base class for all nodes in the Scene Graph.
86 * Each node provides a transformation which applies to the node and its children.
87 * Node data is double-buffered. This allows an update thread to modify node data, without interferring
88 * with another thread reading the values from the previous update traversal.
90 class Node : public PropertyOwner, public RenderDataProvider
95 static const PositionInheritanceMode DEFAULT_POSITION_INHERITANCE_MODE;
96 static const ColorMode DEFAULT_COLOR_MODE;
101 * Construct a new Node.
111 * When a Node is marked "active" it has been disconnected, but its properties have been modified.
112 * @note An inactive Node will be skipped during the UpdateManager ResetProperties stage.
113 * @param[in] isActive True if the Node is active.
115 void SetActive( bool isActive )
117 mIsActive = isActive;
121 * Query whether the Node is active.
122 * @return True if the Node is active.
124 bool IsActive() const
130 * Called during UpdateManager::DestroyNode shortly before Node is destroyed.
137 * Query whether the node is a layer.
138 * @return True if the node is a layer.
142 return (GetLayer() != NULL);
146 * Convert a node to a layer.
147 * @return A pointer to the layer, or NULL.
149 virtual Layer* GetLayer()
157 * Attach an object to this Node; This should only be done by UpdateManager::AttachToNode.
158 * @pre The Node does not already have an attachment.
159 * @param[in] attachment The object to attach.
161 void Attach( NodeAttachment& attachment );
164 * Query the node if it has an attachment.
165 * @return True if it has an attachment.
167 bool HasAttachment() const
173 * Retreive the object attached to this node.
174 * @return The attachment.
176 NodeAttachment& GetAttachment() const
181 // Containment methods
184 * Query whether a node is the root node. Root nodes cannot have a parent node.
185 * A node becomes a root node, when it is installed by UpdateManager.
186 * @return True if the node is a root node.
194 * Set whether a node is the root node. Root nodes cannot have a parent node.
195 * This method should only be called by UpdateManager.
196 * @pre When isRoot is true, the node must not have a parent.
197 * @param[in] isRoot Whether the node is now a root node.
199 void SetRoot(bool isRoot);
202 * Retrieve the parent of a Node.
203 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
211 * Retrieve the parent of a Node.
212 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
214 const Node* GetParent() const
220 * Connect a node to the scene-graph.
221 * @pre A node cannot be added to itself.
222 * @pre The parent node is connected to the scene-graph.
223 * @pre The childNode does not already have a parent.
224 * @pre The childNode is not a root node.
225 * @param[in] childNode The child to add.
226 * @param[in] index to insert at, if not supplied or -1 it will be appended
229 void ConnectChild( Node* childNode, int index = -1);
232 * Disconnect a child (& its children) from the scene-graph.
233 * @pre childNode is a child of this Node.
234 * @param[in] updateBufferIndex The current update buffer index.
235 * @param[in] childNode The node to disconnect.
236 * @param[in] connectedNodes Disconnected Node attachments should be removed from here.
237 * @param[in] disconnectedNodes Disconnected Node attachments should be added here.
239 void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes );
242 * Retrieve the children a Node.
243 * @return The container of children.
245 const NodeContainer& GetChildren() const
251 * Retrieve the children a Node.
252 * @return The container of children.
254 NodeContainer& GetChildren()
262 * Flag that one of the node values has changed in the current frame.
263 * @param[in] flag The flag to set.
265 void SetDirtyFlag(NodePropertyFlags flag)
271 * Flag that all of the node values are dirty.
273 void SetAllDirtyFlags()
275 mDirtyFlags = AllFlags;
279 * Query whether a node is dirty.
280 * @return The dirty flags
282 int GetDirtyFlags() const;
285 * Query whether a node is clean.
286 * @return True if the node is clean.
290 return ( NothingFlag == GetDirtyFlags() );
294 * Retrieve the parent-origin of the node.
295 * @return The parent-origin.
297 const Vector3& GetParentOrigin() const
299 return mParentOrigin.mValue;
303 * Sets both the local & base parent-origins of the node.
304 * @param[in] origin The new local & base parent-origins.
306 void SetParentOrigin(const Vector3& origin)
308 mParentOrigin.mValue = origin;
309 mParentOrigin.OnSet();
313 * Retrieve the anchor-point of the node.
314 * @return The anchor-point.
316 const Vector3& GetAnchorPoint() const
318 return mAnchorPoint.mValue;
322 * Sets both the local & base anchor-points of the node.
323 * @param[in] anchor The new local & base anchor-points.
325 void SetAnchorPoint(const Vector3& anchor)
327 mAnchorPoint.mValue = anchor;
328 mAnchorPoint.OnSet();
332 * Retrieve the local position of the node, relative to its parent.
333 * @param[in] bufferIndex The buffer to read from.
334 * @return The local position.
336 const Vector3& GetPosition(BufferIndex bufferIndex) const
338 return mPosition[bufferIndex];
342 * Sets both the local & base positions of the node.
343 * @param[in] updateBufferIndex The current update buffer index.
344 * @param[in] position The new local & base position.
346 void BakePosition(BufferIndex updateBufferIndex, const Vector3& position)
348 mPosition.Bake( updateBufferIndex, position );
352 * Sets the world of the node derived from the position of all its parents.
353 * @param[in] updateBufferIndex The current update buffer index.
354 * @param[in] position The world position.
356 void SetWorldPosition( BufferIndex updateBufferIndex, const Vector3& position )
358 mWorldPosition.Set( updateBufferIndex, position );
362 * Sets the position of the node derived from the position of all its parents.
363 * This method should only be called when the parent's world position is up-to-date.
364 * With a non-central anchor-point, the local orientation and scale affects the world position.
365 * Therefore the world orientation & scale must be updated before the world position.
366 * @pre The node has a parent.
367 * @param[in] updateBufferIndex The current update buffer index.
369 void InheritWorldPosition(BufferIndex updateBufferIndex)
371 DALI_ASSERT_DEBUG(mParent != NULL);
373 switch( mPositionInheritanceMode )
375 case INHERIT_PARENT_POSITION : ///@see Dali::PositionInheritanceMode for how these modes are expected to work
377 Vector3 finalPosition(-0.5f, -0.5f, -0.5f);
379 finalPosition += mParentOrigin.mValue;
380 finalPosition *= mParent->GetSize(updateBufferIndex);
381 finalPosition += mPosition[updateBufferIndex];
382 finalPosition *= mParent->GetWorldScale(updateBufferIndex);
383 const Quaternion& parentWorldOrientation = mParent->GetWorldOrientation(updateBufferIndex);
384 if(!parentWorldOrientation.IsIdentity())
386 finalPosition *= parentWorldOrientation;
389 // check if a node needs to be offsetted locally (only applies when AnchorPoint is not central)
390 // dont use operator== as that does a slower comparison (and involves function calls)
391 Vector3 localOffset(0.5f, 0.5f, 0.5f); // AnchorPoint::CENTER
392 localOffset -= mAnchorPoint.mValue;
394 if( ( fabsf( localOffset.x ) >= Math::MACHINE_EPSILON_0 ) ||
395 ( fabsf( localOffset.y ) >= Math::MACHINE_EPSILON_0 ) ||
396 ( fabsf( localOffset.z ) >= Math::MACHINE_EPSILON_0 ) )
398 localOffset *= mSize[updateBufferIndex];
400 Vector3 scale = mWorldScale[updateBufferIndex];
401 if(GetTransmitGeometryScaling())
403 // Remove geometry scaling to get back to actor scale
404 scale /= mGeometryScale;
406 // Also 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 * Set the initial volume of the node. Used for calculating geometry scaling
595 * as the node size is changed when transmitGeometryScaling is set to true.
597 * This property is not animatable.
599 * @param[in] volume The initial volume of this nodes meshes & children
601 void SetInitialVolume( const Vector3& volume )
603 mInitialVolume = volume;
604 SetDirtyFlag(SizeFlag);
608 * Get the initial volume. Used for calculating geometry scaling
609 * when TransmitGeometryScaling is true (i.e., the scaling is baked
610 * into the node tranform)
612 * @return The initial volume of this node and children.
614 Vector3 GetInitialVolume()
616 return mInitialVolume;
620 * Sets whether the geometry scaling should be applied to the node
621 * (In which case, set the initial scale using SetInitialVolume()).
623 * If it is applied to the node, then the attachments are not scaled,
624 * as the scaling is then already baked into the node transform.
626 * @param[in] transmitGeometryScaling true if scaling is to be applied
629 void SetTransmitGeometryScaling(bool transmitGeometryScaling)
631 mTransmitGeometryScaling = transmitGeometryScaling;
632 SetDirtyFlag(SizeFlag);
636 * Find out whether the node allows geometry scaling to be transmitted to its children.
637 * @return true if transmitted.
639 bool GetTransmitGeometryScaling() const
641 return mTransmitGeometryScaling;
645 * Retrieve the local scale of the node, relative to its parent.
646 * @param[in] bufferIndex The buffer to read from.
647 * @return The local scale.
649 const Vector3& GetScale(BufferIndex bufferIndex) const
651 return mScale[bufferIndex];
655 * Sets the scale of the node derived from the scale of all its parents and a pre-scale
656 * @param[in] updateBufferIndex The current update buffer index.
657 * @param[in] scale The world scale.
659 void SetWorldScale(BufferIndex updateBufferIndex, const Vector3& scale)
661 mWorldScale.Set( updateBufferIndex, mGeometryScale * scale );
665 * Sets the scale of the node derived from the scale of all its parents and a pre-scale.
666 * This method should only be called when the parents world scale is up-to-date.
667 * @pre The node has a parent.
668 * @param[in] updateBufferIndex The current update buffer index.
670 void InheritWorldScale(BufferIndex updateBufferIndex)
672 DALI_ASSERT_DEBUG(mParent != NULL);
674 mWorldScale.Set( updateBufferIndex, mParent->GetWorldScale(updateBufferIndex) * mGeometryScale * mScale[updateBufferIndex] );
678 * Copies the previous inherited scale, if this changed in the previous frame.
679 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
680 * does not need to be recalculated in the current frame.
681 * @param[in] updateBufferIndex The current update buffer index.
683 void CopyPreviousWorldScale( BufferIndex updateBufferIndex )
685 mWorldScale.CopyPrevious( updateBufferIndex );
689 * Retrieve the scale of the node derived from the scale of all its parents.
690 * @param[in] bufferIndex The buffer to read from.
691 * @return The world scale.
693 const Vector3& GetWorldScale( BufferIndex bufferIndex ) const
695 return mWorldScale[bufferIndex];
699 * Set whether the Node inherits scale.
700 * @param inherit True if the Node inherits scale.
702 void SetInheritScale( bool inherit )
704 if( inherit != mInheritScale )
706 mInheritScale = inherit;
708 SetDirtyFlag( TransformFlag );
713 * Query whether the Node inherits scale.
714 * @return if scale is inherited
716 bool IsScaleInherited() const
718 return mInheritScale;
722 * Sets a geometry scale, calculated when TransmitGeometryScaling is true.
723 * Must only be used from render thread.
724 * @param[in] geometryScale The geometry scale value
726 void SetGeometryScale(Vector3 geometryScale)
728 mGeometryScale = geometryScale;
730 SetDirtyFlag( TransformFlag );
734 * Retrieve the geometry scale, calculated when TransmitGeometryScaling is true.
735 * @return The geometry scale value.
737 const Vector3& GetGeometryScale() const
739 return mGeometryScale;
743 * Copies the previously used size, if this changed in the previous frame.
744 * @param[in] updateBufferIndex The current update buffer index.
746 void CopyPreviousSize( BufferIndex updateBufferIndex )
748 SetSize( updateBufferIndex, GetSize( 1u - updateBufferIndex ) );
752 * Retrieve the visibility of the node.
753 * @param[in] bufferIndex The buffer to read from.
754 * @return True if the node is visible.
756 bool IsVisible(BufferIndex bufferIndex) const
758 return mVisible[bufferIndex];
762 * Retrieves whether a node is fully visible.
763 * A node is fully visible if is visible and all its ancestors are visible.
764 * @param[in] updateBufferIndex The current update buffer index.
765 * @return True if the node is fully visible.
767 bool IsFullyVisible( BufferIndex updateBufferIndex ) const;
770 * Retrieve the opacity of the node.
771 * @param[in] bufferIndex The buffer to read from.
772 * @return The opacity.
774 float GetOpacity(BufferIndex bufferIndex) const
776 return mColor[bufferIndex].a;
780 * Retrieve the color of the node.
781 * @param[in] bufferIndex The buffer to read from.
784 const Vector4& GetColor(BufferIndex bufferIndex) const
786 return mColor[bufferIndex];
790 * Sets the color of the node derived from the color of all its parents.
791 * @param[in] color The world color.
792 * @param[in] updateBufferIndex The current update buffer index.
794 void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
796 mWorldColor.Set( updateBufferIndex, color );
800 * Sets the color of the node derived from the color of all its parents.
801 * This method should only be called when the parents world color is up-to-date.
802 * @pre The node has a parent.
803 * @param[in] updateBufferIndex The current update buffer index.
805 void InheritWorldColor( BufferIndex updateBufferIndex )
807 DALI_ASSERT_DEBUG(mParent != NULL);
810 if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA )
812 const Vector4& ownColor = mColor[updateBufferIndex];
813 mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a );
815 else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR )
817 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] );
819 else if( mColorMode == USE_PARENT_COLOR )
821 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) );
823 else // USE_OWN_COLOR
825 mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] );
830 * Copies the previous inherited scale, if this changed in the previous frame.
831 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
832 * does not need to be recalculated in the current frame.
833 * @param[in] updateBufferIndex The current update buffer index.
835 void CopyPreviousWorldColor( BufferIndex updateBufferIndex )
837 mWorldColor.CopyPrevious( updateBufferIndex );
841 * Retrieve the color of the node, possibly derived from the color
842 * of all its parents, depending on the value of mColorMode.
843 * @param[in] bufferIndex The buffer to read from.
844 * @return The world color.
846 const Vector4& GetWorldColor(BufferIndex bufferIndex) const
848 return mWorldColor[bufferIndex];
852 * Set the color mode. This specifies whether the Node uses its own color,
853 * or inherits its parent color.
854 * @param[in] colorMode The new color mode.
856 void SetColorMode(ColorMode colorMode)
858 mColorMode = colorMode;
860 SetDirtyFlag(ColorFlag);
864 * Retrieve the color mode.
865 * @return The color mode.
867 ColorMode GetColorMode() const
873 * Sets the size of the node.
874 * @param[in] bufferIndex The buffer to write to.
875 * @param[in] size The size to write.
877 void SetSize( BufferIndex bufferIndex, const Vector3& size )
879 mSize[bufferIndex] = size;
883 * Retrieve the size of the node.
884 * @param[in] bufferIndex The buffer to read from.
887 const Vector3& GetSize(BufferIndex bufferIndex) const
889 return mSize[bufferIndex];
893 * Set the world-matrix of a node, with scale + rotation + translation.
894 * Scale and rotation are centered at the origin.
895 * Translation is applied independently of the scale or rotatation axis.
896 * @param[in] updateBufferIndex The current update buffer index.
897 * @param[in] scale The scale.
898 * @param[in] rotation The rotation.
899 * @param[in] translation The translation.
901 void SetWorldMatrix( BufferIndex updateBufferIndex, const Vector3& scale, const Quaternion& rotation, const Vector3& translation )
903 mWorldMatrix.Get( updateBufferIndex ).SetTransformComponents( scale, rotation, translation );
904 mWorldMatrix.SetDirty( updateBufferIndex );
908 * Retrieve the cached world-matrix of a node.
909 * @param[in] bufferIndex The buffer to read from.
910 * @return The world-matrix.
912 const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
914 return mWorldMatrix[ bufferIndex ];
918 * Copy previous frames world matrix
919 * @param[in] updateBufferIndex The current update buffer index.
921 void CopyPreviousWorldMatrix( BufferIndex updateBufferIndex )
923 mWorldMatrix.CopyPrevious( updateBufferIndex );
927 * Mark the node as exclusive to a single RenderTask.
928 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
930 void SetExclusiveRenderTask( RenderTask* renderTask )
932 mExclusiveRenderTask = renderTask;
936 * Query whether the node is exclusive to a single RenderTask.
937 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
939 RenderTask* GetExclusiveRenderTask() const
941 return mExclusiveRenderTask;
945 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
946 * @param[in] drawMode The new draw-mode to use.
948 void SetDrawMode( const DrawMode::Type& drawMode )
950 mDrawMode = drawMode;
954 * Returns whether node is an overlay or not.
955 * @return True if node is an overlay, false otherwise.
957 DrawMode::Type GetDrawMode() const
963 * Equality operator, checks for identity, not values.
966 bool operator==( const Node* rhs ) const
976 * Set the inhibit local transform flag.@n
977 * Setting this flag will stop the node's local transform (position, scale and orientation)
978 * being applied on top of its parents transformation.
979 * @param[in] flag When true, local transformation is inhibited when calculating the world matrix.
981 void SetInhibitLocalTransform( bool flag )
983 SetDirtyFlag( TransformFlag );
984 mInhibitLocalTransform = flag;
988 * Get the inhibit local transform flag.@n
989 * See @ref SetInhibitLocalTransform
990 * @result A flag, when true, local transformation is inhibited when calculating the world matrix.
992 bool GetInhibitLocalTransform() const
994 return mInhibitLocalTransform;
1000 * Set the parent of a Node.
1001 * @param[in] parentNode the new parent.
1003 void SetParent(Node& parentNode);
1006 * Protected constructor; See also Node::New()
1010 private: // from RenderDataProvider
1013 * @copydoc RenderDataProvider::GetModelMatrix
1015 virtual const Matrix& GetModelMatrix( unsigned int bufferId )
1017 return GetWorldMatrix( bufferId );
1021 * @copydoc RenderDataProvider::GetRenderColor
1023 virtual const Vector4& GetRenderColor( unsigned int bufferId )
1025 return GetWorldColor( bufferId );
1034 Node& operator=(const Node& rhs);
1037 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
1039 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
1042 * Recursive helper to disconnect a Node and its children.
1043 * Disconnected Nodes have no parent or children.
1044 * @param[in] updateBufferIndex The current update buffer index.
1045 * @param[in] connectedNodes Disconnected Node attachments should be removed from here.
1046 * @param[in] disconnectedNodes Disconnected Node attachments should be added here.
1048 void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes );
1050 public: // Default properties
1052 PropertyVector3 mParentOrigin; ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
1053 PropertyVector3 mAnchorPoint; ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
1055 AnimatableProperty<Vector3> mSize; ///< Size is provided for layouting
1056 AnimatableProperty<Vector3> mPosition; ///< Local transform; distance between parent-origin & anchor-point
1057 AnimatableProperty<Quaternion> mOrientation; ///< Local transform; rotation relative to parent node
1058 AnimatableProperty<Vector3> mScale; ///< Local transform; scale relative to parent node
1059 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
1060 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
1062 // Inherited properties; read-only from public API
1064 InheritedVector3 mWorldPosition; ///< Full inherited position
1065 InheritedQuaternion mWorldOrientation; ///< Full inherited orientation
1066 InheritedVector3 mWorldScale; ///< Full inherited scale
1067 InheritedMatrix mWorldMatrix; ///< Full inherited world matrix
1068 InheritedColor mWorldColor; ///< Full inherited color
1072 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
1073 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
1075 NodeAttachmentOwner mAttachment; ///< Optional owned attachment
1076 NodeContainer mChildren; ///< Container of children; not owned
1078 Vector3 mGeometryScale; ///< Applied before calculating world transform.
1079 Vector3 mInitialVolume; ///< Initial volume... TODO - need a better name.
1081 // flags, compressed to bitfield
1082 int mDirtyFlags:10; ///< A composite set of flags for each of the Node properties
1084 bool mIsRoot:1; ///< True if the node cannot have a parent
1085 bool mInheritOrientation:1; ///< Whether the parent's orientation should be inherited.
1086 bool mInheritScale:1; ///< Whether the parent's scale should be inherited.
1087 bool mTransmitGeometryScaling:1; ///< Whether geometry scaling should be applied to world transform.
1088 bool mInhibitLocalTransform:1; ///< whether local transform should be applied.
1089 bool mIsActive:1; ///< When a Node is marked "active" it has been disconnected, and its properties have not been modified
1091 DrawMode::Type mDrawMode:2; ///< How the Node and its children should be drawn
1092 PositionInheritanceMode mPositionInheritanceMode:2;///< Determines how position is inherited, 2 bits is enough
1093 ColorMode mColorMode:2; ///< Determines whether mWorldColor is inherited, 2 bits is enough
1095 // Changes scope, should be at end of class
1096 DALI_LOG_OBJECT_STRING_DECLARATION;
1099 // Messages for Node
1101 inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1103 typedef MessageValue1< Node, bool > LocalType;
1105 // Reserve some memory inside the message queue
1106 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1108 // Construct message in the message queue memory; note that delete should not be called on the return value
1109 new (slot) LocalType( &node, &Node::SetInheritOrientation, inherit );
1112 inline void SetInitialVolumeMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& initialVolume )
1114 typedef MessageValue1< Node, Vector3 > LocalType;
1116 // Reserve some memory inside the message queue
1117 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1119 // Construct message in the message queue memory; note that delete should not be called on the return value
1120 new (slot) LocalType( &node, &Node::SetInitialVolume, initialVolume );
1123 inline void SetTransmitGeometryScalingMessage( EventThreadServices& eventThreadServices, const Node& node, bool transmitGeometryScaling )
1125 typedef MessageValue1< Node, bool > LocalType;
1127 // Reserve some memory inside the message queue
1128 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1130 // Construct message in the message queue memory; note that delete should not be called on the return value
1131 new (slot) LocalType( &node, &Node::SetTransmitGeometryScaling, transmitGeometryScaling );
1134 inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
1136 typedef MessageValue1< Node, Vector3 > LocalType;
1138 // Reserve some memory inside the message queue
1139 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1141 // Construct message in the message queue memory; note that delete should not be called on the return value
1142 new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
1145 inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
1147 typedef MessageValue1< Node, Vector3 > LocalType;
1149 // Reserve some memory inside the message queue
1150 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1152 // Construct message in the message queue memory; note that delete should not be called on the return value
1153 new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
1156 inline void SetPositionInheritanceModeMessage( EventThreadServices& eventThreadServices, const Node& node, PositionInheritanceMode mode )
1158 typedef MessageValue1< Node, PositionInheritanceMode > LocalType;
1160 // Reserve some memory inside the message queue
1161 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1163 // Construct message in the message queue memory; note that delete should not be called on the return value
1164 new (slot) LocalType( &node, &Node::SetPositionInheritanceMode, mode );
1167 inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1169 typedef MessageValue1< Node, bool > LocalType;
1171 // Reserve some memory inside the message queue
1172 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1174 // Construct message in the message queue memory; note that delete should not be called on the return value
1175 new (slot) LocalType( &node, &Node::SetInheritScale, inherit );
1178 inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
1180 typedef MessageValue1< Node, ColorMode > LocalType;
1182 // Reserve some memory inside the message queue
1183 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1185 // Construct message in the message queue memory; note that delete should not be called on the return value
1186 new (slot) LocalType( &node, &Node::SetColorMode, colorMode );
1189 inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
1191 typedef MessageValue1< Node, DrawMode::Type > LocalType;
1193 // Reserve some memory inside the message queue
1194 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1196 // Construct message in the message queue memory; note that delete should not be called on the return value
1197 new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
1200 } // namespace SceneGraph
1202 } // namespace Internal
1206 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_H_