[Bf-blender-cvs] [3863660] master: Fix face creation using incorrect loop-custom-data

Campbell Barton noreply at git.blender.org
Thu Nov 5 10:25:26 CET 2015


Commit: 3863660c37d23f64f0d76a202da425e8aaf7ba95
Author: Campbell Barton
Date:   Thu Nov 5 20:04:36 2015 +1100
Branches: master
https://developer.blender.org/rB3863660c37d23f64f0d76a202da425e8aaf7ba95

Fix face creation using incorrect loop-custom-data

Custom-data on newly created face data was often rotated.

Now the API doesn't copy data from adjacent loops when creating faces.
Most functions were already overwriting this anyway.

Since such decisions are better made at a higher level, now it's the responsibility of the caller.

===================================================================

M	source/blender/bmesh/intern/bmesh_core.c
M	source/blender/bmesh/operators/bmo_create.c
M	source/blender/bmesh/operators/bmo_edgenet.c

===================================================================

diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index 4e17868..d507cbe 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -206,6 +206,11 @@ BMEdge *BM_edge_create(
 	return e;
 }
 
+/**
+ * \note In most cases a \a l_example should be NULL,
+ * since this is a low level API and we shouldn't attempt to be clever and guess whats intended.
+ * In cases where copying adjacent loop-data is useful, see #BM_face_copy_shared.
+ */
 static BMLoop *bm_loop_create(
         BMesh *bm, BMVert *v, BMEdge *e, BMFace *f,
         const BMLoop *l_example, const eBMCreateFlag create_flag)
@@ -215,7 +220,15 @@ static BMLoop *bm_loop_create(
 	l = BLI_mempool_alloc(bm->lpool);
 
 	BLI_assert((l_example == NULL) || (l_example->head.htype == BM_LOOP));
-	BLI_assert(!(create_flag & 1));
+	BLI_assert(!(create_flag & BM_CREATE_NO_DOUBLE));
+
+#ifndef NDEBUG
+	if (l_example) {
+		/* ensure passing a loop is either sharing the same vertex, or entirely disconnected
+		 * use to catch mistake passing in loop offset-by-one. */
+		BLI_assert((v == l_example->v) || !ELEM(v, l_example->prev->v, l_example->next->v));
+	}
+#endif
 
 	/* --- assign all members --- */
 	l->head.data = NULL;
@@ -267,7 +280,7 @@ static BMLoop *bm_face_boundary_add(
 #ifdef USE_BMESH_HOLES
 	BMLoopList *lst = BLI_mempool_calloc(bm->looplistpool);
 #endif
-	BMLoop *l = bm_loop_create(bm, startv, starte, f, starte->l, create_flag);
+	BMLoop *l = bm_loop_create(bm, startv, starte, f, NULL /* starte->l */, create_flag);
 	
 	bmesh_radial_append(starte, l);
 
@@ -442,7 +455,7 @@ BMFace *BM_face_create(
 	startl->v = verts[0];
 	startl->e = edges[0];
 	for (i = 1; i < len; i++) {
-		l = bm_loop_create(bm, verts[i], edges[i], f, edges[i]->l, create_flag);
+		l = bm_loop_create(bm, verts[i], edges[i], f, NULL /* edges[i]->l */, create_flag);
 		
 		l->f = f;
 		bmesh_radial_append(edges[i], l);
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index 1c054e8..a1e20da 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -291,6 +291,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
 			if (use_smooth) {
 				BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
 			}
+			BM_face_copy_shared(bm, f, NULL, NULL);
 			BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, ELE_OUT);
 		}
 
diff --git a/source/blender/bmesh/operators/bmo_edgenet.c b/source/blender/bmesh/operators/bmo_edgenet.c
index 4423123..f348014 100644
--- a/source/blender/bmesh/operators/bmo_edgenet.c
+++ b/source/blender/bmesh/operators/bmo_edgenet.c
@@ -73,8 +73,8 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
 	/* --- Attribute Fill --- */
 	/* may as well since we have the faces already in a buffer */
 	BMO_op_initf(bm, &op_attr, op->flag,
-	             "face_attribute_fill faces=%S use_normals=%b",
-	             op, "faces.out", true);
+	             "face_attribute_fill faces=%S use_normals=%b use_data=%b",
+	             op, "faces.out", true, true);
 
 	BMO_op_exec(bm, &op_attr);




More information about the Bf-blender-cvs mailing list