From 652b2b656acd014287ec2e914515192ce9ff06ce Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 17 Feb 2015 07:16:59 +1100 Subject: [PATCH] Fix bake action visual-keying option Disabling did nothing --- .../scripts/modules/bpy_extras/anim_utils.py | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py index 8905f327f18..4ee5e685668 100644 --- a/release/scripts/modules/bpy_extras/anim_utils.py +++ b/release/scripts/modules/bpy_extras/anim_utils.py @@ -74,7 +74,7 @@ def bake_action(frame_start, # ------------------------------------------------------------------------- # Helper Functions and vars - def pose_frame_info(obj, do_visual_keying): + def pose_frame_info(obj): matrix = {} for name, pbone in obj.pose.bones.items(): if do_visual_keying: @@ -85,16 +85,29 @@ def bake_action(frame_start, return matrix if do_parents_clear: - def obj_frame_info(obj, do_visual_keying): - return obj.matrix_world.copy() if do_visual_keying else obj.matrix_world.copy() + if do_visual_keying: + def obj_frame_info(obj): + return obj.matrix_world.copy() + else: + def obj_frame_info(obj): + parent = obj.parent + matrix = obj.matrix_basis + if parent: + return parent.matrix_world * matrix + else: + return matrix.copy() else: - def obj_frame_info(obj, do_visual_keying): - parent = obj.parent - matrix = obj.matrix_world if do_visual_keying else obj.matrix_world - if parent: - return parent.matrix_world.inverted_safe() * matrix - else: - return matrix.copy() + if do_visual_keying: + def obj_frame_info(obj): + parent = obj.parent + matrix = obj.matrix_world + if parent: + return parent.matrix_world.inverted_safe() * matrix + else: + return matrix.copy() + else: + def obj_frame_info(obj): + return obj.matrix_basis.copy() # ------------------------------------------------------------------------- # Setup the Context @@ -124,9 +137,9 @@ def bake_action(frame_start, scene.frame_set(f) scene.update() if do_pose: - pose_info.append(pose_frame_info(obj, do_visual_keying)) + pose_info.append(pose_frame_info(obj)) if do_object: - obj_info.append(obj_frame_info(obj, do_visual_keying)) + obj_info.append(obj_frame_info(obj)) # ------------------------------------------------------------------------- # Create action