fix normalize if bones contains null

#467
This commit is contained in:
ousttrue 2020-07-07 19:32:59 +09:00
parent 155acf3547
commit c27848a093

View File

@ -184,7 +184,7 @@ namespace VRM
.Select(x =>
{
Transform dstBone;
if (boneMap.TryGetValue(x.x, out dstBone))
if (x.x != null && boneMap.TryGetValue(x.x, out dstBone))
{
return dstBones.IndexOf(dstBone);
}
@ -199,7 +199,15 @@ namespace VRM
{
if (indexMap[i] < 0)
{
Debug.LogWarningFormat("{0} is removed", srcBones[i].name);
var srcBone = srcBones[i];
if (srcBone == null)
{
Debug.LogWarningFormat("bones[{0}] is null", i);
}
else
{
Debug.LogWarningFormat("{0} is removed", srcBone.name);
}
}
}
@ -289,9 +297,10 @@ namespace VRM
}
var dstBones = srcRenderer.bones
.Where(x => boneMap.ContainsKey(x))
.Where(x => x != null && boneMap.ContainsKey(x))
.Select(x => boneMap[x])
.ToArray();
var hasBoneWeight = srcRenderer.bones != null && srcRenderer.bones.Length > 0;
if (!hasBoneWeight)
{