[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25359] trunk/blender: Keyframing Bugfixes and Feature Requests:

Joshua Leung aligorith at gmail.com
Mon Dec 14 13:09:22 CET 2009


Revision: 25359
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25359
Author:   aligorith
Date:     2009-12-14 13:09:20 +0100 (Mon, 14 Dec 2009)

Log Message:
-----------
Keyframing Bugfixes and Feature Requests:

* Added a User-Pref option for the "XYZ to RGB" colour-mode setting for new F-Curves to compliment the one used for Keying Sets. With this option enabled, the builtin Keying Sets also can obey this option.

* Made all places that were previously manually checking the flags for keyframing to use a standard API function to do this now.

* Fixed bug introduced earlier today in commit 25353 by reverting the changes to keyingsets.c. Forgot that delete_keyframe doesn't handle do the "entire array" hack with array_index = -1

* Fixed bug with the insert-keyframe code for the array_index = -1 case, where too many channels were being keyed (i.e. an imaginary channel was often keyed in addition to the valid ones)

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_userpref.py
    trunk/blender/source/blender/editors/animation/anim_channels_defines.c
    trunk/blender/source/blender/editors/animation/keyframing.c
    trunk/blender/source/blender/editors/animation/keyingsets.c
    trunk/blender/source/blender/editors/include/ED_keyframing.h
    trunk/blender/source/blender/editors/interface/interface_anim.c
    trunk/blender/source/blender/editors/space_action/action_edit.c
    trunk/blender/source/blender/editors/space_graph/graph_edit.c
    trunk/blender/source/blender/editors/transform/transform_conversions.c
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/makesrna/intern/rna_animation.c
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c

Modified: trunk/blender/release/scripts/ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref.py	2009-12-14 10:52:02 UTC (rev 25358)
+++ trunk/blender/release/scripts/ui/space_userpref.py	2009-12-14 12:09:20 UTC (rev 25359)
@@ -213,6 +213,7 @@
 
         col.label(text="New F-Curve Defaults:")
         col.prop(edit, "new_interpolation_type", text="Interpolation")
+        col.prop(edit, "insertkey_xyz_to_rgb", text="XYZ to RGB")
 
         col.separator()
 

Modified: trunk/blender/source/blender/editors/animation/anim_channels_defines.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_defines.c	2009-12-14 10:52:02 UTC (rev 25358)
+++ trunk/blender/source/blender/editors/animation/anim_channels_defines.c	2009-12-14 12:09:20 UTC (rev 25359)
@@ -2395,14 +2395,8 @@
 	cfra= (float)CFRA;
 	
 	/* get flags for keyframing */
-	if (IS_AUTOKEY_FLAG(INSERTNEEDED))
-		flag |= INSERTKEY_NEEDED;
-	if (IS_AUTOKEY_FLAG(AUTOMATKEY))
-		flag |= INSERTKEY_MATRIX;
-	if (IS_AUTOKEY_MODE(scene, EDITKEYS))
-		flag |= INSERTKEY_REPLACE;
+	flag = ANIM_get_keyframing_flags(scene, 1);
 	
-	
 	/* get RNA pointer, and resolve the path */
 	RNA_id_pointer_create(id, &id_ptr);
 	
@@ -2438,14 +2432,8 @@
 	cfra= (float)CFRA;
 	
 	/* get flags for keyframing */
-	if (IS_AUTOKEY_FLAG(INSERTNEEDED))
-		flag |= INSERTKEY_NEEDED;
-	if (IS_AUTOKEY_FLAG(AUTOMATKEY))
-		flag |= INSERTKEY_MATRIX;
-	if (IS_AUTOKEY_MODE(scene, EDITKEYS))
-		flag |= INSERTKEY_REPLACE;
+	flag = ANIM_get_keyframing_flags(scene, 1);
 	
-	
 	/* get RNA pointer, and resolve the path */
 	RNA_id_pointer_create((ID *)key, &id_ptr);
 	

Modified: trunk/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframing.c	2009-12-14 10:52:02 UTC (rev 25358)
+++ trunk/blender/source/blender/editors/animation/keyframing.c	2009-12-14 12:09:20 UTC (rev 25359)
@@ -80,6 +80,40 @@
 
 #include "anim_intern.h"
 
