2.5 - Restoring Bone Groups
[blender-staging.git] / source / blender / editors / armature / editarmature_generate.c
index 6d271375c646178d462612b452edb55f93efc290..6c0eab16af094d68913cd6ff97df4aeab38c2c6b 100644 (file)
@@ -285,6 +285,8 @@ EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *
        EditBone *lastBone = NULL;
        EditBone *child = NULL;
        EditBone *parent = NULL;
        EditBone *lastBone = NULL;
        EditBone *child = NULL;
        EditBone *parent = NULL;
+       float *normal = NULL;
+       float size_buffer = 1.2;
        int bone_start = 0;
        int end = iter->length;
        int index;
        int bone_start = 0;
        int end = iter->length;
        int index;
@@ -294,6 +296,13 @@ EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *
        parent = addEditBone(arm, "Bone");
        VECCOPY(parent->head, iter->p);
        
        parent = addEditBone(arm, "Bone");
        VECCOPY(parent->head, iter->p);
        
+       if (iter->size > 0)
+       {
+               parent->rad_head = iter->size * size_buffer;
+       }
+       
+       normal = iter->no;
+       
        index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail);
        while (index != -1)
        {
        index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail);
        while (index != -1)
        {
@@ -304,21 +313,33 @@ EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *
                child->parent = parent;
                child->flag |= BONE_CONNECTED;
                
                child->parent = parent;
                child->flag |= BONE_CONNECTED;
                
+               if (iter->size > 0)
+               {
+                       child->rad_head = iter->size * size_buffer;
+                       parent->rad_tail = iter->size * size_buffer;
+               }
+
                /* going to next bone, fix parent */
                Mat4MulVecfl(invmat, parent->tail);
                Mat4MulVecfl(invmat, parent->head);
                /* going to next bone, fix parent */
                Mat4MulVecfl(invmat, parent->tail);
                Mat4MulVecfl(invmat, parent->head);
-               setBoneRollFromNormal(parent, iter->no, invmat, tmat);
+               setBoneRollFromNormal(parent, normal, invmat, tmat);
 
                parent = child; // new child is next parent
                bone_start = index; // start next bone from current index
 
 
                parent = child; // new child is next parent
                bone_start = index; // start next bone from current index
 
+               normal = iter->no; /* use normal at head, not tail */
+
                index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail);
        }
        
        iter->tail(iter);
 
        VECCOPY(parent->tail, iter->p);
                index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail);
        }
        
        iter->tail(iter);
 
        VECCOPY(parent->tail, iter->p);
-
+       if (iter->size > 0)
+       {
+               parent->rad_tail = iter->size * size_buffer;
+       }
+               
        /* fix last bone */
        Mat4MulVecfl(invmat, parent->tail);
        Mat4MulVecfl(invmat, parent->head);
        /* fix last bone */
        Mat4MulVecfl(invmat, parent->tail);
        Mat4MulVecfl(invmat, parent->head);