[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45132] trunk/blender/source/blender/ editors/mesh/mesh_data.c: fix for error adding vertex colors in editmode.

Campbell Barton ideasman42 at gmail.com
Sat Mar 24 12:02:41 CET 2012


Revision: 45132
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45132
Author:   campbellbarton
Date:     2012-03-24 11:02:28 +0000 (Sat, 24 Mar 2012)
Log Message:
-----------
fix for error adding vertex colors in editmode.

also correct delete_customdata_layer having invalid 'tot' in editmode, seems harmless for now but better assign correct value.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/mesh/mesh_data.c

Modified: trunk/blender/source/blender/editors/mesh/mesh_data.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/mesh_data.c	2012-03-24 10:41:42 UTC (rev 45131)
+++ trunk/blender/source/blender/editors/mesh/mesh_data.c	2012-03-24 11:02:28 UTC (rev 45132)
@@ -83,14 +83,26 @@
 	int type= layer->type;
 	int index;
 	int i, actindex, rndindex, cloneindex, stencilindex, tot;
-	
+
 	if (layer->type == CD_MLOOPCOL || layer->type == CD_MLOOPUV) {
-		data = (me->edit_btmesh)? &me->edit_btmesh->bm->ldata: &me->ldata;
-		tot = me->totloop;
+		if (me->edit_btmesh) {
+			data = &me->edit_btmesh->bm->ldata;
+			tot = me->edit_btmesh->bm->totloop;
+		}
+		else {
+			data = &me->ldata;
+			tot = me->totloop;
+		}
 	}
 	else {
-		data = (me->edit_btmesh)? &me->edit_btmesh->bm->pdata: &me->pdata;
-		tot = me->totpoly;
+		if (me->edit_btmesh) {
+			data = &me->edit_btmesh->bm->pdata;
+			tot = me->edit_btmesh->bm->totface;
+		}
+		else {
+			data = &me->pdata;
+			tot = me->totpoly;
+		}
 	}
 	
 	index = CustomData_get_layer_index(data, type);
@@ -405,12 +417,12 @@
 			return -1;
 		}
 
-		BM_data_layer_add(em->bm, &em->bm->pdata, CD_MLOOPCOL);
+		BM_data_layer_add(em->bm, &em->bm->ldata, CD_MLOOPCOL);
 		CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPCOL, layernum);
 
 		/* copy data from active vertex color layer */
 		if (layernum) {
-			copy_editface_active_customdata(em, CD_MCOL, layernum);
+			copy_editface_active_customdata(em, CD_MLOOPCOL, layernum);
 		}
 
 		if (active_set || layernum == 0) {




More information about the Bf-blender-cvs mailing list