+/* ************************************************** */
+/* Keyframing Setting Wrangling */
+
+/* Get the active settings for keyframing settings from context (specifically the given scene) */
+short ANIM_get_keyframing_flags (Scene *scene, short incl_mode)
+{
+	short flag = 0;
+	
+	/* standard flags */
+	{
+		/* visual keying */
+		if (IS_AUTOKEY_FLAG(AUTOMATKEY)) 
+			flag |= INSERTKEY_MATRIX;
+		
+		/* only needed */
+		if (IS_AUTOKEY_FLAG(INSERTNEEDED)) 
+			flag |= INSERTKEY_NEEDED;
+		
+		/* default F-Curve color mode - RGB from XYZ indicies */
+		if (IS_AUTOKEY_FLAG(XYZ2RGB)) 
+			flag |= INSERTKEY_XYZ2RGB;
+	}
+		
+	/* only if including settings from the autokeying mode... */
+	if (incl_mode) 
+	{ 
+		/* keyframing mode - only replace existing keyframes */
+		if (IS_AUTOKEY_MODE(scene, EDITKEYS)) 
+			flag |= INSERTKEY_REPLACE;
+	}
+		
+	return flag;
+}
+
 /* ******************************************* */
 /* Animation Data Validation */
 
@@ -838,7 +872,7 @@
 	/* key entire array convenience method */
 	if (array_index == -1) { 
 		array_index= 0;
-		array_index_max= RNA_property_array_length(&ptr, prop) + 1;
+		array_index_max= RNA_property_array_length(&ptr, prop);
 	}
 	
 	/* will only loop once unless the array index was -1 */
@@ -1326,12 +1360,7 @@
 	short flag = 0;
 	
 	/* flags for inserting keyframes */
-	if (IS_AUTOKEY_FLAG(AUTOMATKEY))
-		flag |= INSERTKEY_MATRIX;
-	if (IS_AUTOKEY_FLAG(INSERTNEEDED))
-		flag |= INSERTKEY_NEEDED;
-	if (IS_AUTOKEY_MODE(scene, EDITKEYS))
-		flag |= INSERTKEY_REPLACE;
+	flag = ANIM_get_keyframing_flags(scene, 1);
 	
 	/* try to insert keyframe using property retrieved from UI */
 	memset(&ptr, 0, sizeof(PointerRNA));

Modified: trunk/blender/source/blender/editors/animation/keyingsets.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyingsets.c	2009-12-14 10:52:02 UTC (rev 25358)
+++ trunk/blender/source/blender/editors/animation/keyingsets.c	2009-12-14 12:09:20 UTC (rev 25359)
@@ -133,11 +133,9 @@
 	 */
 	flag |= KEYINGSET_ABSOLUTE;
 	
-	if (IS_AUTOKEY_FLAG(AUTOMATKEY)) 
-		keyingflag |= INSERTKEY_MATRIX;
-	if (IS_AUTOKEY_FLAG(INSERTNEEDED)) 
-		keyingflag |= INSERTKEY_NEEDED;
-		
+	/* 2nd arg is 0 to indicate that we don't want to include autokeying mode related settings */
+	keyingflag = ANIM_get_keyframing_flags(scene, 0);
+	
 	/* call the API func, and set the active keyingset index */
 	BKE_keyingset_add(&scene->keyingsets, NULL, flag, keyingflag);
 	
@@ -326,6 +324,8 @@
 			keyingflag |= INSERTKEY_MATRIX;
 		if (IS_AUTOKEY_FLAG(INSERTNEEDED)) 
 			keyingflag |= INSERTKEY_NEEDED;
+		if (IS_AUTOKEY_FLAG(XYZ2RGB)) 
+			keyingflag |= INSERTKEY_XYZ2RGB;
 			
 		/* call the API func, and set the active keyingset index */
 		ks= BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", flag, keyingflag);
@@ -1305,9 +1305,7 @@
 		kflag= ks->keyingflag;
 		
 		/* suppliment with info from the context */
-		if (IS_AUTOKEY_FLAG(AUTOMATKEY)) kflag |= INSERTKEY_MATRIX;
-		if (IS_AUTOKEY_FLAG(INSERTNEEDED)) kflag |= INSERTKEY_NEEDED;
-		if (IS_AUTOKEY_MODE(scene, EDITKEYS)) kflag |= INSERTKEY_REPLACE;
+		kflag |= ANIM_get_keyframing_flags(scene, 1);
 	}
 	else if (mode == MODIFYKEY_MODE_DELETE)
 		kflag= 0;
@@ -1318,7 +1316,7 @@
 		 * provided by the user, and is stored, ready to use, in the KeyingSet paths.
 		 */
 		for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
-			int i;
+			int arraylen, i;
 			
 			/* get pointer to name of group to add channels to */
 			if (ksp->groupmode == KSP_GROUP_NONE)
@@ -1328,15 +1326,37 @@
 			else
 				groupname= ksp->group;
 			
-			/* passing -1 as the array_index results in the entire array being modified */
-			i= (ksp->flag & KSP_FLAG_WHOLE_ARRAY) ? (-1) : (ksp->array_index);
+			/* init arraylen and i - arraylen should be greater than i so that
+			 * normal non-array entries get keyframed correctly
+			 */
+			i= ksp->array_index;
+			arraylen= i;
 			
