code cleanup: rename flip_side_name to BKE_deform_flip_side_name
authorCampbell Barton <ideasman42@gmail.com>
Sat, 16 Nov 2013 17:20:31 +0000 (04:20 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 16 Nov 2013 18:23:05 +0000 (05:23 +1100)
source/blender/blenkernel/BKE_deform.h
source/blender/blenkernel/intern/deform.c
source/blender/editors/armature/armature_naming.c
source/blender/editors/armature/armature_skinning.c
source/blender/editors/armature/armature_utils.c
source/blender/editors/armature/pose_edit.c
source/blender/editors/armature/pose_select.c
source/blender/editors/armature/pose_transform.c
source/blender/editors/object/object_select.c
source/blender/editors/sculpt_paint/paint_vertex.c

index 435cad17e571761bc0d196683c6adf7def9ef906..e203549fef589c562165bd55e16e8ea8d2e926ae 100644 (file)
@@ -91,6 +91,7 @@ void defvert_normalize_lock_map(struct MDeformVert *dvert,
 void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char base[MAX_VGROUP_NAME], char ext[MAX_VGROUP_NAME]);
 void BKE_deform_split_prefix(const char string[MAX_VGROUP_NAME], char base[MAX_VGROUP_NAME], char ext[MAX_VGROUP_NAME]);
 
-void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number);
+void BKE_deform_flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME],
+                               const bool strip_number);
 
 #endif  /* __BKE_DEFORM_H__ */
index a183872552dd69ad6865a7b8c3ccbc785a7617e8..dafc0c3c7546a609dae94af7438717c0e57d3473 100644 (file)
@@ -447,7 +447,7 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, const bool use_default)
        }
        else {
                bDeformGroup *dg;
-               char name[sizeof(dg->name)];
+               char name_flip[sizeof(dg->name)];
                int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__);
 
                for (i = 0; i < defbase_tot; i++) {
@@ -461,9 +461,10 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, const bool use_default)
                                if (use_default)
                                        map[i] = i;
 
