From 4df5bcfea98f5bb95d47abba7535ee26c19272a9 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Thu, 8 Feb 2024 15:06:17 +0100 Subject: [PATCH] Sculpt: Disable sculpt brushes on invisible objects * Brushes no longer affect invisible objects or objects that are entirely contained by hidden collections * The brush cursor no longer highlights vertices of invisible objects and the cursor circle remains view-aligned. Resolves part of #112371 Pull Request: https://projects.blender.org/blender/blender/pulls/117746 --- source/blender/editors/sculpt_paint/sculpt.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 49dc215bb45..2c58ac174a5 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -44,6 +44,7 @@ #include "BKE_customdata.hh" #include "BKE_image.h" #include "BKE_key.hh" +#include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_mesh.hh" @@ -4894,7 +4895,10 @@ bool SCULPT_cursor_geometry_info_update(bContext *C, ob = vc.obact; ss = ob->sculpt; - if (!ss->pbvh || !vc.rv3d) { + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + + if (!ss->pbvh || !vc.rv3d || !BKE_base_is_visible(v3d, base)) { zero_v3(out->location); zero_v3(out->normal); zero_v3(out->active_vertex_co); @@ -5635,16 +5639,13 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent int retval; Object *ob = CTX_data_active_object(C); + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(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) { + * global view3d keymap. */ + if (!BKE_base_is_visible(v3d, base)) { return OPERATOR_CANCELLED; }