Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-09-10 09:58:04 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-09-10 10:16:47 +0300
commit6d2cd1719b8e087041d54261db1e2a501f00c674 (patch)
tree08840040261cfa62324297afbd52547a867591cf /release/scripts/startup/bl_operators/anim.py
parenta4a59d578cc835477c90e9e5920edaead61fb644 (diff)
Bake Action: operate on selected objects
Previously only the active object was used. Use coroutines to support baking frames for multiple objects at once, without having to playback the animation multiple times.
Diffstat (limited to 'release/scripts/startup/bl_operators/anim.py')
-rw-r--r--release/scripts/startup/bl_operators/anim.py27
1 files changed, 12 insertions, 15 deletions
diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py
index 380c1257a3d..0632f9bc3ca 100644
--- a/release/scripts/startup/bl_operators/anim.py
+++ b/release/scripts/startup/bl_operators/anim.py
@@ -198,7 +198,7 @@ class ANIM_OT_keying_set_export(Operator):
class BakeAction(Operator):
- """Bake object/pose loc/scale/rotation animation to a new action"""
+ """Bake all selected objects loc/scale/rotation animation to an action"""
bl_idname = "nla.bake"
bl_label = "Bake Action"
bl_options = {'REGISTER', 'UNDO'}
@@ -222,7 +222,7 @@ class BakeAction(Operator):
default=1,
)
only_selected = BoolProperty(
- name="Only Selected",
+ name="Only Selected Bones",
description="Only key selected bones (Pose baking only)",
default=True,
)
@@ -259,18 +259,16 @@ class BakeAction(Operator):
def execute(self, context):
from bpy_extras import anim_utils
+ objects = context.selected_editable_objects
+ object_action_pairs = (
+ [(obj, getattr(obj.animation_data, "action", None)) for obj in objects]
+ if self.use_current_action else
+ [(obj, None) for obj in objects]
+ )
- obj = context.object
- action = None
- if self.use_current_action:
- if obj.animation_data:
- action = obj.animation_data.action
-
- action = anim_utils.bake_action(
- obj,
- self.frame_start,
- self.frame_end,
- frame_step=self.step,
+ actions = anim_utils.bake_action_objects(
+ object_action_pairs,
+ frames=range(self.frame_start, self.frame_end + 1, self.step),
only_selected=self.only_selected,
do_pose='POSE' in self.bake_types,
do_object='OBJECT' in self.bake_types,
@@ -278,10 +276,9 @@ class BakeAction(Operator):
do_constraint_clear=self.clear_constraints,
do_parents_clear=self.clear_parents,
do_clean=True,
- action=action,
)
- if action is None:
+ if not any(actions):
self.report({'INFO'}, "Nothing to bake")
return {'CANCELLED'}