Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Oeser <info@graphics-engineer.com>2021-11-08 19:05:10 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2021-11-09 12:19:51 +0300
commit04b4ec78898b53dab7ad898736a883353a3eaaed (patch)
tree60a1036c215d865d2fa1e885bd0ab56c78ce5b12 /source/blender/editors/mesh/mesh_data.c
parent486d1e85102f738bc5933d8e241267c390865393 (diff)
Fix T92318: adding layers (UVs, ...) doesn't notify about limit
When adding certain customdata layers (namely UVs, vertex colors and sculpt vertex colors), the user does not get notified the specific limit has been hit (blender just silently does nothing). Now inform the user [decided to not do this in poll() since it could get messy once operators are extended to operate on all selected objects, so left this as a visible error in execute() -- or from python]. Maniphest Tasks: T92318 Differential Revision: https://developer.blender.org/D13147
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r--source/blender/editors/mesh/mesh_data.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index c075d2550cb..7391451b694 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -254,7 +254,8 @@ void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
}
/* NOTE: keep in sync with #ED_mesh_color_add. */
-int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, const bool do_init)
+int ED_mesh_uv_texture_add(
+ Mesh *me, const char *name, const bool active_set, const bool do_init, ReportList *reports)
{
BMEditMesh *em;
int layernum_dst;
@@ -266,6 +267,7 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, co
layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV);
if (layernum_dst >= MAX_MTFACE) {
+ BKE_reportf(reports, RPT_ERROR, "Cannot add more than %i UV maps", MAX_MTFACE);
return -1;
}
@@ -285,6 +287,7 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, co
else {
layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
if (layernum_dst >= MAX_MTFACE) {
+ BKE_reportf(reports, RPT_ERROR, "Cannot add more than %i UV maps", MAX_MTFACE);
return -1;
}
@@ -325,13 +328,13 @@ void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name)
layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV);
if (layernum_dst == 0) {
- ED_mesh_uv_texture_add(me, name, true, true);
+ ED_mesh_uv_texture_add(me, name, true, true, NULL);
}
}
else {
layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
if (layernum_dst == 0) {
- ED_mesh_uv_texture_add(me, name, true, true);
+ ED_mesh_uv_texture_add(me, name, true, true, NULL);
}
}
}
@@ -379,7 +382,8 @@ bool ED_mesh_uv_texture_remove_named(Mesh *me, const char *name)
}
/* NOTE: keep in sync with #ED_mesh_uv_texture_add. */
-int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set, const bool do_init)
+int ED_mesh_color_add(
+ Mesh *me, const char *name, const bool active_set, const bool do_init, ReportList *reports)
{
BMEditMesh *em;
int layernum;
@@ -389,6 +393,7 @@ int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set, const b
layernum = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPCOL);
if (layernum >= MAX_MCOL) {
+ BKE_reportf(reports, RPT_ERROR, "Cannot add more than %i vertex color layers", MAX_MCOL);
return -1;
}
@@ -406,6 +411,7 @@ int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set, const b
else {
layernum = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL);
if (layernum >= MAX_MCOL) {
+ BKE_reportf(reports, RPT_ERROR, "Cannot add more than %i vertex color layers", MAX_MCOL);
return -1;
}
@@ -511,7 +517,8 @@ static bool sculpt_vertex_color_remove_poll(bContext *C)
}
/* 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, ReportList *reports)
{
BMEditMesh *em;
int layernum;
@@ -521,6 +528,8 @@ int ED_mesh_sculpt_color_add(Mesh *me, const char *name, const bool active_set,
layernum = CustomData_number_of_layers(&em->bm->vdata, CD_PROP_COLOR);
if (layernum >= MAX_MCOL) {
+ BKE_reportf(
+ reports, RPT_ERROR, "Cannot add more than %i sculpt vertex color layers", MAX_MCOL);
return -1;
}
@@ -538,6 +547,8 @@ int ED_mesh_sculpt_color_add(Mesh *me, const char *name, const bool active_set,
else {
layernum = CustomData_number_of_layers(&me->vdata, CD_PROP_COLOR);
if (layernum >= MAX_MCOL) {
+ BKE_reportf(
+ reports, RPT_ERROR, "Cannot add more than %i sculpt vertex color layers", MAX_MCOL);
return -1;
}
@@ -634,12 +645,12 @@ static bool uv_texture_remove_poll(bContext *C)
return false;
}
-static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
+static int mesh_uv_texture_add_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
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, op->reports) == -1) {
return OPERATOR_CANCELLED;
}
@@ -719,12 +730,12 @@ static bool vertex_color_remove_poll(bContext *C)
return false;
}
-static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
+static int mesh_vertex_color_add_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (ED_mesh_color_add(me, NULL, true, true) == -1) {
+ if (ED_mesh_color_add(me, NULL, true, true, op->reports) == -1) {
return OPERATOR_CANCELLED;
}
@@ -775,12 +786,12 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot)
/*********************** 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 *op)
{
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (ED_mesh_sculpt_color_add(me, NULL, true, true) == -1) {
+ if (ED_mesh_sculpt_color_add(me, NULL, true, true, op->reports) == -1) {
return OPERATOR_CANCELLED;
}