Operator: Add 'use_automerge_and_split' option for Translate

This commit is contained in:
Germano Cavalcante 2020-04-15 11:55:22 -03:00
parent fe513a5b61
commit 8f86da71fe
5 changed files with 42 additions and 11 deletions

View File

@ -157,6 +157,8 @@ int BIF_countTransformOrientation(const struct bContext *C);
#define P_GPENCIL_EDIT (1 << 13)
#define P_CURSOR_EDIT (1 << 14)
#define P_CLNOR_INVALIDATE (1 << 15)
/* For properties performed when confirming the transformation. */
#define P_POST_TRANSFORM (1 << 16)
void Transform_Properties(struct wmOperatorType *ot, int flags);

View File

@ -677,6 +677,10 @@ enum {
T_MODAL_CURSOR_SET = 1 << 26,
T_CLNOR_REBUILD = 1 << 27,
/* Special Aftertrans. */
T_AUTOMERGE = 1 << 28,
T_AUTOSPLIT = 1 << 29,
};
/** #TransInfo.modifiers */

View File

@ -1843,8 +1843,8 @@ static void special_aftertrans_update__node(bContext *C, TransInfo *t)
static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
{
/* so automerge supports mirror */
if ((t->scene->toolsettings->automerge) && ((t->flag & T_EDIT) && t->obedit_type == OB_MESH)) {
bool use_automerge = (t->flag & (T_AUTOMERGE | T_AUTOSPLIT)) != 0;
if (use_automerge && ((t->flag & T_EDIT) && t->obedit_type == OB_MESH)) {
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
@ -1870,14 +1870,12 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
hflag = BM_ELEM_SELECT;
}
if (t->scene->toolsettings->automerge & AUTO_MERGE) {
if (t->scene->toolsettings->automerge & AUTO_MERGE_AND_SPLIT) {
EDBM_automerge_and_split(
tc->obedit, true, true, true, hflag, t->scene->toolsettings->doublimit);
}
else {
EDBM_automerge(tc->obedit, true, hflag, t->scene->toolsettings->doublimit);
}
if (t->flag & T_AUTOSPLIT) {
EDBM_automerge_and_split(
tc->obedit, true, true, true, hflag, t->scene->toolsettings->doublimit);
}
else {
EDBM_automerge(tc->obedit, true, hflag, t->scene->toolsettings->doublimit);
}
/* Special case, this is needed or faces won't re-select.

View File

@ -1763,6 +1763,24 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->options |= CTX_NO_PET;
}
if (t->obedit_type == OB_MESH) {
if (op && (prop = RNA_struct_find_property(op->ptr, "use_automerge_and_split")) &&
RNA_property_is_set(op->ptr, prop)) {
if (RNA_property_boolean_get(op->ptr, prop)) {
t->flag |= T_AUTOMERGE | T_AUTOSPLIT;
}
}
else {
char automerge = t->scene->toolsettings->automerge;
if (automerge & AUTO_MERGE) {
t->flag |= T_AUTOMERGE;
if (automerge & AUTO_MERGE_AND_SPLIT) {
t->flag |= T_AUTOSPLIT;
}
}
}
}
// Mirror is not supported with PET, turn it off.
#if 0
if (t->flag & T_PROP_EDIT) {

View File

@ -705,6 +705,15 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
prop = RNA_def_boolean(ot->srna, "use_accurate", 0, "Accurate", "Use accurate transformation");
RNA_def_property_flag(prop, PROP_HIDDEN);
}
if (flags & P_POST_TRANSFORM) {
prop = RNA_def_boolean(ot->srna,
"use_automerge_and_split",
0,
"Auto Merge & Split",
"Forces the use of Auto Merge & Split");
RNA_def_property_flag(prop, PROP_HIDDEN);
}
}
static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
@ -730,7 +739,7 @@ static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
Transform_Properties(ot,
P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP |
P_OPTIONS | P_GPENCIL_EDIT | P_CURSOR_EDIT);
P_OPTIONS | P_GPENCIL_EDIT | P_CURSOR_EDIT | P_POST_TRANSFORM);
}
static void TRANSFORM_OT_resize(struct wmOperatorType *ot)