[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43163] branches/bmesh/blender/source/ blender: added a function to ensure derived mesh has tessface's, in preparation for removal of tessface recalculation after each modifier runs .

Campbell Barton ideasman42 at gmail.com
Thu Jan 5 13:40:17 CET 2012


Revision: 43163
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43163
Author:   campbellbarton
Date:     2012-01-05 12:40:09 +0000 (Thu, 05 Jan 2012)
Log Message:
-----------
added a function to ensure derived mesh has tessface's, in preparation for removal of tessface recalculation after each modifier runs.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenkernel/BKE_DerivedMesh.h
    branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_boolean.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_decimate.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_explode.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_particleinstance.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_remesh.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_solidify.c

Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_DerivedMesh.h	2012-01-05 11:23:24 UTC (rev 43162)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_DerivedMesh.h	2012-01-05 12:40:09 UTC (rev 43163)
@@ -517,6 +517,8 @@
 /*sets up mpolys for a DM based on face iterators in source*/
 void DM_DupPolys(DerivedMesh *source, DerivedMesh *target);
 
+void DM_ensure_tessface(DerivedMesh *dm);
+
 /* interpolates vertex data from the vertices indexed by src_indices in the
  * source mesh using the given weights and stores the result in the vertex
  * indexed by dest_index in the dest mesh

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c	2012-01-05 11:23:24 UTC (rev 43162)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c	2012-01-05 12:40:09 UTC (rev 43163)
@@ -352,6 +352,26 @@
 	}
 }
 
+/* note: until all modifiers can take MPoly's as input,
+ * use this at the start of modifiers  */
+void DM_ensure_tessface(DerivedMesh *dm)
+{
+	const int numTessFaces = dm->getNumTessFaces(dm);
+	const int numPolys =     dm->getNumPolys(dm);
+
+	if ( (numTessFaces == 0) && (numPolys != 0)) {
+		dm->recalcTesselation(dm);
+
+		if (dm->getNumTessFaces(dm)) {
+			printf("warning %s: could not create tessfaces from %d polygons, dm->type=%d\n",
+			       __func__, numPolys, dm->type);
+		}
+		else {
+			printf("info %s: polys -> ngons calculated\n", __func__);
+		}
+	}
+}
+
 void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
 {
 	/* dm might depend on me, so we need to do everything with a local copy */

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_boolean.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_boolean.c	2012-01-05 11:23:24 UTC (rev 43162)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_boolean.c	2012-01-05 12:40:09 UTC (rev 43163)
@@ -137,6 +137,10 @@
 		result = get_quick_derivedMesh(derivedData, dm, bmd->operation);
 
 		if(result == NULL) {
+
+			DM_ensure_tessface(dm);          /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
+			DM_ensure_tessface(derivedData); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
+
 			result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob,
 					1 + bmd->operation);
 		}

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_decimate.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_decimate.c	2012-01-05 11:23:24 UTC (rev 43162)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_decimate.c	2012-01-05 12:40:09 UTC (rev 43163)
@@ -81,6 +81,8 @@
 	int totvert, totface;
 	int a, numTris;
 
+	DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
+
 	mvert = dm->getVertArray(dm);
 	mface = dm->getTessFaceArray(dm);
 	totvert = dm->getNumVerts(dm);

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_explode.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_explode.c	2012-01-05 11:23:24 UTC (rev 43162)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_explode.c	2012-01-05 12:40:09 UTC (rev 43163)
@@ -983,6 +983,8 @@
 	ExplodeModifierData *emd= (ExplodeModifierData*) md;
 	ParticleSystemModifierData *psmd=findPrecedingParticlesystem(ob,md);
 
+	DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
+
 	if(psmd){
 		ParticleSystem * psys=psmd->psys;
 

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_particleinstance.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_particleinstance.c	2012-01-05 11:23:24 UTC (rev 43162)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_particleinstance.c	2012-01-05 12:40:09 UTC (rev 43163)
@@ -122,6 +122,8 @@
 	float max_co=0.0, min_co=0.0, temp_co[3], cross[3];
 	float *size=NULL;
 
+	DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
+
 	trackneg=((ob->trackflag>2)?1:0);
 
 	if(pimd->ob==ob){

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_remesh.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_remesh.c	2012-01-05 11:23:24 UTC (rev 43162)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_remesh.c	2012-01-05 12:40:09 UTC (rev 43163)
@@ -151,6 +151,8 @@
 	DualConFlags flags = 0;
 	DualConMode mode = 0;
 
+	DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
+
 	rmd = (RemeshModifierData*)md;
 
 	init_dualcon_mesh(&input, dm);

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_solidify.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_solidify.c	2012-01-05 11:23:24 UTC (rev 43162)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_solidify.c	2012-01-05 12:40:09 UTC (rev 43163)
@@ -725,6 +725,7 @@
 	
 	/* must recalculate normals with vgroups since they can displace unevenly [#26888] */
 	if(dvert) {
+		/* BMESH_TODO, we only need to get vertex normals here, this is way overkill */
 		CDDM_calc_normals(result);
 	}
 	else {



More information about the Bf-blender-cvs mailing list