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
This commit is contained in:
Sean Kim
2024-02-08 15:06:17 +01:00
committed by Brecht Van Lommel
parent 9d0b811da6
commit 4df5bcfea9

View File

@@ -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;
}