[Bf-blender-cvs] [deaddbdcff2] master: Fix forced snap status being removed when changing transform mode

Germano Cavalcante noreply at git.blender.org
Mon Feb 6 15:17:38 CET 2023


Commit: deaddbdcff2ac555429296b32ea632036edd6cb0
Author: Germano Cavalcante
Date:   Mon Feb 6 11:04:07 2023 -0300
Branches: master
https://developer.blender.org/rBdeaddbdcff2ac555429296b32ea632036edd6cb0

Fix forced snap status being removed when changing transform mode

The `SNAP_FORCED` setting is set to the operation and not the snap
status.

Therefore, this option should not be cleared along with the other
statuses when resetting snapping.

Move then the location of this setting to `TransInfo::modifiers`.

===================================================================

M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_snap.cc

===================================================================

diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 7f16a5796ba..d05c78ff993 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1589,7 +1589,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
     /* Update `ToolSettings` for properties that change during modal. */
     if (t->flag & T_MODAL) {
       /* Do we check for parameter? */
-      if (transformModeUseSnap(t) && !(t->tsnap.status & SNAP_FORCED)) {
+      if (transformModeUseSnap(t) && !(t->modifiers & MOD_SNAP_FORCED)) {
         if (!(t->modifiers & MOD_SNAP) != !(t->tsnap.flag & SCE_SNAP)) {
           /* Type is #eSnapFlag, but type must match various snap attributes in #ToolSettings. */
           short *snap_flag_ptr;
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 08f560d16e9..d548cf631f1 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -155,18 +155,18 @@ typedef enum {
   MOD_SNAP_INVERT = 1 << 3,
   MOD_CONSTRAINT_SELECT_PLANE = 1 << 4,
   MOD_NODE_ATTACH = 1 << 5,
+  MOD_SNAP_FORCED = 1 << 6,
 } eTModifier;
 ENUM_OPERATORS(eTModifier, MOD_NODE_ATTACH)
 
 /** #TransSnap.status */
 typedef enum eTSnap {
   SNAP_RESETTED = 0,
-  SNAP_FORCED = 1 << 0,
-  SNAP_SOURCE_FOUND = 1 << 1,
+  SNAP_SOURCE_FOUND = 1 << 0,
   /* Special flag for snap to grid. */
-  SNAP_TARGET_GRID_FOUND = 1 << 2,
-  SNAP_TARGET_FOUND = 1 << 3,
-  SNAP_MULTI_POINTS = 1 << 4,
+  SNAP_TARGET_GRID_FOUND = 1 << 1,
+  SNAP_TARGET_FOUND = 1 << 2,
+  SNAP_MULTI_POINTS = 1 << 3,
 } eTSnap;
 ENUM_OPERATORS(eTSnap, SNAP_MULTI_POINTS)
 
diff --git a/source/blender/editors/transform/transform_snap.cc b/source/blender/editors/transform/transform_snap.cc
index 8a1cb2d9788..425f97a23f4 100644
--- a/source/blender/editors/transform/transform_snap.cc
+++ b/source/blender/editors/transform/transform_snap.cc
@@ -147,7 +147,7 @@ bool transformModeUseSnap(const TransInfo *t)
 
 static bool doForceIncrementSnap(const TransInfo *t)
 {
-  if (t->tsnap.status & SNAP_FORCED) {
+  if (t->modifiers & MOD_SNAP_FORCED) {
     return false;
   }
 
@@ -808,7 +808,8 @@ void initSnapping(TransInfo *t, wmOperator *op)
       if ((prop = RNA_struct_find_property(op->ptr, "snap_point")) &&
           RNA_property_is_set(op->ptr, prop)) {
         RNA_property_float_get_array(op->ptr, prop, t->tsnap.snap_target);
-        t->tsnap.status |= SNAP_FORCED | SNAP_TARGET_FOUND;
+        t->modifiers |= MOD_SNAP_FORCED;
+        t->tsnap.status |= SNAP_TARGET_FOUND;
       }
 
       /* snap align only defined in specific cases */



More information about the Bf-blender-cvs mailing list