[Bf-blender-cvs] [ecbf3e2d0f1] sculpt-dev: Sculpt: Face Set Edit fill component mode

Pablo Dobarro noreply at git.blender.org
Mon Dec 21 23:58:03 CET 2020


Commit: ecbf3e2d0f1331451e47947c4559121885247f77
Author: Pablo Dobarro
Date:   Mon Dec 21 20:00:56 2020 +0100
Branches: sculpt-dev
https://developer.blender.org/rBecbf3e2d0f1331451e47947c4559121885247f77

Sculpt: Face Set Edit fill component mode

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

M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_face_set.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h

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

diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 1f57678edab..e40a018a777 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -9196,7 +9196,7 @@ static bool SCULPT_connected_components_floodfill_cb(
   return true;
 }
 
-static void sculpt_connected_components_ensure(Object *ob)
+void SCULPT_connected_components_ensure(Object *ob)
 {
   SculptSession *ss = ob->sculpt;
 
@@ -9271,7 +9271,7 @@ void SCULPT_fake_neighbors_ensure(Sculpt *sd, Object *ob, const float max_dist)
     return;
   }
 
-  sculpt_connected_components_ensure(ob);
+  SCULPT_connected_components_ensure(ob);
   SCULPT_fake_neighbor_init(ss, max_dist);
 
   for (int i = 0; i < totvert; i++) {
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c
index 1fba958d695..f3c38840f30 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c
@@ -1027,6 +1027,11 @@ typedef enum eSculptFaceSetEditMode {
   SCULPT_FACE_SET_EDIT_DELETE_GEOMETRY = 2,
   SCULPT_FACE_SET_EDIT_FAIR_POSITIONS = 3,
   SCULPT_FACE_SET_EDIT_FAIR_TANGENCY = 4,
+  /* TODO(pablodp606): enable this after supporting cotangent weights in fairing. */
+  /*
+  SCULPT_FACE_SET_EDIT_FAIR_CURVATURE = 5,
+  */
+  SCULPT_FACE_SET_EDIT_FILL_COMPONENT = 6,
 } eSculptFaceSetEditMode;
 
 static EnumPropertyItem prop_sculpt_face_sets_edit_types[] = {
@@ -1067,6 +1072,13 @@ static EnumPropertyItem prop_sculpt_face_sets_edit_types[] = {
         "Creates a smooth as possible geometry patch from the Face Set minimizing changes in "
         "vertex tangents",
     },
+    {
+        SCULPT_FACE_SET_EDIT_FILL_COMPONENT,
+        "FILL_COMPONENT",
+        0,
+        "Fill Component",
+        "Expand a Face Set to fill all affected connected components",
+    },
     {0, NULL, 0, NULL, NULL},
 };
 
@@ -1098,6 +1110,38 @@ static void sculpt_face_set_grow(Object *ob,
   }
 }
 
+static void sculpt_face_set_fill_component(Object *ob,
+                                           SculptSession *ss,
+                                           const int active_face_set_id,
+                                           const bool UNUSED(modify_hidden))
+{
+  SCULPT_connected_components_ensure(ob);
+  GSet *connected_components = BLI_gset_int_new("affected_components");
+
+  const int totvert = SCULPT_vertex_count_get(ss);
+  for (int i = 0; i < totvert; i++) {
+    if (!SCULPT_vertex_has_face_set(ss, i, active_face_set_id)) {
+      continue;
+    }
+    const int vertex_connected_component = ss->vertex_info.connected_component[i];
+    if (BLI_gset_haskey(connected_components, POINTER_FROM_INT(vertex_connected_component))) {
+      continue;
+    }
+    BLI_gset_add(connected_components, POINTER_FROM_INT(vertex_connected_component));
+  }
+
+  for (int i = 0; i < totvert; i++) {
+    const int vertex_connected_component = ss->vertex_info.connected_component[i];
+    if (!BLI_gset_haskey(connected_components, POINTER_FROM_INT(vertex_connected_component))) {
+      continue;
+    }
+
+    SCULPT_vertex_face_set_set(ss, i, active_face_set_id);
+  }
+
+  BLI_gset_free(connected_components, NULL);
+}
+
 static void sculpt_face_set_shrink(Object *ob,
                                    SculptSession *ss,
                                    const int *prev_face_sets,
@@ -1243,6 +1287,10 @@ static void sculpt_face_set_apply_edit(Object *ob,
       MEM_SAFE_FREE(prev_face_sets);
       break;
     }
+    case SCULPT_FACE_SET_EDIT_FILL_COMPONENT: {
+      sculpt_face_set_fill_component(ob, ss, active_face_set_id, modify_hidden);
+      break;
+    }
     case SCULPT_FACE_SET_EDIT_DELETE_GEOMETRY:
       sculpt_face_set_delete_geometry(ob, ss, active_face_set_id, modify_hidden);
       break;
@@ -1403,6 +1451,7 @@ static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEven
       break;
     case SCULPT_FACE_SET_EDIT_GROW:
     case SCULPT_FACE_SET_EDIT_SHRINK:
+    case SCULPT_FACE_SET_EDIT_FILL_COMPONENT:
       sculpt_face_set_edit_modify_face_sets(ob, active_face_set, mode, modify_hidden);
       break;
     case SCULPT_FACE_SET_EDIT_FAIR_POSITIONS:
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index d9c998f3300..e3de03bb903 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -184,6 +184,7 @@ void SCULPT_fake_neighbors_free(struct Object *ob);
 
 /* Vertex Info. */
 void SCULPT_boundary_info_ensure(Object *object);
+void SCULPT_connected_components_ensure(Object *ob);
 /* Boundary Info needs to be initialized in order to use this function. */
 bool SCULPT_vertex_is_boundary(const SculptSession *ss, const int index);



More information about the Bf-blender-cvs mailing list