[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43619] branches/bmesh/blender/source/ blender: disable re-tesselation for modifiers that use bmesh, array/bevel/ edge split - were tesselating 2 times and didnt need to.

Campbell Barton ideasman42 at gmail.com
Sun Jan 22 22:12:30 CET 2012


Revision: 43619
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43619
Author:   campbellbarton
Date:     2012-01-22 21:12:18 +0000 (Sun, 22 Jan 2012)
Log Message:
-----------
disable re-tesselation for modifiers that use bmesh, array/bevel/edge split - were tesselating 2 times and didnt need to.
also comment array modifier from flushing selection flags.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h
    branches/bmesh/blender/source/blender/blenkernel/BKE_tessmesh.h
    branches/bmesh/blender/source/blender/blenkernel/intern/editderivedmesh.c
    branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c
    branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_bevel.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c

Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h	2012-01-22 20:25:25 UTC (rev 43618)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h	2012-01-22 21:12:18 UTC (rev 43619)
@@ -69,7 +69,8 @@
 /* useful for OrcoDM creation for curves with constructive modifiers */
 DerivedMesh *CDDM_from_curve_customDB(struct Object *ob, struct ListBase *dispbase);
 
-struct BMEditMesh *CDDM_To_BMesh(struct Object *ob, struct DerivedMesh *dm, struct BMEditMesh *existing);
+struct BMEditMesh *CDDM_To_BMesh(struct Object *ob, struct DerivedMesh *dm,
+                                 struct BMEditMesh *existing, int do_tesselate);
 
 
 /* Copies the given DerivedMesh with verts, faces & edges stored as

Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_tessmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_tessmesh.h	2012-01-22 20:25:25 UTC (rev 43618)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_tessmesh.h	2012-01-22 21:12:18 UTC (rev 43619)
@@ -67,7 +67,7 @@
 #define BMESH_EM_UNDO_RECALC_TESSFACE_WORKAROUND
 
 void BMEdit_RecalcTesselation(BMEditMesh *tm);
-BMEditMesh *BMEdit_Create(BMesh *bm);
+BMEditMesh *BMEdit_Create(BMesh *bm, int do_tesselate);
 BMEditMesh *BMEdit_Copy(BMEditMesh *tm);
 void BMEdit_Free(BMEditMesh *em);
 void BMEdit_UpdateLinkedCustomData(BMEditMesh *em);

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/editderivedmesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/editderivedmesh.c	2012-01-22 20:25:25 UTC (rev 43618)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/editderivedmesh.c	2012-01-22 21:12:18 UTC (rev 43619)
@@ -70,14 +70,15 @@
 extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */
 
 
-BMEditMesh *BMEdit_Create(BMesh *bm)
+BMEditMesh *BMEdit_Create(BMesh *bm, int do_tesselate)
 {
 	BMEditMesh *tm = MEM_callocN(sizeof(BMEditMesh), __func__);
 
 	tm->bm = bm;
+	if (do_tesselate) {
+		BMEdit_RecalcTesselation(tm);
+	}
 
-	BMEdit_RecalcTesselation(tm);
-
 	return tm;
 }
 

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c	2012-01-22 20:25:25 UTC (rev 43618)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c	2012-01-22 21:12:18 UTC (rev 43619)
@@ -103,7 +103,7 @@
 
 /*converts a cddm to a BMEditMesh.  if existing is non-NULL, the
   new geometry will be put in there.*/
-BMEditMesh *CDDM_To_BMesh(Object *ob, DerivedMesh *dm, BMEditMesh *existing)
+BMEditMesh *CDDM_To_BMesh(Object *ob, DerivedMesh *dm, BMEditMesh *existing, int do_tesselate)
 {
 	int allocsize[4] = {512, 512, 2048, 512};
 	BMesh *bm, bmold; /*bmold is for storing old customdata layout*/
@@ -205,8 +205,14 @@
 	BLI_array_free(verts);
 	BLI_array_free(edges);
 
-	if (!em) em = BMEdit_Create(bm);
-	else BMEdit_RecalcTesselation(em);
+	if (!em) {
+		em = BMEdit_Create(bm, do_tesselate);
+	}
+	else {
+		if (do_tesselate) {
+			BMEdit_RecalcTesselation(em);
+		}
+	}
 
 	return em;
 }

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c	2012-01-22 20:25:25 UTC (rev 43618)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c	2012-01-22 21:12:18 UTC (rev 43619)
@@ -374,7 +374,7 @@
 	/*switch multires data out of tangent space*/
 	if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
 		Object *ob = bm->ob;
