diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-04-11 12:42:25 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-04-11 12:42:25 +0400 |
commit | 577a1b9239be28f29ea1d0b1c6f4454b4e825967 (patch) | |
tree | ebe1e4295c2b9f1fdd4837e6fcdbe23208f560a1 /release/scripts/modules/bpy_extras/anim_utils.py | |
parent | acac5b8402e93ff45ada9b353fcb6b3d931cb764 (diff) |
fix [#34805] Bake action ignores parent motion
in fact this is more feature request.
add an option to bake a parented objects animation, then clear the parent and apply the action.
Diffstat (limited to 'release/scripts/modules/bpy_extras/anim_utils.py')
-rw-r--r-- | release/scripts/modules/bpy_extras/anim_utils.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py index de702b53978..c9ed91d3a83 100644 --- a/release/scripts/modules/bpy_extras/anim_utils.py +++ b/release/scripts/modules/bpy_extras/anim_utils.py @@ -32,6 +32,7 @@ def bake_action(frame_start, do_pose=True, do_object=True, do_constraint_clear=False, + do_parents_clear=False, do_clean=False, action=None, ): @@ -54,6 +55,8 @@ def bake_action(frame_start, :type do_object: bool :arg do_constraint_clear: Remove constraints (and do 'visual keying'). :type do_constraint_clear: bool + :arg do_parents_clear: Unparent after baking objects. + :type do_parents_clear: bool :arg do_clean: Remove redundant keyframes after baking. :type do_clean: bool :arg action: An action to bake the data into, or None for a new action @@ -77,8 +80,17 @@ def bake_action(frame_start, matrix[name] = pbone.matrix_basis.copy() return matrix - def obj_frame_info(obj, do_visual_keying): - return obj.matrix_local.copy() if do_visual_keying else obj.matrix_basis.copy() + if do_parents_clear: + def obj_frame_info(obj, do_visual_keying): + parent = obj.parent + matrix = obj.matrix_local if do_visual_keying else obj.matrix_basis + if parent: + return parent.matrix_world * matrix + else: + return matrix.copy() + else: + def obj_frame_info(obj, do_visual_keying): + return obj.matrix_local.copy() if do_visual_keying else obj.matrix_basis.copy() # ------------------------------------------------------------------------- # Setup the Context @@ -192,6 +204,9 @@ def bake_action(frame_start, obj.keyframe_insert("scale", -1, f, name, options) + if do_parents_clear: + obj.parent = None + # ------------------------------------------------------------------------- # Clean |