[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19241] branches/bmesh/blender/source/ blender: fixed some dissolveverts/ faces bugs and added a few hackish fixes for some others, so they don' t crash
Joseph Eagar
joeedh at gmail.com
Mon Mar 9 16:15:17 CET 2009
Revision: 19241
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19241
Author: joeedh
Date: 2009-03-09 16:15:17 +0100 (Mon, 09 Mar 2009)
Log Message:
-----------
fixed some dissolveverts/faces bugs and added a few hackish fixes for some others, so they don't crash
Modified Paths:
--------------
branches/bmesh/blender/source/blender/bmesh/bmesh_error.h
branches/bmesh/blender/source/blender/bmesh/intern/editmesh_to_bmesh.c
branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c
branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c
branches/bmesh/blender/source/blender/editors/mesh/editmesh_tools.c
Modified: branches/bmesh/blender/source/blender/bmesh/bmesh_error.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh_error.h 2009-03-09 13:24:37 UTC (rev 19240)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh_error.h 2009-03-09 15:15:17 UTC (rev 19241)
@@ -35,6 +35,7 @@
#define BMERR_WALKER_FAILED 4
#define BMERR_DISSOLVEFACES_FAILED 5
#define BMERR_DISSOLVEVERTS_FAILED 6
+#define BMERR_TESSELATION 7
static char *bmop_error_messages[] = {
0,
@@ -44,6 +45,7 @@
"Could not traverse mesh",
"Could not dissolve faces",
"Could not dissolve vertices",
+ "Tesselation error",
};
#endif /* _BMESH_ERROR_H */
\ No newline at end of file
Modified: branches/bmesh/blender/source/blender/bmesh/intern/editmesh_to_bmesh.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/editmesh_to_bmesh.c 2009-03-09 13:24:37 UTC (rev 19240)
+++ branches/bmesh/blender/source/blender/bmesh/intern/editmesh_to_bmesh.c 2009-03-09 15:15:17 UTC (rev 19241)
@@ -249,6 +249,11 @@
if (((BMLoop*)l->radial.next->data)->f->head.flag & BM_ACTIVE) act = BM_ACTIVE;
sf = BM_Join_Faces(bm,l->f, ((BMLoop*)l->radial.next->data)->f, l->e, 0,0);
+ if (!sf) {
+ //tesselation error
+ break;
+ }
+
sf->head.flag |= act;
if(sf){
done = 0;
Modified: branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c 2009-03-09 13:24:37 UTC (rev 19240)
+++ branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c 2009-03-09 15:15:17 UTC (rev 19241)
@@ -57,7 +57,7 @@
BMLoop ***regions = NULL;
BMLoop **region = NULL;
BMWalker walker, regwalker;
- int i, j, fcopied;
+ int i, j, a, fcopied;
BMO_Flag_Buffer(bm, op, BMOP_DISFACES_FACEIN, FACE_MARK);
@@ -134,8 +134,17 @@
edges[V_COUNT(edges)-1] = region[j]->e;
}
- f= BM_Make_Ngon(bm, region[0]->v, region[1]->v, edges, j, 1);
-
+ if (region[0]->e->v1 == region[0]->v)
+ f= BM_Make_Ngon(bm, region[0]->e->v1, region[0]->e->v2, edges, j, 1);
+ else
+ f= BM_Make_Ngon(bm, region[0]->e->v2, region[0]->e->v1, edges, j, 1);
+
+ if (!f) {
+ BMO_RaiseError(bm, op, BMERR_DISSOLVEFACES_FAILED,
+ "Could not create merged face");
+ goto cleanup;
+ }
+
/*if making the new face failed (e.g. overlapping test)
unmark the original faces for deletion.*/
BMO_ClearFlag(bm, f, FACE_ORIG);
@@ -170,7 +179,7 @@
}
BMO_CallOpf(bm, "del geom=%ff context=%d", FACE_ORIG, DEL_FACES);
- if (BMO_HasError(bm)) return;
+ if (BMO_HasError(bm)) goto cleanup;
BMO_Flag_To_Slot(bm, op, BMOP_DISFACES_REGIONOUT, FACE_NEW, BM_FACE);
@@ -189,6 +198,7 @@
BMIter iter, fiter;
BMVert *v;
BMFace *f;
+ int i;
vinput = BMO_GetSlot(op, BMOP_DISVERTS_VERTIN);
@@ -211,6 +221,18 @@
BMO_ClearStack(bm);
BMO_RaiseError(bm, op, BMERR_DISSOLVEVERTS_FAILED,msg);
}
+
+ /*clean up any remaining*/
+ for (v=BMIter_New(&iter, bm, BM_VERTS, NULL); v; v=BMIter_Step(&iter)) {
+ if (BMO_TestFlag(bm, v, VERT_MARK)) {
+ if (!BM_Dissolve_Vert(bm, v)) {
+ BMO_RaiseError(bm, op,
+ BMERR_DISSOLVEVERTS_FAILED, NULL);
+ return;
+ }
+ }
+ }
+
}
/*this code is for cleaning up two-edged faces, it shall become
Modified: branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c 2009-03-09 13:24:37 UTC (rev 19240)
+++ branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c 2009-03-09 15:15:17 UTC (rev 19241)
@@ -489,7 +489,8 @@
a = numcuts*2 + 2 + i;
b = numcuts + numcuts - i;
e = BM_Connect_Verts(bm, verts[a], verts[b], &nf);
-
+ if (!e) goto cleanup;
+
BMO_SetFlag(bm, e, ELE_INNER);
BMO_SetFlag(bm, nf, ELE_INNER);
@@ -531,8 +532,9 @@
}
}
+cleanup:
for (i=1; i<numcuts+2; i++) {
- MEM_freeN(lines[i]);
+ if (lines[i]) MEM_freeN(lines[i]);
}
MEM_freeN(lines);
Modified: branches/bmesh/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/editmesh_tools.c 2009-03-09 13:24:37 UTC (rev 19240)
+++ branches/bmesh/blender/source/blender/editors/mesh/editmesh_tools.c 2009-03-09 15:15:17 UTC (rev 19241)
@@ -1111,7 +1111,7 @@
{4, "EDGE_FACE","Edges & Faces", ""},
{5, "ONLY_FACE","Only Faces", ""},
{6, "EDGE_LOOP","Edge Loop", ""},
- {7, "COLLAPSE","Collapse", ""},
+ {7, "DISSOLVE","Dissolve Verts", ""},
{0, NULL, NULL, NULL}
};
@@ -6921,7 +6921,9 @@
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
- convert_to_triface(em,0);
+ //convert_to_triface(em,0);
+ if (!EDBM_CallOpf(em, op, "triangulate faces=%hf", BM_SELECT))
+ return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
More information about the Bf-blender-cvs
mailing list