BMesh: avoid recursion for BM_mesh_edgenet, runs out stack memory on large nets

This commit is contained in:
Campbell Barton 2014-06-08 22:20:03 +10:00
parent f8f25c38d3
commit c6ea6e368b

View file

@ -203,12 +203,18 @@ static BMEdge *bm_edgenet_path_step(
BMVert *v_curr, LinkNode **v_ls,
VertNetInfo *vnet_info, BLI_mempool *path_pool)
{
const VertNetInfo *vn_curr = &vnet_info[BM_elem_index_get(v_curr)];
const VertNetInfo *vn_curr;
BMEdge *e;
BMIter iter;
unsigned int tot = 0;
unsigned int v_ls_tot = 0;
unsigned int tot;
unsigned int v_ls_tot;
begin:
tot = 0;
v_ls_tot = 0;
vn_curr = &vnet_info[BM_elem_index_get(v_curr)];
BM_ITER_ELEM (e, &iter, v_curr, BM_EDGES_OF_VERT) {
BMVert *v_next = BM_edge_other_vert(e, v_curr);
@ -256,7 +262,12 @@ static BMEdge *bm_edgenet_path_step(
/* trick to walk along wire-edge paths */
if (v_ls_tot == 1 && tot == 1) {
v_curr = BLI_linklist_pop_pool(v_ls, path_pool);
/* avoid recursion, can crash on very large nets */
#if 0
bm_edgenet_path_step(v_curr, v_ls, vnet_info, path_pool);
#else
goto begin;
#endif
}
return NULL;