Skip to content

Commit

Permalink
restore expression
Browse files Browse the repository at this point in the history
  • Loading branch information
ousttrue committed Nov 1, 2024
1 parent 1584ca9 commit d059cbe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
36 changes: 18 additions & 18 deletions Assets/VRM10/Runtime/IO/ExpressionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ namespace UniVRM10
{
public static class ExpressionExtensions
{
// public static MorphTargetBinding? Build10(this MorphTargetBind bind, GameObject root, Vrm10Importer.ModelMap loader, VrmLib.Model model)
// {
// if (bind.Node.TryGetValidIndex(model.Nodes.Count, out var nodeIndex))
// {
// var libNode = model.Nodes[nodeIndex];
// if (libNode.MeshGroup == null)
// {
// return default;
// }
// var node = loader.Nodes[libNode].transform;
// var relativePath = node.RelativePathFrom(root.transform);
// return new MorphTargetBinding(relativePath, bind.Index.Value, bind.Weight.Value);
// }
// else
// {
// return default;
// }
// }
public static MorphTargetBinding? Build10(this MorphTargetBind bind, GameObject root, Vrm10Importer importer)
{
if (bind.Node.TryGetValidIndex(importer.Nodes.Count, out var nodeIndex))
{
var node = importer.Nodes[nodeIndex];
var smr = node.GetComponent<SkinnedMeshRenderer>();
if (smr == null)
{
return default;
}
var relativePath = node.RelativePathFrom(root.transform);
return new MorphTargetBinding(relativePath, bind.Index.Value, bind.Weight.Value);
}
else
{
return default;
}
}

public static UniVRM10.MaterialColorBinding? Build10(this MaterialColorBind bind, IReadOnlyList<MaterialFactory.MaterialLoadInfo> materials)
{
Expand Down
18 changes: 9 additions & 9 deletions Assets/VRM10/Runtime/IO/Vrm10Importer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,15 @@ VRM10Expression GetOrLoadExpression(in SubAssetKey key, ExpressionPreset preset,
clip.OverrideLookAt = expression.OverrideLookAt;
clip.OverrideMouth = expression.OverrideMouth;

// if (expression.MorphTargetBinds != null)
// {
// clip.MorphTargetBindings = expression.MorphTargetBinds?
// .Select(x => x.Build10(Root, m_map, m_model))
// .Where(x => x.HasValue)
// .Select(x => x.Value)
// .ToArray();
// }
// else
if (expression.MorphTargetBinds != null)
{
clip.MorphTargetBindings = expression.MorphTargetBinds?
.Select(x => x.Build10(Root, this))
.Where(x => x.HasValue)
.Select(x => x.Value)
.ToArray();
}
else
{
clip.MorphTargetBindings = new MorphTargetBinding[] { };
}
Expand Down

0 comments on commit d059cbe

Please sign in to comment.