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

Joshua Leung aligorith at gmail.com
Sat Jun 23 08:56:16 CEST 2007


Revision: 11028
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11028
Author:   aligorith
Date:     2007-06-23 08:56:16 +0200 (Sat, 23 Jun 2007)

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

I've moved the Auto-Keyframing functionality out of the special_aftertrans_update function into two separate functions, which can be called independent of the Transform system. One is for Bones, while the other is for Objects.

This now means that the Shift-S Snapping Tools will now work with auto-keyframing. 

Modified Paths:
--------------
    trunk/blender/source/blender/include/transform.h
    trunk/blender/source/blender/src/edit.c
    trunk/blender/source/blender/src/transform_conversions.c

Modified: trunk/blender/source/blender/include/transform.h
===================================================================
--- trunk/blender/source/blender/include/transform.h	2007-06-23 05:28:07 UTC (rev 11027)
+++ trunk/blender/source/blender/include/transform.h	2007-06-23 06:56:16 UTC (rev 11028)
@@ -44,6 +44,7 @@
 struct Object;
 struct View3D;
 struct ScrArea;
+struct bPose;
 
 
 typedef struct NumInput {
@@ -344,6 +345,10 @@
 void add_tdi_poin(float *poin, float *old, float delta);
 void special_aftertrans_update(TransInfo *t);
 
+/* auto-keying stuff used by special_aftertrans_update */
+void autokeyframe_ob_cb_func(struct Object *ob, int tmode);
+void autokeyframe_pose_cb_func(struct Object *ob, int tmode, short targetless_ik);
+
 /*********************** Constraints *****************************/
 
 void getConstraintMatrix(TransInfo *t);

Modified: trunk/blender/source/blender/src/edit.c
===================================================================
--- trunk/blender/source/blender/src/edit.c	2007-06-23 05:28:07 UTC (rev 11027)
+++ trunk/blender/source/blender/src/edit.c	2007-06-23 06:56:16 UTC (rev 11028)
@@ -120,6 +120,7 @@
 /*#include "armature.h"*/
 /*  #include "edit.h" */
 #include "nla.h"
+#include "transform.h"
 
 #ifdef __NLA
 #include "BIF_editarmature.h"
@@ -1209,7 +1210,10 @@
 					}
 				}
 				ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
-				ob->recalc |= OB_RECALC_DATA;
+				
+				/* autokeyframing */
+				autokeyframe_pose_cb_func(ob, TFM_TRANSLATION, 0);
+				DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
 			}
 			else {
 				ob->recalc |= OB_RECALC_OB;
@@ -1235,6 +1239,9 @@
 #ifdef WITH_VERSE
 				if(ob->vnode) b_verse_send_transformation(ob);
 #endif
+			
+				/* auto-keyframing */
+				autokeyframe_ob_cb_func(ob, TFM_TRANSLATION);
 			}
 		}
 
@@ -1318,7 +1325,10 @@
 					}
 				}
 				ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
-				ob->recalc |= OB_RECALC_DATA;
+				
+				/* autokeyframing */
+				autokeyframe_pose_cb_func(ob, TFM_TRANSLATION, 0);
+				DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
 			}
 			else {
 				ob->recalc |= OB_RECALC_OB;
@@ -1344,6 +1354,9 @@
 #ifdef WITH_VERSE
 				if(ob->vnode) b_verse_send_transformation(ob);
 #endif
+				
+				/* auto-keyframing */
+				autokeyframe_ob_cb_func(ob, TFM_TRANSLATION);
 			}
 		}
 
@@ -1667,8 +1680,11 @@
 						}
 					}
 				}
-				ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
-				ob->recalc |= OB_RECALC_DATA;
+				
+				/* autokeyframing */
+				ob->pose->flag |= POSE_DO_UNLOCK;
+				autokeyframe_pose_cb_func(ob, TFM_TRANSLATION, 0);
+				DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
 			}
 			else {
 				ob->recalc |= OB_RECALC_OB;
@@ -1694,6 +1710,9 @@
 #ifdef WITH_VERSE
 				if(ob->vnode) b_verse_send_transformation(ob);
 #endif
+				
+				/* auto-keyframing */
+				autokeyframe_ob_cb_func(ob, TFM_TRANSLATION);
 			}
 		}
 

