diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-22 00:15:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-22 00:15:39 +0400 |
commit | fa1cd9ce9b841510588ff899c2fd8be5a7293ae0 (patch) | |
tree | 57e756272e22ff8ab381f8531ae1f68ea9267af7 /source/blender/editors/mesh/mesh_data.c | |
parent | 21c55d5304f5e1093d0f8e96cec5bd1014b08c16 (diff) |
python api: add functionality to remove vertex color layers.
note: that this intentionally removes check to exit vpaint mode when a vertex color layer is removed,
since being in vertex-paint mode without a vertex color layer is supported.
also minor change to drawing camera limits while picking from previous commit.
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index b6b2550bd45..751529faf82 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -123,9 +123,8 @@ static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_t } #define GET_CD_DATA(me, data) (me->edit_btmesh ? &me->edit_btmesh->bm->data : &me->data) -static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *layer) +static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer) { - Mesh *me = ob->data; CustomData *data; void *actlayerdata, *rndlayerdata, *clonelayerdata, *stencillayerdata, *layerdata = layer->data; int type = layer->type; @@ -162,9 +161,6 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la BKE_mesh_update_customdata_pointers(me, true); } - if (!CustomData_has_layer(data, type) && (type == CD_MLOOPCOL && (ob->mode & OB_MODE_VERTEX_PAINT))) - ED_object_toggle_modes(C, OB_MODE_VERTEX_PAINT); - /* reconstruct active layer */ if (actlayerdata != layerdata) { /* find index */ @@ -435,8 +431,8 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me) if (!cdlp || !cdlu) return 0; - delete_customdata_layer(C, ob, cdlp); - delete_customdata_layer(C, ob, cdlu); + delete_customdata_layer(ob->data, cdlp); + delete_customdata_layer(ob->data, cdlu); DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); @@ -498,42 +494,46 @@ int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mes return layernum; } -int ED_mesh_color_remove(bContext *C, Object *ob, Mesh *me) +bool ED_mesh_color_remove_index(Mesh *me, const int n) { CustomData *ldata = GET_CD_DATA(me, ldata); CustomDataLayer *cdl; int index; - index = CustomData_get_active_layer_index(ldata, CD_MLOOPCOL); + index = CustomData_get_layer_index_n(ldata, CD_MLOOPCOL, n); cdl = (index == -1) ? NULL : &ldata->layers[index]; if (!cdl) - return 0; + return false; - delete_customdata_layer(C, ob, cdl); + delete_customdata_layer(me, cdl); DAG_id_tag_update(&me->id, 0); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); + WM_main_add_notifier(NC_GEOM | ND_DATA, me); - return 1; + return true; } - -int ED_mesh_color_remove_named(bContext *C, Object *ob, Mesh *me, const char *name) +bool ED_mesh_color_remove_active(Mesh *me) { CustomData *ldata = GET_CD_DATA(me, ldata); - CustomDataLayer *cdl; - int index; - - index = CustomData_get_named_layer_index(ldata, CD_MLOOPCOL, name); - cdl = (index == -1) ? NULL : &ldata->layers[index]; - - if (!cdl) - return 0; - - delete_customdata_layer(C, ob, cdl); - DAG_id_tag_update(&me->id, 0); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); + const int n = CustomData_get_active_layer(ldata, CD_MLOOPCOL); + if (n != -1) { + return ED_mesh_color_remove_index(me, n); + } + else { + return false; + } +} - return 1; +bool ED_mesh_color_remove_named(Mesh *me, const char *name) +{ + CustomData *ldata = GET_CD_DATA(me, ldata); + const int n = CustomData_get_named_layer(ldata, CD_MLOOPCOL, name); + if (n != -1) { + return ED_mesh_color_remove_index(me, n); + } + else { + return false; + } } /*********************** UV texture operators ************************/ @@ -725,7 +725,7 @@ static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_context(C); Mesh *me = ob->data; - if (!ED_mesh_color_remove(C, ob, me)) + if (!ED_mesh_color_remove_active(me)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; |