[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45710] trunk/blender/source/blender/ blenkernel/intern: Fix crash with texture draw in edit mode after commit 45672.

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Apr 17 13:02:33 CEST 2012


Revision: 45710
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45710
Author:   blendix
Date:     2012-04-17 11:02:32 +0000 (Tue, 17 Apr 2012)
Log Message:
-----------
Fix crash with texture draw in edit mode after commit 45672.

Don't create empty tesselated faces layers in edit derivedmesh, these are
being created on the fly so this will conflicted, and use loop data for
opengl attributes for edit derivedmesh drawing.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
    trunk/blender/source/blender/blenkernel/intern/editderivedmesh.c

Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c	2012-04-17 10:25:23 UTC (rev 45709)
+++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c	2012-04-17 11:02:32 UTC (rev 45710)
@@ -2757,7 +2757,7 @@
 	fdata = tfdata = dm->getTessFaceDataLayout(dm);
 	
 	/* calc auto bump scale if necessary */
-	if (dm->auto_bump_scale<=0.0f)
+	if (dm->auto_bump_scale <= 0.0f)
 		DM_calc_auto_bump_scale(dm);
 
 	/* add a tangent layer if necessary */
@@ -2769,59 +2769,77 @@
 	for (b = 0; b < gattribs->totlayer; b++) {
 		if (gattribs->layer[b].type == CD_MTFACE) {
 			/* uv coordinates */
-			if (gattribs->layer[b].name[0])
-				layer = CustomData_get_named_layer_index(tfdata, CD_MTFACE,
-					gattribs->layer[b].name);
-			else
-				layer = CustomData_get_active_layer_index(tfdata, CD_MTFACE);
+			if(dm->type == DM_TYPE_EDITBMESH) {
+				/* exception .. */
+				CustomData *ldata = dm->getLoopDataLayout(dm);
 
-			if (layer != -1) {
-				a = attribs->tottface++;
+				if (gattribs->layer[b].name[0])
+					layer = CustomData_get_named_layer_index(ldata, CD_MLOOPUV,
+						gattribs->layer[b].name);
+				else
+					layer = CustomData_get_active_layer_index(ldata, CD_MLOOPUV);
 
-				attribs->tface[a].array = tfdata->layers[layer].data;
-				attribs->tface[a].emOffset = tfdata->layers[layer].offset;
-				attribs->tface[a].glIndex = gattribs->layer[b].glindex;
-				attribs->tface[a].glTexco = gattribs->layer[b].gltexco;
+				if (layer != -1) {
+					a = attribs->tottface++;
+
+					attribs->tface[a].array = tfdata->layers[layer].data;
+					attribs->tface[a].emOffset = tfdata->layers[layer].offset;
+					attribs->tface[a].glIndex = gattribs->layer[b].glindex;
+					attribs->tface[a].glTexco = gattribs->layer[b].gltexco;
+				}
 			}
-			/* BMESH_TODO - BMESH ONLY, may need to get this working?, otherwise remove */
-#if 0
 			else {
-				int player;
-				CustomData *pdata = dm->getPolyDataLayout(dm);
-				
 				if (gattribs->layer[b].name[0])
-					player = CustomData_get_named_layer_index(pdata, CD_MTEXPOLY,
+					layer = CustomData_get_named_layer_index(tfdata, CD_MTFACE,
 						gattribs->layer[b].name);
 				else
-					player = CustomData_get_active_layer_index(pdata, CD_MTEXPOLY);
-				
-				if (player != -1) {
+					layer = CustomData_get_active_layer_index(tfdata, CD_MTFACE);
+
+				if (layer != -1) {
 					a = attribs->tottface++;
-	
-					attribs->tface[a].array = NULL;
-					attribs->tface[a].emOffset = pdata->layers[layer].offset;
+
+					attribs->tface[a].array = tfdata->layers[layer].data;
+					attribs->tface[a].emOffset = tfdata->layers[layer].offset;
 					attribs->tface[a].glIndex = gattribs->layer[b].glindex;
 					attribs->tface[a].glTexco = gattribs->layer[b].gltexco;
-					
 				}
 			}
-#endif
 		}
 		else if (gattribs->layer[b].type == CD_MCOL) {
-			/* vertex colors */
-			if (gattribs->layer[b].name[0])
-				layer = CustomData_get_named_layer_index(tfdata, CD_MCOL,
-					gattribs->layer[b].name);
-			else
-				layer = CustomData_get_active_layer_index(tfdata, CD_MCOL);
+			if(dm->type == DM_TYPE_EDITBMESH) {
+				/* exception .. */
+				CustomData *ldata = dm->getLoopDataLayout(dm);
 
-			if (layer != -1) {
-				a = attribs->totmcol++;
+				if (gattribs->layer[b].name[0])
+					layer = CustomData_get_named_layer_index(ldata, CD_MLOOPCOL,
+						gattribs->layer[b].name);
+				else
+					layer = CustomData_get_active_layer_index(ldata, CD_MLOOPCOL);
 
-				attribs->mcol[a].array = tfdata->layers[layer].data;
-				attribs->mcol[a].emOffset = tfdata->layers[layer].offset;
-				attribs->mcol[a].glIndex = gattribs->layer[b].glindex;
+				if (layer != -1) {
+					a = attribs->totmcol++;
+
+					attribs->mcol[a].array = tfdata->layers[layer].data;
+					attribs->mcol[a].emOffset = tfdata->layers[layer].offset;
+					attribs->mcol[a].glIndex = gattribs->layer[b].glindex;
+				}
 			}
+			else {
+				/* vertex colors */
+				if (gattribs->layer[b].name[0])
+					layer = CustomData_get_named_layer_index(tfdata, CD_MCOL,
+						gattribs->layer[b].name);
+				else
+					layer = CustomData_get_active_layer_index(tfdata, CD_MCOL);
+
+				if (layer != -1) {
+					a = attribs->totmcol++;
+
+					attribs->mcol[a].array = tfdata->layers[layer].data;
+					attribs->mcol[a].emOffset = tfdata->layers[layer].offset;
+					attribs->mcol[a].glIndex = gattribs->layer[b].glindex;
+				}
+			}
 		}
 		else if (gattribs->layer[b].type == CD_TANGENT) {
 			/* tangents */

Modified: trunk/blender/source/blender/blenkernel/intern/editderivedmesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/editderivedmesh.c	2012-04-17 10:25:23 UTC (rev 45709)
+++ trunk/blender/source/blender/blenkernel/intern/editderivedmesh.c	2012-04-17 11:02:32 UTC (rev 45710)
@@ -1628,8 +1628,6 @@
 	DM_init((DerivedMesh*)bmdm, DM_TYPE_EDITBMESH, em->bm->totvert,
 		 em->bm->totedge, em->tottri, em->bm->totloop, em->bm->totface);
 
-	CustomData_from_bmeshpoly(&bmdm->dm.faceData, &em->bm->pdata, &em->bm->ldata, 0);
-
 	bmdm->dm.getVertCos = emDM_getVertCos;
 	bmdm->dm.getMinMax = emDM_getMinMax;
 




More information about the Bf-blender-cvs mailing list