diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2012-08-07 16:54:32 +0400 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2012-08-07 16:54:32 +0400 |
commit | 3e5cbb48f6c99d8a1c14664042f581b5dd8176b7 (patch) | |
tree | 59e273342b52f57603d2b89ed1878fb5f5a981d7 /source/blender | |
parent | 9ee3a8655fe35af2fdca6c54953da93ed42111a3 (diff) |
Fix knife stack overflow (bug #31907).
The mutual recursion was removed: it was not needed.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 4d636e64430..229bbdbefb7 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -339,14 +339,13 @@ static KnifeVert *get_bm_knife_vert(KnifeTool_OpData *kcd, BMVert *v) return kfv; } -/** - * get a KnifeEdge wrapper for an existing BMEdge - * \note #knife_get_face_kedges / #get_bm_knife_edge are called recursively - KEEP STACK MEM USAGE LOW */ +/* get a KnifeEdge wrapper for an existing BMEdge */ static KnifeEdge *get_bm_knife_edge(KnifeTool_OpData *kcd, BMEdge *e) { KnifeEdge *kfe = BLI_ghash_lookup(kcd->origedgemap, e); if (!kfe) { - BMLoop *l_iter, *l_first; + BMIter bmiter; + BMFace *f; kfe = new_knife_edge(kcd); kfe->e = e; @@ -357,17 +356,9 @@ static KnifeEdge *get_bm_knife_edge(KnifeTool_OpData *kcd, BMEdge *e) BLI_ghash_insert(kcd->origedgemap, e, kfe); - /* avoid BM_ITER because of stack memory usage - * otherwise we could use BM_FACES_OF_EDGE */ - l_iter = l_first = e->l; - do { - knife_append_list(kcd, &kfe->faces, l_iter->f); - - /* ensures the kedges lst for this f is initialized, - * it automatically adds kfe by itself */ - knife_get_face_kedges(kcd, l_iter->f); - - } while ((l_iter = l_iter->radial_next) != l_first); + BM_ITER_ELEM(f, &bmiter, e, BM_FACES_OF_EDGE) { + knife_append_list(kcd, &kfe->faces, f); + } } return kfe; @@ -397,23 +388,19 @@ static void knife_start_cut(KnifeTool_OpData *kcd) } } -/** - * \note #knife_get_face_kedges / #get_bm_knife_edge are called recursively - KEEP STACK MEM USAGE LOW */ static ListBase *knife_get_face_kedges(KnifeTool_OpData *kcd, BMFace *f) { ListBase *lst = BLI_ghash_lookup(kcd->kedgefacemap, f); if (!lst) { - BMLoop *l_iter, *l_first; + BMIter bmiter; + BMEdge *e; lst = knife_empty_list(kcd); - /* avoid BM_ITER because of stack memory usage - * otherwise we could use BM_EDGES_OF_FACE */ - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { - knife_append_list(kcd, lst, get_bm_knife_edge(kcd, l_iter->e)); - } while ((l_iter = l_iter->next) != l_first); + BM_ITER_ELEM(e, &bmiter, f, BM_EDGES_OF_FACE) { + knife_append_list(kcd, lst, get_bm_knife_edge(kcd, e)); + } BLI_ghash_insert(kcd->kedgefacemap, f, lst); } |