- Edited
Animation clean up
Prior to Spine 3.5, applying animations at runtime generally required a lot of extra keys to be set at the start of every animation. Now that the new AnimationState in 3.5 solves this problem, we have added a new feature to clean up your animations. Starting in 3.5.38, there is a Clean Up
button when selecting an animation in the tree:
Loading Image
Clicking the button deletes unnecessary keys, ie keys that do not affect how the animation looks. Fewer keys means less data, which is always good, but it can also mean fewer timelines which translates to using less CPU to apply the animation at runtime.
Here's the raptor walk animation before:
Loading Image
And after:
Loading Image
Loading Image
You can select multiple animations and then click Clean Up
to do them all at once. It's easy for a skeleton with a few animations to have thousands of unnecessary keys and hundreds of unnecessary timelines! Here's 22 animations from the 2D Anim Heroes project:
Loading Image
During normal designing of your animations, it's common to end up with some extra keys. Trying to be efficient with your keys in the beginning of a new animation can be painful, so now you can key liberally and use Clean Up
later.
There may be some rare times you don't want to use Clean Up
, such as when not using AnimationState at runtime or maybe if you programmatically find some key and change its value. For most people though, Clean Up
should be used.
Please note: While we have tested it extensively, this is a new feature that deletes keys in your animations. Make a backup before giving it a try, and verify after Clean Up
that your animations still work correctly both in Spine and your applications. :nerd:
Very interesting and useful feature! I remember you were adding the possibility to delete unnecessary vertices in meshes but this is useful on a whole new level!
Note the benefits:
- A cleaner dopesheet so you understand what's actually changing.
- Fewer stuff for the runtime to crunch, so it costs less performance to have more and more of your characters/skeletons at any time.
When not to use it:
- If you have a multi-track animation setup, and you specifically keyed certain bones to override the movement of bones, and parts of the override pose happen to be setup pose.
- If you added timelines with only setup-pose keys for any deliberate reason.
- If you added more than 2 keys repeating the same value/pose for any deliberate reason.
Very good point Pharan about animations intended to be applied on AnimationState tracks > 0. We'll be sure to include that in the docs.
This is fantastic.. we never used SetUpToPose and thus keyed a lot of extra bs. Will abuse this and let you know the results once it's out.
Working good so far.
1045 keys cleaned up in our main character, lol.
If you build things around known problems "safely".. they will fix it
Pharan wrote3. If you added more than 2 keys repeating the same value/pose for any deliberate reason.
So if we fluffed the end of an animation by copying all the frames at say.. 20 and copied them to 25, this would "clean" them off? That could pose some issues for sure if so.. didn't spot it right away but we hold positions sometimes with this "trick."
Sounds very promising :p
@Majicpanda.
No, it doesn't remove ending keys.
It doesn't remove holds. It does remove keys between two similar keys though. But just two similar keys together won't trigger it.
Actually, it would remove a hold key at the end of an animation, which could reduce the animation duration. In 3.5.41 we've updated Clean Up
to leave one otherwise unnecessary key if needed so the animation duration doesn't change.
a new record?
main character
Loading Image
It breaks any animations which turn something off at the end of the animation, but other than that. e.g. the sword
attachment being left visible when dropped or thrown(keyed off)
maybe this has changed in a new-er version of the runtime. maybe it is a bug, our version of the runtimes are a bit up in the air at the moment and I don't have an opportunity to look into this/put keys back in. Ill revert for now, but wow :party: now I don't need to take out 25k keys out by hand
You win a broken animation!
I was editing the post as you wrote that , and its not actually that bad except from attachments
main enemy:
Loading Image
Damn, 24k keys is a lot!
BinaryCats wroteIt breaks any animations which turn something off at the end of the animation, but other than that. e.g. the sword attachment being left visible when dropped or thrown(keyed off)
What Spine version does this happen? Can you show a .spine file that has keys which are deleted by Clean Up
which you don't think should be deleted?
3.5.38
investigating further, it seemed like we relied on the next animation keying things off.
i.e. We would play and animation which key'ed the visibility of the sword attachment on (Attack_throwSword
at the start) but then would key it off in the Idle
animation (the next animation to play, which Attack_throwSword
would return to). But the clean up, I assume, would delete because the sword_attachment
is off in setup pose the key is redundant.
and we use a lot of one frame, animations which key attachment(s) on and off
3.5.41 has Clean Up
improvements, so I suggest using that.
Clean Up
assumes AnimationState is being used without any customization, which is how it can make assumptions about what keys are unnecessary. If you're doing something else, you may need to write a tool to do clean up on JSON data specific to your needs.
I think it would be easier just to re-add the keys that go wrong great tool
:rofl: Loading Image v3.5.41
Performance gain
(unity)
Idle cleanup removes 222 keys.
Single spine object, playing one idle looping animation:
Idle animation Without cleanup:
SkeletonAnimation.update: 7% to 9% of frametime
Idle animation With cleanup:
SkeletonAnimation.update: 6.3% to 7.5% of frametime
Sweet! 8) The biggest gains come from removing unnecessary deform keys, especially when the entire deform timeline can be deleted.
hmm, we don't really mesh deform on the player character. let me try with a enemy
One character:
Idle animation (82 keys removed) arms and legs are mesh deformed.
Without cleanup 8%-10%
with: 7%-8%
much less keys removed here, but still gains are made.
Hi there,
I'm using 3.6.09-beta, and when I click "Clean Up" all my attachment off keys get erased... Is this intended behavior? Because I don't feel that's useful at all. :p
I'm using those keys at frame 0 to tell Spine which attachments should be off in a specific animation, no matter what the setup pose says...
Thank you.
Hate to auto-bump but...
Bump? :p
Can you send us your project file? contact@esotericsoftware.com.