[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28070] trunk/blender/source/blender/ editors: Auto Keyframing:

Joshua Leung aligorith at gmail.com
Wed Apr 7 13:27:59 CEST 2010


Revision: 28070
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28070
Author:   aligorith
Date:     2010-04-07 13:27:59 +0200 (Wed, 07 Apr 2010)

Log Message:
-----------
Auto Keyframing:

Made 'PoseLib', 'Pose Paste', and 'Transforms' use the active KeyingSet instead of a hardcoded one if there is an active KeyingSet and the 'Only Insert for Keying Set' option is enabled in the User Prefs.

Also, made sure that for transforms, the active KeyingSet is provided with the data being modified instead of having them retrieve this from the context (which may miss a few items).

---

While making the changes for pose paste, made pasting poses not destroy the existing properties on the bones if the buffer bones didn't have any properties to replace the old ones with. IMO, this seems a bit too destructive if they don't get replaced, but perhaps in some cases not removing causes some problems with bad poses? 

Modified Paths:
--------------
    trunk/blender/source/blender/editors/armature/poselib.c
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/transform/transform_conversions.c

Modified: trunk/blender/source/blender/editors/armature/poselib.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poselib.c	2010-04-07 10:26:53 UTC (rev 28069)
+++ trunk/blender/source/blender/editors/armature/poselib.c	2010-04-07 11:27:59 UTC (rev 28070)
@@ -769,12 +769,19 @@
 			if (pchan) {
 				if (autokeyframe_cfra_can_key(scene, &pld->ob->id)) {
 					ListBase dsources = {NULL, NULL};
+					KeyingSet *ks = NULL;
 					
-					/* get KeyingSet to use */
-					// TODO: for getting the KeyingSet used, we should really check which channels were affected
-					// TODO: this should get modified so that custom props are taken into account too!
+					/* get KeyingSet to use 
+					 *	- use the active KeyingSet if defined (and user wants to use it for all autokeying), 
+					 * 	  or otherwise key transforms only
+					 */
 					if (poselib_ks_locrotscale == NULL)
 						poselib_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
+					 
+					if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
+						ks = ANIM_scene_get_active_keyingset(scene);
+					else 
+						ks = ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
 					
 					/* now insert the keyframe(s) using the Keying Set
 					 *	1) add datasource override for the PoseChannel
@@ -782,7 +789,7 @@
 					 *	3) free the extra info 
 					 */
 					ANIM_relative_keyingset_add_source(&dsources, &pld->ob->id, &RNA_PoseBone, pchan); 
-					ANIM_apply_keyingset(C, &dsources, NULL, poselib_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
+					ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
 					BLI_freelistN(&dsources);
 					
 					/* clear any unkeyed tags */

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c	2010-04-07 10:26:53 UTC (rev 28069)
+++ trunk/blender/source/blender/editors/armature/poseobject.c	2010-04-07 11:27:59 UTC (rev 28070)
@@ -892,9 +892,6 @@
 
 /* ---- */
 
-/* Pointers to the builtin KeyingSets that we want to use */
-static KeyingSet *posePaste_ks_locrotscale = NULL;		/* the only keyingset we'll need */
-
 static int pose_paste_exec (bContext *C, wmOperator *op)
 {
 	Scene *scene= CTX_data_scene(C);
@@ -937,6 +934,10 @@
 					if (pchan->rotmode > 0) {
 						VECCOPY(pchan->eul, chan->eul);
 					}
+					else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
+						VECCOPY(pchan->rotAxis, chan->rotAxis);
+						pchan->rotAngle = chan->rotAngle;
+					}
 					else {
 						QUATCOPY(pchan->quat, chan->quat);
 					}
@@ -979,13 +980,6 @@
 						eul[1]*= -1;
 						eul[2]*= -1;
 						eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, eul, EULER_ORDER_DEFAULT);
-						
-						// experimental method (uncomment to test):
-#if 0
-						/* experimental method: just flip the orientation of the axis on x/y axes */
-						pchan->quat[1] *= -1;
-						pchan->quat[2] *= -1;
-#endif
 					}
 					else {
 						float eul[3];
@@ -997,25 +991,36 @@
 					}
 				}
 				
-				/* ID property */
-				if (pchan->prop) {
-					IDP_FreeProperty(pchan->prop);
-					MEM_freeN(pchan->prop);
-					pchan->prop= NULL;
+				/* ID properties 
+				 *	- only free the existing properties if the channel we're copying from has them
+				 * 	  NOTE: this means that if the pose depends on some pchan property, the pose may not be ok,
+				 *		    but this is better than loosing all the setting you've painstakingly added...
+				 */
+				if (chan->prop) {
+					/* free the old properties since we want to replace them now */
+					if (pchan->prop) {
+						IDP_FreeProperty(pchan->prop);
+						MEM_freeN(pchan->prop);
+						pchan->prop= NULL;
+					}
+					
+					/* now copy over the new copy of the properties */
+					pchan->prop= IDP_CopyProperty(chan->prop);	
 				}
 				
-				if (chan->prop)
-					pchan->prop= IDP_CopyProperty(chan->prop);
-				
 				/* keyframing tagging */
-				if (autokeyframe_cfra_can_key(scene, &ob->id)) {	
+				if (autokeyframe_cfra_can_key(scene, &ob->id)) {
 					ListBase dsources = {NULL, NULL};
+					KeyingSet *ks = NULL;
 					
-					/* get KeyingSet to use */
-					// TODO: for getting the KeyingSet used, we should really check which channels were affected
-					// TODO: this should get modified so that custom props are taken into account too!
-					if (posePaste_ks_locrotscale == NULL)
-						posePaste_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
+					/* get KeyingSet to use 
+					 *	- use the active KeyingSet if defined (and user wants to use it for all autokeying), 
+					 * 	  or otherwise key transforms only
+					 */
+					if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
+						ks = ANIM_scene_get_active_keyingset(scene);
+					else 
+						ks = ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
 					
 					/* now insert the keyframe(s) using the Keying Set
 					 *	1) add datasource override for the PoseChannel
@@ -1023,7 +1028,7 @@
 					 *	3) free the extra info 
 					 */
 					ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan); 
-					ANIM_apply_keyingset(C, &dsources, NULL, posePaste_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
+					ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
 					BLI_freelistN(&dsources);
 					
 					/* clear any unkeyed tags */

Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c	2010-04-07 10:26:53 UTC (rev 28069)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c	2010-04-07 11:27:59 UTC (rev 28070)
@@ -4451,7 +4451,7 @@
 			/* only insert into active keyingset 
 			 * NOTE: we assume here that the active Keying Set does not need to have its iterator overridden spe
 			 */
-			ANIM_apply_keyingset(C, NULL, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra);
+			ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra);
 		}
 		else if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
 			AnimData *adt= ob->adt;
@@ -4560,9 +4560,9 @@
 				ANIM_relative_keyingset_add_source(&dsources, id, &RNA_PoseBone, pchan); 
 				
 				/* only insert into active keyingset? */
-				// TODO: move this first case out of the loop
 				if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (active_ks)) {
-					ANIM_apply_keyingset(C, NULL, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra);
+					/* run the active Keying Set on the current datasource */
+					ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra);
 				}
 				/* only insert into available channels? */
 				else if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {





More information about the Bf-blender-cvs mailing list