Sculpt Expand: fix topology recursion and flood fill
This commit is contained in:
parent
112c67f688
commit
b4e90b6e61
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue