[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27673] trunk/blender: Keying Sets: BuiltIn vs Absolute Tweaks

Joshua Leung aligorith at gmail.com
Tue Mar 23 12:59:34 CET 2010


Revision: 27673
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27673
Author:   aligorith
Date:     2010-03-23 12:59:34 +0100 (Tue, 23 Mar 2010)

Log Message:
-----------
Keying Sets: BuiltIn vs Absolute Tweaks

This commit clarifies the somewhat "murky" separation between "builtin" and "absolute" KeyingSets as a result of discussions with Cessen.

* "Builtin" Keying Sets are now just the Keying Sets which in the past have been known as PyKeyingSets or Relative KeyingSets. These are registered from Py Scripts at startup, and will use the context info to determine what data they should be keyframing. These are stored per Blender session, independent of files, since usually these will be coded specific to sets of rigs used at a studio.

* "Absolute" Keying Sets are the ones that you can create from the Scene buttons and/or KKEY or RMB over any property. They specify the exact set of properties which should always get keyframed together. These are stored in the scene. 

In relation to this, I've made it possible to now set one of the builtin Keying Set types as the active Keying Set. 
* For now, this can only be done via the box beside the insert/delete key operator buttons on the TimeLine header (now complete with an recycled icon - HINT TO ICON DESIGNERS, to make this a bit more obvious). Later on I'll commit an operator to set this via a hotkey.
* The "IKEY" menu will only show up when there is no active Keying Set. When there is one, keying will happen silently (with info notice at the top of the screen). Later on, I'll hook this menu up to a hotkey, so that that active Keying Set can be changed without inserting keyframes or clearing active Keying Set...
* By default, there isn't any default Keying Set enabled. IMO, this is probably a good default, though some might like to have LocRotScale instead.
* I'm not terribly impressed with the search menu for the items being SORTED (and of all things, alphabetically!) currently, since this does break muscle-memory with the menu (and jumbles up order of closely related vs not closely related).
* The Scene buttons for KeyingSets still need some changes to fully cope with users setting builtin KeyingSets as active sometimes. Controls which are useless or shouldn't be used when a builtin set is shown are being shown.

Builtin set registrations have been tweaked a bit:
* Renamed "bl_idname" to "bl_label" for consistency with rest of API. Note that this is the identifier used by Blender internally when searching for the KeyingSet, and is also what the user sees.

Modified Paths:
--------------
    trunk/blender/release/scripts/keyingsets/keyingsets_builtins.py
    trunk/blender/release/scripts/ui/properties_scene.py
    trunk/blender/release/scripts/ui/space_time.py
    trunk/blender/source/blender/blenkernel/intern/anim_sys.c
    trunk/blender/source/blender/editors/animation/keyingsets.c
    trunk/blender/source/blender/editors/include/ED_keyframing.h
    trunk/blender/source/blender/makesrna/intern/rna_animation.c
    trunk/blender/source/blender/makesrna/intern/rna_scene.c

Modified: trunk/blender/release/scripts/keyingsets/keyingsets_builtins.py
===================================================================
--- trunk/blender/release/scripts/keyingsets/keyingsets_builtins.py	2010-03-23 11:38:47 UTC (rev 27672)
+++ trunk/blender/release/scripts/keyingsets/keyingsets_builtins.py	2010-03-23 11:59:34 UTC (rev 27673)
@@ -11,8 +11,7 @@
 
 # Location
 class BUILTIN_KSI_Location(bpy.types.KeyingSetInfo):
-	bl_idname = "Location"
-	bl_builtin = True
+	bl_label = "Location"
 	
 	# poll - use predefined callback for selected bones/objects
 	poll = RKS_POLL_selected_items
@@ -25,8 +24,7 @@
 	
 # Rotation
 class BUILTIN_KSI_Rotation(bpy.types.KeyingSetInfo):
-	bl_idname = "Rotation"
-	bl_builtin = True
+	bl_label = "Rotation"
 	
 	# poll - use predefined callback for selected bones/objects
 	poll = RKS_POLL_selected_items
@@ -39,8 +37,7 @@
 	
 # Scale
 class BUILTIN_KSI_Scaling(bpy.types.KeyingSetInfo):
-	bl_idname = "Scaling"
-	bl_builtin = True
+	bl_label = "Scaling"
 	
 	# poll - use predefined callback for selected bones/objects
 	poll = RKS_POLL_selected_items
@@ -55,8 +52,7 @@
 	
 # LocRot
 class BUILTIN_KSI_LocRot(bpy.types.KeyingSetInfo):
-	bl_idname = "LocRot"
-	bl_builtin = True
+	bl_label = "LocRot"
 	
 	# poll - use predefined callback for selected bones/objects
 	poll = RKS_POLL_selected_items
@@ -73,8 +69,7 @@
 
 # LocScale
 class BUILTIN_KSI_LocScale(bpy.types.KeyingSetInfo):
-	bl_idname = "LocScale"
-	bl_builtin = True
+	bl_label = "LocScale"
 	
 	# poll - use predefined callback for selected bones/objects
 	poll = RKS_POLL_selected_items