-		BMEditMesh *em = BMEdit_Create(bm);
+		BMEditMesh *em = BMEdit_Create(bm, FALSE);
 		DerivedMesh *dm = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
 		MDisps *mdisps;
 		BMFace *f;

Modified: branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c	2012-01-22 20:25:25 UTC (rev 43618)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c	2012-01-22 21:12:18 UTC (rev 43619)
@@ -310,7 +310,7 @@
 		MEM_freeN(me->edit_btmesh);
 	}
 
-	me->edit_btmesh = BMEdit_Create(bm);
+	me->edit_btmesh = BMEdit_Create(bm, TRUE);
 	me->edit_btmesh->selectmode= me->edit_btmesh->bm->selectmode= ts->selectmode;
 	me->edit_btmesh->me = me;
 	me->edit_btmesh->ob = ob;
@@ -589,7 +589,7 @@
 	bm = BM_Make_Mesh(ob, allocsize);
 	BMO_CallOpf(bm, "mesh_to_bmesh mesh=%p object=%p set_shapekey=%i", me, ob, 0);
 
-	em2 = BMEdit_Create(bm);
+	em2 = BMEdit_Create(bm, TRUE);
 	*em = *em2;
 	
 	em->selectmode = me->selectmode;

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c	2012-01-22 20:25:25 UTC (rev 43618)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c	2012-01-22 21:12:18 UTC (rev 43619)
@@ -208,7 +208,7 @@
 										  int UNUSED(initFlags))
 {
 	DerivedMesh *cddm = dm; //copying shouldn't be necassary here, as all modifiers return CDDM's
-	BMEditMesh *em = CDDM_To_BMesh(ob, cddm, NULL);
+	BMEditMesh *em = CDDM_To_BMesh(ob, cddm, NULL, FALSE);
 	BMOperator op, oldop, weldop;
 	int i, j, indexLen;
 	/* offset matrix */
@@ -385,10 +385,9 @@
 	BMO_Finish_Op(em->bm, &weldop);
 
 	/* Bump the stack level back down to match the adjustment up above */
-	bmesh_end_edit(em->bm, 0);
 	BMO_pop(em->bm);
 
-	BMEdit_RecalcTesselation(em);
+	BLI_assert(em->looptris == NULL);
 	cddm = CDDM_from_BMEditMesh(em, NULL, FALSE, FALSE);
 
 	BMEdit_Free(em);

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_bevel.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_bevel.c	2012-01-22 20:25:25 UTC (rev 43618)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_bevel.c	2012-01-22 21:12:18 UTC (rev 43619)
@@ -123,7 +123,7 @@
 		cddm = CDDM_copy(dm, 0);
 	} else cddm = dm;
 
-	em = CDDM_To_BMesh(ob, dm, NULL);
+	em = CDDM_To_BMesh(ob, dm, NULL, FALSE);
 	bm = em->bm;
 
 	BM_Compute_Normals(bm);
@@ -152,13 +152,13 @@
 	BMO_CallOpf(bm, "bevel geom=%fe percent=%f use_even=%i use_dist=%i",
 	            EDGE_MARK, bmd->value, (bmd->flags & BME_BEVEL_EVEN)!=0, (bmd->flags & BME_BEVEL_DIST)!=0);
 	BMO_pop(bm);
-	BMEdit_RecalcTesselation(em);
 
 	if (cddm != dm) {
 		cddm->needsFree = 1;
 		cddm->release(cddm);
 	}
 
+	BLI_assert(em->looptris == NULL);
 	cddm = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
 	BMEdit_Free(em);
 	MEM_freeN(em);

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c	2012-01-22 20:25:25 UTC (rev 43618)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c	2012-01-22 21:12:18 UTC (rev 43619)
@@ -71,7 +71,7 @@
 		cddm = CDDM_copy(dm, 0);
 	} else cddm = dm;
 	
-	em = CDDM_To_BMesh(ob, dm, NULL);
+	em = CDDM_To_BMesh(ob, dm, NULL, FALSE);
 	bm = em->bm;
 
 	BM_Compute_Normals(bm);	
@@ -101,13 +101,13 @@
 	BMO_CallOpf(bm, "edgesplit edges=%fe", EDGE_MARK);
 	
 	BMO_pop(bm);
-	BMEdit_RecalcTesselation(em);
 	
 	if (cddm != dm) {
 		cddm->needsFree = 1;
 		cddm->release(cddm);
 	}
-	
+
+	BLI_assert(em->looptris == NULL);
 	cddm = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
 	BMEdit_Free(em);
 	MEM_freeN(em);



More information about the Bf-blender-cvs mailing list