[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34685] trunk/blender/source/blender/ editors/animation/keyframing.c: Visual Keying Code Tweaks:

Joshua Leung aligorith at gmail.com
Mon Feb 7 12:38:58 CET 2011


Revision: 34685
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34685
Author:   aligorith
Date:     2011-02-07 11:38:57 +0000 (Mon, 07 Feb 2011)
Log Message:
-----------
Visual Keying Code Tweaks:

Moving this code to the same method as is used for Apply Visual
Transform (for bones case), which uses standardised decomposition
methods instead of the improvised ones used here before. This was in
an attempt to get IK chains Visual Keyed correctly, though this
doesn't seem to have improved the situation much.

Also, the decompositon for objects here now takes care of euler
rotation modes.
TODO: other rotation modes should get included here too...

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/keyframing.c

Modified: trunk/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframing.c	2011-02-07 10:54:55 UTC (rev 34684)
+++ trunk/blender/source/blender/editors/animation/keyframing.c	2011-02-07 11:38:57 UTC (rev 34685)
@@ -642,10 +642,10 @@
 			if (strstr(identifier, "location")) {
 				return ob->obmat[3][array_index];
 			}
-			else if (strstr(identifier, "rotation")) {
+			else if (strstr(identifier, "rotation_euler")) {
 				float eul[3];
 				
-				mat4_to_eul( eul,ob->obmat);
+				mat4_to_eulO(eul, ob->rotmode, ob->obmat);
 				return eul[array_index];
 			}
 		}
@@ -653,40 +653,37 @@
 	else if (ptr->type == &RNA_PoseBone) {
 		Object *ob= (Object *)ptr->id.data; /* we assume that this is always set, and is an object */
 		bPoseChannel *pchan= (bPoseChannel *)ptr->data;
-		float tmat[4][4];
+		bPoseChannel tchan;
 		
-		/* Although it is not strictly required for this particular space conversion, 
-		 * arg1 must not be null, as there is a null check for the other conversions to
-		 * be safe. Therefore, the active object is passed here, and in many cases, this
-		 * will be what owns the pose-channel that is getting this anyway.
+		/* make a copy of pchan so that we can apply and decompose its chan_mat, thus getting the 
+		 * rest-pose to pose-mode transform that got stored there at the end of posing calculations
+		 * for B-Bone deforms to use
+		 *	- it should be safe to just make a local copy like this, since we're not doing anything with the copied pointers
 		 */
-		copy_m4_m4(tmat, pchan->pose_mat);
-		constraint_mat_convertspace(ob, pchan, tmat, CONSTRAINT_SPACE_POSE, CONSTRAINT_SPACE_LOCAL);
+		memcpy(&tchan, pchan, sizeof(bPoseChannel));
+		pchan_apply_mat4(&tchan, pchan->chan_mat);
 		
 		/* Loc, Rot/Quat keyframes are supported... */
 		if (strstr(identifier, "location")) {
 			/* only use for non-connected bones */
 			if ((pchan->bone->parent) && !(pchan->bone->flag & BONE_CONNECTED))
-				return tmat[3][array_index];
+				return tchan.loc[array_index];
 			else if (pchan->bone->parent == NULL)
-				return tmat[3][array_index];
+				return tchan.loc[array_index];
 		}
 		else if (strstr(identifier, "rotation_euler")) {
-			float eul[3];
-			
-			/* euler-rotation test before standard rotation, as standard rotation does quats */
-			mat4_to_eulO( eul, pchan->rotmode,tmat);
-			return eul[array_index];
+			return tchan.eul[array_index];
 		}
 		else if (strstr(identifier, "rotation_quaternion")) {
-			float trimat[3][3], quat[4];
-			
-			copy_m3_m4(trimat, tmat);
-			mat3_to_quat_is_ok( quat,trimat);
-			
-			return quat[array_index];
+			return tchan.quat[array_index];
 		}
-		// TODO: axis-angle...
+		else if (strstr(identifier, "rotation_axisangle")) {
+			/* w = 0, x,y,z = 1,2,3 */
+			if (array_index == 0)
+				return tchan.rotAngle;
+			else
+				return tchan.rotAxis[array_index - 1];
+		}
 	}
 	
 	/* as the function hasn't returned yet, read value from system in the default way */




More information about the Bf-blender-cvs mailing list