@@ -91,8 +86,7 @@
 
 # LocRotScale
 class BUILTIN_KSI_LocRotScale(bpy.types.KeyingSetInfo):
-	bl_idname = "LocRotScale"
-	bl_builtin = True
+	bl_label = "LocRotScale"
 	
 	# poll - use predefined callback for selected bones/objects
 	poll = RKS_POLL_selected_items
@@ -111,8 +105,7 @@
 
 # RotScale
 class BUILTIN_KSI_RotScale(bpy.types.KeyingSetInfo):
-	bl_idname = "RotScale"
-	bl_builtin = True
+	bl_label = "RotScale"
 	
 	# poll - use predefined callback for selected bones/objects
 	poll = RKS_POLL_selected_items
@@ -131,8 +124,7 @@
 
 # Location
 class BUILTIN_KSI_VisualLoc(bpy.types.KeyingSetInfo):
-	bl_idname = "Visual Location"
-	bl_builtin = True
+	bl_label = "Visual Location"
 	
 	insertkey_visual = True
 	
@@ -147,8 +139,7 @@
 	
 # Rotation
 class BUILTIN_KSI_VisualRot(bpy.types.KeyingSetInfo):
-	bl_idname = "Visual Rotation"
-	bl_builtin = True
+	bl_label = "Visual Rotation"
 	
 	insertkey_visual = True
 	
@@ -163,8 +154,7 @@
 
 # VisualLocRot
 class BUILTIN_KSI_VisualLocRot(bpy.types.KeyingSetInfo):
-	bl_idname = "Visual LocRot"
-	bl_builtin = True
+	bl_label = "Visual LocRot"
 	
 	insertkey_visual = True
 	
@@ -185,8 +175,7 @@
 
 # Available
 class BUILTIN_KSI_Available(bpy.types.KeyingSetInfo):
-	bl_idname = "Available"
-	bl_builtin = True
+	bl_label = "Available"
 	
 	# poll - use predefined callback for selected objects
 	# TODO: this should really check whether the selected object (or datablock) 

Modified: trunk/blender/release/scripts/ui/properties_scene.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_scene.py	2010-03-23 11:38:47 UTC (rev 27672)
+++ trunk/blender/release/scripts/ui/properties_scene.py	2010-03-23 11:59:34 UTC (rev 27673)
@@ -101,7 +101,6 @@
 
             col = row.column()
             col.prop(ks, "name")
-            col.prop(ks, "absolute")
 
             subcol = col.column()
             subcol.operator_context = 'INVOKE_DEFAULT'

Modified: trunk/blender/release/scripts/ui/space_time.py
===================================================================
--- trunk/blender/release/scripts/ui/space_time.py	2010-03-23 11:38:47 UTC (rev 27672)
+++ trunk/blender/release/scripts/ui/space_time.py	2010-03-23 11:59:34 UTC (rev 27673)
@@ -77,7 +77,7 @@
         layout.separator()
 
         row = layout.row(align=True)
-        row.prop_object(scene, "active_keying_set", scene, "keying_sets", text="")
+        row.prop_object(scene, "active_keying_set", scene, "all_keying_sets", text="")
         row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
         row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
 

