diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index abdad8f84..b3127c210 100644 --- a/CHANGELOG-PRERELEASE.md +++ b/CHANGELOG-PRERELEASE.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog]. ### Fixed - Some Humanoid Bones might be removed `#1137` - Repeated `AddPathDependency` is broken. +- Render is broken if all weighted bone is none and some other non-weight bone is not none `#1138` ### Security diff --git a/CHANGELOG.md b/CHANGELOG.md index ec314c9a0..8e3601470 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog]. ### Fixed - Some Humanoid Bones might be removed `#1137` - Repeated `AddPathDependency` is broken. +- Render is broken if all weighted bone is none and some other non-weight bone is not none `#1138` ### Security diff --git a/Internal/MeshInfo2/MeshInfo2.cs b/Internal/MeshInfo2/MeshInfo2.cs index a16e9c75d..ce323187b 100644 --- a/Internal/MeshInfo2/MeshInfo2.cs +++ b/Internal/MeshInfo2/MeshInfo2.cs @@ -443,12 +443,22 @@ public void Optimize() private void RemoveUnusedBones() { + if (Bones.Count == 0) return; + var hasValidBone = Bones.Any(x => x.Transform != null); + // GC Bones var usedBones = new HashSet(); foreach (var meshInfo2Vertex in Vertices) foreach (var (bone, _) in meshInfo2Vertex.BoneWeights) usedBones.Add(bone); Bones.RemoveAll(x => !usedBones.Contains(x)); + + if (hasValidBone && Bones.All(x => x.Transform == null)) + { + // if all transform is null, the renderer will render nothing. + // so we have to some bone to render. + if (RootBone) Bones.Add(new Bone(Matrix4x4.identity, RootBone)); + } } /// true if we flattened multi pass rendering