1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_NODE_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_NODE_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/actors/actor-enumerations.h>
23 #include <dali/public-api/actors/draw-mode.h>
24 #include <dali/devel-api/common/set-wrapper.h>
25 #include <dali/public-api/math/quaternion.h>
26 #include <dali/public-api/math/math-utils.h>
27 #include <dali/public-api/math/vector3.h>
28 #include <dali/internal/common/message.h>
29 #include <dali/internal/event/common/event-thread-services.h>
30 #include <dali/internal/update/common/animatable-property.h>
31 #include <dali/internal/update/common/property-owner.h>
32 #include <dali/internal/update/common/property-vector3.h>
33 #include <dali/internal/update/common/scene-graph-buffers.h>
34 #include <dali/internal/update/common/inherited-property.h>
35 #include <dali/integration-api/debug.h>
36 #include <dali/internal/update/nodes/node-declarations.h>
37 #include <dali/internal/update/node-attachments/node-attachment-declarations.h>
38 #include <dali/internal/render/data-providers/node-data-provider.h>
39 #include <dali/internal/update/rendering/scene-graph-renderer.h>
47 // value types used by messages
48 template <> struct ParameterType< ColorMode > : public BasicType< ColorMode > {};
49 template <> struct ParameterType< PositionInheritanceMode > : public BasicType< PositionInheritanceMode > {};
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 * Overriden delete operator
116 * Deletes the node from its global memory pool
118 void operator delete( void* ptr );
121 * Called during UpdateManager::DestroyNode shortly before Node is destroyed.
128 * Query whether the node is a layer.
129 * @return True if the node is a layer.
133 return (GetLayer() != NULL);
137 * Convert a node to a layer.
138 * @return A pointer to the layer, or NULL.
140 virtual Layer* GetLayer()
148 * Attach an object to this Node; This should only be done by UpdateManager::AttachToNode.
149 * @pre The Node does not already have an attachment.
150 * @param[in] attachment The object to attach.
152 void Attach( NodeAttachment& attachment );
155 * Query the node if it has an attachment.
156 * @return True if it has an attachment.
158 bool HasAttachment() const
164 * Add a renderer to the node
165 * @param[in] renderer The renderer added to the node
167 void AddRenderer( Renderer* renderer )
169 //Check that it has not been already added
170 unsigned int rendererCount( mRenderer.Size() );
171 for( unsigned int i(0); i<rendererCount; ++i )
173 if( mRenderer[i] == renderer )
175 //Renderer already in the list
180 //If it is the first renderer added, make sure the world transform will be calculated
181 //in the next update as world transform is not computed if node has no renderers
182 if( rendererCount == 0 )
184 mDirtyFlags |= TransformFlag;
187 mRenderer.PushBack( renderer );
191 * Remove a renderer from the node
192 * @param[in] renderer The renderer to be removed
194 void RemoveRenderer( Renderer* renderer );
197 * Get the renderer at the given index
200 Renderer* GetRendererAt( unsigned int index )
202 return mRenderer[index];
206 * Retrieve the number of renderers for the node
208 unsigned int GetRendererCount()
210 return mRenderer.Size();
214 * Retreive the object attached to this node.
215 * @return The attachment.
217 NodeAttachment& GetAttachment() const
222 // Containment methods
225 * Query whether a node is the root node. Root nodes cannot have a parent node.
226 * A node becomes a root node, when it is installed by UpdateManager.
227 * @return True if the node is a root node.
235 * Set whether a node is the root node. Root nodes cannot have a parent node.
236 * This method should only be called by UpdateManager.
237 * @pre When isRoot is true, the node must not have a parent.
238 * @param[in] isRoot Whether the node is now a root node.
240 void SetRoot(bool isRoot);
243 * Retrieve the parent of a Node.
244 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
252 * Retrieve the parent of a Node.
253 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
255 const Node* GetParent() const
261 * Connect a node to the scene-graph.
262 * @pre A node cannot be added to itself.
263 * @pre The parent node is connected to the scene-graph.
264 * @pre The childNode does not already have a parent.
265 * @pre The childNode is not a root node.
266 * @param[in] childNode The child to add.
268 void ConnectChild( Node* childNode );
271 * Disconnect a child (& its children) from the scene-graph.
272 * @pre childNode is a child of this Node.
273 * @param[in] updateBufferIndex The current update buffer index.
274 * @param[in] childNode The node to disconnect.
276 void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode );
279 * Retrieve the children a Node.
280 * @return The container of children.
282 const NodeContainer& GetChildren() const
288 * Retrieve the children a Node.
289 * @return The container of children.
291 NodeContainer& GetChildren()
299 * Flag that one of the node values has changed in the current frame.
300 * @param[in] flag The flag to set.
302 void SetDirtyFlag(NodePropertyFlags flag)
308 * Flag that all of the node values are dirty.
310 void SetAllDirtyFlags()
312 mDirtyFlags = AllFlags;
316 * Query whether a node is dirty.
317 * @return The dirty flags
319 int GetDirtyFlags() const;
322 * Query whether a node is clean.
323 * @return True if the node is clean.
327 return ( NothingFlag == GetDirtyFlags() );
331 * Retrieve the parent-origin of the node.
332 * @return The parent-origin.
334 const Vector3& GetParentOrigin() const
336 return mParentOrigin.mValue;
340 * Sets both the local & base parent-origins of the node.
341 * @param[in] origin The new local & base parent-origins.
343 void SetParentOrigin(const Vector3& origin)
345 mParentOrigin.mValue = origin;
346 mParentOrigin.OnSet();
350 * Retrieve the anchor-point of the node.
351 * @return The anchor-point.
353 const Vector3& GetAnchorPoint() const
355 return mAnchorPoint.mValue;
359 * Sets both the local & base anchor-points of the node.
360 * @param[in] anchor The new local & base anchor-points.
362 void SetAnchorPoint(const Vector3& anchor)
364 mAnchorPoint.mValue = anchor;
365 mAnchorPoint.OnSet();
369 * Retrieve the local position of the node, relative to its parent.
370 * @param[in] bufferIndex The buffer to read from.
371 * @return The local position.
373 const Vector3& GetPosition(BufferIndex bufferIndex) const
375 return mPosition[bufferIndex];
379 * Sets both the local & base positions of the node.
380 * @param[in] updateBufferIndex The current update buffer index.
381 * @param[in] position The new local & base position.
383 void BakePosition(BufferIndex updateBufferIndex, const Vector3& position)
385 mPosition.Bake( updateBufferIndex, position );
389 * Sets the world of the node derived from the position of all its parents.
390 * @param[in] updateBufferIndex The current update buffer index.
391 * @param[in] position The world position.
393 void SetWorldPosition( BufferIndex updateBufferIndex, const Vector3& position )
395 mWorldPosition.Set( updateBufferIndex, position );
399 * Sets the position of the node derived from the position of all its parents.
400 * This method should only be called when the parent's world position is up-to-date.
401 * With a non-central anchor-point, the local orientation and scale affects the world position.
402 * Therefore the world orientation & scale must be updated before the world position.
403 * @pre The node has a parent.
404 * @param[in] updateBufferIndex The current update buffer index.
406 void InheritWorldPosition(BufferIndex updateBufferIndex)
408 DALI_ASSERT_DEBUG(mParent != NULL);
410 switch( mPositionInheritanceMode )
412 case INHERIT_PARENT_POSITION : ///@see Dali::PositionInheritanceMode for how these modes are expected to work
414 Vector3 finalPosition(-0.5f, -0.5f, -0.5f);
416 finalPosition += mParentOrigin.mValue;
417 finalPosition *= mParent->GetSize(updateBufferIndex);
418 finalPosition += mPosition[updateBufferIndex];
419 finalPosition *= mParent->GetWorldScale(updateBufferIndex);
420 const Quaternion& parentWorldOrientation = mParent->GetWorldOrientation(updateBufferIndex);
421 if(!parentWorldOrientation.IsIdentity())
423 finalPosition *= parentWorldOrientation;
426 // check if a node needs to be offsetted locally (only applies when AnchorPoint is not central)
427 // dont use operator== as that does a slower comparison (and involves function calls)
428 Vector3 localOffset(0.5f, 0.5f, 0.5f); // AnchorPoint::CENTER
429 localOffset -= mAnchorPoint.mValue;
431 if( ( fabsf( localOffset.x ) >= Math::MACHINE_EPSILON_0 ) ||
432 ( fabsf( localOffset.y ) >= Math::MACHINE_EPSILON_0 ) ||
433 ( fabsf( localOffset.z ) >= Math::MACHINE_EPSILON_0 ) )
435 localOffset *= mSize[updateBufferIndex];
437 Vector3 scale = mWorldScale[updateBufferIndex];
439 // Pick up sign of local scale
440 if (mScale[updateBufferIndex].x < 0.0f)
444 if (mScale[updateBufferIndex].y < 0.0f)
448 if (mScale[updateBufferIndex].z < 0.0f)
453 // If the anchor-point is not central, then position is affected by the local orientation & scale
454 localOffset *= scale;
455 const Quaternion& localWorldOrientation = mWorldOrientation[updateBufferIndex];
456 if(!localWorldOrientation.IsIdentity())
458 localOffset *= localWorldOrientation;
460 finalPosition += localOffset;
463 finalPosition += mParent->GetWorldPosition(updateBufferIndex);
464 mWorldPosition.Set( updateBufferIndex, finalPosition );
467 case USE_PARENT_POSITION_PLUS_LOCAL_POSITION :
469 // copy parents position plus local transform
470 mWorldPosition.Set( updateBufferIndex, mParent->GetWorldPosition(updateBufferIndex) + mPosition[updateBufferIndex] );
473 case USE_PARENT_POSITION :
475 // copy parents position
476 mWorldPosition.Set( updateBufferIndex, mParent->GetWorldPosition(updateBufferIndex) );
479 case DONT_INHERIT_POSITION :
481 // use local position as world position
482 mWorldPosition.Set( updateBufferIndex, mPosition[updateBufferIndex] );
489 * Copies the previous inherited position, if this changed in the previous frame.
490 * This method should be called instead of InheritWorldPosition i.e. if the inherited position
491 * does not need to be recalculated in the current frame.
492 * @param[in] updateBufferIndex The current update buffer index.
494 void CopyPreviousWorldPosition( BufferIndex updateBufferIndex )
496 mWorldPosition.CopyPrevious( updateBufferIndex );
500 * Retrieve the position of the node derived from the position of all its parents.
501 * @return The world position.
503 const Vector3& GetWorldPosition( BufferIndex bufferIndex ) const
505 return mWorldPosition[bufferIndex];
509 * Set whether the Node inherits position.
510 * @param[in] inherit True if the parent position is inherited.
512 void SetInheritPosition(bool inherit)
514 if (inherit != mInheritPosition)
516 mInheritPosition = inherit;
517 mPositionInheritanceMode = inherit ? INHERIT_PARENT_POSITION : DONT_INHERIT_POSITION;
518 SetDirtyFlag(TransformFlag);
523 * Set the position inheritance mode.
524 * @see Dali::Actor::PositionInheritanceMode
525 * @param[in] mode The new position inheritance mode.
527 void SetPositionInheritanceMode( PositionInheritanceMode mode )
529 mPositionInheritanceMode = mode;
531 SetDirtyFlag(TransformFlag);
535 * @return The position inheritance mode.
537 PositionInheritanceMode GetPositionInheritanceMode() const
539 return mPositionInheritanceMode;
543 * Retrieve the local orientation of the node, relative to its parent.
544 * @param[in] bufferIndex The buffer to read from.
545 * @return The local orientation.
547 const Quaternion& GetOrientation(BufferIndex bufferIndex) const
549 return mOrientation[bufferIndex];
553 * Sets both the local & base orientations of the node.
554 * @param[in] updateBufferIndex The current update buffer index.
555 * @param[in] orientation The new local & base orientation.
557 void BakeOrientation(BufferIndex updateBufferIndex, const Quaternion& orientation)
559 mOrientation.Bake( updateBufferIndex, orientation );
563 * Sets the orientation of the node derived from the rotation of all its parents.
564 * @param[in] updateBufferIndex The current update buffer index.
565 * @param[in] orientation The world orientation.
567 void SetWorldOrientation( BufferIndex updateBufferIndex, const Quaternion& orientation )
569 mWorldOrientation.Set( updateBufferIndex, orientation );
573 * Sets the orientation of the node derived from the rotation of all its parents.
574 * This method should only be called when the parents world orientation is up-to-date.
575 * @pre The node has a parent.
576 * @param[in] updateBufferIndex The current update buffer index.
578 void InheritWorldOrientation( BufferIndex updateBufferIndex )
580 DALI_ASSERT_DEBUG(mParent != NULL);
582 const Quaternion& localOrientation = mOrientation[updateBufferIndex];
584 if(localOrientation.IsIdentity())
586 mWorldOrientation.Set( updateBufferIndex, mParent->GetWorldOrientation(updateBufferIndex) );
590 Quaternion finalOrientation( mParent->GetWorldOrientation(updateBufferIndex) );
591 finalOrientation *= localOrientation;
592 mWorldOrientation.Set( updateBufferIndex, finalOrientation );
597 * Copies the previous inherited orientation, if this changed in the previous frame.
598 * This method should be called instead of InheritWorldOrientation i.e. if the inherited orientation
599 * does not need to be recalculated in the current frame.
600 * @param[in] updateBufferIndex The current update buffer index.
602 void CopyPreviousWorldOrientation( BufferIndex updateBufferIndex )
604 mWorldOrientation.CopyPrevious( updateBufferIndex );
608 * Retrieve the orientation of the node derived from the rotation of all its parents.
609 * @param[in] bufferIndex The buffer to read from.
610 * @return The world rotation.
612 const Quaternion& GetWorldOrientation( BufferIndex bufferIndex ) const
614 return mWorldOrientation[bufferIndex];
618 * Set whether the Node inherits orientation.
619 * @param[in] inherit True if the parent orientation is inherited.
621 void SetInheritOrientation(bool inherit)
623 if (inherit != mInheritOrientation)
625 mInheritOrientation = inherit;
627 SetDirtyFlag(TransformFlag);
632 * Query whether the node inherits orientation from its parent.
633 * @return True if the parent orientation is inherited.
635 bool IsOrientationInherited() const
637 return mInheritOrientation;
641 * Retrieve the local scale of the node, relative to its parent.
642 * @param[in] bufferIndex The buffer to read from.
643 * @return The local scale.
645 const Vector3& GetScale(BufferIndex bufferIndex) const
647 return mScale[bufferIndex];
651 * Sets the scale of the node derived from the scale of all its parents and a pre-scale
652 * @param[in] updateBufferIndex The current update buffer index.
653 * @param[in] scale The world scale.
655 void SetWorldScale(BufferIndex updateBufferIndex, const Vector3& scale)
657 mWorldScale.Set( updateBufferIndex, scale );
661 * Sets the scale of the node derived from the scale of all its parents and a pre-scale.
662 * This method should only be called when the parents world scale is up-to-date.
663 * @pre The node has a parent.
664 * @param[in] updateBufferIndex The current update buffer index.
666 void InheritWorldScale(BufferIndex updateBufferIndex)
668 DALI_ASSERT_DEBUG(mParent != NULL);
670 mWorldScale.Set( updateBufferIndex, mParent->GetWorldScale(updateBufferIndex) * mScale[updateBufferIndex] );
674 * Copies the previous inherited scale, if this changed in the previous frame.
675 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
676 * does not need to be recalculated in the current frame.
677 * @param[in] updateBufferIndex The current update buffer index.
679 void CopyPreviousWorldScale( BufferIndex updateBufferIndex )
681 mWorldScale.CopyPrevious( updateBufferIndex );
685 * Retrieve the scale of the node derived from the scale of all its parents.
686 * @param[in] bufferIndex The buffer to read from.
687 * @return The world scale.
689 const Vector3& GetWorldScale( BufferIndex bufferIndex ) const
691 return mWorldScale[bufferIndex];
695 * Set whether the Node inherits scale.
696 * @param inherit True if the Node inherits scale.
698 void SetInheritScale( bool inherit )
700 if( inherit != mInheritScale )
702 mInheritScale = inherit;
704 SetDirtyFlag( TransformFlag );
709 * Query whether the Node inherits scale.
710 * @return if scale is inherited
712 bool IsScaleInherited() const
714 return mInheritScale;
718 * Retrieve the visibility of the node.
719 * @param[in] bufferIndex The buffer to read from.
720 * @return True if the node is visible.
722 bool IsVisible(BufferIndex bufferIndex) const
724 return mVisible[bufferIndex];
728 * Retrieve the opacity of the node.
729 * @param[in] bufferIndex The buffer to read from.
730 * @return The opacity.
732 float GetOpacity(BufferIndex bufferIndex) const
734 return mColor[bufferIndex].a;
738 * Retrieve the color of the node.
739 * @param[in] bufferIndex The buffer to read from.
742 const Vector4& GetColor(BufferIndex bufferIndex) const
744 return mColor[bufferIndex];
748 * Sets the color of the node derived from the color of all its parents.
749 * @param[in] color The world color.
750 * @param[in] updateBufferIndex The current update buffer index.
752 void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
754 mWorldColor.Set( updateBufferIndex, color );
758 * Sets the color of the node derived from the color of all its parents.
759 * This method should only be called when the parents world color is up-to-date.
760 * @pre The node has a parent.
761 * @param[in] updateBufferIndex The current update buffer index.
763 void InheritWorldColor( BufferIndex updateBufferIndex )
765 DALI_ASSERT_DEBUG(mParent != NULL);
768 if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA )
770 const Vector4& ownColor = mColor[updateBufferIndex];
771 mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a );
773 else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR )
775 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] );
777 else if( mColorMode == USE_PARENT_COLOR )
779 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) );
781 else // USE_OWN_COLOR
783 mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] );
788 * Copies the previous inherited scale, if this changed in the previous frame.
789 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
790 * does not need to be recalculated in the current frame.
791 * @param[in] updateBufferIndex The current update buffer index.
793 void CopyPreviousWorldColor( BufferIndex updateBufferIndex )
795 mWorldColor.CopyPrevious( updateBufferIndex );
799 * Retrieve the color of the node, possibly derived from the color
800 * of all its parents, depending on the value of mColorMode.
801 * @param[in] bufferIndex The buffer to read from.
802 * @return The world color.
804 const Vector4& GetWorldColor(BufferIndex bufferIndex) const
806 return mWorldColor[bufferIndex];
810 * Set the color mode. This specifies whether the Node uses its own color,
811 * or inherits its parent color.
812 * @param[in] colorMode The new color mode.
814 void SetColorMode(ColorMode colorMode)
816 mColorMode = colorMode;
818 SetDirtyFlag(ColorFlag);
822 * Retrieve the color mode.
823 * @return The color mode.
825 ColorMode GetColorMode() const
831 * Retrieve the size of the node.
832 * @param[in] bufferIndex The buffer to read from.
835 const Vector3& GetSize(BufferIndex bufferIndex) const
837 return mSize[bufferIndex];
841 * Set the world-matrix of a node, with scale + rotation + translation.
842 * Scale and rotation are centered at the origin.
843 * Translation is applied independently of the scale or rotatation axis.
844 * @param[in] updateBufferIndex The current update buffer index.
845 * @param[in] scale The scale.
846 * @param[in] rotation The rotation.
847 * @param[in] translation The translation.
849 void SetWorldMatrix( BufferIndex updateBufferIndex, const Vector3& scale, const Quaternion& rotation, const Vector3& translation )
851 mWorldMatrix.Get( updateBufferIndex ).SetTransformComponents( scale, rotation, translation );
852 mWorldMatrix.SetDirty( updateBufferIndex );
856 * Retrieve the cached world-matrix of a node.
857 * @param[in] bufferIndex The buffer to read from.
858 * @return The world-matrix.
860 const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
862 return mWorldMatrix[ bufferIndex ];
866 * Copy previous frames world matrix
867 * @param[in] updateBufferIndex The current update buffer index.
869 void CopyPreviousWorldMatrix( BufferIndex updateBufferIndex )
871 mWorldMatrix.CopyPrevious( updateBufferIndex );
875 * Mark the node as exclusive to a single RenderTask.
876 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
878 void SetExclusiveRenderTask( RenderTask* renderTask )
880 mExclusiveRenderTask = renderTask;
884 * Query whether the node is exclusive to a single RenderTask.
885 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
887 RenderTask* GetExclusiveRenderTask() const
889 return mExclusiveRenderTask;
893 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
894 * @param[in] drawMode The new draw-mode to use.
896 void SetDrawMode( const DrawMode::Type& drawMode )
898 mDrawMode = drawMode;
902 * Returns whether node is an overlay or not.
903 * @return True if node is an overlay, false otherwise.
905 DrawMode::Type GetDrawMode() const
911 * Equality operator, checks for identity, not values.
914 bool operator==( const Node* rhs ) const
923 unsigned short GetDepth() const
930 * @copydoc UniformMap::Add
932 void AddUniformMapping( UniformPropertyMapping* map );
935 * @copydoc UniformMap::Remove
937 void RemoveUniformMapping( const std::string& uniformName );
940 * Prepare the node for rendering.
941 * This is called by the UpdateManager when an object is due to be rendered in the current frame.
942 * @param[in] updateBufferIndex The current update buffer index.
944 void PrepareRender( BufferIndex bufferIndex );
949 * Set the parent of a Node.
950 * @param[in] parentNode the new parent.
952 void SetParent(Node& parentNode);
955 * Protected constructor; See also Node::New()
959 private: // from NodeDataProvider
962 * @copydoc NodeDataProvider::GetModelMatrix
964 virtual const Matrix& GetModelMatrix( unsigned int bufferId ) const
966 return GetWorldMatrix( bufferId );
970 * @copydoc NodeDataProvider::GetRenderColor
972 virtual const Vector4& GetRenderColor( unsigned int bufferId ) const
974 return GetWorldColor( bufferId );
977 virtual const Vector3& GetRenderSize( unsigned int bufferId ) const
979 return GetSize( bufferId );
982 public: // From UniformMapDataProvider
984 * @copydoc UniformMapDataProvider::GetUniformMapChanged
986 virtual bool GetUniformMapChanged( BufferIndex bufferIndex ) const
988 return mUniformMapChanged[bufferIndex];
992 * @copydoc UniformMapDataProvider::GetUniformMap
994 virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const
996 return mCollectedUniformMap[bufferIndex];
1005 Node& operator=(const Node& rhs);
1008 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
1010 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
1013 * Recursive helper to disconnect a Node and its children.
1014 * Disconnected Nodes have no parent or children.
1015 * @param[in] updateBufferIndex The current update buffer index.
1017 void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex );
1019 public: // Default properties
1021 PropertyVector3 mParentOrigin; ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
1022 PropertyVector3 mAnchorPoint; ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
1024 AnimatableProperty<Vector3> mSize; ///< Size is provided for layouting
1025 AnimatableProperty<Vector3> mPosition; ///< Local transform; distance between parent-origin & anchor-point
1026 AnimatableProperty<Quaternion> mOrientation; ///< Local transform; rotation relative to parent node
1027 AnimatableProperty<Vector3> mScale; ///< Local transform; scale relative to parent node
1028 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
1029 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
1031 // Inherited properties; read-only from public API
1033 InheritedVector3 mWorldPosition; ///< Full inherited position
1034 InheritedQuaternion mWorldOrientation; ///< Full inherited orientation
1035 InheritedVector3 mWorldScale; ///< Full inherited scale
1036 InheritedMatrix mWorldMatrix; ///< Full inherited world matrix
1037 InheritedColor mWorldColor; ///< Full inherited color
1041 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
1042 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
1044 NodeAttachmentOwner mAttachment; ///< Optional owned attachment
1045 RendererContainer mRenderer; ///< Container of renderers; not owned
1047 NodeContainer mChildren; ///< Container of children; not owned
1049 CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps of the node
1050 unsigned int mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame
1051 unsigned int mRegenerateUniformMap : 2; ///< Indicate if the uniform map has to be regenerated this frame
1053 // flags, compressed to bitfield
1054 unsigned short mDepth: 12; ///< Depth in the hierarchy
1055 int mDirtyFlags:8; ///< A composite set of flags for each of the Node properties
1057 bool mIsRoot:1; ///< True if the node cannot have a parent
1058 bool mInheritPosition:1; ///< Whether the parent's position should be inherited.
1059 bool mInheritOrientation:1; ///< Whether the parent's orientation should be inherited.
1060 bool mInheritScale:1; ///< Whether the parent's scale should be inherited.
1062 DrawMode::Type mDrawMode:2; ///< How the Node and its children should be drawn
1063 PositionInheritanceMode mPositionInheritanceMode:2;///< Determines how position is inherited, 2 bits is enough.
1064 ColorMode mColorMode:2; ///< Determines whether mWorldColor is inherited, 2 bits is enough
1066 // Changes scope, should be at end of class
1067 DALI_LOG_OBJECT_STRING_DECLARATION;
1070 // Messages for Node
1072 inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1074 typedef MessageValue1< Node, bool > LocalType;
1076 // Reserve some memory inside the message queue
1077 unsigned int* slot = eventThreadServices.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::SetInheritOrientation, inherit );
1083 inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
1085 typedef MessageValue1< Node, Vector3 > LocalType;
1087 // Reserve some memory inside the message queue
1088 unsigned int* slot = eventThreadServices.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::SetParentOrigin, origin );
1094 inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
1096 typedef MessageValue1< Node, Vector3 > LocalType;
1098 // Reserve some memory inside the message queue
1099 unsigned int* slot = eventThreadServices.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::SetAnchorPoint, anchor );
1105 inline void SetPositionInheritanceModeMessage( EventThreadServices& eventThreadServices, const Node& node, PositionInheritanceMode mode )
1107 typedef MessageValue1< Node, PositionInheritanceMode > LocalType;
1109 // Reserve some memory inside the message queue
1110 unsigned int* slot = eventThreadServices.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::SetPositionInheritanceMode, mode );
1116 inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1118 typedef MessageValue1< Node, bool > LocalType;
1120 // Reserve some memory inside the message queue
1121 unsigned int* slot = eventThreadServices.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::SetInheritPosition, inherit );
1127 inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1129 typedef MessageValue1< Node, bool > LocalType;
1131 // Reserve some memory inside the message queue
1132 unsigned int* slot = eventThreadServices.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::SetInheritScale, inherit );
1138 inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
1140 typedef MessageValue1< Node, ColorMode > LocalType;
1142 // Reserve some memory inside the message queue
1143 unsigned int* slot = eventThreadServices.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::SetColorMode, colorMode );
1149 inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
1151 typedef MessageValue1< Node, DrawMode::Type > LocalType;
1153 // Reserve some memory inside the message queue
1154 unsigned int* slot = eventThreadServices.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::SetDrawMode, drawMode );
1160 inline void AddRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
1162 typedef MessageValue1< Node, Renderer* > LocalType;
1164 // Reserve some memory inside the message queue
1165 unsigned int* slot = eventThreadServices.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::AddRenderer, renderer );
1171 inline void RemoveRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
1173 typedef MessageValue1< Node, Renderer* > LocalType;
1175 // Reserve some memory inside the message queue
1176 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1178 // Construct message in the message queue memory; note that delete should not be called on the return value
1179 new (slot) LocalType( &node, &Node::RemoveRenderer, renderer );
1181 } // namespace SceneGraph
1183 } // namespace Internal
1187 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_H_