Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/mesh_data.c
| Show First 20 Lines • Show All 476 Lines • ▼ Show 20 Lines | bool ED_mesh_color_remove_named(Mesh *me, const char *name) | ||||
| CustomData *ldata = GET_CD_DATA(me, ldata); | CustomData *ldata = GET_CD_DATA(me, ldata); | ||||
| const int n = CustomData_get_named_layer(ldata, CD_MLOOPCOL, name); | const int n = CustomData_get_named_layer(ldata, CD_MLOOPCOL, name); | ||||
| if (n != -1) { | if (n != -1) { | ||||
| return ED_mesh_color_remove_index(me, n); | return ED_mesh_color_remove_index(me, n); | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /*********************** General poll ************************/ | |||||
| static bool layers_poll(bContext *C) | |||||
| { | |||||
| Object *ob = ED_object_context(C); | |||||
| ID *data = (ob) ? ob->data : NULL; | |||||
| return (ob && !ID_IS_LINKED(ob) && ob->type == OB_MESH && data && !ID_IS_LINKED(data)); | |||||
| } | |||||
| /*********************** Sculpt Vertex colors operators ************************/ | /*********************** Sculpt Vertex colors operators ************************/ | ||||
| static bool sculpt_vertex_color_remove_poll(bContext *C) | |||||
| { | |||||
| if (!layers_poll(C)) { | |||||
| return false; | |||||
| } | |||||
| Object *ob = ED_object_context(C); | |||||
| Mesh *me = ob->data; | |||||
| CustomData *vdata = GET_CD_DATA(me, vdata); | |||||
| const int active = CustomData_get_active_layer(vdata, CD_PROP_COLOR); | |||||
| if (active != -1) { | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /* NOTE: keep in sync with #ED_mesh_uv_texture_add. */ | /* NOTE: keep in sync with #ED_mesh_uv_texture_add. */ | ||||
| int ED_mesh_sculpt_color_add(Mesh *me, const char *name, const bool active_set, const bool do_init) | int ED_mesh_sculpt_color_add(Mesh *me, const char *name, const bool active_set, const bool do_init) | ||||
| { | { | ||||
| BMEditMesh *em; | BMEditMesh *em; | ||||
| int layernum; | int layernum; | ||||
| if (me->edit_mesh) { | if (me->edit_mesh) { | ||||
| em = me->edit_mesh; | em = me->edit_mesh; | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | bool ED_mesh_sculpt_color_remove_named(Mesh *me, const char *name) | ||||
| if (n != -1) { | if (n != -1) { | ||||
| return ED_mesh_sculpt_color_remove_index(me, n); | return ED_mesh_sculpt_color_remove_index(me, n); | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /*********************** UV texture operators ************************/ | /*********************** UV texture operators ************************/ | ||||
| static bool layers_poll(bContext *C) | static bool uv_texture_remove_poll(bContext *C) | ||||
| { | { | ||||
| if (!layers_poll(C)) { | |||||
| return false; | |||||
| } | |||||
| Object *ob = ED_object_context(C); | Object *ob = ED_object_context(C); | ||||
| ID *data = (ob) ? ob->data : NULL; | Mesh *me = ob->data; | ||||
| return (ob && !ID_IS_LINKED(ob) && ob->type == OB_MESH && data && !ID_IS_LINKED(data)); | CustomData *ldata = GET_CD_DATA(me, ldata); | ||||
| const int active = CustomData_get_active_layer(ldata, CD_MLOOPUV); | |||||
| if (active != -1) { | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | } | ||||
| static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op)) | static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Object *ob = ED_object_context(C); | Object *ob = ED_object_context(C); | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| if (ED_mesh_uv_texture_add(me, NULL, true, true) == -1) { | if (ED_mesh_uv_texture_add(me, NULL, true, true) == -1) { | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
| void MESH_OT_uv_texture_remove(wmOperatorType *ot) | void MESH_OT_uv_texture_remove(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Remove UV Map"; | ot->name = "Remove UV Map"; | ||||
| ot->description = "Remove UV map"; | ot->description = "Remove UV map"; | ||||
| ot->idname = "MESH_OT_uv_texture_remove"; | ot->idname = "MESH_OT_uv_texture_remove"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->poll = layers_poll; | ot->poll = uv_texture_remove_poll; | ||||
| ot->exec = mesh_uv_texture_remove_exec; | ot->exec = mesh_uv_texture_remove_exec; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| /*********************** vertex color operators ************************/ | /*********************** vertex color operators ************************/ | ||||
| static bool vertex_color_remove_poll(bContext *C) | |||||
| { | |||||
| if (!layers_poll(C)) { | |||||
| return false; | |||||
| } | |||||
| Object *ob = ED_object_context(C); | |||||
| Mesh *me = ob->data; | |||||
| CustomData *ldata = GET_CD_DATA(me, ldata); | |||||
| const int active = CustomData_get_active_layer(ldata, CD_MLOOPCOL); | |||||
| if (active != -1) { | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op)) | static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Object *ob = ED_object_context(C); | Object *ob = ED_object_context(C); | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| if (ED_mesh_color_add(me, NULL, true, true) == -1) { | if (ED_mesh_color_add(me, NULL, true, true) == -1) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| Show All 32 Lines | |||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Remove Vertex Color"; | ot->name = "Remove Vertex Color"; | ||||
| ot->description = "Remove vertex color layer"; | ot->description = "Remove vertex color layer"; | ||||
| ot->idname = "MESH_OT_vertex_color_remove"; | ot->idname = "MESH_OT_vertex_color_remove"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = mesh_vertex_color_remove_exec; | ot->exec = mesh_vertex_color_remove_exec; | ||||
| ot->poll = layers_poll; | ot->poll = vertex_color_remove_poll; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| /*********************** Sculpt Vertex Color Operators ************************/ | /*********************** Sculpt Vertex Color Operators ************************/ | ||||
| static int mesh_sculpt_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op)) | static int mesh_sculpt_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| Show All 39 Lines | |||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Remove Sculpt Vertex Color"; | ot->name = "Remove Sculpt Vertex Color"; | ||||
| ot->description = "Remove vertex color layer"; | ot->description = "Remove vertex color layer"; | ||||
| ot->idname = "MESH_OT_sculpt_vertex_color_remove"; | ot->idname = "MESH_OT_sculpt_vertex_color_remove"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = mesh_sculpt_vertex_color_remove_exec; | ot->exec = mesh_sculpt_vertex_color_remove_exec; | ||||
| ot->poll = layers_poll; | ot->poll = sculpt_vertex_color_remove_poll; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| /* *** CustomData clear functions, we need an operator for each *** */ | /* *** CustomData clear functions, we need an operator for each *** */ | ||||
| static int mesh_customdata_clear_exec__internal(bContext *C, char htype, int type) | static int mesh_customdata_clear_exec__internal(bContext *C, char htype, int type) | ||||
| ▲ Show 20 Lines • Show All 597 Lines • Show Last 20 Lines | |||||