From 0916a709466473b52e92f0c30eeaa14b813e47cb Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Mon, 12 Feb 2024 16:23:02 -0800 Subject: [PATCH] Sculpt: Disable modal filter operators on invisible objects Ref: \#112371 --- source/blender/editors/sculpt_paint/sculpt_cloth.cc | 7 +++++++ .../blender/editors/sculpt_paint/sculpt_filter_color.cc | 6 ++++++ source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.cc b/source/blender/editors/sculpt_paint/sculpt_cloth.cc index c4397e63f1f..f693f655934 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.cc @@ -25,6 +25,7 @@ #include "BKE_collision.h" #include "BKE_colortools.hh" #include "BKE_context.hh" +#include "BKE_layer.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_paint.hh" @@ -1529,6 +1530,12 @@ static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent Sculpt *sd = CTX_data_tool_settings(C)->sculpt; SculptSession *ss = ob->sculpt; + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + const eSculptClothFilterType filter_type = eSculptClothFilterType(RNA_enum_get(op->ptr, "type")); /* Update the active vertex */ diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.cc b/source/blender/editors/sculpt_paint/sculpt_filter_color.cc index 44319a12fa0..743658151f6 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_color.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.cc @@ -18,6 +18,7 @@ #include "DNA_userdef_types.h" #include "BKE_context.hh" +#include "BKE_layer.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" @@ -332,6 +333,11 @@ static int sculpt_color_filter_init(bContext *C, wmOperator *op) SculptSession *ss = ob->sculpt; View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + int mval[2]; RNA_int_get_array(op->ptr, "start_mouse", mval); float mval_fl[2] = {float(mval[0]), float(mval[1])}; diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc index 05d7b1f774d..614878d9be7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc @@ -24,6 +24,7 @@ #include "BKE_brush.hh" #include "BKE_context.hh" +#include "BKE_layer.hh" #include "BKE_modifier.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" @@ -959,6 +960,13 @@ static int sculpt_mesh_filter_start(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + int mval[2]; RNA_int_get_array(op->ptr, "start_mouse", mval); -- 2.30.2