fix [#31197] Limited dissolve leaves faces/edges/verts behind

bad bug where vertices could be in a face more then once (which isn't allowed), now check for this when creating a face.
This commit is contained in:
Campbell Barton 2012-05-06 18:04:37 +00:00
parent ffed654ff2
commit 3d9d26d6bf
2 changed files with 14 additions and 0 deletions

@ -214,6 +214,9 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i
BLI_array_append(verts, v);
BLI_array_append(edges2, e);
/* we only flag the verts to check if they are in the face more then once */
BM_ELEM_API_FLAG_ENABLE(v, _FLAG_MV);
do {
e2 = bmesh_disk_edge_next(e2, v);
if (e2 != e && BM_ELEM_API_FLAG_TEST(e2, _FLAG_MF)) {
@ -269,6 +272,12 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i
if (!edges2[i]) {
goto err;
}
/* check if vert is in face more then once. if the flag is disabled. we've already visited */
if (!BM_ELEM_API_FLAG_TEST(verts[i], _FLAG_MV)) {
goto err;
}
BM_ELEM_API_FLAG_DISABLE(verts[i], _FLAG_MV);
}
f = BM_face_create(bm, verts, edges2, len, nodouble);
@ -286,6 +295,10 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i
err:
for (i = 0; i < len; i++) {
BM_ELEM_API_FLAG_DISABLE(edges[i], _FLAG_MF);
/* vert count may != len */
if (i < BLI_array_count(verts)) {
BM_ELEM_API_FLAG_DISABLE(verts[i], _FLAG_MV);
}
}
BLI_array_free(verts);

@ -60,6 +60,7 @@ int bmesh_disk_count(BMVert *v);
* on using these internal flags!*/
#define _FLAG_JF 1 /* join faces */
#define _FLAG_MF 2 /* make face */
#define _FLAG_MV 2 /* make face, vertex */
#define BM_ELEM_API_FLAG_ENABLE(element, f) ((element)->oflags[0].pflag |= (f))
#define BM_ELEM_API_FLAG_DISABLE(element, f) ((element)->oflags[0].pflag &= ~(f))