[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23702] trunk/blender/source/blender/ editors: Bugfix #19576: Auto keyframing does not record rotations on object level animation

Joshua Leung aligorith at gmail.com
Thu Oct 8 07:53:26 CEST 2009


Revision: 23702
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23702
Author:   aligorith
Date:     2009-10-08 07:53:26 +0200 (Thu, 08 Oct 2009)

Log Message:
-----------
Bugfix #19576: Auto keyframing does not record rotations on object level animation

The hardcoded paths for rotation keyframes on objects got broken by my commits to rename the rotation properties. I've taken this opportunity to recode the auto-keyframing code here to use the builtin keyingsets instead of going through and manually calling insert_keyframe(), thus preventing this problem in future.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/keyframing.c
    trunk/blender/source/blender/editors/animation/keyingsets.c
    trunk/blender/source/blender/editors/armature/poseSlide.c
    trunk/blender/source/blender/editors/armature/poselib.c
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/include/ED_keyframing.h
    trunk/blender/source/blender/editors/transform/transform_conversions.c

Modified: trunk/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframing.c	2009-10-08 05:02:04 UTC (rev 23701)
+++ trunk/blender/source/blender/editors/animation/keyframing.c	2009-10-08 05:53:26 UTC (rev 23702)
@@ -981,12 +981,15 @@
 	}
 	
 	/* try to insert keyframes for the channels specified by KeyingSet */
-	success= modify_keyframes(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
-	printf("KeyingSet '%s' - Successfully added %d Keyframes \n", ks->name, success);
+	success= modify_keyframes(scene, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+	if (G.f & G_DEBUG)
+		printf("KeyingSet '%s' - Successfully added %d Keyframes \n", ks->name, success);
 	
 	/* report failure? */
 	if (success == 0)
 		BKE_report(op->reports, RPT_WARNING, "Keying Set failed to insert any keyframes");
+	else
+		WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
 	
 	/* free temp context-data if available */
 	if (dsources.first) {
@@ -995,11 +998,8 @@
 	}
 	
 	/* send updates */
-	ED_anim_dag_flush_update(C);	
+	ED_anim_dag_flush_update(C);
 	
-	/* for now, only send ND_KEYS for KeyingSets */
-	WM_event_add_notifier(C, ND_KEYS, NULL);
-	
 	return OPERATOR_FINISHED;
 }
 
@@ -1132,12 +1132,15 @@
 	}
 	
 	/* try to insert keyframes for the channels specified by KeyingSet */
-	success= modify_keyframes(C, &dsources, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
-	printf("KeyingSet '%s' - Successfully removed %d Keyframes \n", ks->name, success);
+	success= modify_keyframes(scene, &dsources, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
+	if (G.f & G_DEBUG)
+		printf("KeyingSet '%s' - Successfully removed %d Keyframes \n", ks->name, success);
 	
 	/* report failure? */
 	if (success == 0)
 		BKE_report(op->reports, RPT_WARNING, "Keying Set failed to remove any keyframes");
+	else
+		WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
 	
 	/* free temp context-data if available */
 	if (dsources.first) {
@@ -1148,9 +1151,6 @@
 	/* send updates */
 	ED_anim_dag_flush_update(C);	
 	
-	/* for now, only send ND_KEYS for KeyingSets */
-	WM_event_add_notifier(C, ND_KEYS, NULL);
-	
 	return OPERATOR_FINISHED;
 }
 

Modified: trunk/blender/source/blender/editors/animation/keyingsets.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyingsets.c	2009-10-08 05:02:04 UTC (rev 23701)
+++ trunk/blender/source/blender/editors/animation/keyingsets.c	2009-10-08 05:53:26 UTC (rev 23702)
@@ -1252,9 +1252,8 @@
  * by the KeyingSet. This takes into account many of the different combinations of using KeyingSets.
  * Returns the number of channels that keyframes were added to
  */
-int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra)
+int modify_keyframes (Scene *scene, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra)
 {
-	Scene *scene= CTX_data_scene(C);
 	KS_Path *ksp;
 	int kflag=0, success= 0;
 	char *groupname= NULL;
@@ -1319,24 +1318,16 @@
 					success+= delete_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag);
 			}
 			
