diff --git a/Scripts/BlendShape/BlendShapeClip.cs b/Scripts/BlendShape/BlendShapeClip.cs index dcc7aa5f2..0bfc9119b 100644 --- a/Scripts/BlendShape/BlendShapeClip.cs +++ b/Scripts/BlendShape/BlendShapeClip.cs @@ -10,6 +10,11 @@ namespace VRM public String RelativePath; public int Index; public float Weight; + + public override string ToString() + { + return string.Format("{0}[{1}]=>{2}", RelativePath, Index, Weight); + } } [Serializable] diff --git a/Scripts/BlendShape/BlendShapeMerger.cs b/Scripts/BlendShape/BlendShapeMerger.cs index 5e8cb4c24..1f45c82c8 100644 --- a/Scripts/BlendShape/BlendShapeMerger.cs +++ b/Scripts/BlendShape/BlendShapeMerger.cs @@ -62,10 +62,18 @@ namespace VRM } if (target != null) { - m_blendShapeSetterMap.Add(binding, x => + if (binding.Index >= 0 && binding.Index < target.sharedMesh.blendShapeCount) + { + m_blendShapeSetterMap.Add(binding, x => { target.SetBlendShapeWeight(binding.Index, x); }); + } + else + { + Debug.LogWarningFormat("Invalid blendshape binding: {0}: {1}", target.name, binding); + } + } else { diff --git a/Scripts/BlendShape/MeshPreviewItem.cs b/Scripts/BlendShape/MeshPreviewItem.cs index ffcce8fd0..be9293aa1 100644 --- a/Scripts/BlendShape/MeshPreviewItem.cs +++ b/Scripts/BlendShape/MeshPreviewItem.cs @@ -147,7 +147,17 @@ namespace VRM { if (x.RelativePath == Path) { - SkinnedMeshRenderer.SetBlendShapeWeight(x.Index, x.Weight * weight); + if(x.Index>=0 && x.Index < SkinnedMeshRenderer.sharedMesh.blendShapeCount) + { + SkinnedMeshRenderer.SetBlendShapeWeight(x.Index, x.Weight * weight); + } + else + { + Debug.LogWarningFormat("Out of range {0}: 0 <= {1} < {2}", + SkinnedMeshRenderer.name, + x.Index, + SkinnedMeshRenderer.sharedMesh.blendShapeCount); + } } } } diff --git a/UniGLTF b/UniGLTF index 03a4b678f..00452b9dc 160000 --- a/UniGLTF +++ b/UniGLTF @@ -1 +1 @@ -Subproject commit 03a4b678fc4e00cbb69e75cf56a2e46b72546b7f +Subproject commit 00452b9dc8c87e10ce9405e8836b08a9d1243a8b