Modified: trunk/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/anim_sys.c	2010-03-23 11:38:47 UTC (rev 27672)
+++ trunk/blender/source/blender/blenkernel/intern/anim_sys.c	2010-03-23 11:59:34 UTC (rev 27673)
@@ -769,11 +769,11 @@
 /* Write the given value to a setting using RNA, and return success */
 static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_index, float value)
 {
-	// printf("%p %s %i %f\n", ptr, path, array_index, value);
-
 	PropertyRNA *prop;
 	PointerRNA new_ptr;
 	
+	//printf("%p %s %i %f\n", ptr, path, array_index, value);
+	
 	/* get property to write to */
 	if (RNA_path_resolve(ptr, path, &new_ptr, &prop)) 
 	{
@@ -781,7 +781,7 @@
 		if (RNA_property_animateable(&new_ptr, prop)) 
 		{
 			int array_len= RNA_property_array_length(&new_ptr, prop);
-
+			
 			if(array_len && array_index >= array_len)
 			{
 				if (G.f & G_DEBUG) {
@@ -789,10 +789,10 @@
 						(ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name+2) : "<No ID>",
 						path, array_index, array_len-1);
 				}
-
+				
 				return 0;
 			}
-
+			
 			switch (RNA_property_type(prop)) 
 			{
 				case PROP_BOOLEAN:
@@ -1003,7 +1003,12 @@
 		animsys_evaluate_fcurves(&strip_ptr, &strip->fcurves, NULL, ctime);
 	}
 
-	if (strip->flag & NLASTRIP_FLAG_USR_TIME && strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC)
+	/* if user can control the evaluation time (using F-Curves), consider the option which allows this time to be clamped 
+	 * to lie within extents of the action-clip, so that a steady changing rate of progress through several cycles of the clip
+	 * can be achieved easily
+	 */
+	// NOTE: if we add any more of these special cases, we better group them up nicely...
+	if ((strip->flag & NLASTRIP_FLAG_USR_TIME) && (strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC))
 		strip->strip_time= fmod(strip->strip_time - strip->actstart, strip->actend - strip->actstart);
 }
 
@@ -1740,7 +1745,7 @@
 	 */
 	// TODO: need to double check that this all works correctly
 	if ((recalc & ADT_RECALC_ANIM) || (adt->recalc & ADT_RECALC_ANIM))
-	 {
+	{
 		/* evaluate NLA data */
 		if ((adt->nla_tracks.first) && !(adt->flag & ADT_NLA_EVAL_OFF))
 		{

Modified: trunk/blender/source/blender/editors/animation/keyingsets.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyingsets.c	2010-03-23 11:38:47 UTC (rev 27672)
+++ trunk/blender/source/blender/editors/animation/keyingsets.c	2010-03-23 11:59:34 UTC (rev 27673)
@@ -521,20 +521,12 @@
 /* Add the given KeyingSetInfo to the list of type infos, and create an appropriate builtin set too */
 void ANIM_keyingset_info_register (const bContext *C, KeyingSetInfo *ksi)
 {
-	Scene *scene = CTX_data_scene(C);
-	ListBase *list = NULL;
 	KeyingSet *ks;
 	
-	/* determine the KeyingSet list to include the new KeyingSet in */
-	if (ksi->builtin==0 && scene)
-		list = &scene->keyingsets;
-	else
-		list = &builtin_keyingsets;
-	
 	/* create a new KeyingSet 
 	 *	- inherit name and keyframing settings from the typeinfo
 	 */
-	ks = BKE_keyingset_add(list, ksi->name, ksi->builtin, ksi->keyingflag);
+	ks = BKE_keyingset_add(&builtin_keyingsets, ksi->name, 1, ksi->keyingflag);
 	
 	/* link this KeyingSet with its typeinfo */
 	memcpy(&ks->typeinfo, ksi->name, sizeof(ks->typeinfo));
@@ -549,8 +541,10 @@
 	Scene *scene = CTX_data_scene(C);
 	KeyingSet *ks, *ksn;
 	
-	/* find relevant scene KeyingSets which use this, and remove them */
-	for (ks= scene->keyingsets.first; ks; ks= ksn) {
+	/* find relevant builtin KeyingSets which use this, and remove them */
+	// TODO: this isn't done now, since unregister is really only used atm when we
+	// reload the scripts, which kindof defeats the purpose of "builtin"?
+	for (ks= builtin_keyingsets.first; ks; ks= ksn) {
 		ksn = ks->next;
 		
 		/* remove if matching typeinfo name */
@@ -560,11 +554,6 @@
 		}
 	}
 	
-	/* do the same with builtin sets? */
-	// TODO: this isn't done now, since unregister is really only used atm when we
-	// reload the scripts, which kindof defeats the purpose of "builtin"?
-	
-	
 	/* free the type info */
 	BLI_freelinkN(&keyingset_type_infos, ksi);
 }
@@ -595,20 +584,51 @@
 /* Get the active Keying Set for the Scene provided */
 KeyingSet *ANIM_scene_get_active_keyingset (Scene *scene)
 {
-	if (ELEM(NULL, scene, scene->keyingsets.first))
+	/* if no scene, we've got no hope of finding the Keying Set */
+	if (scene == NULL)
 		return NULL;
 	
 	/* currently, there are several possibilities here:
 	 *	-   0: no active keying set
 	 *	- > 0: one of the user-defined Keying Sets, but indices start from 0 (hence the -1)
-	 *	- < 0: a builtin keying set (XXX this isn't enabled yet so that we don't get errors on reading back files)
+	 *	- < 0: a builtin keying set
 	 */
 	if (scene->active_keyingset > 0)
 		return BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
-	else // for now...
-		return NULL; 
+	else
+		return BLI_findlink(&builtin_keyingsets, (-scene->active_keyingset)-1);
 }
 
+/* Get the index of the Keying Set provided, for the given Scene */
+int ANIM_scene_get_keyingset_index (Scene *scene, KeyingSet *ks)
+{
+	int index;
+	
+	/* if no KeyingSet provided, have none */
+	if (ks == NULL)
+		return 0;
+	
+	/* check if the KeyingSet exists in scene list */
+	if (scene) {
+		/* get index and if valid, return 
+		 *	- (absolute) Scene KeyingSets are from (>= 1)
+		 */
+		index = BLI_findindex(&scene->keyingsets, ks);
+		if (index != -1)
+			return (index + 1);
+	}
+	
+	/* still here, so try builtins list too 
+	 *	- builtins are from (<= -1)
+	 *	- none/invalid is (= 0)
+	 */
+	index = BLI_findindex(&builtin_keyingsets, ks);
+	if (index != -1)
+		return -(index + 1);
+	else
+		return 0;
+}
+
 /* Check if KeyingSet can be used in the current context */
 short ANIM_keyingset_context_ok_poll (bContext *C, KeyingSet *ks)
 {

Modified: trunk/blender/source/blender/editors/include/ED_keyframing.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_keyframing.h	2010-03-23 11:38:47 UTC (rev 27672)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list