diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-13 14:37:33 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-13 14:37:33 +0400 |
commit | a1e6e75adda2499cb1dc2f7102b79a9927c7bdef (patch) | |
tree | 09539bcad5f434a6771de702205051deeb9419f6 /source | |
parent | 0cabb2fa6aa2f7dddeab3f7f85d25af9a7752e30 (diff) |
fix [#30936] Face Inset gives bad UV's
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_construct.c | 34 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_inset.c | 5 |
2 files changed, 27 insertions, 12 deletions
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 4dad2f384a0..ec2b9ac006f 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -125,25 +125,35 @@ BMFace *BM_face_create_quad_tri_v(BMesh *bm, BMVert **verts, int len, const BMFa return f; } -/* copies face data from shared adjacent faces */ +/** + * \brief copies face loop data from shared adjacent faces. + * \note when a matching edge is found, both loops of that edge are copied + * this is done since the face may not be completely surrounded by faces, + * this way: a quad with 2 connected quads on either side will still get all 4 loops updated */ void BM_face_copy_shared(BMesh *bm, BMFace *f) { - BMIter iter; - BMLoop *l, *l_other; + BMLoop *l_first; + BMLoop *l_iter; - BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) { - l_other = l->radial_next; - - if (l_other && l_other != l) { - if (l_other->v == l->v) { - bm_loop_attrs_copy(bm, bm, l_other, l); + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + BMLoop *l_other = l_iter->radial_next; + + if (l_other && l_other != l_iter) { + if (l_other->v == l_iter->v) { + bm_loop_attrs_copy(bm, bm, l_other, l_iter); + bm_loop_attrs_copy(bm, bm, l_other->next, l_iter->next); } else { - l_other = l_other->next; - bm_loop_attrs_copy(bm, bm, l_other, l); + bm_loop_attrs_copy(bm, bm, l_other->next, l_iter); + bm_loop_attrs_copy(bm, bm, l_other, l_iter->next); + } + /* since we copy both loops of the shared edge, step over the next loop here */ + if ((l_iter = l_iter->next) == l_first) { + break; } } - } + } while ((l_iter = l_iter->next) != l_first); } /** diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index 61447e98c15..3bfacb29197 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -482,6 +482,11 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) /* yes - reverse face is correct in this case */ f = BM_face_create_quad_tri_v(bm, varr, j, es->l->f, FALSE); BMO_elem_flag_enable(bm, f, ELE_NEW); + + /* copy for loop data, otherwise UV's and vcols are no good. + * tiny speedup here we could be more clever and copy from known adjacent data + * also - we could attempt to interpolate the loop data, this would be much slower but more useful too */ + BM_face_copy_shared(bm, f); } MEM_freeN(edge_info); |