diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-09-07 20:59:03 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-09-07 21:01:03 +0300 |
commit | 946b850b3eaba1e017755e9eee164c1883740d97 (patch) | |
tree | 08437a348e213f5f67dfe95ed54ef009318ce34f /release | |
parent | 9de20963cd6eddf1ef1e3d3ec5ee65d537af4b04 (diff) |
Fix T46040: Bake action cleans existing keyframes
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/bpy_extras/anim_utils.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py index 4ee5e685668..021a8bbb530 100644 --- a/release/scripts/modules/bpy_extras/anim_utils.py +++ b/release/scripts/modules/bpy_extras/anim_utils.py @@ -142,6 +142,13 @@ def bake_action(frame_start, obj_info.append(obj_frame_info(obj)) # ------------------------------------------------------------------------- + # Clean (store initial data) + if do_clean and action is not None: + clean_orig_data = {fcu: {p.co[1] for p in fcu.keyframe_points} for fcu in action.fcurves} + else: + clean_orig_data = {} + + # ------------------------------------------------------------------------- # Create action # in case animation data hasn't been created @@ -230,12 +237,19 @@ def bake_action(frame_start, if do_clean: for fcu in action.fcurves: + fcu_orig_data = clean_orig_data.get(fcu, set()) + keyframe_points = fcu.keyframe_points i = 1 - while i < len(fcu.keyframe_points) - 1: + while i < len(keyframe_points) - 1: + val = keyframe_points[i].co[1] + + if val in fcu_orig_data: + i += 1 + continue + val_prev = keyframe_points[i - 1].co[1] val_next = keyframe_points[i + 1].co[1] - val = keyframe_points[i].co[1] if abs(val - val_prev) + abs(val - val_next) < 0.0001: keyframe_points.remove(keyframe_points[i]) |