From 6b0f57facf8f7ffb887992d41a2251d86b4e7e11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 16 Oct 2025 19:17:18 +0200 Subject: [PATCH] Fix #142285: 3D cursor placement ignores unselectable objects This was caused by 3dfec1ff7387239da75d1ca3fe675a192469fdfb which introduce the new behavior. This was to fix workflows using a lot of semi-transparent objects which made nagivation difficult. This patch first roll back to the previous behavior: The unselectable object will affect depth-aware operators. This patch introduces a new visibility property to remove the influence of objects in all depth picking operations and selection operations. However the object is still selectable through non-drawing selection operators (e.g. select by material) and through the outliner. This is to adress the aforementionned navigation issues. Pull Request: https://projects.blender.org/blender/blender/pulls/146706 --- scripts/startup/bl_ui/properties_object.py | 5 ++++- source/blender/draw/engines/overlay/overlay_instance.cc | 4 ++++ source/blender/draw/intern/draw_context.cc | 3 --- .../blender/editors/transform/transform_snap_object.cc | 5 +++++ source/blender/makesdna/DNA_object_types.h | 1 + source/blender/makesrna/intern/rna_object.cc | 9 +++++++++ 6 files changed, 23 insertions(+), 4 deletions(-) diff --git a/scripts/startup/bl_ui/properties_object.py b/scripts/startup/bl_ui/properties_object.py index 2d6588be132..44ee8f17933 100644 --- a/scripts/startup/bl_ui/properties_object.py +++ b/scripts/startup/bl_ui/properties_object.py @@ -415,7 +415,10 @@ class OBJECT_PT_visibility(ObjectButtonsPanel, Panel): layout = self.layout ob = context.object - layout.prop(ob, "hide_select", text="Selectable", toggle=False, invert_checkbox=True) + col = layout.column() + col.prop(ob, "hide_select", text="Selectable", toggle=False, invert_checkbox=True) + col.prop(ob, "hide_surface_pick", text="Surface Picking", toggle=False, invert_checkbox=True) + layout.separator() col = layout.column(heading="Show In") col.prop(ob, "hide_viewport", text="Viewports", toggle=False, invert_checkbox=True) diff --git a/source/blender/draw/engines/overlay/overlay_instance.cc b/source/blender/draw/engines/overlay/overlay_instance.cc index 0c79c8d3fa4..903b94735d1 100644 --- a/source/blender/draw/engines/overlay/overlay_instance.cc +++ b/source/blender/draw/engines/overlay/overlay_instance.cc @@ -1089,6 +1089,10 @@ bool Instance::object_needs_prepass(const ObjectRef &ob_ref, bool in_paint_mode) } if (resources.is_selection() || state.is_depth_only_drawing) { + if (ob_ref.object->visibility_flag & OB_HIDE_SURFACE_PICK) { + /* Special flag to avoid surfaces to contribute to depth picking and selection. */ + return false; + } /* Selection and depth picking always need a prepass. * Note that depth writing and depth test might be disable for certain selection mode. */ return true; diff --git a/source/blender/draw/intern/draw_context.cc b/source/blender/draw/intern/draw_context.cc index cf795cc89c4..777034b4e7a 100644 --- a/source/blender/draw/intern/draw_context.cc +++ b/source/blender/draw/intern/draw_context.cc @@ -2043,9 +2043,6 @@ void DRW_draw_depth_loop(Depsgraph *depsgraph, if (use_only_selected && !(ob.base_flag & BASE_SELECTED)) { return false; } - if ((ob.base_flag & BASE_SELECTABLE) == 0) { - return false; - } return true; }; diff --git a/source/blender/editors/transform/transform_snap_object.cc b/source/blender/editors/transform/transform_snap_object.cc index d726fa279d7..9de9d8d42aa 100644 --- a/source/blender/editors/transform/transform_snap_object.cc +++ b/source/blender/editors/transform/transform_snap_object.cc @@ -580,6 +580,11 @@ static eSnapMode raycast_obj_fn(SnapObjectContext *sctx, { bool retval = false; + if (ob_eval->visibility_flag & OB_HIDE_SURFACE_PICK) { + /* Do not snap it surface picking is disabled. */ + return SCE_SNAP_TO_NONE; + } + if (ob_data == nullptr) { if ((sctx->runtime.occlusion_test_edit == SNAP_OCCLUSION_AS_SEEM) && ELEM(ob_eval->dt, OB_BOUNDBOX, OB_WIRE)) diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 1be3a9769c9..f806384197c 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -690,6 +690,7 @@ enum { OB_HIDE_PROBE_VOLUME = 1 << 11, OB_HIDE_PROBE_CUBEMAP = 1 << 12, OB_HIDE_PROBE_PLANAR = 1 << 13, + OB_HIDE_SURFACE_PICK = 1 << 14, }; /** #Object.shapeflag */ diff --git a/source/blender/makesrna/intern/rna_object.cc b/source/blender/makesrna/intern/rna_object.cc index 55855edb9d3..db886e36e9c 100644 --- a/source/blender/makesrna/intern/rna_object.cc +++ b/source/blender/makesrna/intern/rna_object.cc @@ -2840,6 +2840,15 @@ static void rna_def_object_visibility(StructRNA *srna) prop, "Disable in Planar Light Probes", "Globally disable in planar light probes"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw"); + prop = RNA_def_property(srna, "hide_surface_pick", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_SURFACE_PICK); + RNA_def_property_ui_text( + prop, + "Disable in Surface Picking", + "Disable surface influence during selection, snapping and depth-picking operators. " + "Usually used to avoid semi-transparent objects to affect scene navigation"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw"); + /* Instancer options. */ prop = RNA_def_property(srna, "show_instancer_for_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "duplicator_visibility_flag", OB_DUPLI_FLAG_RENDER);