fix [#30374] Can't Fill Triangular Face

the problem was a triangle couldnt be made when there was a quad that used 3 of the verts.

* now check if overlapping face has same length as the one to be created.
* an unrelated fix - the output of a triangle was not being flagged by the bmesh_contextual_create operator.
This commit is contained in:
Campbell Barton 2012-02-28 07:19:28 +00:00
parent 729ddf51b7
commit 94f171f2c6
4 changed files with 20 additions and 10 deletions

@ -95,7 +95,8 @@ float BM_edge_face_angle(struct BMesh *bm, struct BMEdge *e);
float BM_vert_edge_angle(struct BMesh *bm, struct BMVert *v);
/* checks overlapping of existing faces with the verts in varr. */
int BM_face_exists_overlap(struct BMesh *bm, struct BMVert **varr, int len, struct BMFace **existface);
int BM_face_exists_overlap(struct BMesh *bm, struct BMVert **varr, int len, struct BMFace **r_existface,
const short do_partial);
/* checks if many existing faces overlap the faces defined by varr */
int BM_face_exists_multi(BMesh *bm, struct BMVert **varr, struct BMEdge **earr, int len);

@ -93,10 +93,10 @@ BMFace *BM_face_create_quad_tri_v(BMesh *bm, BMVert **verts, int len, const BMFa
if (nodouble) {
/* check if face exists or overlaps */
if (len == 4) {
overlap = BM_face_exists_overlap(bm, verts, len, &f);
overlap = BM_face_exists_overlap(bm, verts, len, &f, FALSE);
}
else {
overlap = BM_face_exists_overlap(bm, verts, len, &f);
overlap = BM_face_exists_overlap(bm, verts, len, &f, FALSE);
}
}

@ -642,26 +642,31 @@ float BM_vert_edge_angle(BMesh *UNUSED(bm), BMVert *v)
*
*
*/
int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **overlapface)
int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_overlapface,
const short do_partial)
{
BMIter vertfaces;
BMFace *f;
int i, amount;
if (overlapface) *overlapface = NULL;
for (i = 0; i < len; i++) {
f = BM_iter_new(&vertfaces, bm, BM_FACES_OF_VERT, varr[i]);
while (f) {
amount = BM_verts_in_face(bm, f, varr, len);
if (amount >= len) {
if (overlapface) *overlapface = f;
if ((amount >= len) && (do_partial == TRUE || len == f->len)) {
if (r_overlapface) {
*r_overlapface = f;
}
return TRUE;
}
f = BM_iter_step(&vertfaces);
}
}
if (r_overlapface) {
*r_overlapface = NULL;
}
return FALSE;
}

@ -1386,7 +1386,11 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op)
}
else if (amount == 3) {
/* create triangl */
BM_face_create_quad_tri(bm, verts[0], verts[1], verts[2], NULL, NULL, TRUE);
f = BM_face_create_quad_tri(bm, verts[0], verts[1], verts[2], NULL, NULL, TRUE);
if (f) {
BMO_elem_flag_enable(bm, f, ELE_OUT);
}
}
else if (amount == 4) {
f = NULL;