fix for crash in grid-fill where it was possible for rail edges to overlap.

This commit is contained in:
Campbell Barton 2013-05-16 15:28:57 +00:00
parent a8964d865f
commit fbf890200c
3 changed files with 29 additions and 0 deletions

@ -601,3 +601,24 @@ void BM_edgeloop_expand(BMesh *UNUSED(bm), BMEdgeLoopStore *el_store, int el_sto
BLI_assert(el_store->len == el_store_len); BLI_assert(el_store->len == el_store_len);
} }
bool BM_edgeloop_overlap_check(struct BMEdgeLoopStore *el_store_a, struct BMEdgeLoopStore *el_store_b)
{
LinkData *node;
/* init */
for (node = el_store_a->verts.first; node; node = node->next) {
BM_elem_flag_disable((BMVert *)node->data, BM_ELEM_INTERNAL_TAG);
}
for (node = el_store_b->verts.first; node; node = node->next) {
BM_elem_flag_enable((BMVert *)node->data, BM_ELEM_INTERNAL_TAG);
}
/* check 'a' */
for (node = el_store_a->verts.first; node; node = node->next) {
if (BM_elem_flag_test((BMVert *)node->data, BM_ELEM_INTERNAL_TAG)) {
return true;
}
}
return false;
}

@ -57,6 +57,8 @@ void BM_edgeloop_calc_normal(BMesh *bm, struct BMEdgeLoopStore *e
void BM_edgeloop_flip(BMesh *bm, struct BMEdgeLoopStore *el_store); void BM_edgeloop_flip(BMesh *bm, struct BMEdgeLoopStore *el_store);
void BM_edgeloop_expand(BMesh *bm, struct BMEdgeLoopStore *el_store, int el_store_len); void BM_edgeloop_expand(BMesh *bm, struct BMEdgeLoopStore *el_store, int el_store_len);
bool BM_edgeloop_overlap_check(struct BMEdgeLoopStore *el_store_a, struct BMEdgeLoopStore *el_store_b);
#define BM_EDGELOOP_NEXT(el_store, elink) \ #define BM_EDGELOOP_NEXT(el_store, elink) \
(elink)->next ? elink->next : (BM_edgeloop_is_closed(el_store) ? BM_edgeloop_verts_get(el_store)->first : NULL) (elink)->next ? elink->next : (BM_edgeloop_is_closed(el_store) ? BM_edgeloop_verts_get(el_store)->first : NULL)

@ -423,6 +423,12 @@ void bmo_grid_fill_exec(BMesh *bm, BMOperator *op)
goto cleanup; goto cleanup;
} }
if (BM_edgeloop_overlap_check(estore_rail_a, estore_rail_b)) {
BMO_error_raise(bm, op, BMERR_INVALID_SELECTION,
"Connecting edge loops overlap");
goto cleanup;
}
/* finally we have all edge loops needed */ /* finally we have all edge loops needed */
bm_grid_fill(bm, estore_a, estore_b, estore_rail_a, estore_rail_b, bm_grid_fill(bm, estore_a, estore_b, estore_rail_a, estore_rail_b,
mat_nr, use_smooth); mat_nr, use_smooth);