Cleanup: Remove unused sculpt and vertex color operators

The "Color Attributes" system from f7bbc7cdbb has replaced
both "Sculpt Vertex Colors" and "Vertex Colors" in the UI. The Operators
for adding and removing them are unused now.

This commit does not break backwards compatibility with the Python
API, it only removes the operators, which generally aren't used by
addons anyway. The mesh RNA properties will be removed in 4.0 (T100153).

Differential Revision: https://developer.blender.org/D15077
This commit is contained in:
Hans Goudey 2022-08-02 14:17:20 -05:00
parent a48e5c53a5
commit 44aa9e40ff
Notes: blender-bot 2023-02-14 05:41:57 +01:00
Referenced by commit 8081a05015, Tests: Remove deprecated/removed operators from tests
5 changed files with 0 additions and 326 deletions

View File

@ -556,11 +556,9 @@ bool ED_mesh_color_remove_index(struct Mesh *me, int n);
bool ED_mesh_color_remove_active(struct Mesh *me);
bool ED_mesh_color_remove_named(struct Mesh *me, const char *name);
bool ED_mesh_sculpt_color_ensure(struct Mesh *me, const char *name);
int ED_mesh_sculpt_color_add(
struct Mesh *me, const char *name, bool active_set, bool do_init, struct ReportList *reports);
bool ED_mesh_sculpt_color_remove_index(struct Mesh *me, int n);
bool ED_mesh_sculpt_color_remove_active(struct Mesh *me);
bool ED_mesh_sculpt_color_remove_named(struct Mesh *me, const char *name);
void ED_mesh_report_mirror(struct wmOperator *op, int totmirr, int totfail);

View File

