forked from bartvdbraak/blender
mesh inset tool - option to interpolate UV's vcols etc, on by default since this is almost always what you'd want.
currently only working for inset-individual, inset-region coming next.
This commit is contained in:
parent
6f1f897d34
commit
36cc2fd6da
@ -1511,6 +1511,7 @@ static BMOpDefine bmo_inset_individual_def = {
|
||||
{"thickness", BMO_OP_SLOT_FLT},
|
||||
{"depth", BMO_OP_SLOT_FLT},
|
||||
{"use_even_offset", BMO_OP_SLOT_BOOL},
|
||||
{"use_interpolate", BMO_OP_SLOT_BOOL},
|
||||
{{'\0'}},
|
||||
},
|
||||
/* slots_out */
|
||||
|
@ -74,6 +74,7 @@ void bmo_inset_individual_exec(BMesh *bm, BMOperator *op)
|
||||
const float thickness = BMO_slot_float_get(op->slots_in, "thickness");
|
||||
const float depth = BMO_slot_float_get(op->slots_in, "depth");
|
||||
const bool use_even_offset = BMO_slot_bool_get(op->slots_in, "use_even_offset");
|
||||
const bool use_interpolate = BMO_slot_bool_get(op->slots_in, "use_interpolate");
|
||||
|
||||
/* Only tag faces in slot */
|
||||
BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, false);
|
||||
@ -81,6 +82,7 @@ void bmo_inset_individual_exec(BMesh *bm, BMOperator *op)
|
||||
BMO_slot_buffer_hflag_enable(bm, op->slots_in, "faces", BM_FACE, BM_ELEM_TAG, false);
|
||||
|
||||
BMO_ITER(f, &oiter, op->slots_in, "faces", BM_FACE) {
|
||||
BMFace *f_new_inner;
|
||||
BMLoop *l_iter, *l_first;
|
||||
BMLoop *l_iter_inner = NULL;
|
||||
int i;
|
||||
@ -152,20 +154,26 @@ void bmo_inset_individual_exec(BMesh *bm, BMOperator *op)
|
||||
copy_v3_v3(eiinfo_arr[index].e_new->v1->co, v_new_co);
|
||||
} while ((l_iter = l_iter->next) != l_first);
|
||||
|
||||
{
|
||||
BMFace *f_new_inner;
|
||||
/* Create New Inset Faces */
|
||||
f_new_inner = BM_face_create(bm, f_verts, f_edges, f->len, 0);
|
||||
BLI_assert(f_new_inner != NULL); /* no reason it should fail */
|
||||
|
||||
/* Copy Face Data */
|
||||
/* Create New Inset Faces */
|
||||
f_new_inner = BM_face_create(bm, f_verts, f_edges, f->len, 0);
|
||||
BLI_assert(f_new_inner != NULL); /* no reason it should fail */
|
||||
|
||||
|
||||
// Don't tag, gives more useful inner/outer select option
|
||||
// BMO_elem_flag_enable(bm, f_new_inner, ELE_NEW);
|
||||
|
||||
|
||||
/* Copy Face Data */
|
||||
/* interpolate loop data or just stretch */
|
||||
if (use_interpolate) {
|
||||
BM_face_interp_from_face(bm, f_new_inner, f);
|
||||
}
|
||||
else {
|
||||
BM_elem_attrs_copy(bm, bm, f, f_new_inner);
|
||||
// Don't tag, gives more useful inner/outer select option
|
||||
// BMO_elem_flag_enable(bm, f_new_inner, ELE_NEW);
|
||||
|
||||
l_iter_inner = BM_FACE_FIRST_LOOP(f_new_inner);
|
||||
}
|
||||
|
||||
l_iter_inner = BM_FACE_FIRST_LOOP(f_new_inner);
|
||||
l_iter = l_first;
|
||||
do {
|
||||
BMFace *f_new_outer;
|
||||
@ -173,7 +181,9 @@ void bmo_inset_individual_exec(BMesh *bm, BMOperator *op)
|
||||
BMLoop *l_a;
|
||||
BMLoop *l_b;
|
||||
|
||||
BM_elem_attrs_copy(bm, bm, l_iter, l_iter_inner);
|
||||
if (use_interpolate == false) {
|
||||
BM_elem_attrs_copy(bm, bm, l_iter, l_iter_inner);
|
||||
}
|
||||
|
||||
f_new_outer = BM_face_create_quad_tri(bm,
|
||||
l_iter->v,
|
||||
@ -203,8 +213,8 @@ void bmo_inset_individual_exec(BMesh *bm, BMOperator *op)
|
||||
|
||||
/* This loop should always have >1 radials
|
||||
* (associated edge connects new and old face) */
|
||||
BM_elem_attrs_copy(bm, bm, l_iter, l_b);
|
||||
BM_elem_attrs_copy(bm, bm, l_iter->next, l_a);
|
||||
BM_elem_attrs_copy(bm, bm, l_iter_inner, l_b);
|
||||
BM_elem_attrs_copy(bm, bm, use_interpolate ? l_iter_inner->next : l_iter->next, l_a);
|
||||
|
||||
} while ((l_iter_inner = l_iter_inner->next),
|
||||
(l_iter = l_iter->next) != l_first);
|
||||
|
@ -99,7 +99,7 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C)
|
||||
opdata->modify_depth ? IFACE_("On") : IFACE_("Off"),
|
||||
RNA_boolean_get(op->ptr, "use_outset") ? IFACE_("On") : IFACE_("Off"),
|
||||
RNA_boolean_get(op->ptr, "use_boundary") ? IFACE_("On") : IFACE_("Off"),
|
||||
RNA_boolean_get(op->ptr, "individual") ? IFACE_("On") : IFACE_("Off")
|
||||
RNA_boolean_get(op->ptr, "use_individual") ? IFACE_("On") : IFACE_("Off")
|
||||
);
|
||||
|
||||
ED_area_headerprint(sa, msg);
|
||||
@ -192,7 +192,8 @@ static int edbm_inset_calc(wmOperator *op)
|
||||
const float depth = RNA_float_get(op->ptr, "depth");
|
||||
const bool use_outset = RNA_boolean_get(op->ptr, "use_outset");
|
||||
const bool use_select_inset = RNA_boolean_get(op->ptr, "use_select_inset"); /* not passed onto the BMO */
|
||||
const bool individual = RNA_boolean_get(op->ptr, "individual");
|
||||
const bool use_individual = RNA_boolean_get(op->ptr, "use_individual");
|
||||
const bool use_interpolate = RNA_boolean_get(op->ptr, "use_interpolate");
|
||||
|
||||
opdata = op->customdata;
|
||||
em = opdata->em;
|
||||
@ -201,10 +202,10 @@ static int edbm_inset_calc(wmOperator *op)
|
||||
EDBM_redo_state_restore(opdata->mesh_backup, em, false);
|
||||
}
|
||||
|
||||
if (individual) {
|
||||
if (use_individual) {
|
||||
EDBM_op_init(em, &bmop, op,
|
||||
"inset_individual faces=%hf thickness=%f depth=%f use_even_offset=%b",
|
||||
BM_ELEM_SELECT, thickness, depth, use_even_offset);
|
||||
"inset_individual faces=%hf thickness=%f depth=%f use_even_offset=%b use_interpolate=%b",
|
||||
BM_ELEM_SELECT, thickness, depth, use_even_offset, use_interpolate);
|
||||
}
|
||||
else {
|
||||
EDBM_op_init(em, &bmop, op,
|
||||
@ -420,8 +421,8 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
break;
|
||||
case IKEY:
|
||||
if (event->val == KM_PRESS) {
|
||||
int individual = RNA_boolean_get(op->ptr, "individual");
|
||||
RNA_boolean_set(op->ptr, "individual", !individual);
|
||||
const bool use_individual = RNA_boolean_get(op->ptr, "use_individual");
|
||||
RNA_boolean_set(op->ptr, "use_individual", !use_individual);
|
||||
if (edbm_inset_calc(op)) {
|
||||
edbm_inset_update_header(op, C);
|
||||
}
|
||||
@ -470,5 +471,6 @@ void MESH_OT_inset(wmOperatorType *ot)
|
||||
|
||||
RNA_def_boolean(ot->srna, "use_outset", false, "Outset", "Outset rather than inset");
|
||||
RNA_def_boolean(ot->srna, "use_select_inset", true, "Select Outer", "Select the new inset faces");
|
||||
RNA_def_boolean(ot->srna, "individual", false, "Individual", "Individual Face Inset");
|
||||
RNA_def_boolean(ot->srna, "use_individual", false, "Individual", "Individual Face Inset");
|
||||
RNA_def_boolean(ot->srna, "use_interpolate", true, "Interpolate", "Blend face data across the inset");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user