[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12339] trunk/blender/source/blender: == Constraints Bugfixes ==

Joshua Leung aligorith at gmail.com
Mon Oct 22 12:49:34 CEST 2007


Revision: 12339
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12339
Author:   aligorith
Date:     2007-10-22 12:49:34 +0200 (Mon, 22 Oct 2007)

Log Message:
-----------
== Constraints Bugfixes ==

* Removed the old get_con_subtarget_name function and fixed the places that used it. This was only suitable for single-target constraints.

* PyConstraints interface drawing should now no longer draw multiple-target fields on top of each other

* Removed double call to BPY_pyconstraint_update when the Update button was clicked. I found this while debugging why PyConstraints didn't seem to be working yet...

Modified Paths:
--------------
    trunk/blender/source/blender/include/BIF_editconstraint.h
    trunk/blender/source/blender/src/editarmature.c
    trunk/blender/source/blender/src/editconstraint.c

Modified: trunk/blender/source/blender/include/BIF_editconstraint.h
===================================================================
--- trunk/blender/source/blender/include/BIF_editconstraint.h	2007-10-22 06:28:39 UTC (rev 12338)
+++ trunk/blender/source/blender/include/BIF_editconstraint.h	2007-10-22 10:49:34 UTC (rev 12339)
@@ -56,8 +56,6 @@
 void add_constraint(int only_IK);
 void ob_clear_constraints(void);
 
-char *get_con_subtarget_name(struct bConstraint *con, struct Object *target);
-
 void rename_constraint(struct Object *ob, struct bConstraint *con, char *newname);
 
 

Modified: trunk/blender/source/blender/src/editarmature.c
===================================================================
--- trunk/blender/source/blender/src/editarmature.c	2007-10-22 06:28:39 UTC (rev 12338)
+++ trunk/blender/source/blender/src/editarmature.c	2007-10-22 10:49:34 UTC (rev 12339)
@@ -1074,10 +1074,10 @@
 	bConstraint *con;
 	
 	TEST_EDITARMATURE;
-	if(okee("Erase selected bone(s)")==0) return;
+	if (okee("Erase selected bone(s)")==0) return;
 	
 	/*  First erase any associated pose channel */
