forked from bartvdbraak/blender
Editmesh: Replace SmallHash with GSet for MESH_OT_loop_to_region
There no reason to assume hash will be small in this case
This commit is contained in:
parent
365ff66987
commit
9db947df41
@ -3189,7 +3189,7 @@ void MESH_OT_region_to_loop(wmOperatorType *ot)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int loop_find_region(BMLoop *l, int flag,
|
static int loop_find_region(BMLoop *l, int flag,
|
||||||
SmallHash *fhash, BMFace ***region_out)
|
GSet *visit_face_set, BMFace ***region_out)
|
||||||
{
|
{
|
||||||
BMFace **region = NULL;
|
BMFace **region = NULL;
|
||||||
BMFace **stack = NULL;
|
BMFace **stack = NULL;
|
||||||
@ -3198,7 +3198,7 @@ static int loop_find_region(BMLoop *l, int flag,
|
|||||||
BMFace *f;
|
BMFace *f;
|
||||||
|
|
||||||
BLI_array_append(stack, l->f);
|
BLI_array_append(stack, l->f);
|
||||||
BLI_smallhash_insert(fhash, (uintptr_t)l->f, NULL);
|
BLI_gset_insert(visit_face_set, l->f);
|
||||||
|
|
||||||
while (BLI_array_count(stack) > 0) {
|
while (BLI_array_count(stack) > 0) {
|
||||||
BMIter liter1, liter2;
|
BMIter liter1, liter2;
|
||||||
@ -3217,11 +3217,10 @@ static int loop_find_region(BMLoop *l, int flag,
|
|||||||
if (BM_elem_flag_test(l2->f, BM_ELEM_TAG)) {
|
if (BM_elem_flag_test(l2->f, BM_ELEM_TAG)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (BLI_smallhash_haskey(fhash, (uintptr_t)l2->f))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
BLI_array_append(stack, l2->f);
|
if (BLI_gset_add(visit_face_set, l2->f)) {
|
||||||
BLI_smallhash_insert(fhash, (uintptr_t)l2->f, NULL);
|
BLI_array_append(stack, l2->f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3254,13 +3253,13 @@ static int verg_radial(const void *va, const void *vb)
|
|||||||
*/
|
*/
|
||||||
static int loop_find_regions(BMEditMesh *em, const bool selbigger)
|
static int loop_find_regions(BMEditMesh *em, const bool selbigger)
|
||||||
{
|
{
|
||||||
SmallHash visithash;
|
GSet *visit_face_set;
|
||||||
BMIter iter;
|
BMIter iter;
|
||||||
const int edges_len = em->bm->totedgesel;
|
const int edges_len = em->bm->totedgesel;
|
||||||
BMEdge *e, **edges;
|
BMEdge *e, **edges;
|
||||||
int count = 0, i;
|
int count = 0, i;
|
||||||
|
|
||||||
BLI_smallhash_init_ex(&visithash, edges_len);
|
visit_face_set = BLI_gset_ptr_new_ex(__func__, edges_len);
|
||||||
edges = MEM_mallocN(sizeof(*edges) * edges_len, __func__);
|
edges = MEM_mallocN(sizeof(*edges) * edges_len, __func__);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -3289,10 +3288,10 @@ static int loop_find_regions(BMEditMesh *em, const bool selbigger)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) {
|
BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) {
|
||||||
if (BLI_smallhash_haskey(&visithash, (uintptr_t)l->f))
|
if (BLI_gset_haskey(visit_face_set, l->f))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
c = loop_find_region(l, BM_ELEM_SELECT, &visithash, ®ion_out);
|
c = loop_find_region(l, BM_ELEM_SELECT, visit_face_set, ®ion_out);
|
||||||
|
|
||||||
if (!region || (selbigger ? c >= tot : c < tot)) {
|
if (!region || (selbigger ? c >= tot : c < tot)) {
|
||||||
/* this region is the best seen so far */
|
/* this region is the best seen so far */
|
||||||
@ -3327,7 +3326,7 @@ static int loop_find_regions(BMEditMesh *em, const bool selbigger)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MEM_freeN(edges);
|
MEM_freeN(edges);
|
||||||
BLI_smallhash_release(&visithash);
|
BLI_gset_free(visit_face_set, NULL);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user