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 the position inheritance mode.
510 * @see Dali::Actor::PositionInheritanceMode
511 * @param[in] mode The new position inheritance mode.
513 void SetPositionInheritanceMode( PositionInheritanceMode mode )
515 mPositionInheritanceMode = mode;
517 SetDirtyFlag(TransformFlag);
521 * @return The position inheritance mode.
523 PositionInheritanceMode GetPositionInheritanceMode() const
525 return mPositionInheritanceMode;
529 * Retrieve the local orientation of the node, relative to its parent.
530 * @param[in] bufferIndex The buffer to read from.
531 * @return The local orientation.
533 const Quaternion& GetOrientation(BufferIndex bufferIndex) const
535 return mOrientation[bufferIndex];
539 * Sets both the local & base orientations of the node.
540 * @param[in] updateBufferIndex The current update buffer index.
541 * @param[in] orientation The new local & base orientation.
543 void BakeOrientation(BufferIndex updateBufferIndex, const Quaternion& orientation)
545 mOrientation.Bake( updateBufferIndex, orientation );
549 * Sets the orientation of the node derived from the rotation of all its parents.
550 * @param[in] updateBufferIndex The current update buffer index.
551 * @param[in] orientation The world orientation.
553 void SetWorldOrientation( BufferIndex updateBufferIndex, const Quaternion& orientation )
555 mWorldOrientation.Set( updateBufferIndex, orientation );
559 * Sets the orientation of the node derived from the rotation of all its parents.
560 * This method should only be called when the parents world orientation is up-to-date.
561 * @pre The node has a parent.
562 * @param[in] updateBufferIndex The current update buffer index.
564 void InheritWorldOrientation( BufferIndex updateBufferIndex )
566 DALI_ASSERT_DEBUG(mParent != NULL);
568 const Quaternion& localOrientation = mOrientation[updateBufferIndex];
570 if(localOrientation.IsIdentity())
572 mWorldOrientation.Set( updateBufferIndex, mParent->GetWorldOrientation(updateBufferIndex) );
576 Quaternion finalOrientation( mParent->GetWorldOrientation(updateBufferIndex) );
577 finalOrientation *= localOrientation;
578 mWorldOrientation.Set( updateBufferIndex, finalOrientation );
583 * Copies the previous inherited orientation, if this changed in the previous frame.
584 * This method should be called instead of InheritWorldOrientation i.e. if the inherited orientation
585 * does not need to be recalculated in the current frame.
586 * @param[in] updateBufferIndex The current update buffer index.
588 void CopyPreviousWorldOrientation( BufferIndex updateBufferIndex )
590 mWorldOrientation.CopyPrevious( updateBufferIndex );
594 * Retrieve the orientation of the node derived from the rotation of all its parents.
595 * @param[in] bufferIndex The buffer to read from.
596 * @return The world rotation.
598 const Quaternion& GetWorldOrientation( BufferIndex bufferIndex ) const
600 return mWorldOrientation[bufferIndex];
604 * Set whether the Node inherits orientation.
605 * @param[in] inherit True if the parent orientation is inherited.
607 void SetInheritOrientation(bool inherit)
609 if (inherit != mInheritOrientation)
611 mInheritOrientation = inherit;
613 SetDirtyFlag(TransformFlag);
618 * Query whether the node inherits orientation from its parent.
619 * @return True if the parent orientation is inherited.
621 bool IsOrientationInherited() const
623 return mInheritOrientation;
627 * Retrieve the local scale of the node, relative to its parent.
628 * @param[in] bufferIndex The buffer to read from.
629 * @return The local scale.
631 const Vector3& GetScale(BufferIndex bufferIndex) const
633 return mScale[bufferIndex];
637 * Sets the scale of the node derived from the scale of all its parents and a pre-scale
638 * @param[in] updateBufferIndex The current update buffer index.
639 * @param[in] scale The world scale.
641 void SetWorldScale(BufferIndex updateBufferIndex, const Vector3& scale)
643 mWorldScale.Set( updateBufferIndex, scale );
647 * Sets the scale of the node derived from the scale of all its parents and a pre-scale.
648 * This method should only be called when the parents world scale is up-to-date.
649 * @pre The node has a parent.
650 * @param[in] updateBufferIndex The current update buffer index.
652 void InheritWorldScale(BufferIndex updateBufferIndex)
654 DALI_ASSERT_DEBUG(mParent != NULL);
656 mWorldScale.Set( updateBufferIndex, mParent->GetWorldScale(updateBufferIndex) * mScale[updateBufferIndex] );
660 * Copies the previous inherited scale, if this changed in the previous frame.
661 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
662 * does not need to be recalculated in the current frame.
663 * @param[in] updateBufferIndex The current update buffer index.
665 void CopyPreviousWorldScale( BufferIndex updateBufferIndex )
667 mWorldScale.CopyPrevious( updateBufferIndex );
671 * Retrieve the scale of the node derived from the scale of all its parents.
672 * @param[in] bufferIndex The buffer to read from.
673 * @return The world scale.
675 const Vector3& GetWorldScale( BufferIndex bufferIndex ) const
677 return mWorldScale[bufferIndex];
681 * Set whether the Node inherits scale.
682 * @param inherit True if the Node inherits scale.
684 void SetInheritScale( bool inherit )
686 if( inherit != mInheritScale )
688 mInheritScale = inherit;
690 SetDirtyFlag( TransformFlag );
695 * Query whether the Node inherits scale.
696 * @return if scale is inherited
698 bool IsScaleInherited() const
700 return mInheritScale;
704 * Retrieve the visibility of the node.
705 * @param[in] bufferIndex The buffer to read from.
706 * @return True if the node is visible.
708 bool IsVisible(BufferIndex bufferIndex) const
710 return mVisible[bufferIndex];
714 * Retrieve the opacity of the node.
715 * @param[in] bufferIndex The buffer to read from.
716 * @return The opacity.
718 float GetOpacity(BufferIndex bufferIndex) const
720 return mColor[bufferIndex].a;
724 * Retrieve the color of the node.
725 * @param[in] bufferIndex The buffer to read from.
728 const Vector4& GetColor(BufferIndex bufferIndex) const
730 return mColor[bufferIndex];
734 * Sets the color of the node derived from the color of all its parents.
735 * @param[in] color The world color.
736 * @param[in] updateBufferIndex The current update buffer index.
738 void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
740 mWorldColor.Set( updateBufferIndex, color );
744 * Sets the color of the node derived from the color of all its parents.
745 * This method should only be called when the parents world color is up-to-date.
746 * @pre The node has a parent.
747 * @param[in] updateBufferIndex The current update buffer index.
749 void InheritWorldColor( BufferIndex updateBufferIndex )
751 DALI_ASSERT_DEBUG(mParent != NULL);
754 if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA )
756 const Vector4& ownColor = mColor[updateBufferIndex];
757 mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a );
759 else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR )
761 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] );
763 else if( mColorMode == USE_PARENT_COLOR )
765 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) );
767 else // USE_OWN_COLOR
769 mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] );
774 * Copies the previous inherited scale, if this changed in the previous frame.
775 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
776 * does not need to be recalculated in the current frame.
777 * @param[in] updateBufferIndex The current update buffer index.
779 void CopyPreviousWorldColor( BufferIndex updateBufferIndex )
781 mWorldColor.CopyPrevious( updateBufferIndex );
785 * Retrieve the color of the node, possibly derived from the color
786 * of all its parents, depending on the value of mColorMode.
787 * @param[in] bufferIndex The buffer to read from.
788 * @return The world color.
790 const Vector4& GetWorldColor(BufferIndex bufferIndex) const
792 return mWorldColor[bufferIndex];
796 * Set the color mode. This specifies whether the Node uses its own color,
797 * or inherits its parent color.
798 * @param[in] colorMode The new color mode.
800 void SetColorMode(ColorMode colorMode)
802 mColorMode = colorMode;
804 SetDirtyFlag(ColorFlag);
808 * Retrieve the color mode.
809 * @return The color mode.
811 ColorMode GetColorMode() const
817 * Retrieve the size of the node.
818 * @param[in] bufferIndex The buffer to read from.
821 const Vector3& GetSize(BufferIndex bufferIndex) const
823 return mSize[bufferIndex];
827 * Set the world-matrix of a node, with scale + rotation + translation.
828 * Scale and rotation are centered at the origin.
829 * Translation is applied independently of the scale or rotatation axis.
830 * @param[in] updateBufferIndex The current update buffer index.
831 * @param[in] scale The scale.
832 * @param[in] rotation The rotation.
833 * @param[in] translation The translation.
835 void SetWorldMatrix( BufferIndex updateBufferIndex, const Vector3& scale, const Quaternion& rotation, const Vector3& translation )
837 mWorldMatrix.Get( updateBufferIndex ).SetTransformComponents( scale, rotation, translation );
838 mWorldMatrix.SetDirty( updateBufferIndex );
842 * Retrieve the cached world-matrix of a node.
843 * @param[in] bufferIndex The buffer to read from.
844 * @return The world-matrix.
846 const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
848 return mWorldMatrix[ bufferIndex ];
852 * Copy previous frames world matrix
853 * @param[in] updateBufferIndex The current update buffer index.
855 void CopyPreviousWorldMatrix( BufferIndex updateBufferIndex )
857 mWorldMatrix.CopyPrevious( updateBufferIndex );
861 * Mark the node as exclusive to a single RenderTask.
862 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
864 void SetExclusiveRenderTask( RenderTask* renderTask )
866 mExclusiveRenderTask = renderTask;
870 * Query whether the node is exclusive to a single RenderTask.
871 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
873 RenderTask* GetExclusiveRenderTask() const
875 return mExclusiveRenderTask;
879 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
880 * @param[in] drawMode The new draw-mode to use.
882 void SetDrawMode( const DrawMode::Type& drawMode )
884 mDrawMode = drawMode;
888 * Returns whether node is an overlay or not.
889 * @return True if node is an overlay, false otherwise.
891 DrawMode::Type GetDrawMode() const
897 * Equality operator, checks for identity, not values.
900 bool operator==( const Node* rhs ) const
909 unsigned short GetDepth() const
916 * @copydoc UniformMap::Add
918 void AddUniformMapping( UniformPropertyMapping* map );
921 * @copydoc UniformMap::Remove
923 void RemoveUniformMapping( const std::string& uniformName );
926 * Prepare the node for rendering.
927 * This is called by the UpdateManager when an object is due to be rendered in the current frame.
928 * @param[in] updateBufferIndex The current update buffer index.
930 void PrepareRender( BufferIndex bufferIndex );
935 * Set the parent of a Node.
936 * @param[in] parentNode the new parent.
938 void SetParent(Node& parentNode);
941 * Protected constructor; See also Node::New()
945 private: // from NodeDataProvider
948 * @copydoc NodeDataProvider::GetModelMatrix
950 virtual const Matrix& GetModelMatrix( unsigned int bufferId ) const
952 return GetWorldMatrix( bufferId );
956 * @copydoc NodeDataProvider::GetRenderColor
958 virtual const Vector4& GetRenderColor( unsigned int bufferId ) const
960 return GetWorldColor( bufferId );
963 virtual const Vector3& GetRenderSize( unsigned int bufferId ) const
965 return GetSize( bufferId );
968 public: // From UniformMapDataProvider
970 * @copydoc UniformMapDataProvider::GetUniformMapChanged
972 virtual bool GetUniformMapChanged( BufferIndex bufferIndex ) const
974 return mUniformMapChanged[bufferIndex];
978 * @copydoc UniformMapDataProvider::GetUniformMap
980 virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const
982 return mCollectedUniformMap[bufferIndex];
991 Node& operator=(const Node& rhs);
994 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
996 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
999 * Recursive helper to disconnect a Node and its children.
1000 * Disconnected Nodes have no parent or children.
1001 * @param[in] updateBufferIndex The current update buffer index.
1003 void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex );
1005 public: // Default properties
1007 PropertyVector3 mParentOrigin; ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
1008 PropertyVector3 mAnchorPoint; ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
1010 AnimatableProperty<Vector3> mSize; ///< Size is provided for layouting
1011 AnimatableProperty<Vector3> mPosition; ///< Local transform; distance between parent-origin & anchor-point
1012 AnimatableProperty<Quaternion> mOrientation; ///< Local transform; rotation relative to parent node
1013 AnimatableProperty<Vector3> mScale; ///< Local transform; scale relative to parent node
1014 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
1015 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
1017 // Inherited properties; read-only from public API
1019 InheritedVector3 mWorldPosition; ///< Full inherited position
1020 InheritedQuaternion mWorldOrientation; ///< Full inherited orientation
1021 InheritedVector3 mWorldScale; ///< Full inherited scale
1022 InheritedMatrix mWorldMatrix; ///< Full inherited world matrix
1023 InheritedColor mWorldColor; ///< Full inherited color
1027 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
1028 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
1030 NodeAttachmentOwner mAttachment; ///< Optional owned attachment
1031 RendererContainer mRenderer; ///< Container of renderers; not owned
1033 NodeContainer mChildren; ///< Container of children; not owned
1035 CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps of the node
1036 unsigned int mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame
1037 unsigned int mRegenerateUniformMap : 2; ///< Indicate if the uniform map has to be regenerated this frame
1039 // flags, compressed to bitfield
1040 unsigned short mDepth: 12; ///< Depth in the hierarchy
1041 int mDirtyFlags:8; ///< A composite set of flags for each of the Node properties
1043 bool mIsRoot:1; ///< True if the node cannot have a parent
1044 bool mInheritOrientation:1; ///< Whether the parent's orientation should be inherited.
1045 bool mInheritScale:1; ///< Whether the parent's scale should be inherited.
1047 DrawMode::Type mDrawMode:2; ///< How the Node and its children should be drawn
1048 PositionInheritanceMode mPositionInheritanceMode:2;///< Determines how position is inherited, 2 bits is enough
1049 ColorMode mColorMode:2; ///< Determines whether mWorldColor is inherited, 2 bits is enough
1051 // Changes scope, should be at end of class
1052 DALI_LOG_OBJECT_STRING_DECLARATION;
1055 // Messages for Node
1057 inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
1059 typedef MessageValue1< Node, bool > LocalType;
1061 // Reserve some memory inside the message queue
1062 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1064 // Construct message in the message queue memory; note that delete should not be called on the return value
1065 new (slot) LocalType( &node, &Node::SetInheritOrientation, inherit );
1068 inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
1070 typedef MessageValue1< Node, Vector3 > LocalType;
1072 // Reserve some memory inside the message queue
1073 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1075 // Construct message in the message queue memory; note that delete should not be called on the return value
1076 new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
1079 inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
1081 typedef MessageValue1< Node, Vector3 > LocalType;
1083 // Reserve some memory inside the message queue
1084 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1086 // Construct message in the message queue memory; note that delete should not be called on the return value
1087 new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
1090 inline void SetPositionInheritanceModeMessage( EventThreadServices& eventThreadServices, const Node& node, PositionInheritanceMode mode )
1092 typedef MessageValue1< Node, PositionInheritanceMode > LocalType;
1094 // Reserve some memory inside the message queue
1095 unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1097 // Construct message in the message queue memory; note that delete should not be called on the return value
1098 new (slot) LocalType( &node, &Node::SetPositionInheritanceMode, mode );
1101 inline void SetInheritScaleMessage( 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::SetInheritScale, inherit );
1112 inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
1114 typedef MessageValue1< Node, ColorMode > 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::SetColorMode, colorMode );
1123 inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
1125 typedef MessageValue1< Node, DrawMode::Type > 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::SetDrawMode, drawMode );
1134 inline void AddRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
1136 typedef MessageValue1< Node, Renderer* > 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::AddRenderer, renderer );
1145 inline void RemoveRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
1147 typedef MessageValue1< Node, Renderer* > 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::RemoveRenderer, renderer );
1155 } // namespace SceneGraph
1157 } // namespace Internal
1161 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_H_