[Bf-blender-cvs] [e557e4d03c1] sculpt-dev: Face Sets Topology: Initial working version

Pablo Dobarro noreply at git.blender.org
Wed Mar 17 01:53:21 CET 2021


Commit: e557e4d03c1b76182792f8f4eb7ba100fc326408
Author: Pablo Dobarro
Date:   Tue Mar 16 23:17:08 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rBe557e4d03c1b76182792f8f4eb7ba100fc326408

Face Sets Topology: Initial working version

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_face_set_topology.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index f931cd65834..29676aa626c 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -4476,6 +4476,9 @@ def km_sculpt(params):
          {"properties": [("mode", 'INVERT')]}),
         ("sculpt.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
          {"properties": [("mode", 'SMOOTH')]}),
+        # Face Set by Topology
+        ("sculpt.face_set_by_topology", {"type": 'J', "value": 'PRESS'},
+         {"properties": [("mode", "POLY_LOOP")]}),
         # Expand
         ("sculpt.expand", {"type": 'A', "value": 'PRESS', "shift": True},
          {"properties": [("target", "MASK"), ("falloff_type", "GEODESIC"), ("invert", True)]}),
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 13df5963055..971c3a9fdcd 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -10055,6 +10055,7 @@ void ED_operatortypes_sculpt(void)
   WM_operatortype_append(SCULPT_OT_face_sets_init);
   WM_operatortype_append(SCULPT_OT_reset_brushes);
   WM_operatortype_append(SCULPT_OT_ipmask_filter);
+  WM_operatortype_append(SCULPT_OT_face_set_by_topology);
 
   WM_operatortype_append(SCULPT_OT_expand);
 }
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set_topology.c b/source/blender/editors/sculpt_paint/sculpt_face_set_topology.c
index 3d8c226f198..7887e5bf52e 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set_topology.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set_topology.c
@@ -115,6 +115,9 @@ static bool sculpt_face_set_loop_step(SculptSession *ss, const int from_poly, co
    if (next_poly == SCULPT_FACE_SET_LOOP_STEP_NONE) {
      return false;
    }
+
+   *r_next_poly = next_poly;
+   return true;
 }
 
 static int sculpt_face_set_loop_opposite_edge_in_quad(SculptSession *ss, const int poly, const int edge) {
@@ -143,6 +146,7 @@ static void sculpt_face_set_by_topology_poly_loop(Object *ob, const int next_fac
   MPoly *initial_poly = &mesh->mpoly[ss->active_face_index];
 
   if (initial_poly->totloop != 4) {
+    printf("NO QUAD ON INITIAL\n");
     return;
   }
 
@@ -184,24 +188,30 @@ static void sculpt_face_set_by_topology_poly_loop(Object *ob, const int next_fac
   int current_poly = ss->active_face_index;
   int current_edge = initial_edge_index;
   int next_poly = SCULPT_FACE_SET_LOOP_STEP_NONE;
-  while(sculpt_face_set_loop_step(ss, current_poly, current_edge, &next_poly)) {
-    if (ss->face_sets[next_poly] == next_face_set_id) {
+  int max_steps = ss->totfaces;
+  while(max_steps && sculpt_face_set_loop_step(ss, current_poly, current_edge, &next_poly)) {
+    printf("LOOP STEP\n");
+    if (ss->face_sets[next_poly] == ss->active_face_index) {
+      printf("BREAK INITIAL\n");
       break;
     }
     if (ss->face_sets[next_poly] < 0) {
+      printf("BREAK HIDDEN\n");
       break;
     }
     if (ss->mpoly[next_poly].totloop != 4) {
+      printf("BREAK NON QUAD %d\n", next_poly);
       break;
     }
 
     ss->face_sets[next_poly] = next_face_set_id;
     current_edge = sculpt_face_set_loop_opposite_edge_in_quad(ss, next_poly, current_edge);
     current_poly = next_poly;
+    max_steps--;
   }
 }
 
-static int sculpt_face_set_by_topology_invok(bContext *C, wmOperator *op, const wmEvent *event)
+static int sculpt_face_set_by_topology_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
   Object *ob = CTX_data_active_object(C);
   SculptSession *ss = ob->sculpt;
@@ -209,6 +219,7 @@ static int sculpt_face_set_by_topology_invok(bContext *C, wmOperator *op, const
 
   const int mode = RNA_enum_get(op->ptr, "mode");
   BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, false);
+  printf("FACE SET TOPOLOGY\n");
 
   /* Update the current active Face Set and Vertex as the operator can be used directly from the
    * tool without brush cursor. */
@@ -224,10 +235,11 @@ static int sculpt_face_set_by_topology_invok(bContext *C, wmOperator *op, const
   BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
   SCULPT_undo_push_begin(ob, "face set edit");
   SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
-  MEM_freeN(nodes);
+
 
   Mesh *mesh = BKE_object_get_original_mesh(ob);
   const int next_face_set = ED_sculpt_face_sets_find_next_available_id(mesh);
+  printf("NEXT FACE SET %d\n", next_face_set);
 
   switch (mode) {
     case SCULPT_FACE_SET_TOPOLOGY_LOOSE_PART:
@@ -238,6 +250,22 @@ static int sculpt_face_set_by_topology_invok(bContext *C, wmOperator *op, const
       break;
   }
 
+
+  /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */
+  SCULPT_visibility_sync_all_face_sets_to_vertices(ob);
+
+  for (int i = 0; i < totnode; i++) {
+    BKE_pbvh_node_mark_update_visibility(nodes[i]);
+  }
+
+  BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility);
+
+  if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
+    BKE_mesh_flush_hidden_from_verts(ob->data);
+  }
+
+  MEM_freeN(nodes);
+
   SCULPT_undo_push_end();
   SCULPT_tag_update_overlays(C);
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 37828d02862..113d5e002ce 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -1422,6 +1422,9 @@ bool SCULPT_get_redraw_rect(struct ARegion *region,
 
 /* Operators. */
 
+/* Face Set by Topology. */
+void SCULPT_OT_face_set_by_topology(struct wmOperatorType *ot);
+
 /* Expand. */
 void SCULPT_OT_expand(struct wmOperatorType *ot);
 void sculpt_expand_modal_keymap(struct wmKeyConfig *keyconf);



More information about the Bf-blender-cvs mailing list