@ -494,23 +494,6 @@ static bool layers_poll(bContext *C)
/*********************** 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 = static_cast<Mesh *>(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;
}
int ED_mesh_sculpt_color_add(
Mesh *me, const char *name, const bool active_set, const bool do_init, ReportList *reports)
{
@ -572,20 +555,6 @@ int ED_mesh_sculpt_color_add(
return layernum;
}
bool ED_mesh_sculpt_color_ensure(Mesh *me, const char *name)
{
BLI_assert(me->edit_mesh == nullptr);
if (me->totvert && !CustomData_has_layer(&me->vdata, CD_PROP_COLOR)) {
CustomData_add_layer_named(&me->vdata, CD_PROP_COLOR, CD_DEFAULT, nullptr, me->totvert, name);
BKE_mesh_update_customdata_pointers(me, true);
}
DEG_id_tag_update(&me->id, 0);
return (me->mloopcol != nullptr);
}
bool ED_mesh_sculpt_color_remove_index(Mesh *me, const int n)
{
CustomData *vdata = GET_CD_DATA(me, vdata);
@ -605,15 +574,6 @@ bool ED_mesh_sculpt_color_remove_index(Mesh *me, const int n)
return true;
}
bool ED_mesh_sculpt_color_remove_active(Mesh *me)
{
CustomData *vdata = GET_CD_DATA(me, vdata);
const int n = CustomData_get_active_layer(vdata, CD_PROP_COLOR);
if (n != -1) {
return ED_mesh_sculpt_color_remove_index(me, n);
}
return false;
}
bool ED_mesh_sculpt_color_remove_named(Mesh *me, const char *name)
{
CustomData *vdata = GET_CD_DATA(me, vdata);
@ -709,135 +669,6 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/*********************** 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 = static_cast<Mesh *>(ob->data);
CustomData *ldata = GET_CD_DATA(me, ldata);
const int active = CustomData_get_active_layer(ldata, CD_PROP_BYTE_COLOR);
if (active != -1) {
return true;
}
return false;
}
static int mesh_vertex_color_add_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
Mesh *me = static_cast<Mesh *>(ob->data);
if (ED_mesh_color_add(me, nullptr, true, true, op->reports) == -1) {
return OPERATOR_CANCELLED;
}
return OPERATOR_FINISHED;
}
void MESH_OT_vertex_color_add(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Add Vertex Color";
ot->description = "Add vertex color layer";
ot->idname = "MESH_OT_vertex_color_add";
/* api callbacks */
ot->poll = layers_poll;
ot->exec = mesh_vertex_color_add_exec;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_object_context(C);
Mesh *me = static_cast<Mesh *>(ob->data);
if (!ED_mesh_color_remove_active(me)) {
return OPERATOR_CANCELLED;
}
return OPERATOR_FINISHED;
}
void MESH_OT_vertex_color_remove(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Remove Vertex Color";
ot->description = "Remove vertex color layer";
ot->idname = "MESH_OT_vertex_color_remove";
/* api callbacks */
ot->exec = mesh_vertex_color_remove_exec;
ot->poll = vertex_color_remove_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/*********************** Sculpt Vertex Color Operators ************************/
static int mesh_sculpt_vertex_color_add_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
Mesh *me = static_cast<Mesh *>(ob->data);
if (ED_mesh_sculpt_color_add(me, nullptr, true, true, op->reports) == -1) {
return OPERATOR_CANCELLED;
}
return OPERATOR_FINISHED;
}
void MESH_OT_sculpt_vertex_color_add(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Add Sculpt Vertex Color";
ot->description = "Add vertex color layer";
ot->idname = "MESH_OT_sculpt_vertex_color_add";
/* api callbacks */
ot->poll = layers_poll;
ot->exec = mesh_sculpt_vertex_color_add_exec;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int mesh_sculpt_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_object_context(C);
Mesh *me = static_cast<Mesh *>(ob->data);
if (!ED_mesh_sculpt_color_remove_active(me)) {
return OPERATOR_CANCELLED;
}
return OPERATOR_FINISHED;
}
void MESH_OT_sculpt_vertex_color_remove(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Remove Sculpt Vertex Color";
ot->description = "Remove vertex color layer";
ot->idname = "MESH_OT_sculpt_vertex_color_remove";
/* api callbacks */
ot->exec = mesh_sculpt_vertex_color_remove_exec;
ot->poll = sculpt_vertex_color_remove_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* *** CustomData clear functions, we need an operator for each *** */
static int mesh_customdata_clear_exec__internal(bContext *C, char htype, int type)

View File

@ -308,10 +308,6 @@ void MESH_OT_mark_freestyle_face(struct wmOperatorType *ot);
void MESH_OT_uv_texture_add(struct wmOperatorType *ot);
void MESH_OT_uv_texture_remove(struct wmOperatorType *ot);
void MESH_OT_vertex_color_add(struct wmOperatorType *ot);
void MESH_OT_vertex_color_remove(struct wmOperatorType *ot);
void MESH_OT_sculpt_vertex_color_add(struct wmOperatorType *ot);
void MESH_OT_sculpt_vertex_color_remove(struct wmOperatorType *ot);
void MESH_OT_customdata_mask_clear(struct wmOperatorType *ot);
void MESH_OT_customdata_skin_add(struct wmOperatorType *ot);
void MESH_OT_customdata_skin_clear(struct wmOperatorType *ot);

View File

@ -134,10 +134,6 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_uv_texture_add);
WM_operatortype_append(MESH_OT_uv_texture_remove);
WM_operatortype_append(MESH_OT_vertex_color_add);
WM_operatortype_append(MESH_OT_vertex_color_remove);
WM_operatortype_append(MESH_OT_sculpt_vertex_color_add);
WM_operatortype_append(MESH_OT_sculpt_vertex_color_remove);
WM_operatortype_append(MESH_OT_customdata_mask_clear);
WM_operatortype_append(MESH_OT_customdata_skin_add);
WM_operatortype_append(MESH_OT_customdata_skin_clear);

View File

