[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45596] trunk/blender/source/blender/bmesh : fix [#30936] Face Inset gives bad UV's

Campbell Barton ideasman42 at gmail.com
Fri Apr 13 12:37:33 CEST 2012


Revision: 45596
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45596
Author:   campbellbarton
Date:     2012-04-13 10:37:33 +0000 (Fri, 13 Apr 2012)
Log Message:
-----------
fix [#30936] Face Inset gives bad UV's

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_construct.c
    trunk/blender/source/blender/bmesh/operators/bmo_inset.c

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_construct.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_construct.c	2012-04-13 09:31:37 UTC (rev 45595)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_construct.c	2012-04-13 10:37:33 UTC (rev 45596)
@@ -125,25 +125,35 @@
 	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);
 }
 
 /**

Modified: trunk/blender/source/blender/bmesh/operators/bmo_inset.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_inset.c	2012-04-13 09:31:37 UTC (rev 45595)
+++ trunk/blender/source/blender/bmesh/operators/bmo_inset.c	2012-04-13 10:37:33 UTC (rev 45596)
@@ -482,6 +482,11 @@
 		/* 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);




More information about the Bf-blender-cvs mailing list