[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12141] trunk/blender/source/blender: == Armature Animation Fixes ==

Joshua Leung aligorith at gmail.com
Tue Sep 25 07:04:34 CEST 2007


Revision: 12141
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12141
Author:   aligorith
Date:     2007-09-25 07:04:34 +0200 (Tue, 25 Sep 2007)

Log Message:
-----------
== Armature Animation Fixes ==

This commit fixes several bugs related to animating armatures. I've also tidied up the formatting in a few files along the way, and also commented the flags for this pose->flag.

What's new/fixed:
* Undo will no longer destroy entire un-keyframed poses. Now it behaves as expected, and only reverses the most recent change.
* On some files, POSE_DO_UNLOCK somehow got set on files and never cleared. The symptom of this was a file in which you suddenly could no longer pose an armature at all without using auto-keyframing. A check to prevent this from happening again has been added (it will also fix old files too)

Notes:
- Now, all PoseChannels get tagged with BONE_UNKEYED after they have been transformed. This flag prevents IPO data being flushed over these new values, even after undo. 
- These tags only get removed on frame-changes or inserting new keyframes. 

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_action.h
    trunk/blender/source/blender/blenkernel/intern/action.c
    trunk/blender/source/blender/blenkernel/intern/scene.c
    trunk/blender/source/blender/makesdna/DNA_action_types.h
    trunk/blender/source/blender/makesdna/DNA_armature_types.h
    trunk/blender/source/blender/src/edit.c
    trunk/blender/source/blender/src/editarmature.c
    trunk/blender/source/blender/src/editipo.c
    trunk/blender/source/blender/src/poseobject.c
    trunk/blender/source/blender/src/transform_conversions.c

Modified: trunk/blender/source/blender/blenkernel/BKE_action.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_action.h	2007-09-25 04:11:57 UTC (rev 12140)
+++ trunk/blender/source/blender/blenkernel/BKE_action.h	2007-09-25 05:04:34 UTC (rev 12141)
@@ -101,6 +101,9 @@
 /* sets constraint flags */
 void update_pose_constraint_flags(struct bPose *pose);
 
+/* clears BONE_UNKEYED flags for frame changing */
+void framechange_poses_clear_unkeyed(void);
+
 /**
  * Allocate a new bAction on the heap and copy 
  * the contents of src into it. If src is NULL NULL is returned.

Modified: trunk/blender/source/blender/blenkernel/intern/action.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/action.c	2007-09-25 04:11:57 UTC (rev 12140)
+++ trunk/blender/source/blender/blenkernel/intern/action.c	2007-09-25 05:04:34 UTC (rev 12141)
@@ -351,6 +351,28 @@
 	}
 }
 
+/* Clears all BONE_UNKEYED flags for every pose channel in every pose 
+ * This should only be called on frame changing, when it is acceptable to
+ * do this. Otherwise, these flags should not get cleared as poses may get lost.
+ */
+void framechange_poses_clear_unkeyed(void)
+{
+	Object *ob;
+	bPose *pose;
+	bPoseChannel *pchan;
+	
+	/* This needs to be done for each object that has a pose */
+	// TODO: proxies may/may not be correctly handled here... (this needs checking) 
+	for (ob= G.main->object.first; ob; ob= ob->id.next) {
+		/* we only need to do this on objects with a pose */
+		if ( (pose= ob->pose) ) {
+			for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
+				if (pchan->bone) 
+					pchan->bone->flag &= ~BONE_UNKEYED;
+			}
+		}
+	}
+}
 
 /* ************************ END Pose channels *************** */
 
@@ -680,9 +702,15 @@
 	
 	/* Copy the data from the action into the pose */
 	for (pchan= pose->chanbase.first; pchan; pchan=pchan->next) {
+		/* skip this pose channel if it has been tagged as having unkeyed poses */
+		if ((pchan->bone) && (pchan->bone->flag & BONE_UNKEYED)) 
+			continue;
+		
+		/* get action channel and clear pchan-transform flags */
 		achan= get_action_channel(act, pchan->name);
 		pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE);
