Sculpt: Init Face Sets by Face Sets boundaries

This adds an extra option to the Face Sets Init operator to initialize
individual Face Sets based on the current Face Sets boundaries.
In particular, this is useful for splitting the patterns created by
Expand into individual Face Sets for further editing.

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D10608
This commit is contained in:
Pablo Dobarro 2021-03-03 20:01:54 +01:00
parent b1ef55abdb
commit e5c1e13ef0
2 changed files with 24 additions and 0 deletions

View File

@ -3197,6 +3197,9 @@ class VIEW3D_MT_face_sets_init(Menu):
op = layout.operator("sculpt.face_sets_init", text='By Loose Parts')
op.mode = 'LOOSE_PARTS'
op = layout.operator("sculpt.face_sets_init", text='By Face Set Boundaries')
op.mode = 'FACE_SET_BOUNDARIES'
op = layout.operator("sculpt.face_sets_init", text='By Materials')
op.mode = 'MATERIALS'

View File

@ -447,6 +447,7 @@ typedef enum eSculptFaceSetsInitMode {
SCULPT_FACE_SETS_FROM_SHARP_EDGES = 5,
SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT = 6,
SCULPT_FACE_SETS_FROM_FACE_MAPS = 7,
SCULPT_FACE_SETS_FROM_FACE_SET_BOUNDARIES = 8,
} eSculptFaceSetsInitMode;
static EnumPropertyItem prop_sculpt_face_sets_init_types[] = {
@ -506,6 +507,14 @@ static EnumPropertyItem prop_sculpt_face_sets_init_types[] = {
"Face Sets from Face Maps",
"Create a Face Set per Face Map",
},
{
SCULPT_FACE_SETS_FROM_FACE_SET_BOUNDARIES,
"FACE_SET_BOUNDARIES",
0,
"Face Sets from Face Set Boundaries",
"Create a Face Set per isolated Face Set",
},
{0, NULL, 0, NULL, NULL},
};
@ -557,6 +566,14 @@ static bool sculpt_face_sets_init_sharp_edges_test(BMesh *UNUSED(bm),
return BM_elem_flag_test(from_e, BM_ELEM_SMOOTH);
}
static bool sculpt_face_sets_init_face_set_boundary_test(
BMesh *bm, BMFace *from_f, BMEdge *UNUSED(from_e), BMFace *to_f, const float UNUSED(threshold))
{
const int cd_face_sets_offset = CustomData_get_offset(&bm->pdata, CD_SCULPT_FACE_SETS);
return BM_ELEM_CD_GET_INT(from_f, cd_face_sets_offset) ==
BM_ELEM_CD_GET_INT(to_f, cd_face_sets_offset);
}
static void sculpt_face_sets_init_flood_fill(Object *ob,
face_sets_flood_fill_test test,
const float threshold)
@ -725,6 +742,10 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op)
case SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT:
sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_bevel_weight_test, threshold);
break;
case SCULPT_FACE_SETS_FROM_FACE_SET_BOUNDARIES:
sculpt_face_sets_init_flood_fill(
ob, sculpt_face_sets_init_face_set_boundary_test, threshold);
break;
case SCULPT_FACE_SETS_FROM_FACE_MAPS:
sculpt_face_sets_init_loop(ob, SCULPT_FACE_SETS_FROM_FACE_MAPS);
break;