From 066bf316ced0ad3f82336090508bc5972b162794 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Sun, 10 Jul 2022 23:39:45 -0700 Subject: Fix T94633: Sculpt mode missing check for hidden active object Note there is a bug in BKE_object_is_visible_in_viewport, it returns false when the object is in local mode. The transform operator poll should do a similar test. That would allow us to move the test from sculpt_brush_strok_invoke to SCULPT_mode_poll (at the moment we cannot do this due to the brush operator falling through to the translate keymap item in global view3d keymap). --- source/blender/editors/sculpt_paint/sculpt.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 3f726531a05..967a13badd4 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -5461,10 +5461,23 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent struct PaintStroke *stroke; int ignore_background_click; int retval; + Object *ob = CTX_data_active_object(C); + + /* Test that ob is visible; otherwise we won't be able to get evaluated data + * from the depsgraph. We do this here instead of SCULPT_mode_poll + * to avoid falling through to the translate operator in the + * global view3d keymap. + * + * Note: BKE_object_is_visible_in_viewport is not working here (it returns false + * if the object is in local view); instead, test for OB_HIDE_VIEWPORT directly. + */ + + if (ob->visibility_flag & OB_HIDE_VIEWPORT) { + return OPERATOR_CANCELLED; + } sculpt_brush_stroke_init(C, op); - Object *ob = CTX_data_active_object(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Brush *brush = BKE_paint_brush(&sd->paint); -- cgit v1.2.3