Modified: trunk/blender/source/blender/src/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/src/transform_conversions.c	2007-06-23 05:28:07 UTC (rev 11027)
+++ trunk/blender/source/blender/src/transform_conversions.c	2007-06-23 06:56:16 UTC (rev 11028)
@@ -2177,13 +2177,171 @@
 	}
 }
 
+/* auto-keyframing feature - for objects 
+ * 	tmode: should be a transform mode 
+ */
+void autokeyframe_ob_cb_func(Object *ob, int tmode)
+{
+	IpoCurve *icu;
+	char *actname="";
+	
+	if (G.flags & G_RECORDKEYS) {
+		if(ob->ipoflag & OB_ACTION_OB)
+			actname= "Object";
+
+		if(U.uiflag & USER_KEYINSERTAVAI) {
+			if(ob->ipo || ob->action) {
+				ID *id= (ID *)(ob);
+				
+				if (ob->ipo) {
+					icu= ob->ipo->curve.first;
+				}
+				else {
+					bActionChannel *achan;
+					achan= get_action_channel(ob->action, actname);
+					
+					if (achan && achan->ipo)
+						icu= achan->ipo->curve.first;
+					else
+						icu= NULL;
+				}
+				
+				while(icu) {
+					icu->flag &= ~IPO_SELECT;
+					if (U.uiflag & USER_KEYINSERTNEED)
+						insertkey_smarter(id, ID_OB, actname, NULL, icu->adrcode);
+					else
+						insertkey(id, ID_OB, actname, NULL, icu->adrcode);
+					icu= icu->next;
+				}
+			}
+		}
+		else if (U.uiflag & USER_KEYINSERTNEED) {
+			if (tmode==TFM_RESIZE) {
+				insertkey_smarter(&ob->id, ID_OB, actname, NULL, OB_SIZE_X);
+				insertkey_smarter(&ob->id, ID_OB, actname, NULL, OB_SIZE_Y);
+				insertkey_smarter(&ob->id, ID_OB, actname, NULL, OB_SIZE_Z);
+			}
+			else if (tmode==TFM_ROTATION) {
+				insertkey_smarter(&ob->id, ID_OB, actname, NULL, OB_ROT_X);
+				insertkey_smarter(&ob->id, ID_OB, actname, NULL, OB_ROT_Y);
+				insertkey_smarter(&ob->id, ID_OB, actname, NULL, OB_ROT_Z);
+			}
+			else if (tmode==TFM_TRANSLATION) {
+				insertkey_smarter(&ob->id, ID_OB, actname, NULL, OB_LOC_X);
+				insertkey_smarter(&ob->id, ID_OB, actname, NULL, OB_LOC_Y);
+				insertkey_smarter(&ob->id, ID_OB, actname, NULL, OB_LOC_Z);
+			}
+		}
+		else {
+			insertkey(&ob->id, ID_OB, actname, NULL, OB_ROT_X);
+			insertkey(&ob->id, ID_OB, actname, NULL, OB_ROT_Y);
+			insertkey(&ob->id, ID_OB, actname, NULL, OB_ROT_Z);
+
+			insertkey(&ob->id, ID_OB, actname, NULL, OB_LOC_X);
+			insertkey(&ob->id, ID_OB, actname, NULL, OB_LOC_Y);
+			insertkey(&ob->id, ID_OB, actname, NULL, OB_LOC_Z);
+
+			insertkey(&ob->id, ID_OB, actname, NULL, OB_SIZE_X);
+			insertkey(&ob->id, ID_OB, actname, NULL, OB_SIZE_Y);
+			insertkey(&ob->id, ID_OB, actname, NULL, OB_SIZE_Z);
+		}
+
+		remake_object_ipos(ob);
+		allqueue(REDRAWIPO, 0);
+		allspace(REMAKEIPO, 0);
+		allqueue(REDRAWVIEW3D, 0);
+		allqueue(REDRAWNLA, 0);
+		allqueue(REDRAWTIME, 0);
+	}
+}
+
+/* auto-keyframing feature - for poses/pose-channels 
+ * 	tmode: should be a transform mode 
+ *	targetless_ik: has targetless ik been done on any channels?
+ */
+void autokeyframe_pose_cb_func(Object *ob, int tmode, short targetless_ik)
+{
+	bAction	*act;
+	bPose	*pose;
+	bPoseChannel *pchan;
+	IpoCurve *icu;
+	
+	pose= ob->pose;
+	act= ob->action;
+	
+	if (G.flags & G_RECORDKEYS) {
+		if (!act)
+			act= ob->action= add_empty_action("Action");
+		
+		for (pchan=pose->chanbase.first; pchan; pchan=pchan->next){
+			if (pchan->bone->flag & BONE_TRANSFORM){
+
+				if(U.uiflag & USER_KEYINSERTAVAI) {
+					bActionChannel *achan; 
+
+					for (achan = act->chanbase.first; achan; achan=achan->next){
+						if (achan->ipo && !strcmp (achan->name, pchan->name)){
+							for (icu = achan->ipo->curve.first; icu; icu=icu->next){
+								if (U.uiflag & USER_KEYINSERTNEED)
+									insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, icu->adrcode);
+								else
+									insertkey(&ob->id, ID_PO, pchan->name, NULL, icu->adrcode);
+							}
+							break;
+						}
+					}
+				}
+				else if (U.uiflag & USER_KEYINSERTNEED) {
+					if ((tmode==TFM_TRANSLATION) && (targetless_ik==0)) {
+						insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_X);
+						insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_Y);
+						insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_Z);
+					}
+					if ((tmode==TFM_ROTATION) || ((tmode==TFM_TRANSLATION) && targetless_ik)) {
+						insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_W);
+						insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_X);
+						insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_Y);
+						insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_Z);
+					}
+					if (tmode==TFM_RESIZE) {
+						insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_SIZE_X);
+						insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_SIZE_Y);
+						insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_SIZE_Z);
+					}
+				}
+				else {
+					insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_SIZE_X);
+					insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_SIZE_Y);
+					insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_SIZE_Z);
+
+					insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_W);
+					insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_X);
+					insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_Y);
+					insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_Z);
+
+					insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_X);
+					insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_Y);
+					insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_Z);
+				}
+			}
+		}
+		
+		remake_action_ipos (act);
+		allspace(REMAKEIPO, 0);
+		allqueue(REDRAWACTION, 0);
+		allqueue(REDRAWIPO, 0);
+		allqueue(REDRAWNLA, 0);
+		allqueue(REDRAWTIME, 0);
+	}
+}
+
 /* inserting keys, refresh ipo-keys, softbody, redraw events... (ton) */
 /* note; transdata has been freed already! */
 void special_aftertrans_update(TransInfo *t)
 {
 	Object *ob;
 	Base *base;
-	IpoCurve *icu;
 	int redrawipo=0;
 	int cancelled= (t->state == TRANS_CANCEL);
 		
@@ -2196,7 +2354,6 @@
 	}
 	else if( (t->flag & T_POSE) && t->poseobj) {
 		bArmature *arm;
-		bAction	*act;
 		bPose	*pose;
 		bPoseChannel *pchan;
 		short targetless_ik= 0;
@@ -2223,74 +2380,8 @@
 			pose_grab_with_ik_clear(ob);
 		
 		/* automatic inserting of keys */
-		if((G.flags & G_RECORDKEYS) && (!cancelled)) {
-			act= ob->action;
-			
-			if (!act)
-				act= ob->action= add_empty_action("Action");
-			
-			for (pchan=pose->chanbase.first; pchan; pchan=pchan->next){
-				if (pchan->bone->flag & BONE_TRANSFORM){
-
-					if(U.uiflag & USER_KEYINSERTAVAI) {
-						bActionChannel *achan; 
-
-						for (achan = act->chanbase.first; achan; achan=achan->next){
-
-							if (achan->ipo && !strcmp (achan->name, pchan->name)){
-								for (icu = achan->ipo->curve.first; icu; icu=icu->next){
-									if (U.uiflag & USER_KEYINSERTNEED)
-										insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, icu->adrcode);
-									else
-										insertkey(&ob->id, ID_PO, pchan->name, NULL, icu->adrcode);
-								}
-
-								break;
-							}
-						}
-					}
-					else if (U.uiflag & USER_KEYINSERTNEED) {
-						if ((t->mode==TFM_TRANSLATION) && (targetless_ik==0)) {
-							insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_X);
-							insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_Y);
-							insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_Z);
-						}
-						if ((t->mode==TFM_ROTATION) || ((t->mode==TFM_TRANSLATION) && targetless_ik)) {
-							insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_W);
-							insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_X);
-							insertkey_smarter(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_Y);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list