[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18989] branches/blender2.5/blender/source /blender/editors: 2.5: Restoring Auto-Keyframing for Transforms

Joshua Leung aligorith at gmail.com
Mon Feb 16 04:02:20 CET 2009


Revision: 18989
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18989
Author:   aligorith
Date:     2009-02-16 04:01:56 +0100 (Mon, 16 Feb 2009)

Log Message:
-----------
2.5: Restoring Auto-Keyframing for Transforms 

Auto-Keyframing does not work anywhere else yet, and probably won't for a while.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/armature/poselib.c
    branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
    branches/blender2.5/blender/source/blender/editors/include/ED_keyframing.h
    branches/blender2.5/blender/source/blender/editors/space_time/time_header.c
    branches/blender2.5/blender/source/blender/editors/transform/transform.h
    branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_generics.c

Modified: branches/blender2.5/blender/source/blender/editors/armature/poselib.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/poselib.c	2009-02-15 23:48:05 UTC (rev 18988)
+++ branches/blender2.5/blender/source/blender/editors/armature/poselib.c	2009-02-16 03:01:56 UTC (rev 18989)
@@ -1203,7 +1203,7 @@
 		DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
 		
 		/* updates */
-		if (IS_AUTOKEY_MODE(NORMAL)) {
+		if (IS_AUTOKEY_MODE(scene, NORMAL)) {
 			remake_action_ipos(ob->action);
 			
 		}

Modified: branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/poseobject.c	2009-02-15 23:48:05 UTC (rev 18988)
+++ branches/blender2.5/blender/source/blender/editors/armature/poseobject.c	2009-02-16 03:01:56 UTC (rev 18989)
@@ -893,7 +893,7 @@
 	/* Update event for pose and deformation children */
 	DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
 	
-	if (IS_AUTOKEY_ON) {
+	if (IS_AUTOKEY_ON(scene)) {
 // XXX		remake_action_ipos(ob->action);
 	}
 	else {

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_keyframing.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_keyframing.h	2009-02-15 23:48:05 UTC (rev 18988)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_keyframing.h	2009-02-16 03:01:56 UTC (rev 18989)
@@ -95,9 +95,9 @@
 
 /* Auto-Keying macros for use by various tools */
 	/* check if auto-keyframing is enabled (per scene takes presidence) */
-#define IS_AUTOKEY_ON			((scene) ? (scene->autokey_mode & AUTOKEY_ON) : (U.autokey_mode & AUTOKEY_ON))
+#define IS_AUTOKEY_ON(scene)	((scene) ? (scene->autokey_mode & AUTOKEY_ON) : (U.autokey_mode & AUTOKEY_ON))
 	/* check the mode for auto-keyframing (per scene takes presidence)  */
-#define IS_AUTOKEY_MODE(mode) 	((scene) ? (scene->autokey_mode == AUTOKEY_MODE_##mode) : (U.autokey_mode == AUTOKEY_MODE_##mode))
+#define IS_AUTOKEY_MODE(scene, mode) 	((scene) ? (scene->autokey_mode == AUTOKEY_MODE_##mode) : (U.autokey_mode == AUTOKEY_MODE_##mode))
 	/* check if a flag is set for auto-keyframing (as userprefs only!) */
 #define IS_AUTOKEY_FLAG(flag)	(U.autokey_flag & AUTOKEY_FLAG_##flag)
 

Modified: branches/blender2.5/blender/source/blender/editors/space_time/time_header.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_time/time_header.c	2009-02-15 23:48:05 UTC (rev 18988)
+++ branches/blender2.5/blender/source/blender/editors/space_time/time_header.c	2009-02-16 03:01:56 UTC (rev 18989)
@@ -34,6 +34,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_windowmanager_types.h"
+#include "DNA_userdef_types.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -352,7 +353,6 @@
 
 #define B_FLIPINFOMENU 0
 #define B_NEWFRAME 0
-#define AUTOKEY_ON 0
 #define B_DIFF 0
 
 
@@ -528,16 +528,18 @@
 				 xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Skip to End frame (Shift UpArrow)");
 	xco+= XIC+8;
 	
-	uiDefIconButBitS(block, TOG, AUTOKEY_ON, REDRAWINFO, ICON_REC,
-					 xco, yco, XIC, YIC, &(scene->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones");
-	xco+= XIC;
-	if (scene->autokey_mode & AUTOKEY_ON) {
-		uiDefButS(block, MENU, REDRAWINFO, 
-				  "Auto-Keying Mode %t|Add/Replace Keys%x3|Replace Keys %x5", 
-				  xco, yco, (int)3.5*XIC, YIC, &(scene->autokey_mode), 0, 1, 0, 0, 
-				  "Mode of automatic keyframe insertion for Objects and Bones");
-		xco+= (4*XIC);
-	}
+	uiBlockBeginAlign(block);
+		uiDefIconButBitS(block, TOG, AUTOKEY_ON, REDRAWINFO, ICON_REC,
+						 xco, yco, XIC, YIC, &(scene->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones");
+		xco+= XIC;
+		if (IS_AUTOKEY_ON(scene)) {
+			uiDefButS(block, MENU, REDRAWINFO, 
+					  "Auto-Keying Mode %t|Add/Replace Keys%x3|Replace Keys %x5", 
+					  xco, yco, (int)5.5*XIC, YIC, &(scene->autokey_mode), 0, 1, 0, 0, 
+					  "Mode of automatic keyframe insertion for Objects and Bones");
+			xco+= (6*XIC);
+		}
+	uiBlockEndAlign(block);
 	
 	xco+= 16;
 	
@@ -550,10 +552,10 @@
 	MEM_freeN(menustr);
 	xco+= (6*XIC);
 	
-	uiDefIconButO(block, BUT, "ANIM_OT_delete_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_DEHLT, xco,yco,XIC,YIC, "Delete Keyframes for the Active Keying Set (Alt-I)");
-	xco+= XIC+4;
-	uiDefIconButO(block, BUT, "ANIM_OT_insert_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_HLT, xco,yco,XIC,YIC, "Insert Keyframes for the Active Keying Set (I)");
-	xco+= XIC+4;
+	uiBlockBeginAlign(block);
+		uiDefIconButO(block, BUT, "ANIM_OT_delete_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_DEHLT, xco,yco,XIC,YIC, "Delete Keyframes for the Active Keying Set (Alt-I)");
+		uiDefIconButO(block, BUT, "ANIM_OT_insert_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_HLT, xco,yco,XIC,YIC, "Insert Keyframes for the Active Keying Set (I)");
+	uiBlockEndAlign(block);
 	
 	xco+= 16;
 	

Modified: branches/blender2.5/blender/source/blender/editors/transform/transform.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform.h	2009-02-15 23:48:05 UTC (rev 18988)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform.h	2009-02-16 03:01:56 UTC (rev 18989)
@@ -49,6 +49,7 @@
 struct wmOperator;
 struct bContext;
 struct wmEvent;
+struct wmTimer;
 struct ARegion;
 
 typedef struct NDofInput {
@@ -249,6 +250,7 @@
 	struct ScrArea	*sa;
 	struct ARegion	*ar;
 	struct Scene	*scene;
+	struct wmTimer *animtimer;
     short       mval[2];        /* current mouse position               */
     struct Object   *obedit;
     void		*draw_handle;
@@ -467,9 +469,9 @@
 void transform_autoik_update(TransInfo *t, short mode);
 
 /* auto-keying stuff used by special_aftertrans_update */
-short autokeyframe_cfra_can_key(struct Object *ob);
-void autokeyframe_ob_cb_func(struct Object *ob, int tmode);
-void autokeyframe_pose_cb_func(struct Object *ob, int tmode, short targetless_ik);
+short autokeyframe_cfra_can_key(struct Scene *scene, struct Object *ob);
+void autokeyframe_ob_cb_func(struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode);
+void autokeyframe_pose_cb_func(struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode, short targetless_ik);
 
 /*********************** Constraints *****************************/
 

Modified: branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c	2009-02-15 23:48:05 UTC (rev 18988)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c	2009-02-16 03:01:56 UTC (rev 18989)
@@ -4086,69 +4086,33 @@
 }
 
 /* auto-keyframing feature - checks for whether anything should be done for the current frame */
-short autokeyframe_cfra_can_key(Object *ob)
+// TODO: this should probably be done per channel instead...
+short autokeyframe_cfra_can_key(Scene *scene, Object *ob)
 {
-#if 0 // TRANSFORM_FIX_ME
-	ListBase keys = {NULL, NULL};
-	ActKeyColumn *ak;
-	float cfra;
-	short found= 0;
+	float cfra= (float)CFRA; // XXX for now, this will do
 	
 	/* only filter if auto-key mode requires this */
-	if (IS_AUTOKEY_ON == 0)
+	if (IS_AUTOKEY_ON(scene) == 0)
 		return 0;
-	else if (IS_AUTOKEY_MODE(NORMAL)) 
+	else if (IS_AUTOKEY_MODE(scene, NORMAL)) 
 		return 1;
-	
-	/* sanity check */
-	if (ob == NULL) 
-		return 0;
-	
-	/* get keyframes that object has (bone anim is stored on ob too) */
-	if (ob->action)
-		action_to_keylist(ob->action, &keys, NULL, NULL);
-	else if (ob->ipo)
-		ipo_to_keylist(ob->ipo, &keys, NULL, NULL);
-	else
-		return 0;
-		
-	/* get current frame (will apply nla-scaling as necessary) */
-	// ack... this is messy...
-	cfra= frame_to_float(CFRA);
-	cfra= get_action_frame(ob, cfra);
-	
-	/* check if a keyframe occurs on current frame */
-	for (ak= keys.first; ak; ak= ak->next) {
-		if (IS_EQ(cfra, ak->cfra)) {
-			found= 1;
-			break;
-		}
-	}
-	
-	/* free temp list */
-	BLI_freelistN(&keys);
-	
-	return found;
-#endif
-return 0;
+	else 
+		return id_frame_has_keyframe(&ob->id, cfra, ANIMFILTER_KEYS_LOCAL);
 }
 
 /* auto-keyframing feature - for objects 
  * 	tmode: should be a transform mode 
  */
-void autokeyframe_ob_cb_func(Object *ob, int tmode)
+void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
 {
-#if 0 // TRANSFORM_FIX_ME
-	ID *id= (ID *)(ob);
-	IpoCurve *icu;
+	ID *id= &ob->id;
+	FCurve *fcu;
 	
-	if (autokeyframe_cfra_can_key(ob)) {
-		char *actname = NULL;
+	if (autokeyframe_cfra_can_key(scene, ob)) {
+		AnimData *adt= ob->adt;
+		float cfra= (float)CFRA; // xxx this will do for now
 		short flag = 0;
 		
-		if (ob->ipoflag & OB_ACTION_OB)
-			actname= "Object";
-			
 		if (IS_AUTOKEY_FLAG(INSERTNEEDED))
 			flag |= INSERTKEY_NEEDED;
 		if (IS_AUTOKEY_FLAG(AUTOMATKEY))
@@ -4156,23 +4120,11 @@
 		
 		if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
 			/* only key on available channels */
-			if ((ob->ipo) || (ob->action)) {
-				if (ob->action && actname) {
-					bActionChannel *achan;
-					achan= get_action_channel(ob->action, actname);
-					
-					if (achan && achan->ipo)
-						icu= achan->ipo->curve.first;
-					else
-						icu= NULL;
+			if (adt && adt->action) {
+				for (fcu= adt->action->curves.first; fcu; fcu= fcu->next) {
+					fcu->flag &= ~FCURVE_SELECTED;
+					insertkey(id, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
 				}
-				else 
-					icu= ob->ipo->curve.first;
-				
-				for (; icu; icu= icu->next) {
-					icu->flag &= ~IPO_SELECT;
-					insertkey(id, ID_OB, actname, NULL, icu->adrcode, flag);
-				}
 			}
 		}
 		else if (IS_AUTOKEY_FLAG(INSERTNEEDED)) {
@@ -4183,88 +4135,85 @@
 				doLoc = 1;
 			}
 			else if (tmode == TFM_ROTATION) {
-				if (G.vd->around == V3D_ACTIVE) {
+				if (v3d->around == V3D_ACTIVE) {
 					if (ob != OBACT)
 						doLoc = 1;
 				}
-				else if (G.vd->around == V3D_CURSOR)
+				else if (v3d->around == V3D_CURSOR)
 					doLoc = 1;	
 				
-				if ((G.vd->flag & V3D_ALIGN)==0) 
+				if ((v3d->flag & V3D_ALIGN)==0) 
 					doRot = 1;
 			}

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list