bmesh inset:
option to inset boundaries.
This commit is contained in:
@@ -1085,8 +1085,9 @@ static BMOpDefine bmo_inset_def = {
|
||||
"inset",
|
||||
{{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
|
||||
{BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */
|
||||
{BMO_OP_SLOT_BOOL, "use_even_offset"}, /* type of thickness calculation */
|
||||
{BMO_OP_SLOT_BOOL, "use_relative_offset"}, /* type of thickness calculation */
|
||||
{BMO_OP_SLOT_BOOL, "use_boundary"},
|
||||
{BMO_OP_SLOT_BOOL, "use_even_offset"},
|
||||
{BMO_OP_SLOT_BOOL, "use_relative_offset"},
|
||||
{BMO_OP_SLOT_FLT, "thickness"},
|
||||
{0} /* null-terminating sentine */},
|
||||
bmo_inset_exec,
|
||||
|
||||
@@ -60,6 +60,7 @@ static void edge_loop_tangent(BMEdge *e, BMLoop *e_loop, float r_no[3])
|
||||
|
||||
void bmo_inset_exec(BMesh *bm, BMOperator *op)
|
||||
{
|
||||
const int use_boundary = BMO_slot_bool_get(op, "use_boundary");
|
||||
const int use_even_offset = BMO_slot_bool_get(op, "use_even_offset");
|
||||
const int use_even_boundry = use_even_offset; /* could make own option */
|
||||
const int use_relative_offset = BMO_slot_bool_get(op, "use_relative_offset");
|
||||
@@ -83,8 +84,13 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
|
||||
/* fill in array and initialize tagging */
|
||||
BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
|
||||
BMLoop *la, *lb;
|
||||
if ((BM_edge_loop_pair(e, &la, &lb)) &&
|
||||
(BM_elem_flag_test(la->f, BM_ELEM_TAG) != BM_elem_flag_test(lb->f, BM_ELEM_TAG)))
|
||||
|
||||
if (
|
||||
/* tag if boundary is enabled */
|
||||
(use_boundary && BM_edge_is_boundary(e) && BM_elem_flag_test(e->l->f, BM_ELEM_TAG)) ||
|
||||
|
||||
/* tag if edge is an interior edge inbetween a tagged and untagged face */
|
||||
((BM_edge_loop_pair(e, &la, &lb)) && (BM_elem_flag_test(la->f, BM_ELEM_TAG) != BM_elem_flag_test(lb->f, BM_ELEM_TAG))))
|
||||
{
|
||||
/* tag */
|
||||
BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
|
||||
@@ -122,8 +128,13 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
|
||||
for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
|
||||
BMLoop *l, *la, *lb;
|
||||
|
||||
BM_edge_loop_pair(es->e_old, &la, &lb); /* we know this will succeed, already checked above */
|
||||
l = BM_elem_flag_test(la->f, BM_ELEM_TAG) ? la : lb;
|
||||
if (BM_edge_loop_pair(es->e_old, &la, &lb)) {
|
||||
l = BM_elem_flag_test(la->f, BM_ELEM_TAG) ? la : lb;
|
||||
}
|
||||
else {
|
||||
l = es->e_old->l; /* must be a boundary */
|
||||
}
|
||||
|
||||
|
||||
/* run the separate arg */
|
||||
bmesh_edge_separate(bm, es->e_old, l);
|
||||
@@ -132,6 +143,11 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
|
||||
es->e_new = l->e;
|
||||
edge_loop_tangent(es->e_new, l, es->no);
|
||||
|
||||
|
||||
if (es->e_new == es->e_old) { /* happens on boundary edges */
|
||||
es->e_old = BM_edge_create(bm, es->e_new->v1, es->e_new->v2, es->e_new, FALSE);
|
||||
}
|
||||
|
||||
/* store index back to original in 'edge_info' */
|
||||
BM_elem_index_set(es->e_new, i);
|
||||
BM_elem_flag_enable(es->e_new, BM_ELEM_TAG);
|
||||
|
||||
@@ -4578,12 +4578,14 @@ static int mesh_inset_exec(bContext *C, wmOperator *op)
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
BMEditMesh *em = BMEdit_FromObject(obedit);
|
||||
BMOperator bmop;
|
||||
const int use_boundary = RNA_boolean_get(op->ptr, "use_boundary");
|
||||
const int use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset");
|
||||
const int use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset");
|
||||
const float thickness = RNA_float_get(op->ptr, "thickness");
|
||||
|
||||
EDBM_InitOpf(em, &bmop, op, "inset faces=%hf use_even_offset=%b use_relative_offset=%b thickness=%f",
|
||||
BM_ELEM_SELECT, use_even_offset, use_relative_offset, thickness);
|
||||
EDBM_InitOpf(em, &bmop, op,
|
||||
"inset faces=%hf use_boundary=%b use_even_offset=%b use_relative_offset=%b thickness=%f",
|
||||
BM_ELEM_SELECT, use_boundary, use_even_offset, use_relative_offset, thickness);
|
||||
|
||||
BMO_op_exec(em->bm, &bmop);
|
||||
|
||||
@@ -4620,8 +4622,9 @@ void MESH_OT_inset(wmOperatorType *ot)
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_boolean(ot->srna, "use_even_offset", TRUE, "Even", "Scale the offset to give more even thickness");
|
||||
RNA_def_boolean(ot->srna, "use_relative_offset", FALSE, "Relative", "Scale the offset by surrounding geometry");
|
||||
RNA_def_boolean(ot->srna, "use_boundary", TRUE, "Boundary", "Inset face boundries");
|
||||
RNA_def_boolean(ot->srna, "use_even_offset", TRUE, "Offset Even", "Scale the offset to give more even thickness");
|
||||
RNA_def_boolean(ot->srna, "use_relative_offset", FALSE, "Offset Relative", "Scale the offset by surrounding geometry");
|
||||
|
||||
prop = RNA_def_float(ot->srna, "thickness", 0.01f, 0.0f, FLT_MAX, "thickness", "", 0.0f, 10.0f);
|
||||
/* use 1 rather then 10 for max else dragging the button moves too far */
|
||||
|
||||
Reference in New Issue
Block a user