[Bf-blender-cvs] [48ea173a7db] master: Sculpt: Create Face Set by Edit Mode Selection

Pablo Dobarro noreply at git.blender.org
Thu Mar 26 16:24:50 CET 2020


Commit: 48ea173a7dbf9fb3678692b12909973854932c60
Author: Pablo Dobarro
Date:   Sun Mar 22 00:29:19 2020 +0100
Branches: master
https://developer.blender.org/rB48ea173a7dbf9fb3678692b12909973854932c60

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

===================================================================

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/editors/sculpt_paint/sculpt.c

===================================================================

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]);
   }



More information about the Bf-blender-cvs mailing list