diff options
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 76 |
1 files changed, 58 insertions, 18 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 86991d7dfeb..a2054a5f43c 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -429,7 +429,7 @@ int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set) /* copy data from active vertex color layer */ if (layernum) { const int layernum_dst = CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPCOL); - BM_data_layer_copy(em->bm, &em->bm->ldata, CD_MLOOPCOL, layernum, layernum_dst); + BM_data_layer_copy(em->bm, &em->bm->ldata, CD_MLOOPCOL, layernum_dst, layernum); } if (active_set || layernum == 0) { CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPCOL, layernum); @@ -748,7 +748,7 @@ static int mesh_customdata_clear_exec__internal(bContext *C, } /* Clear Mask */ -static int mesh_customdata_clear_mask_poll(bContext *C) +static int mesh_customdata_mask_clear_poll(bContext *C) { Object *ob = ED_object_context(C); if (ob && ob->type == OB_MESH) { @@ -772,7 +772,7 @@ static int mesh_customdata_clear_mask_poll(bContext *C) } return false; } -static int mesh_customdata_clear_mask_exec(bContext *C, wmOperator *UNUSED(op)) +static int mesh_customdata_mask_clear_exec(bContext *C, wmOperator *UNUSED(op)) { int ret_a = mesh_customdata_clear_exec__internal(C, BM_VERT, CD_PAINT_MASK); int ret_b = mesh_customdata_clear_exec__internal(C, BM_LOOP, CD_GRID_PAINT_MASK); @@ -787,24 +787,27 @@ static int mesh_customdata_clear_mask_exec(bContext *C, wmOperator *UNUSED(op)) } } -void MESH_OT_customdata_clear_mask(wmOperatorType *ot) +void MESH_OT_customdata_mask_clear(wmOperatorType *ot) { /* identifiers */ ot->name = "Clear Sculpt-Mask Data"; - ot->idname = "MESH_OT_customdata_clear_mask"; + ot->idname = "MESH_OT_customdata_mask_clear"; ot->description = "Clear vertex sculpt masking data from the mesh"; /* api callbacks */ - ot->exec = mesh_customdata_clear_mask_exec; - ot->poll = mesh_customdata_clear_mask_poll; + ot->exec = mesh_customdata_mask_clear_exec; + ot->poll = mesh_customdata_mask_clear_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* Clear Skin */ -static int mesh_customdata_clear_skin_poll(bContext *C) +/** + * Clear Skin + * \return -1 invalid state, 0 no skin, 1 has skin. + */ +static int mesh_customdata_skin_state(bContext *C) { Object *ob = ED_object_context(C); @@ -812,28 +815,65 @@ static int mesh_customdata_clear_skin_poll(bContext *C) Mesh *me = ob->data; if (me->id.lib == NULL) { CustomData *data = GET_CD_DATA(me, vdata); - if (CustomData_has_layer(data, CD_MVERT_SKIN)) { - return true; - } + return CustomData_has_layer(data, CD_MVERT_SKIN); } } - return false; + return -1; } -static int mesh_customdata_clear_skin_exec(bContext *C, wmOperator *UNUSED(op)) + +static int mesh_customdata_skin_add_poll(bContext *C) +{ + return (mesh_customdata_skin_state(C) == 0); +} + +static int mesh_customdata_skin_add_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *ob = ED_object_context(C); + Mesh *me = ob->data; + + BKE_mesh_ensure_skin_customdata(me); + + DAG_id_tag_update(&me->id, 0); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); + + return OPERATOR_FINISHED; +} + +void MESH_OT_customdata_skin_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Add Skin Data"; + ot->idname = "MESH_OT_customdata_skin_add"; + ot->description = "Add a vertex skin layer"; + + /* api callbacks */ + ot->exec = mesh_customdata_skin_add_exec; + ot->poll = mesh_customdata_skin_add_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +static int mesh_customdata_skin_clear_poll(bContext *C) +{ + return (mesh_customdata_skin_state(C) == 1); +} + +static int mesh_customdata_skin_clear_exec(bContext *C, wmOperator *UNUSED(op)) { return mesh_customdata_clear_exec__internal(C, BM_VERT, CD_MVERT_SKIN); } -void MESH_OT_customdata_clear_skin(wmOperatorType *ot) +void MESH_OT_customdata_skin_clear(wmOperatorType *ot) { /* identifiers */ ot->name = "Clear Skin Data"; - ot->idname = "MESH_OT_customdata_clear_skin"; + ot->idname = "MESH_OT_customdata_skin_clear"; ot->description = "Clear vertex skin layer"; /* api callbacks */ - ot->exec = mesh_customdata_clear_skin_exec; - ot->poll = mesh_customdata_clear_skin_poll; + ot->exec = mesh_customdata_skin_clear_exec; + ot->poll = mesh_customdata_skin_clear_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; |