[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54356] trunk/blender/source/blender: problem with own changes to triabgulate: calling beauty fill directly would re-allocate the faces which mean' t triangulates output slots pointers became invalid.

Campbell Barton ideasman42 at gmail.com
Wed Feb 6 16:57:13 CET 2013


Revision: 54356
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54356
Author:   campbellbarton
Date:     2013-02-06 15:57:12 +0000 (Wed, 06 Feb 2013)
Log Message:
-----------
problem with own changes to triabgulate: calling beauty fill directly would re-allocate the faces which mean't triangulates output slots pointers became invalid. (noticed when using from py api)

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c
    trunk/blender/source/blender/bmesh/intern/bmesh_operators.c
    trunk/blender/source/blender/bmesh/operators/bmo_triangulate.c
    trunk/blender/source/blender/editors/mesh/editmesh_knife.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	2013-02-06 14:02:19 UTC (rev 54355)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c	2013-02-06 15:57:12 UTC (rev 54356)
@@ -1436,7 +1436,7 @@
 	"beautify_fill",
 	/* slots_in */
 	{{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* input faces */
-	 {"constrain_edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* edges that can't be flipped */
+	 {"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* edges that can be flipped */
 	 {{'\0'}},
 	},
 	/* slots_out */

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operators.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operators.c	2013-02-06 14:02:19 UTC (rev 54355)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operators.c	2013-02-06 15:57:12 UTC (rev 54356)
@@ -562,7 +562,7 @@
 	BMElemF *ele_f;
 	int i;
 
-	BLI_assert(ELEM(true, false, test_for_enabled));
+	BLI_assert((unsigned int)test_for_enabled <= 1);
 
 	for (i = 0; i < 3; i++) {
 		if (htype & flag_types[i]) {
@@ -938,7 +938,7 @@
 	int totelement, i = 0;
 
 	BLI_assert(op->slots_in == slot_args || op->slots_out == slot_args);
-	BLI_assert(ELEM(true, false, test_for_enabled));
+	BLI_assert((unsigned int)test_for_enabled <= 1);
 
 	if (test_for_enabled)
 		totelement = BMO_mesh_enabled_flag_count(bm, htype, oflag);
@@ -1586,7 +1586,7 @@
  * **Utility**
  *
  * Pass an existing slot which is copied to either an input or output slot.
- * Taking the operator and slot-name pair of args.
+ * Taking the operator and slot-name pair of args (BMOperator *, const char *).
  * - `s` - slot_in (lower case)
  * - `S` - slot_out (upper case)
  *

Modified: trunk/blender/source/blender/bmesh/operators/bmo_triangulate.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_triangulate.c	2013-02-06 14:02:19 UTC (rev 54355)
+++ trunk/blender/source/blender/bmesh/operators/bmo_triangulate.c	2013-02-06 15:57:12 UTC (rev 54356)
@@ -51,12 +51,6 @@
 
 	BM_mesh_triangulate(bm, use_beauty, true, op, slot_facemap_out);
 
-	if (use_beauty) {
-		BMO_op_callf(bm, op->flag,
-		             "beautify_fill faces=%hf constrain_edges=%He",
-		             BM_ELEM_TAG, BM_ELEM_TAG);
-	}
-
 	BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_TAG);
 	BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
 }
@@ -69,7 +63,7 @@
 	BMEdge *e;
 	int stop = 0;
 	
-	BMO_slot_buffer_flag_enable(bm, op->slots_in, "constrain_edges", BM_EDGE, EDGE_MARK);
+	BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK);
 	
 	BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) {
 		if (f->len == 3) {
@@ -83,7 +77,7 @@
 		BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
 			BMVert *v1, *v2, *v3, *v4;
 			
-			if (!BM_edge_is_manifold(e) || BMO_elem_flag_test(bm, e, EDGE_MARK)) {
+			if (!BM_edge_is_manifold(e) || !BMO_elem_flag_test(bm, e, EDGE_MARK)) {
 				continue;
 			}
 
@@ -123,7 +117,7 @@
 				if (fac1 > fac2) {
 					e = BM_edge_rotate(bm, e, false, BM_EDGEROT_CHECK_EXISTS);
 					if (e) {
-						BMO_elem_flag_enable(bm, e, ELE_NEW);
+						BMO_elem_flag_enable(bm, e, ELE_NEW | EDGE_MARK);
 
 						BMO_elem_flag_enable(bm, e->l->f, FACE_MARK | ELE_NEW);
 						BMO_elem_flag_enable(bm, e->l->radial_next->f, FACE_MARK | ELE_NEW);
@@ -194,7 +188,7 @@
 	BLI_smallhash_release(&hash);
 	
 	/* clean up fill */
-	BMO_op_initf(bm, &bmop, op->flag, "beautify_fill faces=%ff constrain_edges=%fe", ELE_NEW, EDGE_MARK);
+	BMO_op_initf(bm, &bmop, op->flag, "beautify_fill faces=%ff edges=%Fe", ELE_NEW, EDGE_MARK);
 	BMO_op_exec(bm, &bmop);
 	BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_FACE | BM_EDGE, ELE_NEW);
 	BMO_op_finish(bm, &bmop);

Modified: trunk/blender/source/blender/editors/mesh/editmesh_knife.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2013-02-06 14:02:19 UTC (rev 54355)
+++ trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2013-02-06 15:57:12 UTC (rev 54356)
@@ -1853,7 +1853,7 @@
 	BMOperator bmop;
 	int idx;
 
-	BMO_op_initf(bm, &bmop, "beautify_fill faces=%ff constrain_edges=%fe", FACE_NEW, BOUNDARY);
+	BMO_op_initf(bm, &bmop, "beautify_fill faces=%ff edges=%Fe", FACE_NEW, BOUNDARY);
 
 	BMO_op_exec(bm, &bmop);
 	BMO_slot_buffer_flag_enable(bm, &bmop, "geom.out", BM_FACE, FACE_NEW);

Modified: trunk/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_tools.c	2013-02-06 14:02:19 UTC (rev 54355)
+++ trunk/blender/source/blender/editors/mesh/editmesh_tools.c	2013-02-06 15:57:12 UTC (rev 54356)
@@ -3355,7 +3355,7 @@
 	Object *obedit = CTX_data_edit_object(C);
 	BMEditMesh *em = BMEdit_FromObject(obedit);
 
-	if (!EDBM_op_callf(em, op, "beautify_fill faces=%hf", BM_ELEM_SELECT))
+	if (!EDBM_op_callf(em, op, "beautify_fill faces=%hf edges=ae", BM_ELEM_SELECT))
 		return OPERATOR_CANCELLED;
 
 	EDBM_update_generic(em, TRUE, TRUE);
@@ -3384,10 +3384,22 @@
 {
 	Object *obedit = CTX_data_edit_object(C);
 	BMEditMesh *em = BMEdit_FromObject(obedit);
+	BMOperator bmop;
 	int use_beauty = RNA_boolean_get(op->ptr, "use_beauty");
 
-	if (!EDBM_op_callf(em, op, "triangulate faces=%hf use_beauty=%b", BM_ELEM_SELECT, use_beauty))
+	EDBM_op_init(em, &bmop, op, "triangulate faces=%hf use_beauty=%b", BM_ELEM_SELECT, use_beauty);
+	BMO_op_exec(em->bm, &bmop);
+
+	/* now call beauty fill */
+	if (use_beauty) {
+		EDBM_op_callf(em, op,
+		              "beautify_fill faces=%S edges=%S",
+		              &bmop, "faces.out", &bmop, "edges.out");
+	}
+
+	if (!EDBM_op_finish(em, &bmop, op, TRUE)) {
 		return OPERATOR_CANCELLED;
+	}
 
 	EDBM_update_generic(em, TRUE, TRUE);
 




More information about the Bf-blender-cvs mailing list