Skip to content

Commit

Permalink
convert to for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
nkast committed Dec 24, 2024
1 parent ed9e36f commit 6294f39
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -965,16 +965,18 @@ private static Matrix4x4 GetRelativeTransform(Node node, Node ancestorNode)

// Get transform of node relative to ancestor.
Matrix4x4 transform = node.Transform;
Node parent = node.Parent;
while (parent != null && parent != ancestorNode)
for (Node parent = node.Parent; parent != ancestorNode; parent = parent.Parent)
{
if (parent == null)
{
if (ancestorNode != null)
throw new ArgumentException(String.Format("Node \"{0}\" is not an ancestor of \"{1}\".", ancestorNode.Name, node.Name));
break;
}

transform = transform * parent.Transform;
parent = parent.Parent;
}

if (parent == null && ancestorNode != null)
throw new ArgumentException(String.Format("Node \"{0}\" is not an ancestor of \"{1}\".", ancestorNode.Name, node.Name));

return transform;
}

Expand Down

0 comments on commit 6294f39

Please sign in to comment.