bake 時に SkinnedMeshRenderer.bones に null が含まれていても通す

This commit is contained in:
ousttrue 2024-07-03 21:07:15 +09:00
parent ae8541e3d6
commit f1fb4cc7ea

View File

@ -20,7 +20,19 @@ namespace UniGLTF.MeshUtility
if (Bones != null)
{
// recalc bindposes
Mesh.bindposes = Bones.Select(x => x.worldToLocalMatrix * dst.transform.localToWorldMatrix).ToArray();
Mesh.bindposes = Bones.Select(x =>
{
if (x != null)
{
return x.worldToLocalMatrix * dst.transform.localToWorldMatrix;
}
else
{
// ボーンが削除された
return dst.transform.localToWorldMatrix;
}
}
).ToArray();
if (dst.GetComponent<SkinnedMeshRenderer>() is SkinnedMeshRenderer dstRenderer)
{