View 3D: disable object mode selection cycling on first-click

Unlike regular selection cycling that is activated when clicking again
in the same location, object mode would cycle to another object
if the object that was selected happened to already be active.

This made it impossible to click-drag to tweak the active object
if there were other objects behind it as those would be activated first.

Resolves T96752.
This commit is contained in:
Campbell Barton 2022-04-14 17:15:07 +10:00
parent 678b76d99a
commit b1908f2e0b
Notes: blender-bot 2023-02-14 07:53:51 +01:00
Referenced by commit 3d72c37f7a, Fix T101686: WPaint + Pose select fails with GPU depth-picking disabled
Referenced by issue #101686, Regression: Weight Painting: CTRL+LClick to select bone does not work if mesh is in front of bone
Referenced by issue #96752, Proposal: disable object mode selection cycling on first click
4 changed files with 5 additions and 52 deletions

View File

@ -2281,7 +2281,8 @@ class USERPREF_PT_experimental_prototypes(ExperimentalPanel, Panel):
),
)
# Keep this as tweaks can be useful to restore.
"""
class USERPREF_PT_experimental_tweaks(ExperimentalPanel, Panel):
bl_label = "Tweaks"
@ -2292,6 +2293,7 @@ class USERPREF_PT_experimental_tweaks(ExperimentalPanel, Panel):
),
)
"""
class USERPREF_PT_experimental_debugging(ExperimentalPanel, Panel):
bl_label = "Debugging"
@ -2413,7 +2415,7 @@ classes = (
USERPREF_PT_experimental_new_features,
USERPREF_PT_experimental_prototypes,
USERPREF_PT_experimental_tweaks,
# USERPREF_PT_experimental_tweaks,
USERPREF_PT_experimental_debugging,
# Add dynamically generated editor theme panels last,

View File

@ -2125,49 +2125,6 @@ static Base *mouse_select_eval_buffer(ViewContext *vc,
hit_index = a;
}
}
/* Find the best active & non-active hits.
* NOTE(@campbellbarton): Checking if `hits > 1` isn't a reliable way to know
* if there are multiple objects selected since it's possible the same object
* generates multiple hits, either from:
* - Multiple sub-components (bones & camera tracks).
* - Multiple selectable elements such as the object center and the geometry.
*
* For this reason, keep track of the best hit as well as the best hit that
* excludes the selected & active object, using this value when it's valid. */
if ((hit_index != -1) &&
/* Special case, cycling away from the active object should only be done when it
* doesn't have a bone selection, otherwise selecting sub-elements is difficult. */
((buffer[hit_index].id & 0xFFFF0000) == 0) &&
/* Only exclude active object when it is selected. */
(BASACT(view_layer) && (BASACT(view_layer)->flag & BASE_SELECTED)) &&
/* Allow disabling this behavior entirely. */
(U.experimental.use_select_nearest_on_first_click == false)) {
const int select_id_active = BASACT(view_layer)->object->runtime.select_id;
/* Check if `hit_index` is the current active object. */
if ((buffer[hit_index].id & 0xFFFF) == select_id_active) {
uint min_not_active = 0xFFFFFFFF;
int hit_index_not_active = -1;
for (a = 0; a < hits; a++) {
/* Any object other than the active-selected. */
if (select_id_active == (buffer[a].id & 0xFFFF)) {
continue;
}
if (min_not_active > buffer[a].depth) {
min_not_active = buffer[a].depth;
hit_index_not_active = a;
}
}
/* When the active was selected, first try to use the index
* for the best non-active hit that was found. */
if (hit_index_not_active != -1) {
hit_index = hit_index_not_active;
}
}
}
}
if (hit_index != -1) {

View File

@ -649,9 +649,9 @@ typedef struct UserDef_Experimental {
char use_extended_asset_browser;
char use_override_templates;
char use_named_attribute_nodes;
char use_select_nearest_on_first_click;
char enable_eevee_next;
char use_sculpt_texture_paint;
char _pad0[1];
/** `makesdna` does not allow empty structs. */
} UserDef_Experimental;

View File

@ -6440,12 +6440,6 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
"Named Attribute Nodes",
"Enable named attribute nodes in the geometry nodes add menu");
prop = RNA_def_property(srna, "use_select_nearest_on_first_click", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_select_nearest_on_first_click", 1);
RNA_def_property_ui_text(prop,
"Object Select Nearest on First Click",
"When enabled, always select the front-most object on the first click");
prop = RNA_def_property(srna, "enable_eevee_next", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "enable_eevee_next", 1);
RNA_def_property_ui_text(prop, "EEVEE Next", "Enable the new EEVEE codebase, requires restart");