Fix #142285: 3D cursor placement ignores unselectable objects

This was caused by 3dfec1ff73
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
This commit is contained in:
Clément Foucault
2025-10-16 19:17:18 +02:00
committed by Clément Foucault
parent e2dc63c5de
commit 6b0f57facf
6 changed files with 23 additions and 4 deletions

View File

@@ -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)

View File

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

View File

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

View File

@@ -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))

View File

@@ -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 */

View File

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