[Bf-blender-cvs] [946b850] master: Fix T46040: Bake action cleans existing keyframes
Campbell Barton
noreply at git.blender.org
Mon Sep 7 20:07:06 CEST 2015
Commit: 946b850b3eaba1e017755e9eee164c1883740d97
Author: Campbell Barton
Date: Tue Sep 8 03:59:03 2015 +1000
Branches: master
https://developer.blender.org/rB946b850b3eaba1e017755e9eee164c1883740d97
Fix T46040: Bake action cleans existing keyframes
===================================================================
M release/scripts/modules/bpy_extras/anim_utils.py
===================================================================
diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py
index 4ee5e68..021a8bb 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])
More information about the Bf-blender-cvs
mailing list