[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12921] trunk/blender/source/blender/src/ editarmature.c: == Fill Bones - Bugfixes ==

Joshua Leung aligorith at gmail.com
Mon Dec 17 11:34:49 CET 2007


Revision: 12921
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12921
Author:   aligorith
Date:     2007-12-17 11:34:49 +0100 (Mon, 17 Dec 2007)

Log Message:
-----------
== Fill Bones - Bugfixes ==

* Some joints were identified multiple times, which caused a "too many joints" error when only 2 joints were selected
* When no joints were selected, "too many joints" error was displayed. This has been changed to "no joints selected"
* Fixed a memory leak that occurred when "too many joints selected"

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

Modified: trunk/blender/source/blender/src/editarmature.c
===================================================================
--- trunk/blender/source/blender/src/editarmature.c	2007-12-17 08:32:14 UTC (rev 12920)
+++ trunk/blender/source/blender/src/editarmature.c	2007-12-17 10:34:49 UTC (rev 12921)
@@ -1944,6 +1944,7 @@
 		VECCOPY(vec, ebo->head);
 	}
 	
+	// FIXME: this algorithm sucks... it misses things it shouldn't
 	for (ebp= points->first; ebp; ebp= ebp->next) {
 		if (VecEqual(ebp->vec, vec)) {			
 			if (eb_tail) {
@@ -1955,7 +1956,7 @@
 				}
 			}
 			else {
-				if ((ebp->tail_owner) && (ebp->tail_owner->parent == ebo)) {
+				if ((ebp->tail_owner) && (ebo->parent == ebp->tail_owner)) {
 					/* so this bone's head owner is this bone */
 					ebp->head_owner= ebo;
 					found = 1;
@@ -1985,32 +1986,21 @@
 /* bone adding between selected joints */
 void fill_bones_armature(void)
 {
+	bArmature *arm= G.obedit->data;
 	EditBone *ebo, *newbone=NULL;
-	
-	ListBase chains = {NULL, NULL};
-	LinkData *chain;
-	
 	ListBase points = {NULL, NULL};
 	int count;
 	
-	
-	/* get chains */
-	chains_find_tips(&chains);
-	if (chains.first == NULL) return;
-	
-	/* traverse chains to find selected joints */
-	for (chain= chains.first; chain; chain= chain->next) {
-		for (ebo= chain->data; ebo; ebo= ebo->parent) {
-			if (ebo->flag & BONE_ROOTSEL)
+	/* loop over all bones, and only consider if visible */
+	for (ebo= G.edbo.first; ebo; ebo= ebo->next) {
+		if ((arm->layer & ebo->layer) && !(ebo->flag & BONE_HIDDEN_A)) {
+			if (!(ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL))
 				fill_add_joint(ebo, 0, &points);
 			if (ebo->flag & BONE_TIPSEL) 
 				fill_add_joint(ebo, 1, &points);
 		}
 	}
 	
-	/* free chains - not needed anymore */
-	BLI_freelistN(&chains);
-	
 	/* the number of joints determines how we fill:
 	 *	1) between joint and cursor (joint=head, cursor=tail)
 	 *	2) between the two joints (order is dependent on active-bone/hierachy)
@@ -2018,7 +2008,11 @@
 	 */
 	count= BLI_countlist(&points);
 	
-	if (count == 1) {
+	if (count == 0) {
+		error("No joints selected");
+		return;
+	}
+	else if (count == 1) {
 		EditBonePoint *ebp;
 		float curs[3];
 		
@@ -2097,6 +2091,8 @@
 	else {
 		// FIXME.. figure out a method for multiple bones
 		error("Too many points selected"); 
+		printf("Points selected: %d \n", count);
+		BLI_freelistN(&points);
 		return;
 	}
 	





More information about the Bf-blender-cvs mailing list