Skip to content

Commit

Permalink
deduplicate dummy clips of same length
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rkc0d3r committed Feb 29, 2024
1 parent f76edf9 commit 3915f0c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Editor/d4rkAvatarOptimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,7 @@ private bool IsAnimatableBinding(EditorCurveBinding binding) {
return animatableBindings.Contains((binding.propertyName, binding.type));
}

private Dictionary<float, AnimationClip> cache_DummyAnimationClipOfLength = null;
private AnimationClip FixAnimationClipPaths(AnimationClip clip)
{
if (clip.name == "d4rkAvatarOptimizer_MergedLayers_Constants")
Expand Down Expand Up @@ -1384,6 +1385,17 @@ void SetObjectReferenceCurve(AnimationClip clipToSet, EditorCurveBinding binding
var dummyCurve = AnimationCurve.Constant(0, lastUnusedKeyframeTime, 1);
AnimationUtility.SetEditorCurve(newClip, dummyBinding, dummyCurve);
changed = true;
if (lastUsedKeyframeTime == -1) {
if (cache_DummyAnimationClipOfLength == null) {
cache_DummyAnimationClipOfLength = new Dictionary<float, AnimationClip>();
}
if (!cache_DummyAnimationClipOfLength.TryGetValue(lastUnusedKeyframeTime, out var dummyClip)) {
newClip.name = $"DummyClip_{lastUnusedKeyframeTime}";
CreateUniqueAsset(newClip, newClip.name + ".anim");
cache_DummyAnimationClipOfLength[lastUnusedKeyframeTime] = dummyClip = newClip;
}
return dummyClip;
}
}
if (changed)
{
Expand Down

0 comments on commit 3915f0c

Please sign in to comment.