Esempio n. 1
0
	void Transform2D::UpdateHierarchy()
	{
		m_bDirty = false;
		Matrix localMatrix;
		// Rebuild your local Matrix
		RebuildTransform(localMatrix);
		
		// Factor in the parent transform
		Transform2D* parent = m_node.GetParent();
		if (parent)
		{
			m_worldMatrix = parent->GetWorldTransform();
			m_worldMatrix.SelfMultiply(localMatrix);
		}
		else
		{
			m_worldMatrix = localMatrix;
		}
		
		// Rebuild the bounds
		RebuildBounds(m_worldBounds, m_dimensions);
		
		// Rebuild the preserved bounds, if there are any
		if (HasPreservedAspect())
			RebuildBounds(m_worldBoundsPreserved, m_dimensionsPreserved);
		
		// Inform your children of these updates
		Transform2D* childTransform = m_node.GetChild();
		while (childTransform)
		{
			childTransform->UpdateHierarchy();
			childTransform = childTransform->m_node.GetSibling();
		}
	}
Esempio n. 2
0
	STATIC void Transform2D::ValidateTransforms(Transform2D* root)
	{
		Transform2D* curTransform = root;
		while (curTransform != NULL)
		{
			Hierarchy<Transform2D>& curNode = curTransform->m_node;

			// If this transform is dirty, then update the rest of it's hierarchy
			if (curTransform->GetIsDirty())
			{
				// We've got dirt on this transform; we know it's number... Update the transforms on downwards
				curTransform->UpdateHierarchy();
				// Traverse upward to continue our traversal
				while (nullptr != curTransform)
				{
					Hierarchy<Transform2D>& upwardNode = curTransform->m_node;

					// Check if there's a sibling of this node
					if (nullptr != upwardNode.GetSibling())
					{
						curTransform = upwardNode.GetSibling();
						break;
					}
					else
					{
						// If this is the root node, then it's time to leave
						if (root == curTransform)
						{
							curTransform = nullptr;
							break;
						}
						curTransform = upwardNode.GetParent();
					}
				}
			}
			else
			{
				curTransform = curNode.Next();
			}
		}
	}