[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45828] trunk/blender/source/blender: fix [#31049] New Faces (F) always solid shaded

Campbell Barton ideasman42 at gmail.com
Sat Apr 21 15:58:30 CEST 2012


Revision: 45828
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45828
Author:   campbellbarton
Date:     2012-04-21 13:58:29 +0000 (Sat, 21 Apr 2012)
Log Message:
-----------
fix [#31049] New Faces (F) always solid shaded

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c
    trunk/blender/source/blender/bmesh/operators/bmo_create.c
    trunk/blender/source/blender/editors/mesh/editmesh_tools.c

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c	2012-04-21 13:37:26 UTC (rev 45827)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c	2012-04-21 13:58:29 UTC (rev 45828)
@@ -404,8 +404,9 @@
 static BMOpDefine bmo_contextual_create_def = {
 	"contextual_create",
 	{{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, //input geometry.
-	 {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, //newly-made face(s)
-	 {BMO_OP_SLOT_INT,         "mat_nr"},  /* material to use */
+	 {BMO_OP_SLOT_ELEMENT_BUF, "faceout"},     /* newly-made face(s) */
+	 {BMO_OP_SLOT_INT,         "mat_nr"},      /* material to use */
+	 {BMO_OP_SLOT_BOOL,        "use_smooth"},  /* material to use */
 	 {0, /* null-terminating sentinel */}},
 	bmo_contextual_create_exec,
 	BMO_OP_FLAG_UNTAN_MULTIRES,
@@ -431,8 +432,9 @@
 	 {BMO_OP_SLOT_BOOL,        "use_fill_check"},
 	 {BMO_OP_SLOT_ELEMENT_BUF, "excludefaces"}, /* list of faces to ignore for manifold check */
 	 {BMO_OP_SLOT_MAPPING,     "faceout_groupmap"}, /* maps new faces to the group numbers they came fro */
-	 {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new face */
-	 {BMO_OP_SLOT_INT,         "mat_nr"},  /* material to use */
+	 {BMO_OP_SLOT_ELEMENT_BUF, "faceout"},     /* new face */
+	 {BMO_OP_SLOT_INT,         "mat_nr"},      /* material to use */
+	 {BMO_OP_SLOT_BOOL,        "use_smooth"},  /* material to use */
 	 {0, /* null-terminating sentinel */}},
 	bmo_edgenet_fill_exec,
 	0,

Modified: trunk/blender/source/blender/bmesh/operators/bmo_create.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_create.c	2012-04-21 13:37:26 UTC (rev 45827)
+++ trunk/blender/source/blender/bmesh/operators/bmo_create.c	2012-04-21 13:58:29 UTC (rev 45828)
@@ -896,9 +896,10 @@
 	BMEdge **edges = NULL;
 	PathBase *pathbase;
 	BLI_array_declare(edges);
-	int use_restrict   = BMO_slot_bool_get(op, "use_restrict");
-	int use_fill_check = BMO_slot_bool_get(op, "use_fill_check");
-	const short mat_nr = BMO_slot_int_get(op, "mat_nr");
+	int use_restrict       = BMO_slot_bool_get(op, "use_restrict");
+	int use_fill_check     = BMO_slot_bool_get(op, "use_fill_check");
+	const short mat_nr     = BMO_slot_int_get(op,  "mat_nr");
+	const short use_smooth = BMO_slot_bool_get(op, "use_smooth");
 	int i, j, group = 0;
 	unsigned int winding[2]; /* accumulte winding directions for each edge which has a face */
 
@@ -1049,6 +1050,9 @@
 				if (f && !BMO_elem_flag_test(bm, f, ELE_ORIG)) {
 					BMO_elem_flag_enable(bm, f, FACE_NEW);
 					f->mat_nr = mat_nr;
+					if (use_smooth) {
+						BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
+					}
 				}
 
 				if (use_restrict) {
@@ -1278,6 +1282,7 @@
 	BMFace *f;
 	int totv = 0, tote = 0, totf = 0, amount;
 	const short mat_nr = BMO_slot_int_get(op, "mat_nr");
+	const short use_smooth = BMO_slot_bool_get(op, "use_smooth");
 
 	/* count number of each element type we were passe */
 	BMO_ITER (h, &oiter, bm, op, "geom", BM_VERT|BM_EDGE|BM_FACE) {
@@ -1365,7 +1370,10 @@
 	BMO_slot_buffer_flag_enable(bm, &op2, "edgeout", BM_EDGE, ELE_NEW);
 	BMO_op_finish(bm, &op2);
 
-	BMO_op_initf(bm, &op2, "edgenet_fill edges=%fe use_fill_check=%b mat_nr=%i", ELE_NEW, TRUE, mat_nr);
+	BMO_op_initf(bm, &op2,
+	             "edgenet_fill edges=%fe use_fill_check=%b mat_nr=%i use_smooth=%b",
+	             ELE_NEW, TRUE, mat_nr, use_smooth);
+
 	BMO_op_exec(bm, &op2);
 
 	/* return if edge net create did something */
@@ -1469,6 +1477,9 @@
 		if (f) {
 			BMO_elem_flag_enable(bm, f, ELE_OUT);
 			f->mat_nr = mat_nr;
+			if (use_smooth) {
+				BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
+			}
 		}
 
 		MEM_freeN(vert_arr);

Modified: trunk/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_tools.c	2012-04-21 13:37:26 UTC (rev 45827)
+++ trunk/blender/source/blender/editors/mesh/editmesh_tools.c	2012-04-21 13:58:29 UTC (rev 45828)
@@ -1020,14 +1020,37 @@
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+static int edbm_add_edge_face__smooth_get(BMesh *bm)
+{
+	BMEdge *e;
+	BMIter iter;
+
+	unsigned int vote_on_smooth[2] = {0, 0};
+
+	BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+		if (BM_elem_flag_test(e, BM_ELEM_SELECT) && e->l)
+		{
+			vote_on_smooth[BM_elem_flag_test_bool(e->l->f, BM_ELEM_SMOOTH)]++;
+		}
+	}
+
+	return (vote_on_smooth[0] < vote_on_smooth[1]);
+}
+
 static int edbm_add_edge_face_exec(bContext *C, wmOperator *op)
 {
 	BMOperator bmop;
 	Object *obedit = CTX_data_edit_object(C);
 	BMEditMesh *em = BMEdit_FromObject(obedit);
-	
-	if (!EDBM_op_init(em, &bmop, op, "contextual_create geom=%hfev mat_nr=%i", BM_ELEM_SELECT, em->mat_nr))
+	const short use_smooth = edbm_add_edge_face__smooth_get(em->bm);
+	/* when this is used to dissolve we could avoid this, but checking isnt too slow */
+
+	if (!EDBM_op_init(em, &bmop, op,
+	                  "contextual_create geom=%hfev mat_nr=%i use_smooth=%b",
+	                  BM_ELEM_SELECT, em->mat_nr, use_smooth))
+	{
 		return OPERATOR_CANCELLED;
+	}
 	
 	BMO_op_exec(em->bm, &bmop);
 	BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE);




More information about the Bf-blender-cvs mailing list