-			/* action to take depends on mode */
-			if (mode == MODIFYKEY_MODE_INSERT)
-				success += insert_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag);
-			else if (mode == MODIFYKEY_MODE_DELETE)
-				success += delete_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag);
+			/* get length of array if whole array option is enabled */
+			if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) {
+				PointerRNA id_ptr, ptr;
+				PropertyRNA *prop;
+				
+				RNA_id_pointer_create(ksp->id, &id_ptr);
+				if (RNA_path_resolve(&id_ptr, ksp->rna_path, &ptr, &prop) && prop)
+					arraylen= RNA_property_array_length(&ptr, prop);
+			}
 			
+			/* we should do at least one step */
+			if (arraylen == i)
+				arraylen++;
+			
+			/* for each possible index, perform operation 
+			 *	- assume that arraylen is greater than index
+			 */
+			for (; i < arraylen; i++) {
+				/* action to take depends on mode */
+				if (mode == MODIFYKEY_MODE_INSERT)
+					success += insert_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag);
+				else if (mode == MODIFYKEY_MODE_DELETE)
+					success += delete_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag);
+			}
+			
 			/* set recalc-flags */
 			if (ksp->id) {
 				switch (GS(ksp->id->name)) {
@@ -1364,7 +1384,7 @@
 			for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
 				DynStr *pathds= BLI_dynstr_new();
 				char *path = NULL;
-				int i;
+				int arraylen, i;
 				
 				/* set initial group name */
 				if (cks->id == NULL) {
@@ -1439,15 +1459,33 @@
 				else if (ksp->groupmode == KSP_GROUP_NAMED)
 					groupname= ksp->group;
 				
-				/* passing -1 as the array_index results in the entire array being modified */
-				i= (ksp->flag & KSP_FLAG_WHOLE_ARRAY) ? (-1) : (ksp->array_index);
+				/* init arraylen and i - arraylen should be greater than i so that
+				 * normal non-array entries get keyframed correctly
+				 */
+				i= ksp->array_index;
+				arraylen= i+1;
 				
-				/* action to take depends on mode */
-				if (mode == MODIFYKEY_MODE_INSERT)
-					success+= insert_keyframe(cks->id, act, groupname, path, i, cfra, kflag);
-				else if (mode == MODIFYKEY_MODE_DELETE)
-					success+= delete_keyframe(cks->id, act, groupname, path, i, cfra, kflag);
+				/* get length of array if whole array option is enabled */
+				if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) {
+					PointerRNA id_ptr, ptr;
+					PropertyRNA *prop;
+					
+					RNA_id_pointer_create(cks->id, &id_ptr);
+					if (RNA_path_resolve(&id_ptr, path, &ptr, &prop) && prop)
+						arraylen= RNA_property_array_length(&ptr, prop);
+				}
 				
+				/* for each possible index, perform operation 
+				 *	- assume that arraylen is greater than index
+				 */
+				for (; i < arraylen; i++) {
+					/* action to take depends on mode */
+					if (mode == MODIFYKEY_MODE_INSERT)
+						success+= insert_keyframe(cks->id, act, groupname, path, i, cfra, kflag);
+					else if (mode == MODIFYKEY_MODE_DELETE)
+						success+= delete_keyframe(cks->id, act, groupname, path, i, cfra, kflag);
+				}
+				
 				/* free the path */
 				MEM_freeN(path);
 			}

Modified: trunk/blender/source/blender/editors/include/ED_keyframing.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_keyframing.h	2009-12-14 10:52:02 UTC (rev 25358)
+++ trunk/blender/source/blender/editors/include/ED_keyframing.h	2009-12-14 12:09:20 UTC (rev 25359)
@@ -49,6 +49,13 @@
 
 /* ************ Keyframing Management **************** */
 
+/* Get the active settings for keyframing settings from context (specifically the given scene) 
+ *	- incl_mode: include settings from keyframing mode in the result (i.e. replace only)
+ */
+short ANIM_get_keyframing_flags(struct Scene *scene, short incl_mode);
+
+/* -------- */
+
 /* Get (or add relevant data to be able to do so) the Active Action for the given 
  * Animation Data block, given an ID block where the Animation Data should reside.
  */

Modified: trunk/blender/source/blender/editors/interface/interface_anim.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_anim.c	2009-12-14 10:52:02 UTC (rev 25358)
+++ trunk/blender/source/blender/editors/interface/interface_anim.c	2009-12-14 12:09:20 UTC (rev 25359)
@@ -147,15 +147,8 @@
 		

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list