[Bf-blender-cvs] [601ce6a] master: POSELIB_OT_pose_add: only create keyframes for selected bones.

Sybren A. Stüvel noreply at git.blender.org
Wed Sep 28 14:03:21 CEST 2016


Commit: 601ce6a89c4f7ecc974f40c85add491a7c295c6f
Author: Sybren A. Stüvel
Date:   Wed Sep 28 13:54:57 2016 +0200
Branches: master
https://developer.blender.org/rB601ce6a89c4f7ecc974f40c85add491a7c295c6f

POSELIB_OT_pose_add: only create keyframes for selected bones.

Previously the pose library used the WholeCharacter key set, which ignores
selection and add keys for almost all bones in the rig. This is a very
slow operation on complex rigs. With this patch, only selected bones are
keyed, defaulting to keying all bones when none are selected.

Note that this fixes the FIXME previously mentioned in the source.

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

M	release/scripts/startup/keyingsets_builtins.py
M	source/blender/editors/armature/pose_lib.c
M	source/blender/editors/include/ED_keyframing.h

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

diff --git a/release/scripts/startup/keyingsets_builtins.py b/release/scripts/startup/keyingsets_builtins.py
index 0b4fbd5..e04b55e 100644
--- a/release/scripts/startup/keyingsets_builtins.py
+++ b/release/scripts/startup/keyingsets_builtins.py
@@ -43,6 +43,7 @@ ANIM_KS_SCALING_ID = "Scaling"
 ANIM_KS_LOC_ROT_SCALE_ID = "LocRotScale"
 ANIM_KS_AVAILABLE_ID = "Available"
 ANIM_KS_WHOLE_CHARACTER_ID = "WholeCharacter"
+ANIM_KS_WHOLE_CHARACTER_SELECTED_ID = "WholeCharacterSelected"
 
 
 # Location
@@ -522,9 +523,24 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo):
             elif prop_rna.is_animatable:
                 ksi.addProp(ks, bone, prop)
 
+# All properties that are likely to get animated in a character rig, only selected bones.
+class BUILTIN_KSI_WholeCharacterSelected(BUILTIN_KSI_WholeCharacter):
+    """Insert a keyframe for all properties that are likely to get animated in a character rig """
+    """(only selected bones)"""
+    bl_idname = ANIM_KS_WHOLE_CHARACTER_SELECTED_ID
+    bl_label = "Whole Character (Selected bones)"
 
-###############################
+    # iterator - all bones regardless of selection
+    def iterator(ksi, context, ks):
+        # Use either the selected bones, or all of them if none are selected.
+        bones = context.selected_pose_bones or context.active_object.pose.bones
 
+        for bone in bones:
+            if bone.name.startswith(BUILTIN_KSI_WholeCharacterSelected.badBonePrefixes):
+                continue
+            ksi.generate(context, ks, bone)
+
+###############################
 
 # Delta Location
 class BUILTIN_KSI_DeltaLocation(KeyingSetInfo):
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 4af7f3f..9309592 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -461,7 +461,7 @@ static int poselib_add_exec(bContext *C, wmOperator *op)
 	bAction *act = poselib_validate(ob);
 	bPose *pose = (ob) ? ob->pose : NULL;
 	TimeMarker *marker;
-	KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_ID); /* this includes custom props :)*/
+	KeyingSet *ks;
 	int frame = RNA_int_get(op->ptr, "frame");
 	char name[64];
 	
@@ -495,8 +495,7 @@ static int poselib_add_exec(bContext *C, wmOperator *op)
 	BLI_uniquename(&act->markers, marker, DATA_("Pose"), '.', offsetof(TimeMarker, name), sizeof(marker->name));
 	
 	/* use Keying Set to determine what to store for the pose */
-	/* FIXME: in the past, the Keying Set respected selections (LocRotScale), but the current one doesn't
-	 * (WholeCharacter) so perhaps we need either a new Keying Set, or just to add overrides here... */
+	ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_SELECTED_ID); /* this includes custom props :)*/
 	ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame);
 	
 	/* store new 'active' pose number */
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 602e203..07cdff6 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -389,6 +389,7 @@ bool ED_autokeyframe_pchan(struct bContext *C, struct Scene *scene, struct Objec
 #define ANIM_KS_LOC_ROT_SCALE_ID    "LocRotScale"
 #define ANIM_KS_AVAILABLE_ID        "Available"
 #define ANIM_KS_WHOLE_CHARACTER_ID  "WholeCharacter"
+#define ANIM_KS_WHOLE_CHARACTER_SELECTED_ID  "WholeCharacterSelected"
 
 #ifdef __cplusplus
 }




More information about the Bf-blender-cvs mailing list