diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-24 02:16:45 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-24 02:16:45 +0400 |
commit | f6c323aa42e94c4750f52940b47a0d57b503c1b9 (patch) | |
tree | 486b03bf59d3e022443c8e290f354265d0126578 /source/blender/editors/mesh/mesh_data.c | |
parent | 1be4eda552aa97aa5f5fe43fd34196c57425a7c2 (diff) |
- move more active properties into their collections:
scene.active_keying_set --> scene.keying_sets.active
...same for active_uv_texture. active_vertex_color, active_keyconfig,
- move mesh.add_uv_layer() and mesh.add_vertex_color() into their collections
also have them return the newly created layer and dont set the layer active.
uvtex = mesh.uv_layers.new(name)
vcol = mesh.vertex_colors.new(name)
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 2d337558f56..edcdedf2a39 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -157,7 +157,7 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la } } -int ED_mesh_uv_texture_add(bContext *C, Scene *scene, Object *ob, Mesh *me) +int ED_mesh_uv_texture_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const char *name, int active_set) { EditMesh *em; int layernum; @@ -167,22 +167,25 @@ int ED_mesh_uv_texture_add(bContext *C, Scene *scene, Object *ob, Mesh *me) layernum= CustomData_number_of_layers(&em->fdata, CD_MTFACE); if(layernum >= MAX_MTFACE) - return OPERATOR_CANCELLED; + return 0; - EM_add_data_layer(em, &em->fdata, CD_MTFACE); - CustomData_set_layer_active(&em->fdata, CD_MTFACE, layernum); + EM_add_data_layer(em, &em->fdata, CD_MTFACE, name); + if(active_set || layernum==0) + CustomData_set_layer_active(&em->fdata, CD_MTFACE, layernum); } else { layernum= CustomData_number_of_layers(&me->fdata, CD_MTFACE); if(layernum >= MAX_MTFACE) - return OPERATOR_CANCELLED; + return 0; if(me->mtface) - CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DUPLICATE, me->mtface, me->totface); + CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DUPLICATE, me->mtface, me->totface, name); else - CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface); + CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface, name); + + if(active_set || layernum==0) + CustomData_set_layer_active(&me->fdata, CD_MTFACE, layernum); - CustomData_set_layer_active(&me->fdata, CD_MTFACE, layernum); mesh_update_customdata_pointers(me); } @@ -198,7 +201,7 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me) CustomDataLayer *cdl; int index; - index= CustomData_get_active_layer_index(data, CD_MTFACE); + index= CustomData_get_active_layer_index(data, CD_MTFACE); cdl= (index == -1) ? NULL: &data->layers[index]; if(!cdl) @@ -211,7 +214,7 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me) return 1; } -int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me) +int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const char *name, int active_set) { EditMesh *em; MCol *mcol; @@ -224,8 +227,9 @@ int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me) if(layernum >= MAX_MCOL) return 0; - EM_add_data_layer(em, &em->fdata, CD_MCOL); - CustomData_set_layer_active(&em->fdata, CD_MCOL, layernum); + EM_add_data_layer(em, &em->fdata, CD_MCOL, name); + if(active_set || layernum==0) + CustomData_set_layer_active(&em->fdata, CD_MCOL, layernum); } else { layernum= CustomData_number_of_layers(&me->fdata, CD_MCOL); @@ -235,11 +239,13 @@ int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me) mcol= me->mcol; if(me->mcol) - CustomData_add_layer(&me->fdata, CD_MCOL, CD_DUPLICATE, me->mcol, me->totface); + CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DUPLICATE, me->mcol, me->totface, name); else - CustomData_add_layer(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface); + CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface, name); + + if(active_set || layernum==0) + CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum); - CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum); mesh_update_customdata_pointers(me); if(!mcol) @@ -286,7 +292,7 @@ static int uv_texture_add_exec(bContext *C, wmOperator *op) Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; Mesh *me= ob->data; - if(!ED_mesh_uv_texture_add(C, scene, ob, me)) + if(!ED_mesh_uv_texture_add(C, scene, ob, me, NULL, TRUE)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -420,7 +426,7 @@ static int vertex_color_add_exec(bContext *C, wmOperator *op) Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; Mesh *me= ob->data; - if(!ED_mesh_color_add(C, scene, ob, me)) + if(!ED_mesh_color_add(C, scene, ob, me, NULL, TRUE)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; |