From d059cbea792b69d6d7c2dcf9022c43f238bf9236 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 1 Nov 2024 19:27:09 +0900 Subject: [PATCH] restore expression --- .../VRM10/Runtime/IO/ExpressionExtensions.cs | 36 +++++++++---------- Assets/VRM10/Runtime/IO/Vrm10Importer.cs | 18 +++++----- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/ExpressionExtensions.cs b/Assets/VRM10/Runtime/IO/ExpressionExtensions.cs index 1d5eb08a30..847a922d2e 100644 --- a/Assets/VRM10/Runtime/IO/ExpressionExtensions.cs +++ b/Assets/VRM10/Runtime/IO/ExpressionExtensions.cs @@ -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(); + 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 materials) { diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index 9124750464..1614085c74 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -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[] { }; }