-	if (G.obedit->pose){
+	if (G.obedit->pose) {
 		bPoseChannel *chan, *next;
 		for (chan=G.obedit->pose->chanbase.first; chan; chan=next) {
 			next= chan->next;
@@ -1088,14 +1088,28 @@
 				BLI_freelinkN (&G.obedit->pose->chanbase, chan);
 			}
 			else {
-				for(con= chan->constraints.first; con; con= con->next) {
-					char *subtarget = get_con_subtarget_name(con, G.obedit);
-					if (subtarget) {
-						curBone = editbone_name_exists (&G.edbo, subtarget);
-						if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) {
-							con->flag |= CONSTRAINT_DISABLE;
-							subtarget[0]= 0;
+				for (con= chan->constraints.first; con; con= con->next) {
+					bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+					ListBase targets = {NULL, NULL};
+					bConstraintTarget *ct;
+					
+					if (cti && cti->get_constraint_targets) {
+						cti->get_constraint_targets(con, &targets);
+						
+						for (ct= targets.first; ct; ct= ct->next) {
+							if (ct->tar == G.obedit) {
+								if (ct->subtarget[0]) {
+									curBone = editbone_name_exists(&G.edbo, ct->subtarget);
+									if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) {
+										con->flag |= CONSTRAINT_DISABLE;
+										ct->subtarget[0]= 0;
+									}
+								}
+							}
 						}
+						
+						if (cti->flush_constraint_targets)
+							cti->flush_constraint_targets(con, &targets, 0);
 					}
 				}
 			}
@@ -1103,9 +1117,9 @@
 	}
 	
 	
-	for (curBone=G.edbo.first;curBone;curBone=next){
+	for (curBone=G.edbo.first;curBone;curBone=next) {
 		next=curBone->next;
-		if(arm->layer & curBone->layer)
+		if (arm->layer & curBone->layer)
 			if (curBone->flag & BONE_SELECTED)
 				delete_bone(curBone);
 	}
@@ -1637,28 +1651,43 @@
 	bPoseChannel *chan;
 	bConstraint  *curcon;
 	ListBase     *conlist;
-	char         *subname;
 
 
-	if ( (chan = verify_pose_channel(OBACT->pose, dupBone->name)) )
-		if ( (conlist = &chan->constraints) )
+	if ( (chan = verify_pose_channel(OBACT->pose, dupBone->name)) ) {
+		if ( (conlist = &chan->constraints) ) {
 			for (curcon = conlist->first; curcon; curcon=curcon->next) {
 				/* does this constraint have a subtarget in
 				 * this armature?
 				 */
-				subname = get_con_subtarget_name(curcon, G.obedit);
-				oldtarget = get_named_editbone(subname);
-				if (oldtarget)
-					/* was the subtarget bone duplicated too? If
-					 * so, update the constraint to point at the 
-					 * duplicate of the old subtarget.
-					 */
-					if (oldtarget->flag & BONE_SELECTED){
-						newtarget = (EditBone*) oldtarget->temp;
-						strcpy(subname, newtarget->name);
+				bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon);
+				ListBase targets = {NULL, NULL};
+				bConstraintTarget *ct;
+				
+				if (cti && cti->get_constraint_targets) {
+					cti->get_constraint_targets(curcon, &targets);
+					
+					for (ct= targets.first; ct; ct= ct->next) {
+						if ((ct->tar == G.obedit) && (ct->subtarget[0])) {
+							oldtarget = get_named_editbone(ct->subtarget);
+							if (oldtarget) {
+								/* was the subtarget bone duplicated too? If
+								 * so, update the constraint to point at the 
+								 * duplicate of the old subtarget.
+								 */
+								if (oldtarget->flag & BONE_SELECTED){
+									newtarget = (EditBone *) oldtarget->temp;
+									strcpy(ct->subtarget, newtarget->name);
+								}
+							}
+						}
 					}
+					
+					if (cti->flush_constraint_targets)
+						cti->flush_constraint_targets(curcon, &targets, 0);
+				}
 			}
-	
+		}
+	}
 }
 
 
@@ -2889,13 +2918,25 @@
 static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldname, char *newname)
 {
 	bConstraint *curcon;
-	char *subtarget;
+	bConstraintTarget *ct;
 	
-	for (curcon = conlist->first; curcon; curcon=curcon->next){
-		subtarget = get_con_subtarget_name(curcon, ob);
-		if (subtarget)
-			if (!strcmp(subtarget, oldname) )
-				BLI_strncpy(subtarget, newname, MAXBONENAME);
+	for (curcon = conlist->first; curcon; curcon=curcon->next) {
+		bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon);
+		ListBase targets = {NULL, NULL};
+		
+		if (cti && cti->get_constraint_targets) {
+			cti->get_constraint_targets(curcon, &targets);
+			
+			for (ct= targets.first; ct; ct= ct->next) {
+				if (ct->tar == ob) {
+					if (!strcmp(ct->subtarget, oldname) )
+						BLI_strncpy(ct->subtarget, newname, MAXBONENAME);
+				}
+			}
+			
+			if (cti->flush_constraint_targets)
+				cti->flush_constraint_targets(curcon, &targets, 0);
+		}	
 	}
 }
 

Modified: trunk/blender/source/blender/src/editconstraint.c
===================================================================
--- trunk/blender/source/blender/src/editconstraint.c	2007-10-22 06:28:39 UTC (rev 12338)
+++ trunk/blender/source/blender/src/editconstraint.c	2007-10-22 10:49:34 UTC (rev 12339)
@@ -253,51 +253,6 @@
 	}
 }
 
-
-char *get_con_subtarget_name(bConstraint *con, Object *target)
-{
-	bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
-	ListBase targets = {NULL, NULL};
-	bConstraintTarget *ct;
-	static char subtarget[32];
-	
-	/* If the target for this constraint is target, return a pointer 
-	 * to the name for this constraints subtarget ... NULL otherwise
-	 */
-	if (target == NULL)
-		return NULL;
-	 
-	if (cti && cti->get_constraint_targets) {
-		cti->get_constraint_targets(con, &targets);
-		
-		for (ct= targets.first; ct; ct= ct->next) {
-			if (ct->tar == target) {
-				if (ct->flag & CONSTRAINT_TAR_TEMP) {
-					/* as temporary targets were created, we can't point to thier subtarget, 
-					 * a local copy is made here... this should be ok as long as this function
-					 * is not called twice with expectations that the string will stay the same
-					 */
-					strcpy(subtarget, ct->subtarget);
-					
-					if (cti->flush_constraint_targets)
-						cti->flush_constraint_targets(con, &targets, 1);
-						
-					return &(subtarget[0]);
-				}
-				else {
-					/* not temporary, so we can return a direct pointer to it */
-					return &(ct->subtarget[0]);
-				}
-			}
-		}
-		
-		if (cti->flush_constraint_targets)
-			cti->flush_constraint_targets(con, &targets, 0);
-	}
-	
-	return NULL;  
-}
-
 /* checks validity of object pointers, and NULLs,
  * if Bone doesnt exist it sets the CONSTRAINT_DISABLE flag 
  */





More information about the Bf-blender-cvs mailing list