[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39871] trunk/blender/source/blender/ editors/animation/keyframing.c: Bugfix [#28435] Key Visual transform and Parenting not working

Joshua Leung aligorith at gmail.com
Fri Sep 2 14:26:58 CEST 2011


Revision: 39871
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39871
Author:   aligorith
Date:     2011-09-02 12:26:57 +0000 (Fri, 02 Sep 2011)
Log Message:
-----------
Bugfix [#28435] Key Visual transform and Parenting not working

After reviewing this code, it seems that this case can work after all.
However, several things needed to be tweaked:
1) Removed check which stopped parented objects from getting the
visual keying coordinates determined. This actually wasn't doing
anything, given that this case would never occur as...
2) Tweaked the visualkey_can_use() function to also consider parenting
as a cause for visual-keying to be necessary.

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-09-02 10:43:51 UTC (rev 39870)
+++ trunk/blender/source/blender/editors/animation/keyframing.c	2011-09-02 12:26:57 UTC (rev 39871)
@@ -530,6 +530,7 @@
 {
 	bConstraint *con= NULL;
 	short searchtype= VISUALKEY_NONE;
+	short has_parent = FALSE;
 	char *identifier= NULL;
 	
 	/* validate data */
@@ -548,6 +549,7 @@
 		
 		con= ob->constraints.first;
 		identifier= (char *)RNA_property_identifier(prop);
+		has_parent= (ob->parent != NULL);
 	}
 	else if (ptr->type == &RNA_PoseBone) {
 		/* Pose Channel */
@@ -555,10 +557,11 @@
 		
 		con= pchan->constraints.first;
 		identifier= (char *)RNA_property_identifier(prop);
+		has_parent= (pchan->parent != NULL);
 	}
 	
 	/* check if any data to search using */
-	if (ELEM(NULL, con, identifier))
+	if (ELEM(NULL, con, identifier) && (has_parent == FALSE))
 		return 0;
 		
 	/* location or rotation identifiers only... */
@@ -573,7 +576,12 @@
 	
 	
 	/* only search if a searchtype and initial constraint are available */
-	if (searchtype && con) {
+	if (searchtype) {
+		/* parent is always matching */
+		if (has_parent)
+			return 1;
+		
+		/* constraints */
 		for (; con; con= con->next) {
 			/* only consider constraint if it is not disabled, and has influence */
 			if (con->flag & CONSTRAINT_DISABLE) continue;
@@ -645,40 +653,35 @@
 	if (ptr->type == &RNA_Object) {
 		Object *ob= (Object *)ptr->data;
 		
-		/* parented objects are not supported, as the effects of the parent
-		 * are included in the matrix, which kindof beats the point
-		 */
-		if (ob->parent == NULL) {
-			/* only Location or Rotation keyframes are supported now */
-			if (strstr(identifier, "location")) {
-				return ob->obmat[3][array_index];
-			}
-			else if (strstr(identifier, "rotation_euler")) {
-				float eul[3];
-				
-				mat4_to_eulO(eul, ob->rotmode, ob->obmat);
-				return eul[array_index];
-			}
-			else if (strstr(identifier, "rotation_quaternion")) {
-				float trimat[3][3], quat[4];
-				
-				copy_m3_m4(trimat, ob->obmat);
-				mat3_to_quat_is_ok(quat, trimat);
-				
-				return quat[array_index];
-			}
-			else if (strstr(identifier, "rotation_axis_angle")) {
-				float axis[3], angle;
-				
-				mat4_to_axis_angle(axis, &angle, ob->obmat);
-				
-				/* w = 0, x,y,z = 1,2,3 */
-				if (array_index == 0)
-					return angle;
-				else
-					return axis[array_index - 1];
-			}
+		/* only Location or Rotation keyframes are supported now */
+		if (strstr(identifier, "location")) {
+			return ob->obmat[3][array_index];
 		}
+		else if (strstr(identifier, "rotation_euler")) {
+			float eul[3];
+			
+			mat4_to_eulO(eul, ob->rotmode, ob->obmat);
+			return eul[array_index];
+		}
+		else if (strstr(identifier, "rotation_quaternion")) {
+			float trimat[3][3], quat[4];
+			
+			copy_m3_m4(trimat, ob->obmat);
+			mat3_to_quat_is_ok(quat, trimat);
+			
+			return quat[array_index];
+		}
+		else if (strstr(identifier, "rotation_axis_angle")) {
+			float axis[3], angle;
+			
+			mat4_to_axis_angle(axis, &angle, ob->obmat);
+			
+			/* w = 0, x,y,z = 1,2,3 */
+			if (array_index == 0)
+				return angle;
+			else
+				return axis[array_index - 1];
+		}
 	}
 	else if (ptr->type == &RNA_PoseBone) {
 		Object *ob = (Object *)ptr->id.data; /* we assume that this is always set, and is an object */




More information about the Bf-blender-cvs mailing list