Page MenuHome

Fix T100879: Bake Action fails with "Nothing to Bake"
ClosedPublic

Authored by Christoph Lendenfeld (ChrisLend) on Nov 23 2022, 5:09 PM.

Details

Summary

Fix for T100879

Exact description of the bug is in the bug task.
But the TLDR is: The "Bake Action" operator when baking to "Pose" was looking for selected objects even when "Only Selected Bones" was enabled.
Because an armature is not necesarily selected when a bone is selected (e.g. box select) it could fail with "Nothing to Bake" even though bones are selected.

While this patch fixes the issue. I am wondering if it should be a bigger refactor. The "Bake Action" operator seems to do too many things, working in the NLA and the Pose Mode
The second issue is that box select does not select the armature, while click select does. @Sybren A. Stüvel (sybren) I am wondering if that is something we should change as well

Diff Detail

Repository
rB Blender

Event Timeline

Christoph Lendenfeld (ChrisLend) requested review of this revision.Nov 23 2022, 5:09 PM
Christoph Lendenfeld (ChrisLend) created this revision.
Sybren A. Stüvel (sybren) requested changes to this revision.Nov 24 2022, 3:00 PM
Sybren A. Stüvel (sybren) added inline comments.
release/scripts/startup/bl_operators/anim.py
257–258

This creates a list of size len(pose_bones), only to remove duplicates later. Better to not create that list in the first place, using a set comprehension:

armature_set = {pose_bone.id_data for pose_bone in pose_bones}
objects = list(armature_set)

This also makes me think, are the items in the final objects list really objects? As in Object ID datablocks? Or are they Armature datablocks? In the case of the latter, the name objects might be misleading.

This revision now requires changes to proceed.Nov 24 2022, 3:00 PM

implemented required changes

not sure I understand the comment about objects
it is e.g. [bpy.data.objects['Armature']] so that are object ID datablocks, right?

not sure I understand the comment about objects
it is e.g. [bpy.data.objects['Armature']] so that are object ID datablocks, right?

Uhu, bpy.data.objects['Armature'] is an Object datablock, and bpy.data.armature['Armature'] would be an Armature datablock. If the former is ob, the latter would be ob.data. I'd refer to the former as "objects" or "armature objects", and the latter as "armatures".

This revision is now accepted and ready to land.Nov 28 2022, 12:47 PM