Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606@gmail.com>2020-03-22 02:29:19 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-03-26 18:24:21 +0300
commit48ea173a7dbf9fb3678692b12909973854932c60 (patch)
tree22c0d03b849b37ca2ab8617a34d587cb54fb7191 /source/blender
parent99530ef4ed70a479523d8e99a40fce24eb9ba658 (diff)
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
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c33
1 files changed, 33 insertions, 0 deletions
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]);
}