[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43539] branches/bmesh/blender/source/ blender: ensure defoem DM has tessface data for the few places that need it .

Campbell Barton ideasman42 at gmail.com
Thu Jan 19 20:23:25 CET 2012


Revision: 43539
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43539
Author:   campbellbarton
Date:     2012-01-19 19:23:25 +0000 (Thu, 19 Jan 2012)
Log Message:
-----------
ensure defoem DM has tessface data for the few places that need it.

also add a workaround for CDDM_recalc_tesselation_ex() which would add a CD_NORMAL to dm->fdata and then overwrite immediate

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h
    branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/bmesh/blender/source/blender/editors/physics/particle_edit.c
    branches/bmesh/blender/source/blender/editors/physics/particle_object.c

Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h	2012-01-19 19:09:59 UTC (rev 43538)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h	2012-01-19 19:23:25 UTC (rev 43539)
@@ -115,6 +115,7 @@
 
 /* reconstitute face triangulation */
 void CDDM_recalc_tesselation(struct DerivedMesh *dm);
+void CDDM_recalc_tesselation_ex(struct DerivedMesh *dm, const int do_face_nor_cpy);
 
 /* lowers the number of vertices/edges/faces in a CDDerivedMesh
  * the layer data stays the same size

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c	2012-01-19 19:09:59 UTC (rev 43538)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c	2012-01-19 19:23:25 UTC (rev 43539)
@@ -1578,14 +1578,14 @@
 
 }
 
-void CDDM_recalc_tesselation(DerivedMesh *dm)
+void CDDM_recalc_tesselation_ex(DerivedMesh *dm, const int do_face_nor_cpy)
 {
 	CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
 
 	dm->numTessFaceData = mesh_recalcTesselation(&dm->faceData, &dm->loopData, &dm->polyData,
 	                                             cddm->mvert,
 	                                             dm->numTessFaceData, dm->numLoopData, dm->numPolyData,
-	                                             TRUE);
+	                                             do_face_nor_cpy);
 
 	if (!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX)) {
 		int *polyIndex = CustomData_get_layer(&dm->faceData, CD_POLYINDEX);
@@ -1599,6 +1599,11 @@
 	CustomData_bmesh_update_active_layers(&dm->faceData, &dm->polyData, &dm->loopData);
 }
 
+void CDDM_recalc_tesselation(DerivedMesh *dm)
+{
+	CDDM_recalc_tesselation_ex(dm, TRUE);
+}
+
 static void cdDM_free_internal(CDDerivedMesh *cddm)
 {
 	if(cddm->fmap) MEM_freeN(cddm->fmap);
@@ -2160,10 +2165,13 @@
 	cddm->mloop = CustomData_get_layer(&dm->loopData, CD_MLOOP);
 	cddm->mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY);
 
+	/* any callers that need tessface data can calculate it - campbell */
+#if 0
 	/* BMESH_TODO: Find out why this is necessary (or else find a way to remove
 	   it). If it is necessary, add a comment explaining why. */
 	CDDM_recalc_tesselation((DerivedMesh *)cddm);
-	
+#endif
+
 	return dm;
 }
 
@@ -2258,8 +2266,12 @@
 
 
 	if (dm->numTessFaceData == 0) {
-		/* No tesselation on this mesh yet, need to calculate one */
-		CDDM_recalc_tesselation(dm);
+		/* No tesselation on this mesh yet, need to calculate one.
+		 *
+		 * Important not to update face normals from polys since it
+		 * interfears with assigning the new normal layer in the following code.
+		 */
+		CDDM_recalc_tesselation_ex(dm, FALSE);
 	}
 	else {
 		/* A tesselation already exists, it should always have a CD_POLYINDEX */

Modified: branches/bmesh/blender/source/blender/editors/physics/particle_edit.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/physics/particle_edit.c	2012-01-19 19:09:59 UTC (rev 43538)
+++ branches/bmesh/blender/source/blender/editors/physics/particle_edit.c	2012-01-19 19:23:25 UTC (rev 43539)
@@ -3067,6 +3067,8 @@
 			return 0;
 	}
 
+	/* BMESH_ONLY, deform dm may not have tessface */
+	DM_ensure_tessface(dm);
 	
 
 	if(pa_minmax==0){

Modified: branches/bmesh/blender/source/blender/editors/physics/particle_object.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/physics/particle_object.c	2012-01-19 19:09:59 UTC (rev 43538)
+++ branches/bmesh/blender/source/blender/editors/physics/particle_object.c	2012-01-19 19:23:25 UTC (rev 43539)
@@ -649,6 +649,10 @@
 	else
 		dm= mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
 
+	/* BMESH_ONLY, deform dm may not have tessface */
+	DM_ensure_tessface(dm);
+
+
 	numverts = dm->getNumVerts (dm);
 
 	/* convert to global coordinates */



More information about the Bf-blender-cvs mailing list