Skip to content

Commit

Permalink
Merge pull request #498 from nekobako/remove-unused-bone-references
Browse files Browse the repository at this point in the history
chore: remove unused bone references just after reading mesh
  • Loading branch information
anatawa12 authored Sep 23, 2023
2 parents def7d18 + fc31517 commit 88cf2fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog].
### Removed

### Fixed
- Remove unused bone references [`#498`](https://github.com/anatawa12/AvatarOptimizer/pull/498)

### Security

Expand Down
7 changes: 7 additions & 0 deletions Editor/Processors/SkinnedMeshes/MeshInfo2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public MeshInfo2(SkinnedMeshRenderer renderer)
var bones = renderer.bones;
for (var i = 0; i < bones.Length && i < Bones.Count; i++) Bones[i].Transform = bones[i];

RemoveUnusedBones();

AssertInvariantContract("SkinnedMeshRenderer");
});
}
Expand Down Expand Up @@ -266,6 +268,11 @@ public void Clear()
}

public void Optimize()
{
RemoveUnusedBones();
}

private void RemoveUnusedBones()
{
// GC Bones
var usedBones = new HashSet<Bone>();
Expand Down

0 comments on commit 88cf2fd

Please sign in to comment.