From cd119b93c693f3388b37358cf69a6618abfc74ee Mon Sep 17 00:00:00 2001 From: Kythyria Tieran Date: Wed, 4 Aug 2021 15:25:47 +0100 Subject: [PATCH] Use the skin node name when there's no unambiguous root bone. --- PD2ModelParser/Importers/GltfImporter.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PD2ModelParser/Importers/GltfImporter.cs b/PD2ModelParser/Importers/GltfImporter.cs index 901fd82..854f968 100644 --- a/PD2ModelParser/Importers/GltfImporter.cs +++ b/PD2ModelParser/Importers/GltfImporter.cs @@ -330,8 +330,9 @@ void ImportSkin(GLTF.Node node, DM.Model model) skinBones = new DM.SkinBones(); skinBones.global_skin_transform = Matrix4x4.Identity; + var rootBoneName = node.Skin.Skeleton?.Name ?? node.Skin.Name; var parent = data.SectionsOfType() - .FirstOrDefault(i => i.Name == node.Skin.Skeleton.Name); + .FirstOrDefault(i => i.Name == rootBoneName); skinBones.ProbablyRootBone = parent; // I have no idea if this is universal. It looks like it might be. // TODO: For skinned meshes, does mesh.Parent == mesh.SkinBones.probably_root_bone?