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:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-04-27 12:35:03 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-04-27 12:35:03 +0400
commitda9d559f367684f3bf41de0c372e74f2b1444aca (patch)
tree3c843640a665dea4af7c1a26e394aab4a159268f
parentbc6828426d73750eabc4a93621579566d2b73007 (diff)
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.
-rw-r--r--source/blender/editors/mesh/mesh_data.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index b6940e8f8f9..f3e26cfee36 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -163,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;
@@ -176,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);
}
@@ -234,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);
}