[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43494] branches/bmesh/blender/source/ blender: argument for CDDM_from_BMEditMesh() so creating tessface data is optional, no functional changes since all callers use this so far.

Campbell Barton ideasman42 at gmail.com
Wed Jan 18 16:09:28 CET 2012


Revision: 43494
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43494
Author:   campbellbarton
Date:     2012-01-18 15:09:27 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------
argument for CDDM_from_BMEditMesh() so creating tessface data is optional, no functional changes since all callers use this so far.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h
    branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
    branches/bmesh/blender/source/blender/blenkernel/intern/armature.c
    branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/bmesh/blender/source/blender/blenkernel/intern/constraint.c
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_armature.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_curve.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_lattice.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_util.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_warp.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_weightvgproximity.c

Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h	2012-01-18 15:08:37 UTC (rev 43493)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h	2012-01-18 15:09:27 UTC (rev 43494)
@@ -57,7 +57,7 @@
 struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh, struct Object *ob);
 
 /* creates a CDDerivedMesh from the given BMEditMesh */
-DerivedMesh *CDDM_from_BMEditMesh(struct BMEditMesh *em, struct Mesh *me, int use_mdisps);
+DerivedMesh *CDDM_from_BMEditMesh(struct BMEditMesh *em, struct Mesh *me, int use_mdisps, int use_tessface);
 
 /* merge verts  */
 DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap);

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c	2012-01-18 15:08:37 UTC (rev 43493)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c	2012-01-18 15:09:27 UTC (rev 43494)
@@ -807,7 +807,7 @@
 	float (*orco)[3];
 	int free;
 
-	if(em) dm= CDDM_from_BMEditMesh(em, me, 0);
+	if(em) dm= CDDM_from_BMEditMesh(em, me, FALSE, TRUE);
 	else dm= CDDM_from_mesh(me, ob);
 
 	orco= get_orco_coords_dm(ob, em, layer, &free);
@@ -1680,7 +1680,7 @@
 				}
 
 			} else {
-				dm = CDDM_from_BMEditMesh(em, ob->data, 0);
+				dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, TRUE);
 
 				if(deformedVerts) {
 					CDDM_apply_vert_coords(dm, deformedVerts);

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/armature.c	2012-01-18 15:08:37 UTC (rev 43493)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/armature.c	2012-01-18 15:09:27 UTC (rev 43494)
@@ -945,7 +945,6 @@
 			else dvert = NULL;
 		} else
 			dvert = NULL;
-
 		if(armature_def_nr >= 0 && dvert) {
 			armature_weight= defvert_find_weight(dvert, armature_def_nr);
 

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c	2012-01-18 15:08:37 UTC (rev 43493)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c	2012-01-18 15:09:27 UTC (rev 43494)
@@ -1963,7 +1963,7 @@
 	}
 }
 
-DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdisps)
+DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdisps, int use_tessface)
 {
 	DerivedMesh *dm = CDDM_new(em->bm->totvert, em->bm->totedge, 
 	                       em->tottri, em->bm->totloop, em->bm->totface);
@@ -1980,7 +1980,7 @@
 	MPoly *mpoly = cddm->mpoly;
 	int numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL);
 	int numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
-	int *index, *polyindex, add_orig;
+	int *index, add_orig;
 	int has_crease, has_edge_bweight, has_vert_bweight;
 	CustomDataMask mask;
 	unsigned int i, j;
@@ -2009,7 +2009,9 @@
 	                 CD_CALLOC, dm->numPolyData);
 	
 	/*add tesselation mface layers*/
-	CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em->tottri);
+	if (use_tessface) {
+		CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em->tottri);
+	}
 
 	index = dm->getVertDataArray(dm, CD_ORIGINDEX);
 
@@ -2056,27 +2058,32 @@
 	}
 	bm->elem_index_dirty &= ~BM_EDGE;
 
-	BM_ElemIndex_Ensure(bm, BM_FACE);
+	/* avoid this where possiblem, takes extra memory */
+	if (use_tessface) {
+		int *polyindex;
 
-	polyindex = dm->getTessFaceDataArray(dm, CD_POLYINDEX);
-	index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
-	for(i = 0; i < dm->numTessFaceData; i++, index++, polyindex++) {
-		MFace *mf = &mface[i];
-		BMLoop **l = em->looptris[i];
-		efa = l[0]->f;
+		BM_ElemIndex_Ensure(bm, BM_FACE);
 
-		mf->v1 = BM_GetIndex(l[0]->v);
-		mf->v2 = BM_GetIndex(l[1]->v);
-		mf->v3 = BM_GetIndex(l[2]->v);
-		mf->v4 = 0;
-		mf->mat_nr = efa->mat_nr;
-		mf->flag = BM_Face_Flag_To_MEFlag(efa);
-		
-		*index = add_orig ? BM_GetIndex(efa) : *(int*)CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_ORIGINDEX);
-		*polyindex = BM_GetIndex(efa);
+		polyindex = dm->getTessFaceDataArray(dm, CD_POLYINDEX);
+		index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+		for(i = 0; i < dm->numTessFaceData; i++, index++, polyindex++) {
+			MFace *mf = &mface[i];
+			BMLoop **l = em->looptris[i];
+			efa = l[0]->f;
 
-		loops_to_customdata_corners(bm, &dm->faceData, i, l, numCol, numTex);
-		test_index_face(mf, &dm->faceData, i, 3);
+			mf->v1 = BM_GetIndex(l[0]->v);
+			mf->v2 = BM_GetIndex(l[1]->v);
+			mf->v3 = BM_GetIndex(l[2]->v);
+			mf->v4 = 0;
+			mf->mat_nr = efa->mat_nr;
+			mf->flag = BM_Face_Flag_To_MEFlag(efa);
+
+			*index = add_orig ? BM_GetIndex(efa) : *(int*)CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_ORIGINDEX);
+			*polyindex = BM_GetIndex(efa);
+
+			loops_to_customdata_corners(bm, &dm->faceData, i, l, numCol, numTex);
+			test_index_face(mf, &dm->faceData, i, 3);
+		}
 	}
 	
 	index = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX);
