diff options
author | Joshua Leung <aligorith@gmail.com> | 2007-12-17 13:34:49 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2007-12-17 13:34:49 +0300 |
commit | 317ad91349a3329dadc6f6090544b284b66f42c5 (patch) | |
tree | 7922116236d0246411f027655d8ae263ab522563 | |
parent | 793d7b1eb9ea7c84324727844ba179959174ea6a (diff) |
== 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"
-rw-r--r-- | source/blender/src/editarmature.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 9639e18281d..8efa44213ed 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -1944,6 +1944,7 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) 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 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) } } 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 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) /* 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 @@ void fill_bones_armature(void) */ 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 @@ void fill_bones_armature(void) else { // FIXME.. figure out a method for multiple bones error("Too many points selected"); + printf("Points selected: %d \n", count); + BLI_freelistN(&points); return; } |