From 3354ec3fb3f6c0785c7c1ad9d84bae1c58d1628f Mon Sep 17 00:00:00 2001 From: jon denning Date: Wed, 6 Jul 2022 16:21:56 -0400 Subject: 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 --- .../editors/transform/transform_snap_object.cc | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/source/blender/editors/transform/transform_snap_object.cc b/source/blender/editors/transform/transform_snap_object.cc index 817474f795e..479214ee2d3 100644 --- a/source/blender/editors/transform/transform_snap_object.cc +++ b/source/blender/editors/transform/transform_snap_object.cc @@ -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; } -- cgit v1.2.3