-		if(achan) {
+		
+		if (achan) {
 			ipo = achan->ipo;
 			if (ipo) {
 				/* Evaluates and sets the internal ipo value */
@@ -1252,12 +1280,11 @@
 
 void do_all_pose_actions(Object *ob)
 {
-
-	// only to have safe calls from editor
+	/* only to have safe calls from editor */
 	if(ob==NULL) return;
 	if(ob->type!=OB_ARMATURE || ob->pose==NULL) return;
 
-	if(ob->pose->flag & POSE_LOCKED) {  // no actions to execute while transform
+	if(ob->pose->flag & POSE_LOCKED) {  /*  no actions to execute while transform */
 		if(ob->pose->flag & POSE_DO_UNLOCK)
 			ob->pose->flag &= ~(POSE_LOCKED|POSE_DO_UNLOCK);
 	}
@@ -1271,6 +1298,9 @@
 	else if(ob->nlastrips.first) {
 		do_nla(ob, ID_AR);
 	}
+	
+	/* clear POSE_DO_UNLOCK flags that might have slipped through (just in case) */
+	ob->pose->flag &= ~POSE_DO_UNLOCK;
 }
 
 /* called from where_is_object */

Modified: trunk/blender/source/blender/blenkernel/intern/scene.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/scene.c	2007-09-25 04:11:57 UTC (rev 12140)
+++ trunk/blender/source/blender/blenkernel/intern/scene.c	2007-09-25 05:04:34 UTC (rev 12141)
@@ -530,6 +530,9 @@
 {
 	Scene *scene= sce;
 	
+	/* clears all BONE_UNKEYED flags for every pose's pchans */
+	framechange_poses_clear_unkeyed();
+	
 	/* object ipos are calculated in where_is_object */
 	do_all_data_ipos();
 	
@@ -540,7 +543,6 @@
 		scene_update(sce, lay);
 
 	scene_update(scene, lay);
-	
 }
 
 /* return default layer, also used to patch old files */

Modified: trunk/blender/source/blender/makesdna/DNA_action_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_action_types.h	2007-09-25 04:11:57 UTC (rev 12140)
+++ trunk/blender/source/blender/makesdna/DNA_action_types.h	2007-09-25 05:04:34 UTC (rev 12141)
@@ -148,18 +148,27 @@
 #define ACHAN_MOVED     0x80000000
 
 /* SpaceAction flag */
-#define SACTION_MOVING		1	/* during transform */
-#define SACTION_SLIDERS		2	/* show sliders (if relevant) - limited to shape keys for now */
-#define SACTION_DRAWTIME	4	/* draw time in seconds instead of time in frames */
+	/* during transform */
+#define SACTION_MOVING		1	
+	/* show sliders (if relevant) - limited to shape keys for now */
+#define SACTION_SLIDERS		2	
+	/* draw time in seconds instead of time in frames */
+#define SACTION_DRAWTIME	4	
 
 /* SpaceAction AutoSnap Settings (also used by SpaceNLA) */
-#define SACTSNAP_OFF	0	/* no auto-snap */
-#define SACTSNAP_STEP	1	/* snap to 1.0 frame/second intervals */
-#define SACTSNAP_FRAME	2	/* snap to actual frames/seconds (nla-action time) */
+	/* no auto-snap */
+#define SACTSNAP_OFF	0	
+	/* snap to 1.0 frame/second intervals */
+#define SACTSNAP_STEP	1
+	/* snap to actual frames/seconds (nla-action time) */
+#define SACTSNAP_FRAME	2	
 
 /* Pose->flag */
+	/* results in armature_rebuild_pose being called */
 #define POSE_RECALC		1
+	/* prevents any channel from getting overridden by anim from IPO */
 #define POSE_LOCKED		2
+	/* clears the POSE_LOCKED flag for the next time the pose is evaluated */
 #define POSE_DO_UNLOCK	4
 
 /* PoseChannel (transform) flags */

Modified: trunk/blender/source/blender/makesdna/DNA_armature_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_armature_types.h	2007-09-25 04:11:57 UTC (rev 12140)
+++ trunk/blender/source/blender/makesdna/DNA_armature_types.h	2007-09-25 05:04:34 UTC (rev 12141)
@@ -145,6 +145,7 @@
 			/* multiplies vgroup with envelope */
 #define		BONE_MULT_VG_ENV	2048
 #define		BONE_NO_DEFORM		4096
+			/* set to prevent destruction of its unkeyframed pose (after transform) */
+#define 	BONE_UNKEYED		8192
 
-
 #endif

Modified: trunk/blender/source/blender/src/edit.c
===================================================================
--- trunk/blender/source/blender/src/edit.c	2007-09-25 04:11:57 UTC (rev 12140)
+++ trunk/blender/source/blender/src/edit.c	2007-09-25 05:04:34 UTC (rev 12141)
@@ -1158,13 +1158,13 @@
 		if ELEM6(G.obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) 
 			make_trans_verts(bmat[0], bmat[1], 0);
 		if(tottrans==0) return;
-
+		
 		Mat3CpyMat4(bmat, G.obedit->obmat);
 		Mat3Inv(imat, bmat);
-
+		
 		tv= transvmain;
 		for(a=0; a<tottrans; a++, tv++) {
-
+			
 			VECCOPY(vec, tv->loc);
 			Mat3MulVecfl(bmat, vec);
 			VecAddf(vec, vec, G.obedit->obmat[3]);
@@ -1172,17 +1172,17 @@
 			vec[1]= G.vd->gridview*floor(.5+ vec[1]/gridf);
 			vec[2]= G.vd->gridview*floor(.5+ vec[2]/gridf);
 			VecSubf(vec, vec, G.obedit->obmat[3]);
-
+			
 			Mat3MulVecfl(imat, vec);
 			VECCOPY(tv->loc, vec);
-
+			
 		}
-
+		
 		special_transvert_update();
 		
 		MEM_freeN(transvmain);
 		transvmain= 0;
-
+	
 		allqueue(REDRAWVIEW3D, 0);
 		return;
 	}
@@ -1274,31 +1274,29 @@
 
 	if(G.obedit) {
 		tottrans= 0;
-
+		
 		if ELEM6(G.obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) 
 			make_trans_verts(bmat[0], bmat[1], 0);
 		if(tottrans==0) return;
-
+		
 		Mat3CpyMat4(bmat, G.obedit->obmat);
 		Mat3Inv(imat, bmat);
-
+		
 		tv= transvmain;
 		for(a=0; a<tottrans; a++, tv++) {
-
 			vec[0]= curs[0]-G.obedit->obmat[3][0];
 			vec[1]= curs[1]-G.obedit->obmat[3][1];
 			vec[2]= curs[2]-G.obedit->obmat[3][2];
-
+			
 			Mat3MulVecfl(imat, vec);
 			VECCOPY(tv->loc, vec);
-
 		}
 		
 		special_transvert_update();
 		
 		MEM_freeN(transvmain);
 		transvmain= 0;
-
+		
 		allqueue(REDRAWVIEW3D, 0);
 		return;
 	}
@@ -1346,10 +1344,10 @@
 				vec[0]= -ob->obmat[3][0] + curs[0];
 				vec[1]= -ob->obmat[3][1] + curs[1];
 				vec[2]= -ob->obmat[3][2] + curs[2];
-
+				
 				if(ob->parent) {
 					where_is_object(ob);
-
+					
 					Mat3Inv(imat, originmat);
 					Mat3MulVecfl(imat, vec);
 					ob->loc[0]+= vec[0];
@@ -1388,7 +1386,6 @@
 	curs[2]= G.vd->gridview*floor(.5+curs[2]/gridf);
 
 	allqueue(REDRAWVIEW3D, 0);
-
 }
 
 void snap_curs_to_sel()
@@ -1406,13 +1403,13 @@
 
 	if(G.obedit) {
 		tottrans=0;
-
+		
 		if ELEM6(G.obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) 
 			make_trans_verts(bmat[0], bmat[1], 2);
 		if(tottrans==0) return;
-
+		
 		Mat3CpyMat4(bmat, G.obedit->obmat);
-
+		
 		tv= transvmain;
 		for(a=0; a<tottrans; a++, tv++) {
 			VECCOPY(vec, tv->loc);
@@ -1421,7 +1418,7 @@
 			VecAddf(centroid, centroid, vec);
 			DO_MINMAX(vec, min, max);
 		}
-
+		
 		if(G.vd->around==V3D_CENTROID) {
 			VecMulf(centroid, 1.0/(float)tottrans);
 			VECCOPY(curs, centroid);
@@ -1492,20 +1489,20 @@
 
 	if(G.obedit) {
 		tottrans=0;
-
+		
 		if ELEM6(G.obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) 
 			make_trans_verts(bmat[0], bmat[1], 0);
 		if(tottrans==0) return;
-
+		
 		Mat3CpyMat4(bmat, G.obedit->obmat);
-
+		
 		tv= transvmain;
 		VECCOPY(vec, tv->loc);
 			/*Mat3MulVecfl(bmat, vec);
 			VecAddf(vec, vec, G.obedit->obmat[3]);
 			VecAddf(centroid, centroid, vec);
 			DO_MINMAX(vec, min, max);*/
-
+		
 		if(G.vd->around==V3D_CENTROID) {
 			VecMulf(vec, 1.0/(float)tottrans);
 			VECCOPY(curs, vec);
@@ -1561,14 +1558,14 @@
 
 	if(G.obedit) {
 		tottrans= 0;
-
+		
 		if ELEM6(G.obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) 
 			make_trans_verts(bmat[0], bmat[1], 0);
 		if(tottrans==0) return;
-
+		
 		Mat3CpyMat4(bmat, G.obedit->obmat);
 		Mat3Inv(imat, bmat);
-
+		
 		tv= transvmain;
 		for(a=0; a<tottrans; a++, tv++) {
 			VECCOPY(vec, tv->loc);
@@ -1577,7 +1574,7 @@
 			VecAddf(centroid, centroid, vec);
 			DO_MINMAX(vec, min, max);
 		}
-
+		
 		if(G.vd->around==V3D_CENTROID) {
 			VecMulf(centroid, 1.0/(float)tottrans);
 			VECCOPY(snaploc, centroid);
@@ -1590,7 +1587,6 @@
 		
 		MEM_freeN(transvmain);
 		transvmain= 0;
-
 	}
 	else {
 		base= (G.scene->base.first);
@@ -1638,21 +1634,20 @@
 	/* Snap the selection to the snaplocation (duh!) */
 	if(G.obedit) {
 		tottrans= 0;
-
+		
 		if ELEM6(G.obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) 
 			make_trans_verts(bmat[0], bmat[1], 0);
 		if(tottrans==0) return;
-
+		
 		Mat3CpyMat4(bmat, G.obedit->obmat);
 		Mat3Inv(imat, bmat);
-
+		
 		tv= transvmain;
 		for(a=0; a<tottrans; a++, tv++) {
-

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list