diff options
author | Joshua Leung <aligorith@gmail.com> | 2008-10-21 05:40:47 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2008-10-21 05:40:47 +0400 |
commit | 3ac142e65459a0c016397cce53debfca9137c475 (patch) | |
tree | 727e2591a73b64f65ee98b70d47b0b92d9390e6c /source/blender/src | |
parent | 11afafb01e42803f578c97a966807e5e5baaefb1 (diff) |
#17873: "switch direction" for bones can cause infinite loop
Second attempt at fixing this bug. Previous fix caused segfault when all bones in a chain are selected. Now it should segments which are selected (i.e. get swapped) will get unparented from segments that aren't (i.e. aren't swapped, so are still in old orientation)
Diffstat (limited to 'source/blender/src')
-rw-r--r-- | source/blender/src/editarmature.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index ef6be4a010d..61ca5c09877 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -3277,7 +3277,8 @@ void switch_direction_armature (void) EditBone *ebo, *child=NULL, *parent=NULL; /* loop over bones in chain */ - for (ebo= chain->data; ebo; child= ebo, ebo=parent) { + for (ebo= chain->data; ebo;) { + /* parent is this bone's original parent (to go to next if we swap) */ parent= ebo->parent; /* only if selected and editable */ @@ -3297,12 +3298,28 @@ void switch_direction_armature (void) else ebo->flag &= ~BONE_CONNECTED; - child->parent = NULL; - child->flag &= ~BONE_CONNECTED; - - /* FIXME: other things that need fixing? - * i.e. roll? + /* get next bones + * - child will become the new parent of next bone + * - next bone to go to will be the original parent + */ + child= ebo; + ebo= parent; + } + else { + /* not swapping this bone, however, if its 'parent' got swapped, unparent us from it + * as it will be facing in opposite direction + */ + if ((parent) && (EBONE_VISIBLE(arm, parent) && EBONE_EDITABLE(parent))) { + ebo->parent= NULL; + ebo->flag &= ~BONE_CONNECTED; + } + + /* get next bones + * - child will become new parent of next bone (not swapping occurred, so set to NULL to prevent infinite-loop) + * - next bone to go to will be the original parent (no change) */ + child= NULL; + ebo= parent; } } } |