[Bf-blender-cvs] [44aa9e40ffe] master: Cleanup: Remove unused sculpt and vertex color operators

Hans Goudey noreply at git.blender.org
Tue Aug 2 21:18:35 CEST 2022


Commit: 44aa9e40ffe40c0b222c2f4675545a5777e27059
Author: Hans Goudey
Date:   Tue Aug 2 14:17:20 2022 -0500
Branches: master
https://developer.blender.org/rB44aa9e40ffe40c0b222c2f4675545a5777e27059

Cleanup: Remove unused sculpt and vertex color operators

The "Color Attributes" system from f7bbc7cdbb6cb0d2850 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

===================================================================

M	source/blender/editors/include/ED_mesh.h
M	source/blender/editors/mesh/mesh_data.cc
M	source/blender/editors/mesh/mesh_intern.h
M	source/blender/editors/mesh/mesh_ops.c
M	source/blender/editors/sculpt_paint/sculpt_ops.c

===================================================================

diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index b73b62d5a9d..d469c29945d 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -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);
diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc
index 67834bf05ce..66e9b1ed673 100644
--- a/source/blender/editors/mesh/mesh_data.cc
+++ b/source/blender/editors/mesh/mesh_data.cc
@@ -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)
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index 303234df48c..7c8dbffeb31 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -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);
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index be7f60b0da0..b9e78740e3c 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -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);
diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c
index 35f9989143d..151eb7744ea 100644
--- a/source/blender/editors/sculpt_paint/sculpt_ops.c
+++ b/source/blender/editors/sculpt_paint/sculpt_ops.c
@@ -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)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list