[Bf-blender-cvs] [dd77b226264] sculpt-dev: Face Sets Topology: Improve keymap and creation delay

Pablo Dobarro noreply at git.blender.org
Wed Mar 17 03:04:06 CET 2021


Commit: dd77b2262640589f6352b54bf3b80f7249d94cab
Author: Pablo Dobarro
Date:   Wed Mar 17 03:03:02 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rBdd77b2262640589f6352b54bf3b80f7249d94cab

Face Sets Topology: Improve keymap and creation delay

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

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

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 74bccaea569..d4e3636ba5e 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -4477,10 +4477,8 @@ def km_sculpt(params):
         ("sculpt.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
          {"properties": [("mode", 'SMOOTH')]}),
         # Face Set by Topology
-        ("sculpt.face_set_by_topology", {"type": 'W', "value": 'RELEASE', "ctrl": True},
+        ("sculpt.face_set_by_topology", {"type": 'W', "value": 'PRESS', "ctrl": True},
          {"properties": [("mode", "POLY_LOOP"), ("repeat_previous", True)]}),
-        ("sculpt.face_set_by_topology", {"type": 'W', "value": 'DOUBLE_CLICK', "ctrl": True},
-         {"properties": [("mode", "POLY_LOOP"), ("repeat_previous", False)]}),
         # Expand
         ("sculpt.expand", {"type": 'A', "value": 'PRESS', "shift": True},
          {"properties": [("target", "MASK"), ("falloff_type", "GEODESIC"), ("invert", True)]}),
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 8f83d203500..27ecf6824f0 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -560,6 +560,8 @@ typedef struct SculptSession {
 
   /* Face Sets by topology. */
   int face_set_last_created;
+  int face_set_last_poly;
+  int face_set_last_edge;
 
   /* Dynamic mesh preview */
   int *preview_vert_index_list;
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 d153f680495..de8dae5e2cb 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set_topology.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set_topology.c
@@ -135,9 +135,14 @@ static int sculpt_face_set_by_topology_invoke(bContext *C, wmOperator *op, const
   SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
 
 
+  const int initial_poly = ss->active_face_index;
+  const int initial_edge = sculpt_poly_loop_initial_edge_from_cursor(ob);
+
   Mesh *mesh = BKE_object_get_original_mesh(ob);
   int new_face_set = SCULPT_FACE_SET_NONE;
-  if (repeat_previous && ss->face_set_last_created != SCULPT_FACE_SET_NONE) {
+
+
+  if (repeat_previous && ss->face_set_last_created != SCULPT_FACE_SET_NONE && initial_poly != ss->face_set_last_poly && initial_edge != ss->face_set_last_edge) {
     new_face_set = ss->face_set_last_created;
   }
   else {
@@ -147,7 +152,6 @@ static int sculpt_face_set_by_topology_invoke(bContext *C, wmOperator *op, const
   switch (mode) {
     case SCULPT_FACE_SET_TOPOLOGY_LOOSE_PART:
       break;
-
     case SCULPT_FACE_SET_TOPOLOGY_POLY_LOOP:
       sculpt_face_set_by_topology_poly_loop(ob, new_face_set);
       break;
@@ -155,6 +159,8 @@ static int sculpt_face_set_by_topology_invoke(bContext *C, wmOperator *op, const
 
 
  ss->face_set_last_created = new_face_set;
+ ss->face_set_last_edge = initial_edge;
+ ss->face_set_last_poly = initial_poly;
 
 
   /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */
@@ -195,5 +201,5 @@ void SCULPT_OT_face_set_by_topology(struct wmOperatorType *ot)
       ot->srna, "mode", prop_sculpt_face_set_by_topology, SCULPT_FACE_SET_TOPOLOGY_POLY_LOOP, "Mode", "");
 
   RNA_def_boolean(
-      ot->srna, "repeat_previous", false, "Repeat previous Face Set", "Repeat the latest created Face Set instead of a new one");
+      ot->srna, "repeat_previous", true, "Repeat previous Face Set", "Repeat the latest created Face Set instead of a new one");
 }
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 5671088c5ad..34f4525aefc 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -1422,6 +1422,7 @@ bool SCULPT_get_redraw_rect(struct ARegion *region,
 
 
 /* Poly Loops. */
+int sculpt_poly_loop_initial_edge_from_cursor(Object *ob);
 BLI_bitmap * sculpt_poly_loop_from_cursor(struct Object *ob);
 
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_poly_loop.c b/source/blender/editors/sculpt_paint/sculpt_poly_loop.c
index ecb166a963a..9b521ab8504 100644
--- a/source/blender/editors/sculpt_paint/sculpt_poly_loop.c
+++ b/source/blender/editors/sculpt_paint/sculpt_poly_loop.c
@@ -72,30 +72,25 @@
 #include <math.h>
 #include <stdlib.h>
 
-typedef enum eSculptFaceSetByTopologyMode {
-  SCULPT_FACE_SET_TOPOLOGY_LOOSE_PART = 0,
-  SCULPT_FACE_SET_TOPOLOGY_POLY_LOOP = 1,
-};
-
-
-static EnumPropertyItem prop_sculpt_face_set_by_topology[] = {
-    {
-        SCULPT_FACE_SET_TOPOLOGY_LOOSE_PART,
-        "LOOSE_PART",
-        0,
-        "Loose Part",
-        "",
-    },
-    {
-        SCULPT_FACE_SET_TOPOLOGY_POLY_LOOP,
-        "POLY_LOOP",
-        0,
-        "Face Loop",
-        "",
-    },
-    {0, NULL, 0, NULL, NULL},
-};
+static void sculpt_poly_loop_topology_data_ensure(Object *ob) {
+  SculptSession *ss = ob->sculpt;
+  Mesh *mesh = BKE_object_get_original_mesh(ob);
 
+  if (!ss->epmap) {
+    BKE_mesh_edge_poly_map_create(&ss->epmap,
+                                  &ss->epmap_mem,
+                                  mesh->medge,
+                                  mesh->totedge,
+                                  mesh->mpoly,
+                                  mesh->totpoly,
+                                  mesh->mloop,
+                                  mesh->totloop);
+  }
+  if (!ss->vemap) {
+    BKE_mesh_vert_edge_map_create(
+        &ss->vemap, &ss->vemap_mem, mesh->medge, mesh->totvert, mesh->totedge);
+  }
+}
 
 #define SCULPT_FACE_SET_LOOP_STEP_NONE -1
 static bool sculpt_poly_loop_step(SculptSession *ss, const int from_poly, const int edge, int *r_next_poly) {
@@ -135,10 +130,12 @@ static int sculpt_poly_loop_opposite_edge_in_quad(SculptSession *ss, const int p
   return ss->mloop[ss->mpoly[poly].loopstart + next_edge_index_in_poly].e;
 }
 
-static int sculpt_poly_loop_initial_edge_from_cursor(Object *ob) {
+int sculpt_poly_loop_initial_edge_from_cursor(Object *ob) {
   SculptSession *ss = ob->sculpt;
   Mesh *mesh = BKE_object_get_original_mesh(ob);
 
+  sculpt_poly_loop_topology_data_ensure(ob);
+
   float *location = ss->cursor_location;
 
   MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss);
@@ -168,26 +165,6 @@ static int sculpt_poly_loop_initial_edge_from_cursor(Object *ob) {
   return initial_edge;
 }
 
-static void sculpt_poly_loop_topology_data_ensure(Object *ob) {
-  SculptSession *ss = ob->sculpt;
-  Mesh *mesh = BKE_object_get_original_mesh(ob);
-
-  if (!ss->epmap) {
-    BKE_mesh_edge_poly_map_create(&ss->epmap,
-                                  &ss->epmap_mem,
-                                  mesh->medge,
-                                  mesh->totedge,
-                                  mesh->mpoly,
-                                  mesh->totpoly,
-                                  mesh->mloop,
-                                  mesh->totloop);
-  }
-  if (!ss->vemap) {
-    BKE_mesh_vert_edge_map_create(
-        &ss->vemap, &ss->vemap_mem, mesh->medge, mesh->totvert, mesh->totedge);
-  }
-}
-
 static void sculpt_poly_loop_iterate_and_fill(SculptSession *ss, const int initial_poly, const int initial_edge, BLI_bitmap *poly_loop) {
   int current_poly = initial_poly;
   int current_edge = initial_edge;



More information about the Bf-blender-cvs mailing list