[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12793] trunk/blender/source/blender/src/ poseobject.c: fix for 2 problems with pose relax,

Campbell Barton ideasman42 at gmail.com
Wed Dec 5 13:04:14 CET 2007


Revision: 12793
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12793
Author:   campbellbarton
Date:     2007-12-05 13:04:14 +0100 (Wed, 05 Dec 2007)

Log Message:
-----------
fix for 2 problems with pose relax,
* Auto key wasnt working, it made the bone not move at all (not sure why used same code as snap to), now check G_RECORDKEYS and add keys manually.
* was ignoring keys that were 1.0 behind the current key. made the limit 0.5, fixes this.

Modified Paths:
--------------
    trunk/blender/source/blender/src/poseobject.c

Modified: trunk/blender/source/blender/src/poseobject.c
===================================================================
--- trunk/blender/source/blender/src/poseobject.c	2007-12-05 11:19:36 UTC (rev 12792)
+++ trunk/blender/source/blender/src/poseobject.c	2007-12-05 12:04:14 UTC (rev 12793)
@@ -1093,7 +1093,7 @@
 		int i;
 		
 		for (i=0; i < icu->totvert; i++, bezt++) {
-			if (bezt->vec[1][0] < framef - 1.0) {
+			if (bezt->vec[1][0] < framef - 0.5) {
 				bezt_prev = bezt;
 			} else {
 				break;
@@ -1106,7 +1106,7 @@
 		bezt = bezt_prev+1;
 		
 		for (; i < icu->totvert; i++, bezt++) {
-			if (bezt->vec[1][0] > framef + 1.0) {
+			if (bezt->vec[1][0] > framef + 0.5) {
 				bezt_next = bezt;
 						break;
 			}
@@ -1150,10 +1150,11 @@
 	float frame_prev, frame_next;
 	float quat_prev[4], quat_next[4], quat_interp[4], quat_orig[4];
 	
-	int do_scale = 0;
+	/*int do_scale = 0;
 	int do_loc = 0;
 	int do_quat = 0;
-	int flag = 0;
+	int flag = 0;*/
+	int do_w, do_x, do_y, do_z;
 	
 	if (!ob) return;
 	
@@ -1170,14 +1171,29 @@
 				achan= get_action_channel(act, pchan->name);
 				if(achan && achan->ipo) {
 					/*calc_ipo(achan->ipo, ctime);*/
-					do_loc += pose_relax_icu(find_ipocurve(achan->ipo, AC_LOC_X), framef, &pchan->loc[0], NULL, NULL);
-					do_loc += pose_relax_icu(find_ipocurve(achan->ipo, AC_LOC_Y), framef, &pchan->loc[1], NULL, NULL);
-					do_loc += pose_relax_icu(find_ipocurve(achan->ipo, AC_LOC_Z), framef, &pchan->loc[2], NULL, NULL);
 					
-					do_scale += pose_relax_icu(find_ipocurve(achan->ipo, AC_SIZE_X), framef, &pchan->size[0], NULL, NULL);
-					do_scale += pose_relax_icu(find_ipocurve(achan->ipo, AC_SIZE_Y), framef, &pchan->size[1], NULL, NULL);
-					do_scale += pose_relax_icu(find_ipocurve(achan->ipo, AC_SIZE_Z), framef, &pchan->size[2], NULL, NULL);
+					do_x = pose_relax_icu(find_ipocurve(achan->ipo, AC_LOC_X), framef, &pchan->loc[0], NULL, NULL);
+					do_y = pose_relax_icu(find_ipocurve(achan->ipo, AC_LOC_Y), framef, &pchan->loc[1], NULL, NULL);
+					do_z = pose_relax_icu(find_ipocurve(achan->ipo, AC_LOC_Z), framef, &pchan->loc[2], NULL, NULL);
+					/* do_loc = do_x + do_y + do_z */
 					
+					if (G.flags & G_RECORDKEYS) {
+						if (do_x) insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_X, 0);
+						if (do_y) insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_Y, 0);
+						if (do_z) insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_Z, 0);
+					}
+					
+					do_x = pose_relax_icu(find_ipocurve(achan->ipo, AC_SIZE_X), framef, &pchan->size[0], NULL, NULL);
+					do_y = pose_relax_icu(find_ipocurve(achan->ipo, AC_SIZE_Y), framef, &pchan->size[1], NULL, NULL);
+					do_z = pose_relax_icu(find_ipocurve(achan->ipo, AC_SIZE_Z), framef, &pchan->size[2], NULL, NULL);
+					/* do_scale = do_x + do_y + do_z */
+					
+					if (G.flags & G_RECORDKEYS) {
+						if (do_x) insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_SIZE_X, 0);
+						if (do_y) insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_SIZE_Y, 0);
+						if (do_z) insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_SIZE_Z, 0);
+					}
+					
 					if(	((icu_w = find_ipocurve(achan->ipo, AC_QUAT_W))) &&
 						((icu_x = find_ipocurve(achan->ipo, AC_QUAT_X))) &&
 						((icu_y = find_ipocurve(achan->ipo, AC_QUAT_Y))) &&
@@ -1206,9 +1222,20 @@
 							QuatInterpol(pchan->quat, quat_orig, quat_interp, 1.0f/6.0f);
 							/* done */
 #endif
-							do_quat++;
+							/*do_quat++;*/
+							
+							if (G.flags & G_RECORDKEYS) {
+								insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_X, 0);
+								insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_Y, 0);
+								insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_Z, 0);
+								insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_QUAT_W, 0);
+							}
 						}
 					}
+					
+					if (G.flags & G_RECORDKEYS) {
+						pchan->bone->flag &= ~BONE_UNKEYED;
+					}
 				}
 			}
 		}
@@ -1216,11 +1243,15 @@
 	
 	ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
 	
-	/* auto-keyframing */
+#if 0
+// 	/* auto-keyframing - dosnt work, no idea why, do manually above */
 	if (do_loc)		flag |= TFM_TRANSLATION;
 	if (do_scale)	flag |= TFM_RESIZE;
 	if (do_quat)	flag |= TFM_ROTATION;
 	autokeyframe_pose_cb_func(ob, flag, 0);
+#endif	
+	
+	
 	DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
 	BIF_undo_push("Relax Pose");
 	





More information about the Bf-blender-cvs mailing list