[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36350] trunk/blender/source/blender/ editors/mesh/mesh_data.c: Fix #27176: Creating a new UV layer in edit mode fails to copy previous one

Sergey Sharybin g.ulairi at gmail.com
Wed Apr 27 10:35:03 CEST 2011


Revision: 36350
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36350
Author:   nazgul
Date:     2011-04-27 08:35:03 +0000 (Wed, 27 Apr 2011)
Log Message:
-----------
Fix #27176: Creating a new UV layer in edit mode fails to copy previous one

Implemented copying data from active MTFACE layer to newly created.
Also, fixed the same bug with vertex colors layer.

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	2011-04-27 08:32:20 UTC (rev 36349)
+++ trunk/blender/source/blender/editors/mesh/mesh_data.c	2011-04-27 08:35:03 UTC (rev 36350)
@@ -163,6 +163,17 @@
 	}
 }
 
+static void copy_editface_active_customdata(EditMesh *em, int type, int index)
+{
+	EditFace *efa;
+	int n= CustomData_get_active_layer(&em->fdata, type);
+
+	for(efa= em->faces.first; efa; efa= efa->next) {
+		void *data= CustomData_em_get_n(&em->fdata, efa->data, type, n);
+		CustomData_em_set_n(&em->fdata, efa->data, type, index, data);
+	}
+}
+
 int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_set)
 {
 	EditMesh *em;
@@ -176,6 +187,10 @@
 			return 0;
 
 		EM_add_data_layer(em, &em->fdata, CD_MTFACE, name);
+
+		if(layernum) /* copy data from active UV */
+			copy_editface_active_customdata(em, CD_MTFACE, layernum);
+
 		if(active_set || layernum==0)
 			CustomData_set_layer_active(&em->fdata, CD_MTFACE, layernum);
 	}
@@ -234,6 +249,10 @@
 			return 0;
 
 		EM_add_data_layer(em, &em->fdata, CD_MCOL, name);
+
+		if(layernum) /* copy data from active vertex color layer */
+			copy_editface_active_customdata(em, CD_MCOL, layernum);
+
 		if(active_set || layernum==0)
 			CustomData_set_layer_active(&em->fdata, CD_MCOL, layernum);
 	}




More information about the Bf-blender-cvs mailing list