Transform: when snap affect is off for a transform mode, ignore snap settings entirely.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 18 Dec 2018 10:54:02 +0000 (11:54 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 18 Dec 2018 11:14:38 +0000 (12:14 +0100)
Ref D4022.

release/scripts/startup/bl_ui/space_view3d.py
source/blender/blenkernel/intern/scene.c
source/blender/blenloader/intern/versioning_280.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_snap.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c

index de1502375cf0991721d94eed36484bfa856aa168..3c713de9a71a450fd464a83eb797ac05b4d2dd35 100644 (file)
@@ -5225,12 +5225,6 @@ class VIEW3D_PT_snapping(Panel):
             col.prop(tool_settings, "use_snap_grid_absolute")
 
         if snap_elements != {'INCREMENT'}:
-            col.label(text="Affect")
-            row = col.row(align=True)
-            row.prop(tool_settings, "use_snap_force_increment_translate", text="Move")
-            row.prop(tool_settings, "use_snap_force_increment_rotate", text="Rotate")
-            row.prop(tool_settings, "use_snap_force_increment_scale", text="Scale")
-
             col.label(text="Target")
             row = col.row(align=True)
             row.prop(tool_settings, "snap_target", expand=True)
@@ -5247,6 +5241,12 @@ class VIEW3D_PT_snapping(Panel):
             if 'VOLUME' in snap_elements:
                 col.prop(tool_settings, "use_snap_peel_object")
 
+        col.label(text="Affect")
+        row = col.row(align=True)
+        row.prop(tool_settings, "use_snap_translate", text="Move", toggle=True)
+        row.prop(tool_settings, "use_snap_rotate", text="Rotate", toggle=True)
+        row.prop(tool_settings, "use_snap_scale", text="Scale", toggle=True)
+
 
 class VIEW3D_PT_transform_orientations(Panel):
     bl_space_type = 'VIEW_3D'
index cd0e437ec7ee0be3fa3b6f9023a331e7600fa875..3a9d22f559baccb2eb0e252e1c28a5776e6dcb8e 100644 (file)
@@ -670,7 +670,7 @@ void BKE_scene_init(Scene *sce)
        sce->toolsettings->snap_mode = SCE_SNAP_MODE_INCREMENT;
        sce->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID;
        sce->toolsettings->snap_uv_mode = SCE_SNAP_MODE_INCREMENT;
-       sce->toolsettings->snap_force_increment_flag = SCE_SNAP_FORCE_INCREMENT_ROTATE | SCE_SNAP_FORCE_INCREMENT_SCALE;
+       sce->toolsettings->snap_transform_mode_flag = SCE_SNAP_TRANSFORM_MODE_TRANSLATE;
 
        sce->toolsettings->curve_paint_settings.curve_type = CU_BEZIER;
        sce->toolsettings->curve_paint_settings.flag |= CURVE_PAINT_FLAG_CORNERS_DETECT;
index 4eda9bc7a123fa0050c4a48d23956953dbc9d7e0..a2a2c3fb73828fe20c9aee0ece393f26decd99a7 100644 (file)
@@ -2737,10 +2737,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
        {
                /* Versioning code until next subversion bump goes here. */
 
-               if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "snap_force_increment_flag")) {
+               if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "snap_transform_mode_flag")) {
                        for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
-                               scene->toolsettings->snap_force_increment_flag =
-                                       SCE_SNAP_FORCE_INCREMENT_ROTATE | SCE_SNAP_FORCE_INCREMENT_SCALE;
+                               scene->toolsettings->snap_transform_mode_flag =
+                                       SCE_SNAP_TRANSFORM_MODE_TRANSLATE;
                        }
                }
        }
index 60c1f4f1f406cde717f600af4e7e3194e96b2882..90bfaf7bc9d71110f6cd3c37f5ae00a36216972b 100644 (file)
@@ -2101,11 +2101,13 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
                }
 
                /* do we check for parameter? */
-               if (t->modifiers & MOD_SNAP) {
-                       ts->snap_flag |= SCE_SNAP;
-               }
-               else {
-                       ts->snap_flag &= ~SCE_SNAP;
+               if (transformModeUseSnap(t)) {
+                       if (t->modifiers & MOD_SNAP) {
+                               ts->snap_flag |= SCE_SNAP;
+                       }
+                       else {
+                               ts->snap_flag &= ~SCE_SNAP;
+                       }
                }
 
                if (t->spacetype == SPACE_VIEW3D) {
index ca341fc873892f9ea116ac466075648c956162b3..75044e77110eea8c0aa1875d0d5bc334f2c8cbde 100644 (file)
@@ -783,6 +783,8 @@ typedef enum {
        SMALL_GEARS     = 2
 } GearsType;
 
+bool transformModeUseSnap(const TransInfo *t);
+
 void snapGridIncrement(TransInfo *t, float *val);
 void snapGridIncrementAction(TransInfo *t, float *val, GearsType action);
 
index c2c864b51adee95cbed10f38a9f3b3ec4de02322..3a73c2386a867ed92b555d1ef041848948217d87 100644 (file)
@@ -137,21 +137,27 @@ bool activeSnap(const TransInfo *t)
               ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT);
 }
 