-                               flip_side_name(name, dg->name, FALSE);
-                               if (strcmp(name, dg->name)) {
-                                       flip_num = defgroup_name_index(ob, name);
+                               BKE_deform_flip_side_name(name_flip, dg->name, false);
+
+                               if (!STREQ(name_flip, dg->name)) {
+                                       flip_num = defgroup_name_index(ob, name_flip);
                                        if (flip_num >= 0) {
                                                map[i] = flip_num;
                                                map[flip_num] = i; /* save an extra lookup */
@@ -485,7 +486,7 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, const bool use_defa
        }
        else {
                bDeformGroup *dg;
-               char name[sizeof(dg->name)];
+               char name_flip[sizeof(dg->name)];
                int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__);
 
                for (i = 0; i < defbase_tot; i++) {
@@ -494,9 +495,9 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, const bool use_defa
 
                dg = BLI_findlink(&ob->defbase, defgroup);
 
-               flip_side_name(name, dg->name, FALSE);
-               if (strcmp(name, dg->name)) {
-                       flip_num = defgroup_name_index(ob, name);
+               BKE_deform_flip_side_name(name_flip, dg->name, false);
+               if (!STREQ(name_flip, dg->name)) {
+                       flip_num = defgroup_name_index(ob, name_flip);
 
                        if (flip_num != -1) {
                                map[defgroup] = flip_num;
@@ -514,11 +515,12 @@ int defgroup_flip_index(Object *ob, int index, const bool use_default)
        int flip_index = -1;
 
        if (dg) {
-               char name[sizeof(dg->name)];
-               flip_side_name(name, dg->name, 0);
+               char name_flip[sizeof(dg->name)];
+               BKE_deform_flip_side_name(name_flip, dg->name, false);
 
-               if (strcmp(name, dg->name))
-                       flip_index = defgroup_name_index(ob, name);
+               if (!STREQ(name_flip, dg->name)) {
+                       flip_index = defgroup_name_index(ob, name_flip);
+               }
        }
 
        return (flip_index == -1 && use_default) ? index : flip_index;
@@ -602,7 +604,8 @@ void BKE_deform_split_prefix(const char string[MAX_VGROUP_NAME], char pre[MAX_VG
 /* finds the best possible flipped name. For renaming; check for unique names afterwards */
 /* if strip_number: removes number extensions
  * note: don't use sizeof() for 'name' or 'from_name' */
-void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number)
+void BKE_deform_flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME],
+                               const bool strip_number)
 {
        int     len;
        char    prefix[MAX_VGROUP_NAME]  = "";   /* The part before the facing */
@@ -624,7 +627,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_
        if (isdigit(name[len - 1])) {
                index = strrchr(name, '.'); // last occurrence
                if (index && isdigit(index[1])) { // doesnt handle case bone.1abc2 correct..., whatever!
-                       if (strip_number == 0) {
+                       if (strip_number == false) {
                                BLI_strncpy(number, index, sizeof(number));
                        }
                        *index = 0;
index 2228cb8386e652f3005344a0967611384bc040d2..10e9724089807adb6bfeb9c07bd920985d80b7c9 100644 (file)
@@ -289,7 +289,6 @@ static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Object *ob = CTX_data_edit_object(C);
        bArmature *arm;
-       char newname[MAXBONENAME];
        
        /* paranoia checks */
        if (ELEM(NULL, ob, ob->pose)) 
@@ -299,8 +298,9 @@ static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op))
        /* loop through selected bones, auto-naming them */
        CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
        {
-               flip_side_name(newname, ebone->name, TRUE); // 1 = do strip off number extensions
-               ED_armature_bone_rename(arm, ebone->name, newname);
+               char name_flip[MAXBONENAME];
+               BKE_deform_flip_side_name(name_flip, ebone->name, true);
+               ED_armature_bone_rename(arm, ebone->name, name_flip);
        }
        CTX_DATA_END;
        
index 0301db4b4cfe9a94454fb8c2fc929d1c4c5050c2..5f15d15d478e8a1956d63f368141e994a83416e1 100644 (file)
@@ -346,11 +346,10 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
                
                /* find flipped group */
                if (dgroup && mirror) {
-                       char name[MAXBONENAME];
+                       char name_flip[MAXBONENAME];
 
-                       // 0 = don't strip off number extensions
-                       flip_side_name(name, dgroup->name, FALSE);
-                       dgroupflip[j] = defgroup_find_name(ob, name);
+                       BKE_deform_flip_side_name(name_flip, dgroup->name, false);
+                       dgroupflip[j] = defgroup_find_name(ob, name_flip);
                }
        }
 
index f2f51dc1bd58826f3ae675deec216f6d24f89b89..7efeeebcf1de7be7cfab1e74743f278749803b50 100644 (file)
@@ -182,16 +182,16 @@ void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4])
 EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo)
 {
        EditBone *eboflip = NULL;
-       char name[MAXBONENAME];
+       char name_flip[MAXBONENAME];
        
        if (ebo == NULL)
                return NULL;
        
-       flip_side_name(name, ebo->name, FALSE);
+       BKE_deform_flip_side_name(name_flip, ebo->name, false);
        
        for (eboflip = edbo->first; eboflip; eboflip = eboflip->next) {
                if (ebo != eboflip) {
-                       if (!strcmp(name, eboflip->name))
+                       if (!strcmp(name_flip, eboflip->name))
                                break;
                }
        }
index 31ff1e161e81499b16e5937e979194fa35844f8a..d1c096e6cf5cee286d0cc0d0c6c48dd73398fef8 100644 (file)
@@ -577,9 +577,9 @@ static int pose_flip_names_exec(bContext *C, wmOperator *UNUSED(op))
        /* loop through selected bones, auto-naming them */
        CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
        {
-               char newname[MAXBONENAME];
-               flip_side_name(newname, pchan->name, TRUE);
-               ED_armature_bone_rename(arm, pchan->name, newname);
+               char name_flip[MAXBONENAME];
+               BKE_deform_flip_side_name(name_flip, pchan->name, true);
+               ED_armature_bone_rename(arm, pchan->name, name_flip);
        }
        CTX_DATA_END;
        
index a53d8050c5dd675da6192941bddbf72d9bfd10d0..687b1f3f9bc931edb123975605fcc0e840b71da3 100644 (file)
@@ -848,10 +848,10 @@ static int pose_bone_flip_active_exec(bContext *C, wmOperator *UNUSED(op))
                
                if (arm->act_bone) {
                        bPoseChannel *pchanf;
-                       char name[MAXBONENAME];
-                       flip_side_name(name, arm->act_bone->name, TRUE);
+                       char name_flip[MAXBONENAME];
+                       BKE_deform_flip_side_name(name_flip, arm->act_bone->name, true);
                        
-                       pchanf = BKE_pose_channel_find_name(ob->pose, name);
+                       pchanf = BKE_pose_channel_find_name(ob->pose, name_flip);
                        if (pchanf && pchanf->bone != arm->act_bone) {
                                arm->act_bone->flag &= ~BONE_SELECTED;
                                pchanf->bone->flag |= BONE_SELECTED;
@@ -860,7 +860,7 @@ static int pose_bone_flip_active_exec(bContext *C, wmOperator *UNUSED(op))
                                
                                /* in weightpaint we select the associated vertex group too */
                                if (ob_act->mode & OB_MODE_WEIGHT_PAINT) {
-                                       ED_vgroup_select_by_name(ob_act, name);
+                                       ED_vgroup_select_by_name(ob_act, name_flip);
                                        DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
                                }
                                
index 79ca70a618963c55418a83a18f743ac94769e153..4e66c3290884d7ddf0773b14f9cf5f9fec6c9c65 100644 (file)
@@ -302,7 +302,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, short se
        
        /* get the name - if flipping, we must flip this first */
        if (flip)
-               flip_side_name(name, chan->name, 0);        /* 0 = don't strip off number extensions */
+               BKE_deform_flip_side_name(name, chan->name, false);
        else
                BLI_strncpy(name, chan->name, sizeof(name));
        
index 974dc3acef9ffdd32206e36949febb5e220a3afc..ffa9eed65b92d3d7860e5e1af2428bfb33eacf20 100644 (file)
@@ -1078,12 +1078,12 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
        
        CTX_DATA_BEGIN (C, Base *, primbase, selected_bases)
        {
-               char tmpname[MAXBONENAME];
+               char name_flip[MAXBONENAME];
 
-               flip_side_name(tmpname, primbase->object->id.name + 2, TRUE);
+               BKE_deform_flip_side_name(name_flip, primbase->object->id.name + 2, true);
                
-               if (strcmp(tmpname, primbase->object->id.name + 2) != 0) { /* names differ */
-                       Object *ob = (Object *)BKE_libblock_find_name(ID_OB, tmpname);
+               if (!STREQ(name_flip, primbase->object->id.name + 2)) {
+                       Object *ob = (Object *)BKE_libblock_find_name(ID_OB, name_flip);
                        if (ob) {
                                Base *secbase = BKE_scene_base_find(scene, ob);
 
index c8c38eebea96a3943d550e179dbd5a792aa35297..714d67c803942d7994e823f9e687f35b70235531 100644 (file)
@@ -378,12 +378,12 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
 
        if (defgroup) {
                int mirrdef;
-               char name[MAXBONENAME];
+               char name_flip[MAXBONENAME];
 
-               flip_side_name(name, defgroup->name, FALSE);
-               mirrdef = defgroup_name_index(ob, name);
+               BKE_deform_flip_side_name(name_flip, defgroup->name, false);
+               mirrdef = defgroup_name_index(ob, name_flip);
                if (mirrdef == -1) {
-                       if (BKE_defgroup_new(ob, name)) {
+                       if (BKE_defgroup_new(ob, name_flip)) {
                                mirrdef = BLI_countlist(&ob->defbase) - 1;
                        }
                }