Skip to content

Commit

Permalink
Fixed Perfare#962
Browse files Browse the repository at this point in the history
  • Loading branch information
Perfare committed Jun 1, 2022
1 parent dc9429f commit 4f88841
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
22 changes: 22 additions & 0 deletions AssetStudio/IImported.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ public ImportedFrame FindFrameByPath(string path)
return null;
}

public ImportedFrame FindRelativeFrameWithPath(string path)
{
var subs = path.Split(new[] { '/' }, 2);
foreach (var child in children)
{
if (child.Name == subs[0])
{
if (subs.Length == 1)
{
return child;
}
else
{
var result = child.FindRelativeFrameWithPath(subs[1]);
if (result != null)
return result;
}
}
}
return null;
}

public ImportedFrame FindFrame(string name)
{
if (Name == name)
Expand Down
11 changes: 3 additions & 8 deletions AssetStudioUtility/ModelConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,26 +1063,21 @@ private void DeoptimizeTransformHierarchy()
else
{
transformName = strs.Last();
var parentFrameName = strs[strs.Length - 2];
parentFrame = RootFrame.FindChild(parentFrameName);
//var parentFramePath = path.Substring(0, path.LastIndexOf('/'));
//parentFrame = RootFrame.FindFrameByPath(parentFramePath);
var parentFramePath = path.Substring(0, path.LastIndexOf('/'));
parentFrame = RootFrame.FindRelativeFrameWithPath(parentFramePath);
}

var skeletonPose = avatar.m_Avatar.m_DefaultPose;
var xform = skeletonPose.m_X[i];

var frame = RootFrame.FindChild(transformName);
if (frame != null)
{
SetFrame(frame, xform.t, xform.q, xform.s);
parentFrame.AddChild(frame);
}
else
{
frame = CreateFrame(transformName, xform.t, xform.q, xform.s);
parentFrame.AddChild(frame);
}
parentFrame.AddChild(frame);
}
}

Expand Down

0 comments on commit 4f88841

Please sign in to comment.