[Bf-blender-cvs] [b4e90b6e613] sculpt-dev: Sculpt Expand: fix topology recursion and flood fill

Pablo Dobarro noreply at git.blender.org
Wed Feb 3 19:26:32 CET 2021


Commit: b4e90b6e613cf7a19c0faffd87ff14cc7ee80740
Author: Pablo Dobarro
Date:   Wed Feb 3 18:49:03 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rBb4e90b6e613cf7a19c0faffd87ff14cc7ee80740

Sculpt Expand: fix topology recursion and flood fill

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

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_expand.c

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index d39740fd816..55e9f06ee28 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5591,7 +5591,7 @@ def km_sculpt_expand_modal(_params):
         ("INVERT", {"type": 'F', "value": 'PRESS', "any": True, "repeat" : False}, None),
         ("PRESERVE", {"type": 'E', "value": 'PRESS', "any": True, "repeat" : False}, None),
         ("GRADIENT", {"type": 'G', "value": 'PRESS', "any": True, "repeat" : False}, None),
-        ("RECURSION_STEP_GEODESIC", {"type": 'R', "value": 'PRESS', "any": True, "repeat" : False}, None),
+        ("RECURSION_STEP_GEODESIC", {"type": 'R', "value": 'PRESS', "repeat" : False}, None),
         ("RECURSION_STEP_TOPOLOGY", {"type": 'R', "value": 'PRESS', "alt" : True ,"any": True, "repeat" : False}, None),
         ("MOVE_TOGGLE", {"type": 'SPACE', "value": 'ANY', "any": True, "repeat" : False}, None),
         ("FALLOFF_GEODESICS", {"type": 'ONE', "value": 'PRESS', "any": True, "repeat" : False}, None),
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index f1e4aecbd3e..896bfcf3925 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1127,6 +1127,7 @@ void SCULPT_floodfill_init(SculptSession *ss, SculptFloodFill *flood)
 void SCULPT_floodfill_add_initial(SculptFloodFill *flood, int index)
 {
   BLI_gsqueue_push(flood->queue, &index);
+  BLI_BITMAP_ENABLE(flood->visited_vertices, index);
 }
 
 void SCULPT_floodfill_add_initial_with_symmetry(
@@ -1148,6 +1149,7 @@ void SCULPT_floodfill_add_initial_with_symmetry(
       }
       if (v != -1) {
         SCULPT_floodfill_add_initial(flood, v);
+        BLI_BITMAP_ENABLE(flood->visited_vertices, v);
       }
     }
   }
diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c b/source/blender/editors/sculpt_paint/sculpt_expand.c
index 46c65c744b1..fbe961d0300 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -206,7 +206,7 @@ typedef struct ExpandFloodFillData {
   float *edge_factor;
 } ExpandFloodFillData;
 
-static bool mask_expand_topology_floodfill_cb(
+static bool expand_topology_floodfill_cb(
     SculptSession *UNUSED(ss), int from_v, int to_v, bool is_duplicate, void *userdata)
 {
   ExpandFloodFillData *data = userdata;
@@ -233,7 +233,7 @@ static float *sculpt_expand_topology_falloff_create(Sculpt *sd, Object *ob, cons
   ExpandFloodFillData fdata;
   fdata.dists = dists;
 
-  SCULPT_floodfill_execute(ss, &flood, mask_expand_topology_floodfill_cb, &fdata);
+  SCULPT_floodfill_execute(ss, &flood, expand_topology_floodfill_cb, &fdata);
   SCULPT_floodfill_free(&flood);
 
   return dists;
@@ -536,14 +536,14 @@ static BLI_bitmap *sculpt_expand_boundary_from_enabled(SculptSession *ss,
                                                        const bool use_mesh_boundary)
 {
   const int totvert = SCULPT_vertex_count_get(ss);
-  BLI_bitmap *boundary_vertices = BLI_BITMAP_NEW(totvert, "enabled vertices");
+  BLI_bitmap *boundary_vertices = BLI_BITMAP_NEW(totvert, "boundary vertices");
   for (int i = 0; i < totvert; i++) {
-    SculptVertexNeighborIter ni;
     if (!BLI_BITMAP_TEST(enabled_vertices, i)) {
       continue;
     }
 
     bool is_expand_boundary = false;
+    SculptVertexNeighborIter ni;
     SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, i, ni) {
       if (!BLI_BITMAP_TEST(enabled_vertices, ni.index)) {
         is_expand_boundary = true;
@@ -555,9 +555,7 @@ static BLI_bitmap *sculpt_expand_boundary_from_enabled(SculptSession *ss,
       is_expand_boundary = true;
     }
 
-    if (is_expand_boundary) {
-      BLI_BITMAP_ENABLE(boundary_vertices, i);
-    }
+    BLI_BITMAP_SET(boundary_vertices, i, is_expand_boundary);
   }
 
   return boundary_vertices;
@@ -590,9 +588,15 @@ static void sculpt_expand_topology_from_state_boundary(Object *ob,
                                                        ExpandCache *expand_cache,
                                                        BLI_bitmap *enabled_vertices)
 {
+  MEM_SAFE_FREE(expand_cache->falloff_factor);
+  MEM_SAFE_FREE(expand_cache->face_falloff_factor);
+
   SculptSession *ss = ob->sculpt;
   const int totvert = SCULPT_vertex_count_get(ss);
+
+  float *dists = MEM_calloc_arrayN(sizeof(float), totvert, "topology dist");
   BLI_bitmap *boundary_vertices = sculpt_expand_boundary_from_enabled(ss, enabled_vertices, false);
+
   SculptFloodFill flood;
   SCULPT_floodfill_init(ss, &flood);
   for (int i = 0; i < totvert; i++) {
@@ -603,13 +607,9 @@ static void sculpt_expand_topology_from_state_boundary(Object *ob,
   }
   MEM_freeN(boundary_vertices);
 
-  MEM_SAFE_FREE(expand_cache->falloff_factor);
-  MEM_SAFE_FREE(expand_cache->face_falloff_factor);
-
-  float *dists = MEM_calloc_arrayN(sizeof(float), totvert, "topology dist");
   ExpandFloodFillData fdata;
   fdata.dists = dists;
-  SCULPT_floodfill_execute(ss, &flood, mask_expand_topology_floodfill_cb, &fdata);
+  SCULPT_floodfill_execute(ss, &flood, expand_topology_floodfill_cb, &fdata);
   SCULPT_floodfill_free(&flood);
 
   expand_cache->falloff_factor = dists;



More information about the Bf-blender-cvs mailing list