Import Blender Animation without Unnecessary Keyframes?

This question pertains to importing animations into the legacy Animation system.

Whenever I import an animated mesh from Blender, be it using the built-in Unity FBX Importer (importing a .blend file), or the built-in Blender FBX Exporter (importing a .fbx file), the resultant AnimationClips have keyframes defined for all bones, even those that are not being animated. These bones have keyframes associated with their localPosition/localRotation/localScale and are flat linear curves – they do nothing but hold the bone stationary.

Holding bones stationary breaks animation blending. All animation clips define animation states for every bone, so animations cannot fall through to lower layers. (Additive blending works fine, of course.)

Is there something I am missing in my export pipeline? In my import pipeline?

EDIT:
I did some more research and tracked down a Blender Developer a lot more knowledgeable than me about this process. Ultimately, he told me that its not really possible if you’re using IK. The IK propogate to other bones, which can themselves be under the effects of IK, and propogate further, etc, to the point where you have to distinguish between tiny floating point values and zero to know if the bone is being animated in an action or not.

He mentioned other constraints in the form of additional ways for a bone to be indirectly animated (drivers, unusual parenting with hinges, “etc”), which I did not understand but figured was worth mentioning.

So what are my options? I can duplicate an animation and remove the bones I don’t think are animated in a given animation, and set up a Unity AssetPostProcessor which copies my imported animations to the target duplicate, inheriting the same bone rejection as before, or I can forfeit animation blending and depend on additive blending instead. For now, I think I will go with the latter, though I’m not happy about it.

Back in blender 2.49 I had to rewrite their export script - it was export_fbx.py or something like that. Simple change once I figured out the language, just had to say “if no bone data continue” inside the bone’s for-loop and everything worked out.

Looks like 2.6 still uses export_fbx.py. Might be able to find the issue by searching for ‘animation’ or ‘bones’. I don’t remember the specifics. :frowning:

Edit: But I found them: Playing two animations from one armature - Unity Answers