Apply patch [#28415] 3d mouse orbit mode individual axes enhancement
authorNathan Letwory <nathan@letworyinteractive.com>
Wed, 7 Sep 2011 10:33:46 +0000 (10:33 +0000)
committerNathan Letwory <nathan@letworyinteractive.com>
Wed, 7 Sep 2011 10:33:46 +0000 (10:33 +0000)
Submitted by Rainer Wahler

This patch enables individual axis inversion in trackball mode.

release/scripts/startup/bl_ui/space_userpref.py
source/blender/editors/space_view3d/view3d_edit.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c

index 13edc3471d2034b786116f4bd2763286842b91d3..67aca5eb4c151d37d76e7e0eb4060030f8e2c37e 100644 (file)
@@ -773,7 +773,18 @@ class USERPREF_MT_ndof_settings(Menu):
 
             layout.separator()
             layout.label(text="orbit options")
-            layout.prop(input_prefs, "ndof_orbit_invert_axes")
+            if input_prefs.view_rotate_method == 'TRACKBALL':
+                layout.prop(input_prefs, "ndof_roll_invert_axis")
+                layout.prop(input_prefs, "ndof_tilt_invert_axis")
+                layout.prop(input_prefs, "ndof_rotate_invert_axis")
+            else:
+                layout.prop(input_prefs, "ndof_orbit_invert_axes")
+
+            layout.separator()
+            layout.label(text="pan options")
+            layout.prop(input_prefs, "ndof_panx_invert_axis")
+            layout.prop(input_prefs, "ndof_pany_invert_axis")
+            layout.prop(input_prefs, "ndof_panz_invert_axis")
 
             layout.separator()
             layout.label(text="fly options")
index 19e8d42db2d6ea94c8625e81c4c970c155cc7ce7..761de836cfb6120e1a64f65aacaf856d25172f0b 100644 (file)
@@ -1017,18 +1017,26 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
                
                        if (has_rotation) {
                
-                               const int invert = U.ndof_flag & NDOF_ORBIT_INVERT_AXES;
-               
                                rv3d->view = RV3D_VIEW_USER;
                
                                if (U.flag & USER_TRACKBALL) {
+                                       const int invert_roll = U.ndof_flag & NDOF_ROLL_INVERT_AXIS;
+                                       const int invert_tilt = U.ndof_flag & NDOF_TILT_INVERT_AXIS;
+                                       const int invert_rot = U.ndof_flag & NDOF_ROTATE_INVERT_AXIS;
+
                                        float rot[4];
                                        float axis[3];
                                        float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis);
-               
-                                       if (invert)
-                                               angle = -angle;
-               
+
+                                       if (invert_roll)
+                                               axis[2] = -axis[2];
+
+                                       if (invert_tilt)
+                                               axis[0] = -axis[0];
+
+                                       if (invert_rot)
+                                               axis[1] = -axis[1];
+
                                        // transform rotation axis from view to world coordinates
                                        mul_qt_v3(view_inv, axis);
                
@@ -1042,6 +1050,8 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event
                                        mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
                                } else {
                                        /* turntable view code by John Aughey, adapted for 3D mouse by [mce] */
+                                       const int invert = U.ndof_flag & NDOF_ORBIT_INVERT_AXES;
+
                                        float angle, rot[4];
                                        float xvec[3] = {1,0,0};
                
@@ -1143,10 +1153,26 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
                        const float vertical_sensitivity = 0.4f;
                        const float lateral_sensitivity = 0.6f;
 
-                       float pan_vec[3] = {lateral_sensitivity * ndof->tvec[0],
-                                                               vertical_sensitivity * ndof->tvec[1],
-                                                               forward_sensitivity * ndof->tvec[2]
-                                                          };
+                       const int invert_panx = U.ndof_flag & NDOF_PANX_INVERT_AXIS;
+                       const int invert_pany = U.ndof_flag & NDOF_PANY_INVERT_AXIS;
+                       const int invert_panz = U.ndof_flag & NDOF_PANZ_INVERT_AXIS;
+
+                       float pan_vec[3];
+
+                       if (invert_panx)
+                               pan_vec[0] = -lateral_sensitivity * ndof->tvec[0];
+                       else
+                               pan_vec[0] = lateral_sensitivity * ndof->tvec[0];
+
+                       if (invert_panz)
+                               pan_vec[1] = -vertical_sensitivity * ndof->tvec[1];
+                       else
+                               pan_vec[1] = vertical_sensitivity * ndof->tvec[1];
+
+                       if (invert_pany)
+                               pan_vec[2] = -forward_sensitivity * ndof->tvec[2];
+                       else
+                               pan_vec[2] = forward_sensitivity * ndof->tvec[2];
 
                        mul_v3_fl(pan_vec, speed * dt);
 #endif
index 43dc532d4f63edffc40c1aa769f90759d8094bb2..d3ac09dc812243cdab00077d56990f1d960038ee 100644 (file)
@@ -607,6 +607,12 @@ extern UserDef U; /* from blenkernel blender.c */
 /* zoom is up/down if this flag is set (otherwise forward/backward) */
 #define NDOF_ZOOM_UPDOWN (1 << 7)
 #define NDOF_ZOOM_INVERT (1 << 8)
+#define NDOF_ROTATE_INVERT_AXIS (1 << 9)
+#define NDOF_TILT_INVERT_AXIS (1 << 10)
+#define NDOF_ROLL_INVERT_AXIS (1 << 11)
+#define NDOF_PANX_INVERT_AXIS (1 << 12)
+#define NDOF_PANY_INVERT_AXIS (1 << 13)
+#define NDOF_PANZ_INVERT_AXIS (1 << 14)
 
 
 #ifdef __cplusplus
index 7d0502f1be9a2c179dc0e9258ef6648d16b3fcc4..66c4e7245c4657e3eecbe5df4445789104d8d2f5 100644 (file)
@@ -2791,6 +2791,36 @@ static void rna_def_userdef_input(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Invert Axes", "Toggle between moving the viewpoint or moving the scene being viewed");
        /* in 3Dx docs, this is called 'object mode' vs. 'target camera mode' */
 
+       /* 3D view: roll */
+       prop= RNA_def_property(srna, "ndof_roll_invert_axis", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_ROLL_INVERT_AXIS);
+       RNA_def_property_ui_text(prop, "Invert roll Axis", "Invert roll axis");
+
+       /* 3D view: tilt */
+       prop= RNA_def_property(srna, "ndof_tilt_invert_axis", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_TILT_INVERT_AXIS);
+       RNA_def_property_ui_text(prop, "Invert tilt Axis", "Invert tilt axis");
+
+       /* 3D view: rotate */
+       prop= RNA_def_property(srna, "ndof_rotate_invert_axis", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_ROTATE_INVERT_AXIS);
+       RNA_def_property_ui_text(prop, "Invert rotation Axis", "Invert rotation axis");
+
+       /* 3D view: pan x */
+       prop= RNA_def_property(srna, "ndof_panx_invert_axis", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_PANX_INVERT_AXIS);
+       RNA_def_property_ui_text(prop, "Invert x Axis", "Invert x axis");
+
+       /* 3D view: pan y */
+       prop= RNA_def_property(srna, "ndof_pany_invert_axis", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_PANY_INVERT_AXIS);
+       RNA_def_property_ui_text(prop, "Invert y Axis", "Invert y axis");
+
+       /* 3D view: pan z */
+       prop= RNA_def_property(srna, "ndof_panz_invert_axis", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_PANZ_INVERT_AXIS);
+       RNA_def_property_ui_text(prop, "Invert z Axis", "Invert z axis");
+
        /* 3D view: fly */
        prop= RNA_def_property(srna, "ndof_lock_horizon", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_LOCK_HORIZON);