converted more mixed tab/space indentations to tabs. only whitespace changes.
[blender.git] / source / blender / editors / armature / editarmature.c
index 76a6cd8..23f91f8 100644 (file)
@@ -416,7 +416,9 @@ void ED_armature_from_edit(Object *obedit)
                newBone->flag= eBone->flag;
                
                if (eBone == arm->act_edbone) {
-                       newBone->flag |= BONE_SELECTED; /* important, editbones can be active with only 1 point selected */
+                       /* don't change active selection, this messes up separate which uses
+                        * editmode toggle and can separate active bone which is de-selected originally */
+                       /* newBone->flag |= BONE_SELECTED; */ /* important, editbones can be active with only 1 point selected */
                        arm->act_edbone= NULL;
                        arm->act_bone= newBone;
                }
@@ -997,7 +999,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
 static void separated_armature_fix_links(Object *origArm, Object *newArm)
 {
        Object *ob;
-       bPoseChannel *pchan, *pcha, *pchb;
+       bPoseChannel *pchan;
        bConstraint *con;
        ListBase *opchans, *npchans;
        
@@ -1024,38 +1026,23 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
                                                         *      - the target isn't origArm/newArm itself
                                                         *      - the target is one that can be found in newArm/origArm
                                                         */
-                                                       if ((ct->tar == origArm) && (ct->subtarget[0] != 0)) {
-                                                               for (pcha=npchans->first, pchb=npchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) {
-                                                                       /* check if either one matches */
-                                                                       if ( (strcmp(pcha->name, ct->subtarget)==0) ||
-                                                                                (strcmp(pchb->name, ct->subtarget)==0) )
-                                                                       {
+                                                       if (ct->subtarget[0] != 0) {
+                                                               if (ct->tar == origArm) {
+                                                                       if(BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) {
                                                                                ct->tar= newArm;
-                                                                               break;
                                                                        }
-                                                                       
-                                                                       /* check if both ends have met (to stop checking) */
-                                                                       if (pcha == pchb) break;
-                                                               }                                                               
-                                                       }
-                                                       else if ((ct->tar == newArm) && (ct->subtarget[0] != 0)) {
-                                                               for (pcha=opchans->first, pchb=opchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) {
-                                                                       /* check if either one matches */
-                                                                       if ( (strcmp(pcha->name, ct->subtarget)==0) ||
-                                                                                (strcmp(pchb->name, ct->subtarget)==0) )
-                                                                       {
+                                                               }
+                                                               else if (ct->tar == newArm) {
+                                                                       if(BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) {
                                                                                ct->tar= origArm;
-                                                                               break;
                                                                        }
-                                                                       
-                                                                       /* check if both ends have met (to stop checking) */
-                                                                       if (pcha == pchb) break;
-                                                               }                                                               
+                                                               }
                                                        }
                                                }
-                                               
-                                               if (cti->flush_constraint_targets)
+
+                                               if (cti->flush_constraint_targets) {
                                                        cti->flush_constraint_targets(con, &targets, 0);
+                                               }
                                        }
                                }
                        }
@@ -1077,58 +1064,33 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
                                                 *      - the target isn't origArm/newArm itself
                                                 *      - the target is one that can be found in newArm/origArm
                                                 */
-                                               if ((ct->tar == origArm) && (ct->subtarget[0] != 0)) {
-                                                       for (pcha=npchans->first, pchb=npchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) {
-                                                               /* check if either one matches */
-                                                               if ( (strcmp(pcha->name, ct->subtarget)==0) ||
-                                                                        (strcmp(pchb->name, ct->subtarget)==0) )
-                                                               {
+                                               if(ct->subtarget[0] != '\0')  {
+                                                       if (ct->tar == origArm) {
+                                                               if(BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) {
                                                                        ct->tar= newArm;
-                                                                       break;
                                                                }
-                                                               
-                                                               /* check if both ends have met (to stop checking) */
-                                                               if (pcha == pchb) break;
-                                                       }                                                               
-                                               }
-                                               else if ((ct->tar == newArm) && (ct->subtarget[0] != 0)) {
-                                                       for (pcha=opchans->first, pchb=opchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) {
-                                                               /* check if either one matches */
-                                                               if ( (strcmp(pcha->name, ct->subtarget)==0) ||
-                                                                        (strcmp(pchb->name, ct->subtarget)==0) )
-                                                               {
+                                                       }
+                                                       else if (ct->tar == newArm) {
+                                                               if(BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) {
                                                                        ct->tar= origArm;
-                                                                       break;
                                                                }
-                                                               
-                                                               /* check if both ends have met (to stop checking) */
-                                                               if (pcha == pchb) break;
-                                                       }                                                               
+                                                       }
                                                }
                                        }
-                                       
-                                       if (cti->flush_constraint_targets)
+
+                                       if (cti->flush_constraint_targets) {
                                                cti->flush_constraint_targets(con, &targets, 0);
+                                       }
                                }
                        }
                }
                
                /* See if an object is parented to this armature */
-               if ((ob->parent) && (ob->parent == origArm)) {
+               if (ob->parent && (ob->parent == origArm)) {
                        /* Is object parented to a bone of this src armature? */
-                       if (ob->partype==PARBONE) {
-                               /* bone name in object */
-                               for (pcha=npchans->first, pchb=npchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) {
-                                       /* check if either one matches */
-                                       if ( (strcmp(pcha->name, ob->parsubstr)==0) ||
-                                                (strcmp(pchb->name, ob->parsubstr)==0) )
-                                       {
-                                               ob->parent= newArm;
-                                               break;
-                                       }
-                                       
-                                       /* check if both ends have met (to stop checking) */
-                                       if (pcha == pchb) break;
+                       if ((ob->partype == PARBONE) && (ob->parsubstr[0] != '\0')) {
+                               if(BLI_findstring(npchans, ob->parsubstr, offsetof(bPoseChannel, name))) {
+                                       ob->parent= newArm;
                                }
                        }
                }
@@ -2762,7 +2724,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
 
        /* cancel if nothing selected */
        if (CTX_DATA_COUNT(C, selected_bones) == 0)
-         return OPERATOR_CANCELLED;
+               return OPERATOR_CANCELLED;
        
        ED_armature_sync_selection(arm->edbo); // XXX why is this needed?
 
@@ -5844,7 +5806,7 @@ EditBone * test_subdivideByCorrelation(Scene *scene, Object *obedit, ReebArc *ar
                lastBone = subdivideArcBy(arm, arm->edbo, iter, invmat, tmat, nextAdaptativeSubdivision);
        }
        
-         return lastBone;
+       return lastBone;
 }
 
 float arcLengthRatio(ReebArc *arc)