I'm currently searching for bugs inside the armature code. Not that I was looking for, but as I'm on it, I found some needless copying (result will be overwritten anyways) and one computed, but never used matrix variable (M_boneRest) inside ED_armature_from_edit().

As I read on the mainpage I can either post the patch to the tracker or mail it on this list. Since it is very minor (changing no functionality) patch, I hope it gets applied immediately.

Patch is inside the appendix

Greatings from
Tobias Oelgarte
Index: source/blender/editors/armature/editarmature.c
===================================================================
--- source/blender/editors/armature/editarmature.c      (Revision 34599)
+++ source/blender/editors/armature/editarmature.c      (Arbeitskopie)
@@ -398,15 +398,15 @@
        
        /* remove zero sized bones, this gives instable restposes */
        for (eBone=arm->edbo->first; eBone; eBone= neBone) {
-               float len= len_v3v3(eBone->head, eBone->tail);
-               neBone= eBone->next;
+               float len = len_v3v3(eBone->head, eBone->tail);
+               neBone = eBone->next;
                if (len <= 0.000001f) {         /* FLT_EPSILON is too large? */
                        EditBone *fBone;
                        
                        /*      Find any bones that refer to this bone  */
                        for (fBone=arm->edbo->first; fBone; fBone= fBone->next) 
{
-                               if (fBone->parent==eBone)
-                                       fBone->parent= eBone->parent;
+                               if (fBone->parent == eBone)
+                                       fBone->parent = eBone->parent;
                        }
                        if (G.f & G_DEBUG)
                                printf("Warning: removed zero sized bone: 
%s\n", eBone->name);
@@ -416,59 +416,52 @@
        
        /*      Copy the bones from the editData into the armature */
        for (eBone=arm->edbo->first; eBone; eBone=eBone->next) {
-               newBone= MEM_callocN(sizeof(Bone), "bone");
-               eBone->temp= newBone;   /* Associate the real Bones with the 
EditBones */
+               newBone = MEM_callocN(sizeof(Bone), "bone");
                
+               /* Associate the real Bones with the EditBones */
+               eBone->temp = newBone;
+               
                BLI_strncpy(newBone->name, eBone->name, sizeof(newBone->name));
-               memcpy(newBone->head, eBone->head, sizeof(newBone->head));
-               memcpy(newBone->tail, eBone->tail, sizeof(newBone->tail));
-               newBone->flag= eBone->flag;
+               newBone->flag = eBone->flag;
                
                if (eBone == arm->act_edbone) {
-                       newBone->flag |= BONE_SELECTED; /* important, editbones 
can be active with only 1 point selected */
-                       arm->act_edbone= NULL;
-                       arm->act_bone= newBone;
+                       /* important, editbones can be active with only 1 point 
selected */
+                       newBone->flag |= BONE_SELECTED;
+                       arm->act_edbone = NULL;
+                       arm->act_bone = newBone;
                }
                newBone->roll = 0.0f;
-               
                newBone->weight = eBone->weight;
                newBone->dist = eBone->dist;
-               
                newBone->xwidth = eBone->xwidth;
                newBone->zwidth = eBone->zwidth;
-               newBone->ease1= eBone->ease1;
-               newBone->ease2= eBone->ease2;
-               newBone->rad_head= eBone->rad_head;
-               newBone->rad_tail= eBone->rad_tail;
-               newBone->segments= eBone->segments;
+               newBone->ease1 = eBone->ease1;
+               newBone->ease2 = eBone->ease2;
+               newBone->rad_head = eBone->rad_head;
+               newBone->rad_tail = eBone->rad_tail;
+               newBone->segments = eBone->segments;
                newBone->layer = eBone->layer;
                
                if(eBone->prop)
-                       newBone->prop= IDP_CopyProperty(eBone->prop);
+                       newBone->prop = IDP_CopyProperty(eBone->prop);
        }
        
        /*      Fix parenting in a separate pass to ensure ebone->bone 
connections
                are valid at this point */
-       for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
-               newBone= (Bone *)eBone->temp;
+       for (eBone=arm->edbo->first; eBone; eBone=eBone->next) {
+               newBone = (Bone *)eBone->temp;
                if (eBone->parent) {
-                       newBone->parent= (Bone *)eBone->parent->temp;
+                       newBone->parent = (Bone *)eBone->parent->temp;
                        BLI_addtail(&newBone->parent->childbase, newBone);
-                       
                        {
-                               float M_boneRest[3][3];
                                float M_parentRest[3][3];
                                float iM_parentRest[3][3];
-                               float   delta[3];
+                               float delta[3];
                                
                                /* Get the parent's  matrix (rotation only) */
                                sub_v3_v3v3(delta, eBone->parent->tail, 
eBone->parent->head);
                                vec_roll_to_mat3(delta, eBone->parent->roll, 
M_parentRest);
-                               
-                               /* Get this bone's  matrix (rotation only) */
-                               sub_v3_v3v3(delta, eBone->tail, eBone->head);
-                               vec_roll_to_mat3(delta, eBone->roll, 
M_boneRest);
-                               
+                                                               
                                /* Invert the parent matrix */
                                invert_m3_m3(iM_parentRest, M_parentRest);
                                
@@ -481,8 +474,11 @@
                        }
                }
                /*      ...otherwise add this bone to the armature's bonebase */
-               else
+               else {
+                       memcpy(newBone->head, eBone->head, 
sizeof(newBone->head));
+                       memcpy(newBone->tail, eBone->tail, 
sizeof(newBone->tail));
                        BLI_addtail(&arm->bonebase, newBone);
+               }
        }
        
        /* Make a pass through the new armature to fix rolling */
_______________________________________________
Bf-committers mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-committers

Reply via email to