[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34578] trunk/blender/source/blender: Bugfix [#25876] bpy.ops.constraint.childof_set_inverse has no effect

Joshua Leung aligorith at gmail.com
Mon Jan 31 12:19:24 CET 2011


Revision: 34578
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34578
Author:   aligorith
Date:     2011-01-31 11:19:23 +0000 (Mon, 31 Jan 2011)
Log Message:
-----------
Bugfix [#25876] bpy.ops.constraint.childof_set_inverse has no effect

This was a two-part bug: a user error + API error.
* User Error: before calling bpy.ops.constraint.childof_set_inverse()
for a constraint defined on a bone, you firstly need to explicitly
make that bone the active bone. To do that, you do
armature.bones.active = posebone.bone # or something similar

* API Error: active bone setting was a bit too strict. It only allows
setting the active bone if the new bone comes from the same armature,
but was overlooking the fact that RNA pointers may have been created
through the object using the armature instead.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/object/object_constraint.c
    trunk/blender/source/blender/makesrna/intern/rna_armature.c

Modified: trunk/blender/source/blender/editors/object/object_constraint.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_constraint.c	2011-01-31 11:17:50 UTC (rev 34577)
+++ trunk/blender/source/blender/editors/object/object_constraint.c	2011-01-31 11:19:23 UTC (rev 34578)
@@ -531,11 +531,20 @@
 		bPoseChannel *pchan= get_active_posechannel(ob);
 		if (pchan)
 			list = &pchan->constraints;
-		else
+		else {
+			//if (G.f & G_DEBUG)
+			//printf("edit_constraint_property_get: No active bone for object '%s'\n", (ob)? ob->id.name+2 : "<None>");
 			return NULL;
+		}
 	}
+	else {
+		//if (G.f & G_DEBUG)
+		//printf("edit_constraint_property_get: defaulting to getting list in the standard way\n");
+		list = get_active_constraints(ob);
+	}
 	
 	con = constraints_findByName(list, constraint_name);
+	printf("constraint found = %p, %s\n", con, (con)?con->name:"<Not found>");
 	
 	if (con && (type != 0) && (con->type != type))
 		con = NULL;
@@ -645,8 +654,11 @@
 	bPoseChannel *pchan= NULL;
 	
 	/* despite 3 layers of checks, we may still not be able to find a constraint */
-	if (data == NULL)
+	if (data == NULL) {
+		printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob)? ob->id.name+2 : "<None>");
+		BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse");
 		return OPERATOR_CANCELLED;
+	}
 	
 	/* try to find a pose channel */
 	// TODO: get from context instead?

Modified: trunk/blender/source/blender/makesrna/intern/rna_armature.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_armature.c	2011-01-31 11:17:50 UTC (rev 34577)
+++ trunk/blender/source/blender/makesrna/intern/rna_armature.c	2011-01-31 11:19:23 UTC (rev 34578)
@@ -66,12 +66,16 @@
 	}
 	else {
 		if(value.id.data != arm) {
-			/* raise an error! */
+			Object *ob = (Object *)value.id.data;
+			
+			if(GS(ob->id.name)!=ID_OB || (ob->data != arm)) {
+				printf("ERROR: armature set active bone - new active doesn't come from this armature\n");
+				return;
+			}
 		}
-		else {
-			arm->act_bone= value.data;
-			arm->act_bone->flag |= BONE_SELECTED;
-		}
+		
+		arm->act_bone= value.data;
+		arm->act_bone->flag |= BONE_SELECTED;
 	}
 }
 




More information about the Bf-blender-cvs mailing list