diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-12-26 06:49:07 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-12-26 07:34:55 +0300 |
commit | 0d7d3177556313dc9a4a613886eb08c4fb96acba (patch) | |
tree | f4ba2cc03af5c47f923154defc8f3b32286c5707 /source/blender/bmesh/intern/bmesh_core.c | |
parent | 77c3ecf88c3109e5a6b14f6e064fe1a88644bab6 (diff) |
BMesh: add checks for duplicates in a face
These could go un-noticed, causing errors later on.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_core.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index b166d60ce8f..d5896dd0b31 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -553,7 +553,10 @@ int bmesh_elem_check(void *element, const char htype) IS_FACE_LOOP_VERT_NOT_IN_EDGE = (1 << 20), IS_FACE_LOOP_WRONG_RADIAL_LENGTH = (1 << 21), IS_FACE_LOOP_WRONG_DISK_LENGTH = (1 << 22), - IS_FACE_WRONG_LENGTH = (1 << 23), + IS_FACE_LOOP_DUPE_LOOP = (1 << 23), + IS_FACE_LOOP_DUPE_VERT = (1 << 24), + IS_FACE_LOOP_DUPE_EDGE = (1 << 25), + IS_FACE_WRONG_LENGTH = (1 << 26), } err = 0; if (!element) @@ -688,9 +691,39 @@ int bmesh_elem_check(void *element, const char htype) } } + /* check for duplicates */ + if (BM_ELEM_API_FLAG_TEST(l_iter, _FLAG_ELEM_CHECK)) { + err |= IS_FACE_LOOP_DUPE_LOOP; + } + BM_ELEM_API_FLAG_ENABLE(l_iter, _FLAG_ELEM_CHECK); + if (l_iter->v) { + if (BM_ELEM_API_FLAG_TEST(l_iter->v, _FLAG_ELEM_CHECK)) { + err |= IS_FACE_LOOP_DUPE_VERT; + } + BM_ELEM_API_FLAG_ENABLE(l_iter->v, _FLAG_ELEM_CHECK); + } + if (l_iter->e) { + if (BM_ELEM_API_FLAG_TEST(l_iter->e, _FLAG_ELEM_CHECK)) { + err |= IS_FACE_LOOP_DUPE_EDGE; + } + BM_ELEM_API_FLAG_ENABLE(l_iter->e, _FLAG_ELEM_CHECK); + } + len++; } while ((l_iter = l_iter->next) != l_first); + /* cleanup duplicates flag */ + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + BM_ELEM_API_FLAG_DISABLE(l_iter, _FLAG_ELEM_CHECK); + if (l_iter->v) { + BM_ELEM_API_FLAG_DISABLE(l_iter->v, _FLAG_ELEM_CHECK); + } + if (l_iter->e) { + BM_ELEM_API_FLAG_DISABLE(l_iter->e, _FLAG_ELEM_CHECK); + } + } while ((l_iter = l_iter->next) != l_first); + if (len != f->len) { err |= IS_FACE_WRONG_LENGTH; } |