mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-26 04:39:51 -05:00
Added range check for blendShape
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
UniGLTF
2
UniGLTF
Submodule UniGLTF updated: 03a4b678fc...00452b9dc8
Reference in New Issue
Block a user