diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-02-28 19:13:31 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-02-28 19:13:31 +0300 |
commit | 4762c099d75b12cfbd1d86000cc01c2bce57414b (patch) | |
tree | 052633b1a235d31a3d5c69524965d36230e9233a | |
parent | cee66b8cc0bf6d5419af3187ccd9392b770a6c2f (diff) |
Fix T52685, part II: Add option to strip numbers from flipped bone names again.
While doing so with Bone_R.001, Bone_R.003, Bone_R.003 etc. is doomed to
issues, doing that on duplicates of actually correctly named bones can
be handy, and safe.
So adding back as an option (was removed in rB702bc5ba26d5).
-rw-r--r-- | source/blender/editors/armature/armature_naming.c | 17 | ||||
-rw-r--r-- | source/blender/editors/armature/pose_edit.c | 10 | ||||
-rw-r--r-- | source/blender/editors/include/ED_armature.h | 2 |
3 files changed, 21 insertions, 8 deletions
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 2d7a83f20c1..cd7e3b4cb39 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -313,8 +313,9 @@ typedef struct BoneFlipNameData { * * \param arm: Armature the bones belong to * \param bones_names: List of BoneConflict elems. + * \param do_flip_numbers: if set, try to get rid of dot-numbers at end of bone names. */ -void ED_armature_bones_flip_names(bArmature *arm, ListBase *bones_names) +void ED_armature_bones_flip_names(bArmature *arm, ListBase *bones_names, const bool do_strip_numbers) { ListBase bones_names_conflicts = {NULL}; BoneFlipNameData *bfn; @@ -326,9 +327,9 @@ void ED_armature_bones_flip_names(bArmature *arm, ListBase *bones_names) char name_flip[MAXBONENAME]; char *name = link->data; - /* Do not strip numbers, otherwise we'll end up with completely mismatched names in cases like + /* WARNING: if do_strip_numbers is set, expect completely mismatched names in cases like * Bone.R, Bone.R.001, Bone.R.002, etc. */ - BLI_string_flip_side_name(name_flip, name, false, sizeof(name_flip)); + BLI_string_flip_side_name(name_flip, name, do_strip_numbers, sizeof(name_flip)); ED_armature_bone_rename(arm, name, name_flip); @@ -351,7 +352,7 @@ void ED_armature_bones_flip_names(bArmature *arm, ListBase *bones_names) /* ************************************************** */ /* Bone Renaming - EditMode */ -static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) +static int armature_flip_names_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_edit_object(C); bArmature *arm; @@ -360,6 +361,8 @@ static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; + const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers"); + arm = ob->data; ListBase bones_names = {NULL}; @@ -370,7 +373,7 @@ static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - ED_armature_bones_flip_names(arm, &bones_names); + ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers); BLI_freelistN(&bones_names); @@ -400,6 +403,10 @@ void ARMATURE_OT_flip_names(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "do_strip_numbers", false, "Strip Numbers", + "Try to remove right-most dot-number from flipped names " + "(WARNING: may result in incoherent naming in some cases)"); } diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index acbf23ecf82..2181a6d5ac9 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -589,7 +589,7 @@ static void pose_copy_menu(Scene *scene) /* ********************************************** */ -static int pose_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_flip_names_exec(bContext *C, wmOperator *op) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm; @@ -598,6 +598,8 @@ static int pose_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; + const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers"); + arm = ob->data; ListBase bones_names = {NULL}; @@ -608,7 +610,7 @@ static int pose_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - ED_armature_bones_flip_names(arm, &bones_names); + ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers); BLI_freelistN(&bones_names); @@ -634,6 +636,10 @@ void POSE_OT_flip_names(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "do_strip_numbers", false, "Strip Numbers", + "Try to remove right-most dot-number from flipped names " + "(WARNING: may result in incoherent naming in some cases)"); } /* ------------------ */ diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 00081b95c51..42bda265375 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -175,7 +175,7 @@ void create_vgroups_from_armature(struct ReportList *reports, struct Scene *scen /* if bone is already in list, pass it as param to ignore it */ void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone); void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const char *newnamep); -void ED_armature_bones_flip_names(struct bArmature *arm, struct ListBase *bones_names); +void ED_armature_bones_flip_names(struct bArmature *arm, struct ListBase *bones_names, const bool do_strip_numbers); void undo_push_armature(struct bContext *C, const char *name); |