-			/* send notifiers and set recalc-flags */
-			// TODO: hopefully this doesn't result in execessive flooding of the notifier stack
-			if (C && ksp->id) {
+			/* set recalc-flags */
+			if (ksp->id) {
 				switch (GS(ksp->id->name)) {
 					case ID_OB: /* Object (or Object-Related) Keyframes */
 					{
 						Object *ob= (Object *)ksp->id;
 						
 						ob->recalc |= OB_RECALC;
-						WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, ksp->id);
 					}
 						break;
-					case ID_MA: /* Material Keyframes */
-						WM_event_add_notifier(C, NC_MATERIAL|ND_KEYS, ksp->id);
-						break;
-					default: /* Any keyframes */
-						WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
-						break;
 				}
 			}
 		}
@@ -1457,24 +1448,16 @@
 				MEM_freeN(path);
 			}
 			
-			/* send notifiers and set recalc-flags */
-			// TODO: hopefully this doesn't result in execessive flooding of the notifier stack
-			if (C && cks->id) {
+			/* set recalc-flags */
+			if (cks->id) {
 				switch (GS(cks->id->name)) {
 					case ID_OB: /* Object (or Object-Related) Keyframes */
 					{
 						Object *ob= (Object *)cks->id;
 						
 						ob->recalc |= OB_RECALC;
-						WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, cks->id);
 					}
 						break;
-					case ID_MA: /* Material Keyframes */
-						WM_event_add_notifier(C, NC_MATERIAL|ND_KEYS, cks->id);
-						break;
-					default: /* Any keyframes */
-						WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
-						break;
 				}
 			}
 		}

Modified: trunk/blender/source/blender/editors/armature/poseSlide.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseSlide.c	2009-10-08 05:02:04 UTC (rev 23701)
+++ trunk/blender/source/blender/editors/armature/poseSlide.c	2009-10-08 05:53:26 UTC (rev 23702)
@@ -560,11 +560,11 @@
 			
 			/* insert keyframes */
 			if (pchan->flag & POSE_LOC)
-				modify_keyframes(C, &dsources, NULL, pso->ks_loc, MODIFYKEY_MODE_INSERT, (float)pso->cframe);
+				modify_keyframes(pso->scene, &dsources, NULL, pso->ks_loc, MODIFYKEY_MODE_INSERT, (float)pso->cframe);
 			if (pchan->flag & POSE_ROT)
-				modify_keyframes(C, &dsources, NULL, pso->ks_rot, MODIFYKEY_MODE_INSERT, (float)pso->cframe);
+				modify_keyframes(pso->scene, &dsources, NULL, pso->ks_rot, MODIFYKEY_MODE_INSERT, (float)pso->cframe);
 			if (pchan->flag & POSE_SIZE)
-				modify_keyframes(C, &dsources, NULL, pso->ks_scale, MODIFYKEY_MODE_INSERT, (float)pso->cframe);
+				modify_keyframes(pso->scene, &dsources, NULL, pso->ks_scale, MODIFYKEY_MODE_INSERT, (float)pso->cframe);
 		}
 	}
 }

Modified: trunk/blender/source/blender/editors/armature/poselib.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poselib.c	2009-10-08 05:02:04 UTC (rev 23701)
+++ trunk/blender/source/blender/editors/armature/poselib.c	2009-10-08 05:53:26 UTC (rev 23702)
@@ -329,6 +329,7 @@
 
 static int poselib_add_exec (bContext *C, wmOperator *op)
 {
+	Scene *scene= CTX_data_scene(C);
 	Object *ob= CTX_data_active_object(C);
 	bAction *act = poselib_validate(ob);
 	bArmature *arm= (ob) ? ob->data : NULL;
@@ -385,7 +386,7 @@
 				/* KeyingSet to use depends on rotation mode (but that's handled by the templates code)  */
 				if (poselib_ks_locrotscale == NULL)
 					poselib_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
-				modify_keyframes(C, &dsources, act, poselib_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)frame);
+				modify_keyframes(scene, &dsources, act, poselib_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)frame);
 			}
 		}
 	}
