[Bf-blender-cvs] [e7407b0] BendyBones: Bendy Bones: Keying Set support

Joshua Leung noreply at git.blender.org
Tue May 17 16:40:47 CEST 2016


Commit: e7407b0f090d8853f036db6c47487bf09eb133ff
Author: Joshua Leung
Date:   Mon May 16 03:02:52 2016 +1200
Branches: BendyBones
https://developer.blender.org/rBe7407b0f090d8853f036db6c47487bf09eb133ff

Bendy Bones: Keying Set support

* Added a "BBone Shape" Keying Set to make it easier to key all these properties at once
* Made "Whole Character" Keying Set aware of these properties

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

M	release/scripts/modules/keyingsets_utils.py
M	release/scripts/startup/keyingsets_builtins.py

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

diff --git a/release/scripts/modules/keyingsets_utils.py b/release/scripts/modules/keyingsets_utils.py
index 03400ed..375ee3f 100644
--- a/release/scripts/modules/keyingsets_utils.py
+++ b/release/scripts/modules/keyingsets_utils.py
@@ -28,11 +28,14 @@ __all__ = (
     "RKS_POLL_selected_objects",
     "RKS_POLL_selected_bones",
     "RKS_POLL_selected_items",
+    "RKS_ITER_selected_object",
+    "RKS_ITER_selected_bones",
     "RKS_ITER_selected_item",
     "RKS_GEN_available",
     "RKS_GEN_location",
     "RKS_GEN_rotation",
     "RKS_GEN_scaling",
+    "RKS_GEN_bendy_bones",
     )
 
 import bpy
@@ -93,11 +96,17 @@ def RKS_ITER_selected_item(ksi, context, ks):
             ksi.generate(context, ks, ob)
 
 
-# all select objects only
+# all selected objects only
 def RKS_ITER_selected_objects(ksi, context, ks):
     for ob in context.selected_objects:
         ksi.generate(context, ks, ob)
 
+
+# all seelcted bones only
+def RKS_ITER_selected_bones(ksi, context, ks):
+    for bone in context.selected_pose_bones:
+        ksi.generate(context, ks, bone)
+
 ###########################
 # Generate Callbacks
 
@@ -207,3 +216,43 @@ def RKS_GEN_scaling(ksi, context, ks, data):
         ks.paths.add(id_block, path, group_method='NAMED', group_name=grouping)
     else:
         ks.paths.add(id_block, path)
+
+# ------
+
+# Property identifiers for Bendy Bones
+bbone_property_ids = (
+    "bbone_curveinx",
+    "bbone_curveiny",
+    "bbone_curveoutx",
+    "bbone_curveouty",
+
+    "bbone_rollin",
+    "bbone_rollout",
+
+    "bbone_scalein",
+    "bbone_scaleout",
+
+    # NOTE: These are in the nested bone struct 
+    # Do it this way to force them to be included
+    # in whatever actions are being keyed here
+    "bone.bbone_in",
+    "bone.bbone_out",
+)
+
+# Add Keying Set entries for bendy bones
+def RKS_GEN_bendy_bones(ksi, context, ks, data):
+    # get id-block and path info
+    # NOTE: This assumes that we're dealing with a bone here...
+    id_block, base_path, grouping = get_transform_generators_base_info(data)
+
+    # for each of the bendy bone properties, add a Keying Set entry for it...
+    for propname in bbone_property_ids:
+        # add the property name to the base path
+        path = path_add_property(base_path, propname)
+
+        # add Keying Set entry for this...
+        if grouping:
+            ks.paths.add(id_block, path, group_method='NAMED', group_name=grouping)
+        else:
+            ks.paths.add(id_block, path)
+
diff --git a/release/scripts/startup/keyingsets_builtins.py b/release/scripts/startup/keyingsets_builtins.py
index 6d52a81..195eaf8 100644
--- a/release/scripts/startup/keyingsets_builtins.py
+++ b/release/scripts/startup/keyingsets_builtins.py
@@ -175,6 +175,22 @@ class BUILTIN_KSI_RotScale(KeyingSetInfo):
 
 # ------------
 
+# Bendy Bones
+class BUILTIN_KSI_BendyBones(KeyingSetInfo):
+    """Insert a keyframe for each of the BBone shape properties"""
+    bl_label = "BBone Shape"
+
+    # poll - use callback for selected bones
+    poll = keyingsets_utils.RKS_POLL_selected_bones
+
+    # iterator - use callback for selected bones
+    iterator = keyingsets_utils.RKS_ITER_selected_bones
+
+    # generator - use generator for bendy bone properties
+    generate = keyingsets_utils.RKS_GEN_bendy_bones
+
+# ------------
+
 
 # VisualLocation
 class BUILTIN_KSI_VisualLoc(KeyingSetInfo):
@@ -387,6 +403,9 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo):
             ksi.doRot3d(ks, bone)
         ksi.doScale(ks, bone)
 
+        # bbone properties?
+        ksi.doBBone(context, ks, bone)
+
         # custom props?
         ksi.doCustomProps(ks, bone)
 
@@ -466,6 +485,19 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo):
 
     # ----------------
 
+    # bendy bone properties
+    def doBBone(ksi, context, ks, pchan):
+        bone = pchan.bone
+        
+        # This check is crude, but is the best we can do for now
+        # It simply adds all of these if the bbone has segments
+        # (and the bone is a control bone). This may lead to some
+        # false positives...
+        if bone.bbone_segments > 1:
+            keyingsets_utils.RKS_GEN_bendy_bones(ksi, context, ks, pchan)
+
+    # ----------------
+
     # custom properties
     def doCustomProps(ksi, ks, bone):




More information about the Bf-blender-cvs mailing list