-static bool doForceIncrementSnap(const TransInfo *t)
+bool transformModeUseSnap(const TransInfo *t)
 {
-       const ToolSettings *ts = t->settings;
+       ToolSettings *ts = t->settings;
        if (t->mode == TFM_TRANSLATION) {
-               return ts->snap_force_increment_flag & SCE_SNAP_FORCE_INCREMENT_TRANSLATE;
+               return (ts->snap_transform_mode_flag & SCE_SNAP_TRANSFORM_MODE_TRANSLATE) != 0;
        }
        if (t->mode == TFM_ROTATION) {
-               return ts->snap_force_increment_flag & SCE_SNAP_FORCE_INCREMENT_ROTATE;
+               return (ts->snap_transform_mode_flag & SCE_SNAP_TRANSFORM_MODE_ROTATE) != 0;
        }
        if (t->mode == TFM_RESIZE) {
-               return ts->snap_force_increment_flag & SCE_SNAP_FORCE_INCREMENT_SCALE;
+               return (ts->snap_transform_mode_flag & SCE_SNAP_TRANSFORM_MODE_SCALE) != 0;
        }
+
        return false;
 }
 
+static bool doForceIncrementSnap(const TransInfo *t)
+{
+       return !transformModeUseSnap(t);
+}
+
 void drawSnapping(const struct bContext *C, TransInfo *t)
 {
        unsigned char col[4], selectedCol[4], activeCol[4];
@@ -656,7 +662,7 @@ void initSnapping(TransInfo *t, wmOperator *op)
        /* use scene defaults only when transform is modal */
        else if (t->flag & T_MODAL) {
                if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) {
-                       if (ts->snap_flag & SCE_SNAP) {
+                       if (transformModeUseSnap(t) && (ts->snap_flag & SCE_SNAP)) {
                                t->modifiers |= MOD_SNAP;
                        }
 
index 8be63add398fb6fce3090bb9a109a0a4860dd2e0..d312566a4fda00d772fe9eb7863a3dff0d5a81ce 100644 (file)
@@ -1351,7 +1351,7 @@ typedef struct ToolSettings {
        char snap_uv_mode;
        char snap_flag;
        char snap_target;
-       char snap_force_increment_flag;
+       char snap_transform_mode_flag;
 
 
        char proportional, prop_mode;
@@ -1910,11 +1910,11 @@ enum {
 #define SCE_SNAP_MODE_NODE_X    (1 << 6)
 #define SCE_SNAP_MODE_NODE_Y    (1 << 7)
 
-/** #ToolSettings.snap_force_increment_flag */
+/** #ToolSettings.snap_transform_mode_flag */
 enum {
-       SCE_SNAP_FORCE_INCREMENT_TRANSLATE  = (1 << 0),
-       SCE_SNAP_FORCE_INCREMENT_ROTATE     = (1 << 1),
-       SCE_SNAP_FORCE_INCREMENT_SCALE      = (1 << 2),
+       SCE_SNAP_TRANSFORM_MODE_TRANSLATE  = (1 << 0),
+       SCE_SNAP_TRANSFORM_MODE_ROTATE     = (1 << 1),
+       SCE_SNAP_TRANSFORM_MODE_SCALE      = (1 << 2),
 };
 
 /* ToolSettings.selectmode */
index 52e4c62ea00e812bd24e93c1cc85f346c53f306f..037b16ab5df831d38ce75c20e7382cf14c7f9934 100644 (file)
@@ -2478,24 +2478,24 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
        RNA_def_property_ui_text(prop, "Project onto Self", "Snap onto itself (Edit Mode Only)");
        RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
 
-       prop = RNA_def_property(srna, "use_snap_force_increment_translate", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_negative_sdna(prop, NULL, "snap_force_increment_flag", SCE_SNAP_FORCE_INCREMENT_TRANSLATE);
-       RNA_def_property_ui_text(prop, "Resctrict Translation",
-                                "Translate uses the snapping modes, otherwise use increment snapping");
+       prop = RNA_def_property(srna, "use_snap_translate", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "snap_transform_mode_flag", SCE_SNAP_TRANSFORM_MODE_TRANSLATE);
+       RNA_def_property_ui_text(prop, "Use Snap for Translation",
+                                "Move is affected by snapping settings");
        RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
 
-       prop = RNA_def_property(srna, "use_snap_force_increment_rotate", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_negative_sdna(prop, NULL, "snap_force_increment_flag", SCE_SNAP_FORCE_INCREMENT_ROTATE);
+       prop = RNA_def_property(srna, "use_snap_rotate", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "snap_transform_mode_flag", SCE_SNAP_TRANSFORM_MODE_ROTATE);
        RNA_def_property_boolean_default(prop, false);
-       RNA_def_property_ui_text(prop, "Resctrict Rotate",
-                                "Rotate uses the snapping modes, otherwise use increment snapping");
+       RNA_def_property_ui_text(prop, "Use Snap for Rotation",
+                                "Rotate is affected by the snapping settings");
        RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
 
-       prop = RNA_def_property(srna, "use_snap_force_increment_scale", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_negative_sdna(prop, NULL, "snap_force_increment_flag", SCE_SNAP_FORCE_INCREMENT_SCALE);
+       prop = RNA_def_property(srna, "use_snap_scale", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "snap_transform_mode_flag", SCE_SNAP_TRANSFORM_MODE_SCALE);
        RNA_def_property_boolean_default(prop, false);
-       RNA_def_property_ui_text(prop, "Resctrict Scale",
-                                "Scale uses the snapping modes, otherwise use increment snapping");
+       RNA_def_property_ui_text(prop, "Use Snap for Scale",
+                                "Scale is affected by snapping settings");
        RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
 
        prop = RNA_def_property(srna, "use_gizmo_mode", PROP_ENUM, PROP_NONE);