diff options
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d.py | 3 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 33 |
2 files changed, 36 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index db128c14cf9..cb5f02b03fd 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -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() diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index f6ca36668bc..c7b15d0c096 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -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]); } |