Sculpt: Create Face Set by Edit Mode Selection
This implements a new mode in the Face Sets Create operator to create a new face sets from the faces selection in edit mode. This can be used when the user considers that the edit mode tools are more convenient for a more precise control or a certain type of selection, like creating a face set from a face loop. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D7211
This commit is contained in:
parent
99530ef4ed
commit
48ea173a7d
|
@ -3134,6 +3134,9 @@ class VIEW3D_MT_face_sets(Menu):
|
|||
|
||||
op = layout.operator("sculpt.face_sets_create", text='Face Set From Visible')
|
||||
op.mode = 'VISIBLE'
|
||||
|
||||
op = layout.operator("sculpt.face_sets_create", text='Face Set From Edit Mode Selection')
|
||||
op.mode = 'SELECTION'
|
||||
|
||||
layout.separator()
|
||||
|
||||
|
|
|
@ -11067,6 +11067,7 @@ typedef enum eSculptFaceGroupsCreateModes {
|
|||
SCULPT_FACE_SET_MASKED = 0,
|
||||
SCULPT_FACE_SET_VISIBLE = 1,
|
||||
SCULPT_FACE_SET_ALL = 2,
|
||||
SCULPT_FACE_SET_SELECTION = 3,
|
||||
} eSculptFaceGroupsCreateModes;
|
||||
|
||||
static EnumPropertyItem prop_sculpt_face_set_create_types[] = {
|
||||
|
@ -11091,6 +11092,13 @@ static EnumPropertyItem prop_sculpt_face_set_create_types[] = {
|
|||
"Face Set Full Mesh",
|
||||
"Create an unique Face Set with all faces in the sculpt",
|
||||
},
|
||||
{
|
||||
SCULPT_FACE_SET_SELECTION,
|
||||
"SELECTION",
|
||||
0,
|
||||
"Face Set From Edit Mode Selection",
|
||||
"Create an Face Set corresponding to the Edit Mode face selection",
|
||||
},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
|
@ -11149,6 +11157,31 @@ static int sculpt_face_set_create_invoke(bContext *C, wmOperator *op, const wmEv
|
|||
}
|
||||
}
|
||||
|
||||
if (mode == SCULPT_FACE_SET_SELECTION) {
|
||||
Mesh *mesh = ob->data;
|
||||
BMesh *bm;
|
||||
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh);
|
||||
bm = BM_mesh_create(&allocsize,
|
||||
&((struct BMeshCreateParams){
|
||||
.use_toolflags = true,
|
||||
}));
|
||||
|
||||
BM_mesh_bm_from_me(bm,
|
||||
mesh,
|
||||
(&(struct BMeshFromMeshParams){
|
||||
.calc_face_normal = true,
|
||||
}));
|
||||
|
||||
BMIter iter;
|
||||
BMFace *f;
|
||||
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
|
||||
if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
|
||||
ss->face_sets[BM_elem_index_get(f)] = next_face_set;
|
||||
}
|
||||
}
|
||||
BM_mesh_free(bm);
|
||||
}
|
||||
|
||||
for (int i = 0; i < totnode; i++) {
|
||||
BKE_pbvh_node_mark_redraw(nodes[i]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue