improve recent commit to copy loop data on extrude

- in some cases the is only a face on the new edge, so check for this as a source to copy from too.
- one of the asserts wasnt correct, if there are no adjacent faces found just return.
This commit is contained in:
2012-04-18 19:05:28 +00:00
parent 446d5ad970
commit 18a6282e59

View File

@@ -118,39 +118,53 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op)
BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, EXT_KEEP); BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, EXT_KEEP);
} }
static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f, BMEdge *e, BMEdge *newedge) /**
* \brief Copy the loop pair from an adjacent face to both sides of this quad.
*
* The face is assumed to be a quad, created by extruding.
* This function won't crash if its not but won't work right either.
* \a e_b is the new edge.
*
* \note this function could be exposed as an api call if other areas need it,
* so far only extrude does.
*/
static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f, BMEdge *e_a, BMEdge *e_b)
{ {
/* 'a' is the starting edge #e, 'b' is the final edge #newedge */ /* 'a' is the starting edge #e, 'b' is the final edge #newedge */
BMLoop *l_dst_a = BM_face_edge_share_loop(f, e); BMLoop *l_dst_a = BM_face_edge_share_loop(f, e_a);
BMLoop *l_dst_b = newedge->l; /* will only ever be one loop */ BMLoop *l_dst_b = BM_face_edge_share_loop(f, e_b);
BMLoop *l_src_a = l_dst_a->radial_next; /* we could only have a face on one-or the other edges,
* chech if either side of the face has an adjacent face */
BMLoop *l_src_1;
BMLoop *l_src_2;
/* there is no l_src_b */ /* there is no l_src_b */
/* sanity */ /* sanity */
BLI_assert(l_src_a->f != l_dst_a->f);
BLI_assert(l_dst_a->f == l_dst_b->f); BLI_assert(l_dst_a->f == l_dst_b->f);
if (l_dst_a != l_dst_a->radial_next) {
BM_elem_attrs_copy(bm, bm, l_src_a->f, l_dst_a->f); l_src_1 = l_dst_a->radial_next;
BM_elem_flag_disable(f, BM_ELEM_HIDDEN); /* possibly we copy from a hidden face */ l_src_2 = l_src_1->next;
}
else if (l_dst_b != l_dst_b->radial_next) {
/* copy data */ l_src_2 = l_dst_b->radial_next;
if (l_src_a->v == l_dst_a->v) { l_src_1 = l_src_2->next;
BM_elem_attrs_copy(bm, bm, l_src_a, l_dst_a);
BM_elem_attrs_copy(bm, bm, l_src_a, l_dst_b->next);
BM_elem_attrs_copy(bm, bm, l_src_a->next, l_dst_a->next);
BM_elem_attrs_copy(bm, bm, l_src_a->next, l_dst_b);
} }
else { else {
l_src_a = l_src_a->next; /* no new faces on either edge, nothing to copy from */
BM_elem_attrs_copy(bm, bm, l_src_a, l_dst_a); return;
BM_elem_attrs_copy(bm, bm, l_src_a, l_dst_b->next);
BM_elem_attrs_copy(bm, bm, l_src_a->prev, l_dst_a->next);
BM_elem_attrs_copy(bm, bm, l_src_a->prev, l_dst_b);
} }
BM_elem_attrs_copy(bm, bm, l_src_1->f, l_dst_a->f);
BM_elem_flag_disable(f, BM_ELEM_HIDDEN); /* possibly we copy from a hidden face */
/* copy data */
BM_elem_attrs_copy(bm, bm, l_src_2, l_dst_a);
BM_elem_attrs_copy(bm, bm, l_src_2, l_dst_b->next);
BM_elem_attrs_copy(bm, bm, l_src_1, l_dst_a->next);
BM_elem_attrs_copy(bm, bm, l_src_1, l_dst_b);
} }
void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op) void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op)