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:
authorDalai Felinto <dfelinto@gmail.com>2010-08-27 04:35:59 +0400
committerDalai Felinto <dfelinto@gmail.com>2010-08-27 04:35:59 +0400
commitc15c223ccdc7d28ae9dd240cfcb4a953f453b1fe (patch)
tree5edf66511f40c286577ac4466635d8c70fdb2983
parent240b164a87517ad616ff500cbf16ba901e2ea461 (diff)
Fix for Mesh.uv_textures.new(name="my_uv") returning the wrong uvmap - reported by Vitor Balbio - not in tracker.
The code was taking the last layer, but that is only valid if the mesh has only one kind of CustomData types (e.g. only UVMaps or only VertexColors). The solution I found is to call CustomData_get_named_layer_index instead. To avoid some situations where an uv with this name may already exist and the number of UVs is already the limit we are returning a CDL only when the texture is properly created. As a bonus that also fixes the same problem with VertexColor.
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 659e08a1878..741b5cbab81 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -1067,26 +1067,28 @@ static int rna_Mesh_tot_face_get(PointerRNA *ptr)
static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, char *name)
{
CustomData *fdata;
- CustomDataLayer *cdl;
+ CustomDataLayer *cdl= NULL;
int index;
- ED_mesh_color_add(C, NULL, NULL, me, name, FALSE);
- fdata= rna_mesh_fdata(me);
- index= CustomData_number_of_layers(fdata, CD_MCOL) - 1;
- cdl= (index == -1)? NULL: &fdata->layers[index];
+ if(ED_mesh_color_add(C, NULL, NULL, me, name, FALSE)) {
+ fdata= rna_mesh_fdata(me);
+ index= CustomData_get_named_layer_index(fdata, CD_MCOL, name);
+ cdl= (index == -1)? NULL: &fdata->layers[index];
+ }
return cdl;
}
static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, char *name)
{
CustomData *fdata;
- CustomDataLayer *cdl;
+ CustomDataLayer *cdl= NULL;
int index;
- ED_mesh_uv_texture_add(C, NULL, NULL, me, name, FALSE);
- fdata= rna_mesh_fdata(me);
- index= CustomData_number_of_layers(fdata, CD_MTFACE) - 1;
- cdl= (index == -1)? NULL: &fdata->layers[index];
+ if(ED_mesh_uv_texture_add(C, NULL, NULL, me, name, FALSE)) {
+ fdata= rna_mesh_fdata(me);
+ index= CustomData_get_named_layer_index(fdata, CD_MTFACE, name);
+ cdl= (index == -1)? NULL: &fdata->layers[index];
+ }
return cdl;
}