diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-25 16:37:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-25 16:37:15 +0400 |
commit | 179ac9ebc0c47ca0f0f068a6258ec16ed787db4b (patch) | |
tree | 5ca3c45fd2c0c23d6abdea78922830b850ac25dd /release/scripts/modules/bpy_extras | |
parent | 049811dabd87de6a6cb044cfe0730bb99c5583e1 (diff) |
baking actions with euler rotations now uses compatible eulers for pose and object bakes.
Diffstat (limited to 'release/scripts/modules/bpy_extras')
-rw-r--r-- | release/scripts/modules/bpy_extras/anim_utils.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py index c4ec805a72d..0ef310dd16a 100644 --- a/release/scripts/modules/bpy_extras/anim_utils.py +++ b/release/scripts/modules/bpy_extras/anim_utils.py @@ -68,7 +68,7 @@ def bake_action(frame_start, # Helper Functions def pose_frame_info(obj): - from mathutils import Matrix + from mathutils import Matrix, Euler info = {} @@ -181,6 +181,9 @@ def bake_action(frame_start, while pbone.constraints: pbone.constraints.remove(pbone.constraints[0]) + # create compatible eulers + euler_prev = None + for f in frame_range: f_step = (f - frame_start) // frame_step matrix = pose_info[f_step][name]["matrix_key"] @@ -198,8 +201,19 @@ def bake_action(frame_start, elif rotation_mode == 'AXIS_ANGLE': pbone.keyframe_insert("rotation_axis_angle", -1, f, name) else: # euler, XYZ, ZXY etc + + if euler_prev is not None: + euler = pbone.rotation_euler.copy() + euler.make_compatible(euler_prev) + pbone.rotation_euler = euler + euler_prev = euler + del euler + pbone.keyframe_insert("rotation_euler", -1, f, name) + if euler_prev is None: + euler_prev = pbone.rotation_euler.copy() + pbone.keyframe_insert("scale", -1, f, name) # object. TODO. multiple objects @@ -208,6 +222,9 @@ def bake_action(frame_start, while obj.constraints: obj.constraints.remove(obj.constraints[0]) + # create compatible eulers + euler_prev = None + for f in frame_range: matrix = obj_info[(f - frame_start) // frame_step]["matrix_key"] obj.matrix_local = matrix @@ -221,8 +238,18 @@ def bake_action(frame_start, elif rotation_mode == 'AXIS_ANGLE': obj.keyframe_insert("rotation_axis_angle", -1, f) else: # euler, XYZ, ZXY etc + if euler_prev is not None: + euler = obj.rotation_euler.copy() + euler.make_compatible(euler_prev) + obj.rotation_euler = euler + euler_prev = euler + del euler + obj.keyframe_insert("rotation_euler", -1, f) + if euler_prev is None: + euler_prev = obj.rotation_euler.copy() + obj.keyframe_insert("scale", -1, f) scene.frame_set(frame_back) |