1
1

Fix T99334: Ignore edit-related snap options in Object mode

When in Object Mode, any of the active- and edit-related snapping
options (Include Active, Include Edited, Include Non-Edited) should be
ignored when in Object Mode, otherwise snapping could be effectively
disabled.

This commit forces snap code to ignore the active- and edit-related
options when in Object Mode.

Reviewed By: Germano Cavalcante (mano-wii)

Differential Revision: https://developer.blender.org/D15366
This commit is contained in:
2022-07-06 16:21:56 -04:00
parent 2a60b979cc
commit 3354ec3fb3

View File

@@ -492,39 +492,39 @@ static bool snap_object_is_snappable(const SnapObjectContext *sctx,
return false;
}
/* get base attributes */
/* Get attributes of potential target. */
const bool is_active = (base_act == base);
const bool is_selected = (base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL);
const bool is_edited = (base->object->mode == OB_MODE_EDIT);
const bool is_selectable = (base->flag & BASE_SELECTABLE);
/* Get attributes of state. */
const bool is_in_object_mode = (base_act == NULL) || (base_act->object->mode == OB_MODE_OBJECT);
if (is_edited) {
if (is_active) {
if (snap_target_select & SCE_SNAP_TARGET_NOT_ACTIVE) {
return false;
}
}
else {
if (snap_target_select & SCE_SNAP_TARGET_NOT_EDITED) {
return false;
}
if (is_in_object_mode) {
/* Handle target selection options that make sense for object mode. */
if ((snap_target_select & SCE_SNAP_TARGET_NOT_SELECTED) && is_selected) {
/* What is selectable or not is part of the object and depends on the mode. */
return false;
}
}
if ((snap_target_select & SCE_SNAP_TARGET_NOT_NONEDITED) && !is_edited) {
return false;
else {
/* Handle target selection options that make sense for edit/pose mode. */
if ((snap_target_select & SCE_SNAP_TARGET_NOT_ACTIVE) && is_active) {
return false;
}
if ((snap_target_select & SCE_SNAP_TARGET_NOT_EDITED) && is_edited && !is_active) {
/* Base is edited, but not active. */
return false;
}
if ((snap_target_select & SCE_SNAP_TARGET_NOT_NONEDITED) && !is_edited) {
return false;
}
}
if ((snap_target_select & SCE_SNAP_TARGET_ONLY_SELECTABLE) && !is_selectable) {
return false;
}
if ((snap_target_select & SCE_SNAP_TARGET_NOT_SELECTED) && is_in_object_mode && is_selected) {
/* What is selectable or not is part of the object and depends on the mode. */
return false;
}
return true;
}