Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2022-03-22 23:21:40 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2022-03-24 10:52:27 +0300
commitb85cfddb5d4a8b61dbc578505c579a2389de7252 (patch)
tree331b00a96f5831e36b474fe61dd1a24f195a0b03
parent7cecb81e193f625ce698806ba36eaee4118240c3 (diff)
Fix T96711: snap in edit mode for selected objects does not work
Regression introduced in 52be06301257a82a1b4a5746e91ff60daa637ded The `SNAP_NOT_SELECTED` option should only consider base selected if we are in object mode.
-rw-r--r--source/blender/editors/transform/transform_snap_object.c67
1 files changed, 40 insertions, 27 deletions
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 515a4360bb5..eb1a007c9e7 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -454,6 +454,44 @@ typedef void (*IterSnapObjsCallback)(SnapObjectContext *sctx,
bool is_object_active,
void *data);
+static bool snap_object_is_snappable(const SnapObjectContext *sctx,
+ const eSnapSelect snap_select,
+ const Base *base_act,
+ const Base *base,
+ const bool is_in_object_mode)
+{
+ if (!BASE_VISIBLE(sctx->runtime.v3d, base)) {
+ return false;
+ }
+
+ if ((snap_select == SNAP_ALL) || (base->flag_legacy & BA_TRANSFORM_LOCKED_IN_PLACE)) {
+ return true;
+ }
+
+ if (base->flag_legacy & BA_SNAP_FIX_DEPS_FIASCO) {
+ return false;
+ }
+
+ if (snap_select == SNAP_NOT_ACTIVE) {
+ return base_act == base;
+ }
+
+ if (snap_select == SNAP_NOT_SELECTED) {
+ if (is_in_object_mode) {
+ return !((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL));
+ }
+
+ /* What is selectable or not is part of the object and depends on the mode. */
+ return true;
+ }
+
+ if (snap_select == SNAP_SELECTABLE) {
+ return (base->flag & BASE_SELECTABLE) != 0;
+ }
+
+ return true;
+}
+
/**
* Walks through all objects in the scene to create the list of objects to snap.
*/
@@ -472,38 +510,13 @@ static void iter_snap_objects(SnapObjectContext *sctx,
return;
}
+ const bool is_in_object_mode = base_act && base_act->object->mode == OB_MODE_OBJECT;
for (Base *base = view_layer->object_bases.first; base != NULL; base = base->next) {
- if (!BASE_VISIBLE(sctx->runtime.v3d, base)) {
- continue;
- }
-
- if ((snap_select == SNAP_ALL) || (base->flag_legacy & BA_TRANSFORM_LOCKED_IN_PLACE)) {
- /* pass */
- }
- else if (base->flag_legacy & BA_SNAP_FIX_DEPS_FIASCO) {
+ if (!snap_object_is_snappable(sctx, snap_select, base_act, base, is_in_object_mode)) {
continue;
}
const bool is_object_active = (base == base_act);
- if (snap_select == SNAP_NOT_ACTIVE) {
- if (is_object_active) {
- continue;
- }
- }
- else if (snap_select == SNAP_NOT_SELECTED) {
- if (is_object_active && base->object->mode != OB_MODE_OBJECT) {
- /* Pass. Consider the selection of elements being edited. */
- }
- else if ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL)) {
- continue;
- }
- }
- else if (snap_select == SNAP_SELECTABLE) {
- if (!(base->flag & BASE_SELECTABLE)) {
- continue;
- }
- }
-
Object *obj_eval = DEG_get_evaluated_object(sctx->runtime.depsgraph, base->object);
if (obj_eval->transflag & OB_DUPLI || BKE_object_has_geometry_set_instances(obj_eval)) {
ListBase *lb = object_duplilist(sctx->runtime.depsgraph, sctx->scene, obj_eval);