@@ -2086,6 +2093,8 @@
 		BMLoop *l;
 		MPoly *mp = &mpoly[i];
 
+		BM_SetIndex(efa, i); /* set_inline */
+
 		mp->totloop = efa->len;
 		mp->flag = BM_Face_Flag_To_MEFlag(efa);
 		mp->loopstart = j;
@@ -2104,6 +2113,7 @@
 
 		if (add_orig) *index = i;
 	}
+	bm->elem_index_dirty &= ~BM_FACE;
 
 	return dm;
 }

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/constraint.c	2012-01-18 15:08:37 UTC (rev 43493)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/constraint.c	2012-01-18 15:09:27 UTC (rev 43494)
@@ -454,7 +454,7 @@
 	/* get DerivedMesh */
 	if (em) {
 		/* target is in editmode, so get a special derived mesh */
-		dm = CDDM_from_BMEditMesh(em, ob->data, 0);
+		dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, TRUE);
 		freeDM= 1;
 	}
 	else {

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c	2012-01-18 15:08:37 UTC (rev 43493)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c	2012-01-18 15:09:27 UTC (rev 43494)
@@ -375,7 +375,7 @@
 	if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
 		Object *ob = bm->ob;
 		BMEditMesh *em = BMEdit_Create(bm);
-		DerivedMesh *dm = CDDM_from_BMEditMesh(em, NULL, 1);
+		DerivedMesh *dm = CDDM_from_BMEditMesh(em, NULL, TRUE, TRUE);
 		MDisps *mdisps;
 		BMFace *f;
 		BMIter iter;

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c	2012-01-18 15:08:37 UTC (rev 43493)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c	2012-01-18 15:09:27 UTC (rev 43494)
@@ -159,7 +159,7 @@
 	"edgerotate",
 	{{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, //input edges
 	 {BMOP_OPSLOT_ELEMENT_BUF, "edgeout"}, //newly spun edges
-   	 {BMOP_OPSLOT_INT, "ccw"}, //rotate edge counter-clockwise if true, othewise clockwise
+	 {BMOP_OPSLOT_INT, "ccw"}, //rotate edge counter-clockwise if true, othewise clockwise
 	{0} /*null-terminating sentinel*/,
 	},
 	bmesh_edgerotate_exec,

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_armature.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_armature.c	2012-01-18 15:08:37 UTC (rev 43493)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_armature.c	2012-01-18 15:09:27 UTC (rev 43494)
@@ -142,7 +142,7 @@
 	ArmatureModifierData *amd = (ArmatureModifierData*) md;
 	DerivedMesh *dm = derivedData;
 
-	if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, 0);
+	if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, TRUE);
 
 	modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
 
@@ -166,7 +166,7 @@
 	ArmatureModifierData *amd = (ArmatureModifierData*) md;
 	DerivedMesh *dm = derivedData;
 
-	if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, 0);
+	if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, TRUE);
 
 	armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts,
 	                      amd->deformflag, NULL, amd->defgrp_name);

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c	2012-01-18 15:08:37 UTC (rev 43493)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c	2012-01-18 15:09:27 UTC (rev 43494)
@@ -389,7 +389,7 @@
 	BMO_pop(em->bm);
 
 	BMEdit_RecalcTesselation(em);
-	cddm = CDDM_from_BMEditMesh(em, NULL, 0);
+	cddm = CDDM_from_BMEditMesh(em, NULL, FALSE, TRUE);
 
 	BMEdit_Free(em);
 	MEM_freeN(em);

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_bevel.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_bevel.c	2012-01-18 15:08:37 UTC (rev 43493)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_bevel.c	2012-01-18 15:09:27 UTC (rev 43494)
@@ -159,7 +159,7 @@
 		cddm->release(cddm);
 	}
 
-	cddm = CDDM_from_BMEditMesh(em, NULL, 1);
+	cddm = CDDM_from_BMEditMesh(em, NULL, TRUE, TRUE);
 	BMEdit_Free(em);
 	MEM_freeN(em);
 

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_curve.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_curve.c	2012-01-18 15:08:37 UTC (rev 43493)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_curve.c	2012-01-18 15:09:27 UTC (rev 43494)
@@ -129,7 +129,7 @@
 {
 	DerivedMesh *dm = derivedData;
 
-	if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, 0);

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list