@ -617,151 +617,6 @@ void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float
ss->preview_vert_count = totpoints;
}
static int vertex_to_loop_colors_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_active_object(C);
ID *data;
data = ob->data;
if (data == NULL || ID_IS_LINKED(data) || ID_IS_OVERRIDE_LIBRARY(data)) {
return OPERATOR_CANCELLED;
}
if (ob->type != OB_MESH) {
return OPERATOR_CANCELLED;
}
Mesh *mesh = ob->data;
const int mloopcol_layer_n = CustomData_get_active_layer(&mesh->ldata, CD_PROP_BYTE_COLOR);
if (mloopcol_layer_n == -1) {
return OPERATOR_CANCELLED;
}
MLoopCol *loopcols = CustomData_get_layer_n(&mesh->ldata, CD_PROP_BYTE_COLOR, mloopcol_layer_n);
const int MPropCol_layer_n = CustomData_get_active_layer(&mesh->vdata, CD_PROP_COLOR);
if (MPropCol_layer_n == -1) {
return OPERATOR_CANCELLED;
}
const MPropCol *vertcols = CustomData_get_layer_n(&mesh->vdata, CD_PROP_COLOR, MPropCol_layer_n);
const MLoop *loops = CustomData_get_layer(&mesh->ldata, CD_MLOOP);
const MPoly *polys = CustomData_get_layer(&mesh->pdata, CD_MPOLY);
for (int i = 0; i < mesh->totpoly; i++) {
const MPoly *c_poly = &polys[i];
for (int j = 0; j < c_poly->totloop; j++) {
int loop_index = c_poly->loopstart + j;
const MLoop *c_loop = &loops[c_poly->loopstart + j];
float srgb_color[4];
linearrgb_to_srgb_v4(srgb_color, vertcols[c_loop->v].color);
loopcols[loop_index].r = (char)(srgb_color[0] * 255);
loopcols[loop_index].g = (char)(srgb_color[1] * 255);
loopcols[loop_index].b = (char)(srgb_color[2] * 255);
loopcols[loop_index].a = (char)(srgb_color[3] * 255);
}
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
return OPERATOR_FINISHED;
}
static bool sculpt_colors_poll(bContext *C)
{
if (!SCULPT_mode_poll(C)) {
return false;
}
Object *ob = CTX_data_active_object(C);
if (!ob->sculpt || !ob->sculpt->pbvh || BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_FACES) {
return false;
}
return SCULPT_has_colors(ob->sculpt);
}
static void SCULPT_OT_vertex_to_loop_colors(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Sculpt Vertex Color to Vertex Color";
ot->description = "Copy the Sculpt Vertex Color to a regular color layer";
ot->idname = "SCULPT_OT_vertex_to_loop_colors";
/* api callbacks */
ot->poll = sculpt_colors_poll;
ot->exec = vertex_to_loop_colors_exec;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int loop_to_vertex_colors_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_active_object(C);
ID *data;
data = ob->data;
if (data == NULL || ID_IS_LINKED(data) || ID_IS_OVERRIDE_LIBRARY(data)) {
return OPERATOR_CANCELLED;
}
if (ob->type != OB_MESH) {
return OPERATOR_CANCELLED;
}
Mesh *mesh = ob->data;
const int mloopcol_layer_n = CustomData_get_active_layer(&mesh->ldata, CD_PROP_BYTE_COLOR);
if (mloopcol_layer_n == -1) {
return OPERATOR_CANCELLED;
}
const MLoopCol *loopcols = CustomData_get_layer_n(
&mesh->ldata, CD_PROP_BYTE_COLOR, mloopcol_layer_n);
const int MPropCol_layer_n = CustomData_get_active_layer(&mesh->vdata, CD_PROP_COLOR);
if (MPropCol_layer_n == -1) {
return OPERATOR_CANCELLED;
}
MPropCol *vertcols = CustomData_get_layer_n(&mesh->vdata, CD_PROP_COLOR, MPropCol_layer_n);
const MLoop *loops = CustomData_get_layer(&mesh->ldata, CD_MLOOP);
const MPoly *polys = CustomData_get_layer(&mesh->pdata, CD_MPOLY);
for (int i = 0; i < mesh->totpoly; i++) {
const MPoly *c_poly = &polys[i];
for (int j = 0; j < c_poly->totloop; j++) {
int loop_index = c_poly->loopstart + j;
const MLoop *c_loop = &loops[c_poly->loopstart + j];
vertcols[c_loop->v].color[0] = (loopcols[loop_index].r / 255.0f);
vertcols[c_loop->v].color[1] = (loopcols[loop_index].g / 255.0f);
vertcols[c_loop->v].color[2] = (loopcols[loop_index].b / 255.0f);
vertcols[c_loop->v].color[3] = (loopcols[loop_index].a / 255.0f);
srgb_to_linearrgb_v4(vertcols[c_loop->v].color, vertcols[c_loop->v].color);
}
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
return OPERATOR_FINISHED;
}
static void SCULPT_OT_loop_to_vertex_colors(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Vertex Color to Sculpt Vertex Color";
ot->description = "Copy the active loop color layer to the vertex color";
ot->idname = "SCULPT_OT_loop_to_vertex_colors";
/* api callbacks */
ot->poll = sculpt_colors_poll;
ot->exec = loop_to_vertex_colors_exec;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int sculpt_sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e))
{
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
@ -1158,8 +1013,6 @@ void ED_operatortypes_sculpt(void)
WM_operatortype_append(SCULPT_OT_project_line_gesture);
WM_operatortype_append(SCULPT_OT_sample_color);
WM_operatortype_append(SCULPT_OT_loop_to_vertex_colors);
WM_operatortype_append(SCULPT_OT_vertex_to_loop_colors);
WM_operatortype_append(SCULPT_OT_color_filter);
WM_operatortype_append(SCULPT_OT_mask_by_color);
WM_operatortype_append(SCULPT_OT_dyntopo_detail_size_edit);