[Bf-blender-cvs] [fc77676f332] master: Bake Action operator: Added missing Bendy Bones support

Joshua Leung noreply at git.blender.org
Sun Nov 19 14:09:27 CET 2017


Commit: fc77676f3326894482848b3f4e544c7569d5b440
Author: Joshua Leung
Date:   Mon Nov 20 01:32:03 2017 +1300
Branches: master
https://developer.blender.org/rBfc77676f3326894482848b3f4e544c7569d5b440

Bake Action operator: Added missing Bendy Bones support

===================================================================

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 ea0bd77c0f0..75d2065a3d1 100644
--- a/release/scripts/modules/bpy_extras/anim_utils.py
+++ b/release/scripts/modules/bpy_extras/anim_utils.py
@@ -153,15 +153,29 @@ def bake_action_iter(
     # -------------------------------------------------------------------------
     # Helper Functions and vars
 
+    # Note: BBONE_PROPS is a list so we can preserve the ordering
+    BBONE_PROPS = [
+        'bbone_curveinx', 'bbone_curveoutx',
+        'bbone_curveiny', 'bbone_curveouty',
+        'bbone_rollin', 'bbone_rollout',
+        'bbone_scalein', 'bbone_scaleout',
+        'bbone_easein', 'bbone_easeout'
+    ]
+
     def pose_frame_info(obj):
         matrix = {}
+        bbones = {}
         for name, pbone in obj.pose.bones.items():
             if do_visual_keying:
                 # Get the final transform of the bone in its own local space...
                 matrix[name] = obj.convert_space(pbone, pbone.matrix, 'POSE', 'LOCAL')
             else:
                 matrix[name] = pbone.matrix_basis.copy()
-        return matrix
+
+            # Bendy Bones
+            if pbone.bone.bbone_segments > 1:
+                bbones[name] = {bb_prop : getattr(pbone, bb_prop) for bb_prop in BBONE_PROPS}
+        return matrix, bbones
 
     if do_parents_clear:
         if do_visual_keying:
@@ -214,7 +228,7 @@ def bake_action_iter(
             break
 
         if do_pose:
-            pose_info.append((frame, pose_frame_info(obj)))
+            pose_info.append((frame, *pose_frame_info(obj)))
         if do_object:
             obj_info.append((frame, obj_frame_info(obj)))
 
@@ -255,7 +269,7 @@ def bake_action_iter(
             # create compatible eulers
             euler_prev = None
 
-            for (f, matrix) in pose_info:
+            for (f, matrix, bbones) in pose_info:
                 pbone.matrix_basis = matrix[name].copy()
 
                 pbone.keyframe_insert("location", -1, f, name, options)
@@ -278,6 +292,14 @@ def bake_action_iter(
 
                 pbone.keyframe_insert("scale", -1, f, name, options)
 
+                # Bendy Bones
+                if pbone.bone.bbone_segments > 1:
+                    bbone_shape = bbones[name]
+                    for bb_prop in BBONE_PROPS:
+                        # update this property with value from bbone_shape, then key it
+                        setattr(pbone, bb_prop, bbone_shape[bb_prop])
+                        pbone.keyframe_insert(bb_prop, -1, f, name, options)
+
     # object. TODO. multiple objects
     if do_object:
         if do_constraint_clear:



More information about the Bf-blender-cvs mailing list