@@ -772,7 +773,7 @@
 					cks.pchan= pchan;
 					
 					/* now insert the keyframe */
-					modify_keyframes(C, &dsources, NULL, poselib_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
+					modify_keyframes(scene, &dsources, NULL, poselib_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
 					
 					/* clear any unkeyed tags */
 					if (pchan->bone)
@@ -783,10 +784,12 @@
 					if (pchan->bone)
 						pchan->bone->flag |= BONE_UNKEYED;
 				}
-		
 			}
 		}
 	}
+	
+	/* send notifiers for this */
+	WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
 }
 
 /* Apply the relevant changes to the pose */

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c	2009-10-08 05:02:04 UTC (rev 23701)
+++ trunk/blender/source/blender/editors/armature/poseobject.c	2009-10-08 05:53:26 UTC (rev 23702)
@@ -1089,7 +1089,7 @@
 					/* init cks for this PoseChannel, then use the relative KeyingSets to keyframe it */
 					cks.pchan= pchan;
 					
-					modify_keyframes(C, &dsources, NULL, posePaste_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
+					modify_keyframes(scene, &dsources, NULL, posePaste_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
 					
 					/* clear any unkeyed tags */
 					if (chan->bone)
@@ -1118,6 +1118,7 @@
 	
 	/* notifiers for updates */
 	WM_event_add_notifier(C, NC_OBJECT|ND_POSE|ND_TRANSFORM, ob);
+	WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); // XXX not really needed, but here for completeness...
 
 	return OPERATOR_FINISHED;
 }

Modified: trunk/blender/source/blender/editors/include/ED_keyframing.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_keyframing.h	2009-10-08 05:02:04 UTC (rev 23701)
+++ trunk/blender/source/blender/editors/include/ED_keyframing.h	2009-10-08 05:53:26 UTC (rev 23702)
@@ -122,7 +122,7 @@
 } eModifyKey_Modes;
 
 /* Keyframing Helper Call - use the provided Keying Set to Add/Remove Keyframes */
-int modify_keyframes(struct bContext *C, struct ListBase *dsources, struct bAction *act, struct KeyingSet *ks, short mode, float cfra);
+int modify_keyframes(struct Scene *scene, struct ListBase *dsources, struct bAction *act, struct KeyingSet *ks, short mode, float cfra);
 
 /* -------- */
 

Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c	2009-10-08 05:02:04 UTC (rev 23701)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c	2009-10-08 05:53:26 UTC (rev 23702)
@@ -4242,10 +4242,15 @@
 
 	// TODO: this should probably be done per channel instead...
 	if (autokeyframe_cfra_can_key(scene, id)) {
-		AnimData *adt= ob->adt;
+		bCommonKeySrc cks;
+		ListBase dsources = {&cks, &cks};
 		float cfra= (float)CFRA; // xxx this will do for now
 		short flag = 0;
 		
+		/* init common-key-source for use by KeyingSets */
+		memset(&cks, 0, sizeof(bCommonKeySrc));
+		cks.id= &ob->id;
+		
 		if (IS_AUTOKEY_FLAG(INSERTNEEDED))
 			flag |= INSERTKEY_NEEDED;
 		if (IS_AUTOKEY_FLAG(AUTOMATKEY))
@@ -4254,6 +4259,8 @@
 			flag |= INSERTKEY_REPLACE;
 			
 		if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
+			AnimData *adt= ob->adt;
+			
 			/* only key on available channels */
 			if (adt && adt->action) {
 				for (fcu= adt->action->curves.first; fcu; fcu= fcu->next) {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list