Bug fix in X-Mirror for armatures
[blender.git] / source / blender / src / editarmature.c
index 172e06f5add32a26640e1f4c66a918940cff81a3..c166a9df7629b38871d2c9d5fe0baa77cf132e6a 100644 (file)
@@ -4097,16 +4097,34 @@ void transform_armature_mirror_update(void)
                        if (eboflip) {
                                /* we assume X-axis flipping for now */
                                if (ebo->flag & BONE_TIPSEL) {
+                                       EditBone *children;
+                                       
                                        eboflip->tail[0]= -ebo->tail[0];
                                        eboflip->tail[1]= ebo->tail[1];
                                        eboflip->tail[2]= ebo->tail[2];
                                        eboflip->rad_tail= ebo->rad_tail;
+
+                                       /* Also move connected children, in case children's name aren't mirrored properly */
+                                       for (children=G.edbo.first; children; children=children->next) {
+                                               if (children->parent == eboflip && children->flag & BONE_CONNECTED) {
+                                                       VECCOPY(children->head, eboflip->tail);
+                                                       children->rad_head = ebo->rad_tail;
+                                               }
+                                       }
                                }
                                if (ebo->flag & BONE_ROOTSEL) {
                                        eboflip->head[0]= -ebo->head[0];
                                        eboflip->head[1]= ebo->head[1];
                                        eboflip->head[2]= ebo->head[2];
                                        eboflip->rad_head= ebo->rad_head;
+                                       
+                                       /* Also move connected parent, in case parent's name isn't mirrored properly */
+                                       if (eboflip->parent && eboflip->flag & BONE_CONNECTED)
+                                       {
+                                               EditBone *parent = eboflip->parent;
+                                               VECCOPY(parent->tail, eboflip->head);
+                                               parent->rad_tail = ebo->rad_head;
+                                       }
                                }
                                if (ebo->flag & BONE_SELECTED) {
                                        eboflip->dist= ebo->dist;