+ * This method sets clipping information on the node based on its hierarchy in the scene-graph.
+ * A value is calculated that can be used during sorting to increase sort speed.
+ * @param[in] clippingId The Clipping ID of the node to set
+ * @param[in] clippingDepth The Clipping Depth of the node to set
+ * @param[in] scissorDepth The Scissor Clipping Depth of the node to set
+ */
+ void SetClippingInformation( const uint32_t clippingId, const uint32_t clippingDepth, const uint32_t scissorDepth )
+ {
+ // We only set up the sort value if we have a stencil clipping depth, IE. At least 1 clipping node has been hit.
+ // If not, if we traverse down a clipping tree and back up, and there is another
+ // node on the parent, this will have a non-zero clipping ID that must be ignored
+ if( clippingDepth > 0u )
+ {
+ mClippingDepth = clippingDepth;
+
+ // Calculate the sort value here on write, as when read (during sort) it may be accessed several times.
+ // The items must be sorted by Clipping ID first (so the ID is kept in the most-significant bits).
+ // For the same ID, the clipping nodes must be first, so we negate the
+ // clipping enabled flag and set it as the least significant bit.
+ mClippingSortModifier = ( clippingId << 1u ) | ( mClippingMode == ClippingMode::DISABLED ? 1u : 0u );
+ }
+ else
+ {
+ // If we do not have a clipping depth, then set this to 0 so we do not have a Clipping ID either.
+ mClippingSortModifier = 0u;
+ }
+
+ // The scissor depth does not modify the clipping sort modifier (as scissor clips are 2D only).
+ // For this reason we can always update the member variable.
+ mScissorDepth = scissorDepth;
+ }
+
+ /**
+ * Gets the Clipping ID for this node.
+ * @return The Clipping ID for this node.
+ */
+ uint32_t GetClippingId() const
+ {
+ return mClippingSortModifier >> 1u;
+ }
+
+ /**
+ * Gets the Clipping Depth for this node.
+ * @return The Clipping Depth for this node.
+ */
+ uint32_t GetClippingDepth() const
+ {
+ return mClippingDepth;
+ }
+
+ /**
+ * Gets the Scissor Clipping Depth for this node.
+ * @return The Scissor Clipping Depth for this node.
+ */
+ uint32_t GetScissorDepth() const
+ {
+ return mScissorDepth;
+ }
+
+ /**
+ * Sets the clipping mode for this node.
+ * @param[in] clippingMode The ClippingMode to set
+ */
+ void SetClippingMode( const ClippingMode::Type clippingMode )
+ {
+ SetPropertyDirty( true );
+ mClippingMode = clippingMode;
+ }
+
+ /**
+ * Gets the Clipping Mode for this node.
+ * @return The ClippingMode of this node
+ */
+ ClippingMode::Type GetClippingMode() const
+ {
+ return mClippingMode;
+ }
+
+ /**