[Bf-blender-cvs] [e82b7f15270] master: 3D View: preferences for rotate sensitivity

Campbell Barton noreply at git.blender.org
Sat Aug 3 17:49:31 CEST 2019


Commit: e82b7f15270eb4e4dbcd119ea09d1f0204f1dc11
Author: Campbell Barton
Date:   Sun Aug 4 01:22:38 2019 +1000
Branches: master
https://developer.blender.org/rBe82b7f15270eb4e4dbcd119ea09d1f0204f1dc11

3D View: preferences for rotate sensitivity

Added because the current default is too fast
for painting with tablets, see D5385.

Turntable and trackball have different settings because
turn-table uses an angle-per-pixel, where as trackball
values are relative to the view-port size so a scale is used.

The sensitivity is scaled by the pixel size so hi-dpi views don't rotate faster.

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

M	release/datafiles/userdef/userdef_default.c
M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/release/datafiles/userdef/userdef_default.c b/release/datafiles/userdef/userdef_default.c
index e41e801c2f2..73146e59123 100644
--- a/release/datafiles/userdef/userdef_default.c
+++ b/release/datafiles/userdef/userdef_default.c
@@ -16,9 +16,14 @@
 
 /* Preferences Data File 'U_default'. */
 
+/* For constants. */
+#include <math.h>
+
 #include "DNA_userdef_types.h"
 #include "DNA_curve_types.h"
 
+#include "BLI_math_rotation.h"
+
 #include "BKE_blender_version.h"
 
 const UserDef U_default = {
@@ -153,6 +158,8 @@ const UserDef U_default = {
     .autokey_flag = AUTOKEY_FLAG_XYZ2RGB,
     .text_render = 0,
     .navigation_mode = VIEW_NAVIGATION_WALK,
+    .view_rotate_sensitivity_turntable = DEG2RAD(0.4),
+    .view_rotate_sensitivity_trackball = 1.0f,
 
     /** Initialized by #BKE_colorband_init. */
     .coba_weight = {0},
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 6a18766fae2..08f36bb15bb 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1459,6 +1459,11 @@ class USERPREF_PT_navigation_orbit(PreferencePanel, Panel):
         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
 
         flow.row().prop(inputs, "view_rotate_method", expand=True)
+        if inputs.view_rotate_method == 'TURNTABLE':
+            flow.prop(inputs, "view_rotate_sensitivity_turntable")
+        else:
+            flow.prop(inputs, "view_rotate_sensitivity_trackball")
+
         flow.prop(inputs, "use_rotate_around_active")
         flow.prop(inputs, "use_auto_perspective")
         flow.prop(inputs, "use_mouse_depth_navigate")
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 1a79b7c9b5a..5780221bcc5 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -3551,5 +3551,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
 
   {
     /* Versioning code until next subversion bump goes here. */
+    if (U.view_rotate_sensitivity_turntable == 0) {
+      U.view_rotate_sensitivity_turntable = DEG2RADF(0.4f);
+      U.view_rotate_sensitivity_trackball = 1.0f;
+    }
   }
 }
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 0d0cfce07d7..62673d9bd5a 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -729,6 +729,10 @@ static void viewrotate_apply(ViewOpsData *vod, const int event_xy[2])
 
     angle = (len_v3(dvec) / (2.0f * TRACKBALLSIZE)) * (float)M_PI;
 
+    /* Before applying the sensitivity this is rotating 1:1,
+     * where the cursor would match the surface of a sphere in the view. */
+    angle *= U.view_rotate_sensitivity_trackball;
+
     /* Allow for rotation beyond the interval [-pi, pi] */
     angle = angle_wrap_rad(angle);
 
@@ -751,11 +755,8 @@ static void viewrotate_apply(ViewOpsData *vod, const int event_xy[2])
     const float zvec_global[3] = {0.0f, 0.0f, 1.0f};
     float xaxis[3];
 
-    /* Sensitivity will control how fast the viewport rotates.  0.007 was
-     * obtained experimentally by looking at viewport rotation sensitivities
-     * on other modeling programs. */
-    /* Perhaps this should be a configurable user parameter. */
-    const float sensitivity = 0.007f;
+    /* Radians per-pixel. */
+    const float sensitivity = U.view_rotate_sensitivity_turntable / U.pixelsize;
 
     /* Get the 3x3 matrix and its inverse from the quaternion */
     quat_to_mat3(m, vod->curr.viewquat);
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 2d3d091c65d..b90f1fd16df 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -735,11 +735,16 @@ typedef struct UserDef {
   short autokey_flag;
 
   /** Options for text rendering. */
-  short text_render;
-  char _pad9;
-
+  char text_render;
   char navigation_mode;
 
+  char _pad9[2];
+
+  /** Turn-table rotation amount per-pixel in radians. Scaled with DPI. */
+  float view_rotate_sensitivity_turntable;
+  /** Track-ball rotation scale. */
+  float view_rotate_sensitivity_trackball;
+
   /** From texture.h. */
   struct ColorBand coba_weight;
 
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 7b7d9e71cd2..e649a95fb06 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -30,6 +30,7 @@
 
 #include "BLI_utildefines.h"
 #include "BLI_math_base.h"
+#include "BLI_math_rotation.h"
 
 #include "BLT_translation.h"
 
@@ -5230,6 +5231,20 @@ static void rna_def_userdef_input(BlenderRNA *brna)
   RNA_def_property_struct_type(prop, "WalkNavigation");
   RNA_def_property_ui_text(prop, "Walk Navigation", "Settings for walk navigation mode");
 
+  prop = RNA_def_property(srna, "view_rotate_sensitivity_turntable", PROP_FLOAT, PROP_ANGLE);
+  RNA_def_property_range(prop, DEG2RADF(0.001f), DEG2RADF(15.0f));
+  RNA_def_property_float_default(prop, DEG2RADF(0.4f));
+  RNA_def_property_ui_range(prop, DEG2RADF(0.001f), DEG2RADF(15.0f), 1.0f, 2);
+  RNA_def_property_ui_text(prop,
+                           "Rotate Sensitivity",
+                           "Rotation amount per-pixel to control how fast the viewport rotates");
+
+  prop = RNA_def_property(srna, "view_rotate_sensitivity_trackball", PROP_FLOAT, PROP_FACTOR);
+  RNA_def_property_range(prop, 0.1f, 10.0f);
+  RNA_def_property_float_default(prop, 1.0f);
+  RNA_def_property_ui_range(prop, 0.1f, 2.0f, 0.01f, 2);
+  RNA_def_property_ui_text(prop, "Rotate Sensitivity", "Scale trackball rotation sensitivity");
+
   /* tweak tablet & mouse preset */
   prop = RNA_def_property(srna, "drag_threshold_mouse", PROP_INT, PROP_PIXEL);
   RNA_def_property_range(prop, 1, 255);



More information about the Bf-blender-cvs mailing list