Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r--source/blender/editors/mesh/mesh_data.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index cfd1b006ece..f3e26cfee36 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -26,6 +26,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/editors/mesh/mesh_data.c
+ * \ingroup edmesh
+ */
+
+
#include <math.h>
#include <stdlib.h>
#include <string.h>
@@ -158,6 +163,17 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
}
}
+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;
@@ -171,6 +187,10 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s
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);
}
@@ -229,6 +249,10 @@ int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const cha
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);
}