diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-23 09:43:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-23 09:43:56 +0400 |
commit | 2363ce3ff3b0c76d869635b0befffe01a25e0fbd (patch) | |
tree | 57d33384453487217ef714efc474f5df6384b844 /source/blender/bmesh | |
parent | 24119cb79bb949980445a3184e1633976179dcbb (diff) |
fix [#30632] Edge Split Modifier (creates invalid mesh)
bug was caused by modifying loops vert value in a BM_LOOPS_OF_VERT iterator.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 4a71de98d37..2b5a96057dc 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -1784,7 +1784,6 @@ int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len) maxindex++; } - BLI_array_free(stack); /* Make enough verts to split v for each group */ verts = MEM_callocN(sizeof(BMVert *) * maxindex, __func__); @@ -1794,6 +1793,7 @@ int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len) } /* Replace v with the new verts in each group */ +#if 0 BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, v) { /* call first since its faster then a hash lookup */ if (l->v != v) { @@ -1810,8 +1810,28 @@ int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len) * towards vertex v, and another for the loop heading out from * vertex v. Only need to swap the vertex on one of those times, * on the outgoing loop. */ + + /* XXX - because this clobbers the iterator, this *whole* block is commented, see below */ l->v = verts[i]; } +#else + /* note: this is the same as the commented code above *except* that it doesnt break iterator + * by modifying data it loops over [#30632], this re-uses the 'stack' variable which is a bit + * bad practice but save alloc'ing a new array - note, the comment above is useful, keep it + * if you are tidying up code - campbell */ + BLI_array_empty(stack); + BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, v) { + if ((l->v == v) && (i = GET_INT_FROM_POINTER(BLI_ghash_lookup(visithash, l->e)))) { + BM_elem_index_set(l, i); /* would be nice to assign vert here but cant, so assign the vert index */ + BLI_array_append(stack, (BMEdge *)l); + } + } + while ((l = (BMLoop *)(BLI_array_pop(stack)))) { + l->v = verts[BM_elem_index_get(l)]; + } +#endif + + BLI_array_free(stack); BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) { i = GET_INT_FROM_POINTER(BLI_ghash_lookup(visithash, e)); |