[Bf-blender-cvs] [cdfa5177608] blender2.8: Insert Keyframe: Change default behaviour for how F-Curves get grouped

Joshua Leung noreply at git.blender.org
Wed May 30 16:46:21 CEST 2018


Commit: cdfa5177608d6f78338477b293beb3e92b7335ed
Author: Joshua Leung
Date:   Wed May 30 16:46:04 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBcdfa5177608d6f78338477b293beb3e92b7335ed

Insert Keyframe: Change default behaviour for how F-Curves get grouped

For many years, animators have been complaining about how keyframing a (transform)
property directly would leave them ungrouped, while keyframing them using a Keying Set
would put them into a group based on the name of the keyingset.

This commit attempts to improve (unify + make consistent) the default behaviour:
* All object transforms now get added to an "Object Transforms" group,
  regardless of whether they were added individually via buttons or keyingset
* All bone transforms now get added to a group corresponding to the name of the bone
  instead of only the ones added via keyingset

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

M	release/scripts/modules/keyingsets_utils.py
M	source/blender/editors/animation/keyframing.c

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

diff --git a/release/scripts/modules/keyingsets_utils.py b/release/scripts/modules/keyingsets_utils.py
index 7ce5f3e029b..48071117bd4 100644
--- a/release/scripts/modules/keyingsets_utils.py
+++ b/release/scripts/modules/keyingsets_utils.py
@@ -153,8 +153,10 @@ def get_transform_generators_base_info(data):
         # no path in this case
         path = ""
 
-        # data on ID-blocks directly should get grouped by the KeyingSet
-        grouping = None
+        # transform data on ID-blocks directly should get grouped under a
+        # hardcoded label ("Object Transforms") so that they get grouped
+        # consistently when keyframed directly
+        grouping = "Object Transforms"
     else:
         # get the path to the ID-block
         path = data.path_from_id()
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 67f5aef2517..1e9d8af418a 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1826,12 +1826,37 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
 			path = RNA_path_from_ID_to_property(&ptr, prop);
 			
 			if (path) {
+				const char *identifier = RNA_property_identifier(prop);
+				char *group = NULL;
+				
+				/* Special exception for keyframing transforms:
+				 * Set "group" for this manually, instead of having them appearing at the bottom (ungrouped)
+				 * part of the channels list. Leaving these ungrouped is not a nice user behaviour in this case.
+				 *
+				 * TODO: Perhaps we can extend this behaviour in future for other properties...
+				 */
+				if ((ptr.type == &RNA_PoseBone) &&
+				    (strstr(identifier, "location") || strstr(identifier, "rotation") || strstr(identifier, "scale")))
+				{
+					bPoseChannel *pchan = (bPoseChannel *)ptr.data;
+					group = pchan->name;
+				}
+				else if ((ptr.type == &RNA_Object) &&
+				         (strstr(identifier, "location") || strstr(identifier, "rotation") || strstr(identifier, "scale")))
+				{
+					/* NOTE: Keep this label in sync with the "ID" case in
+					 * keyingsets_utils.py :: get_transform_generators_base_info()
+					 */
+					group = "Object Transforms";
+				}
+				
+				
 				if (all) {
 					/* -1 indicates operating on the entire array (or the property itself otherwise) */
 					index = -1;
 				}
 				
-				success = insert_keyframe(depsgraph, op->reports, ptr.id.data, NULL, NULL, path, index, cfra, ts->keyframe_type, flag);
+				success = insert_keyframe(depsgraph, op->reports, ptr.id.data, NULL, group, path, index, cfra, ts->keyframe_type, flag);
 				
 				MEM_freeN(path);
 			}



More information about the Bf-blender-cvs mailing list