From 64696cc699323da621fd0773ad0ec49a8ae757d9 Mon Sep 17 00:00:00 2001 From: Kamil Galik Date: Thu, 5 Jun 2025 20:30:29 +1000 Subject: [PATCH] NDOF: simplify the UI and preferences - Navigation modes has been redefined a bit and introduced in a form of an enum so that new ones can me implemented in the future. Additionally switching between modes shouldn't require any additional configurations like inverting all the axes. Currently there are only 2 modes implemented, but 2 more are planned and will be proposed in follow-up PRs. Implemented modes are: - Object: works like "Orbit" option. but has all axes implicitly inverted - Fly: works the same as "Free". - "Turntable" option has been turned into "Lock Horizon". This single option works for both normal navigation and Fly/Walk modes now. - Pan and Rotation axes inversion has been removed from default configuration. - UI has been simplified following the design from #136880. - Zoom Invert has been removed since it looks like a duplication of `NDOF_PANZ_INVERT`. Ref !139343 --- release/datafiles/userdef/userdef_default.c | 9 +-- scripts/startup/bl_ui/space_userpref.py | 61 +++++++++-------- .../editors/interface/view2d/view2d_ops.cc | 4 +- source/blender/editors/space_clip/clip_ops.cc | 2 +- .../blender/editors/space_image/image_ops.cc | 2 +- .../editors/space_view3d/view3d_draw.cc | 2 +- .../editors/space_view3d/view3d_navigate.cc | 2 +- .../space_view3d/view3d_navigate_view_ndof.cc | 25 +++---- source/blender/makesdna/DNA_userdef_types.h | 39 +++++++++-- source/blender/makesrna/intern/rna_userdef.cc | 67 +++++++++++-------- source/blender/makesrna/intern/rna_wm.cc | 2 +- source/blender/windowmanager/WM_api.hh | 4 +- .../windowmanager/intern/wm_event_query.cc | 21 +++++- 13 files changed, 143 insertions(+), 97 deletions(-) diff --git a/release/datafiles/userdef/userdef_default.c b/release/datafiles/userdef/userdef_default.c index 500eaca3bd1..e81d5a32c26 100644 --- a/release/datafiles/userdef/userdef_default.c +++ b/release/datafiles/userdef/userdef_default.c @@ -157,13 +157,8 @@ const UserDef U_default = { .ndof_sensitivity = 4.0, .ndof_orbit_sensitivity = 4.0, .ndof_deadzone = 0.0, - .ndof_flag = (NDOF_SHOW_GUIDE_ORBIT_CENTER | NDOF_ORBIT_CENTER_AUTO | NDOF_MODE_ORBIT | - NDOF_LOCK_HORIZON | NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE | - /* Software from the driver authors follows this convention - * so invert this by default, see: #67579. */ - NDOF_ROTX_INVERT_AXIS | NDOF_ROTY_INVERT_AXIS | NDOF_ROTZ_INVERT_AXIS | - NDOF_PANX_INVERT_AXIS | NDOF_PANY_INVERT_AXIS | NDOF_PANZ_INVERT_AXIS | - NDOF_ZOOM_INVERT | NDOF_CAMERA_PAN_ZOOM), + .ndof_flag = (NDOF_SHOW_GUIDE_ORBIT_CENTER | NDOF_ORBIT_CENTER_AUTO | NDOF_LOCK_HORIZON | + NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE | NDOF_CAMERA_PAN_ZOOM), .image_draw_method = IMAGE_DRAW_METHOD_AUTO, .glalphaclip = 0.004, .autokey_mode = (AUTOKEY_MODE_NORMAL & ~AUTOKEY_ON), diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index e8f682b6d0f..9952ca2498f 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -2072,25 +2072,17 @@ class USERPREF_PT_ndof_settings(Panel): @staticmethod def draw_settings(layout, props, show_3dview_settings=True): - col = layout.column() - col.prop(props, "ndof_sensitivity", text="Pan Sensitivity") - col.prop(props, "ndof_orbit_sensitivity") - col.prop(props, "ndof_deadzone") layout.separator() if show_3dview_settings: col = layout.column() - col.row().prop(props, "ndof_view_navigate_method", expand=True, text="Navigation") - col.row().prop(props, "ndof_view_rotate_method", expand=True, text="Rotation") + col.row().prop(props, "ndof_navigation_mode", text="Navigation Mode") + col.prop(props, "ndof_lock_horizon", text="Lock Horizon") layout.separator() if show_3dview_settings: - col = layout.column(heading="Show Guides") - col.prop(props, "ndof_show_guide_orbit_axis", text="Orbit Axis") - col.prop(props, "ndof_show_guide_orbit_center", text="Orbit Center") - col = layout.column(heading="Orbit Center") col.prop(props, "ndof_orbit_center_auto") colsub = col.column() @@ -2099,36 +2091,43 @@ class USERPREF_PT_ndof_settings(Panel): del colsub col.separator() - col = layout.column(heading="Zoom") - col.prop(props, "ndof_zoom_invert") - col.prop(props, "ndof_lock_camera_pan_zoom") - row = col.row(heading="Pan") - row.prop(props, "ndof_pan_yz_swap_axis", text="Swap Y and Z Axes") + col = layout.column(heading="Show") + col.prop(props, "ndof_show_guide_orbit_axis", text="Orbit Axis") + col.prop(props, "ndof_show_guide_orbit_center", text="Orbit Center") layout.separator() - row = layout.row(heading=("Invert Axis Pan" if show_3dview_settings else "Invert Pan Axis")) - for text, attr in ( - ("X", "ndof_panx_invert_axis"), - ("Y", "ndof_pany_invert_axis"), - ("Z", "ndof_panz_invert_axis"), - ): - row.prop(props, attr, text=text, toggle=True) + layout_header, layout_advanced = layout.panel("NDOF_advanced", default_closed=True) + layout_header.label(text="Advanced") + if layout_advanced: + col = layout_advanced.column() + col.prop(props, "ndof_sensitivity", text="Pan Sensitivity") + col.prop(props, "ndof_orbit_sensitivity") + col.prop(props, "ndof_deadzone") - if show_3dview_settings: - row = layout.row(heading="Orbit") + col.separator() + col.row().prop(props, "ndof_zoom_direction", expand=True) + col.separator() + + row = col.row(heading=("Invert Pan" if show_3dview_settings else "Invert Pan Axis")) for text, attr in ( - ("X", "ndof_rotx_invert_axis"), - ("Y", "ndof_roty_invert_axis"), - ("Z", "ndof_rotz_invert_axis"), + ("X", "ndof_panx_invert_axis"), + ("Y", "ndof_pany_invert_axis"), + ("Z", "ndof_panz_invert_axis"), ): row.prop(props, attr, text=text, toggle=True) - layout.separator() + if show_3dview_settings: + row = col.row(heading="Invert Rotate") + for text, attr in ( + ("X", "ndof_rotx_invert_axis"), + ("Y", "ndof_roty_invert_axis"), + ("Z", "ndof_rotz_invert_axis"), + ): + row.prop(props, attr, text=text, toggle=True) - col = layout.column(heading="Fly/Walk") - col.prop(props, "ndof_lock_horizon") - col.prop(props, "ndof_fly_helicopter") + if show_3dview_settings: + col.prop(props, "ndof_lock_camera_pan_zoom") def draw(self, context): layout = self.layout diff --git a/source/blender/editors/interface/view2d/view2d_ops.cc b/source/blender/editors/interface/view2d/view2d_ops.cc index d9c288f9098..07cf380367d 100644 --- a/source/blender/editors/interface/view2d/view2d_ops.cc +++ b/source/blender/editors/interface/view2d/view2d_ops.cc @@ -1532,7 +1532,7 @@ static wmOperatorStatus view2d_ndof_invoke(bContext *C, wmOperator *op, const wm if (has_translate) { float pan_vec[3]; - WM_event_ndof_pan_get(ndof, pan_vec, false); + WM_event_ndof_pan_get(ndof, pan_vec); pan_vec[0] *= speed; pan_vec[1] *= speed; @@ -1550,7 +1550,7 @@ static wmOperatorStatus view2d_ndof_invoke(bContext *C, wmOperator *op, const wm bool do_zoom_xy[2]; - if (U.ndof_flag & NDOF_ZOOM_INVERT) { + if (U.ndof_flag & NDOF_PANZ_INVERT_AXIS) { zoom_factor = -zoom_factor; } diff --git a/source/blender/editors/space_clip/clip_ops.cc b/source/blender/editors/space_clip/clip_ops.cc index 1212b9c823e..1a06f949967 100644 --- a/source/blender/editors/space_clip/clip_ops.cc +++ b/source/blender/editors/space_clip/clip_ops.cc @@ -1654,7 +1654,7 @@ static wmOperatorStatus clip_view_ndof_invoke(bContext *C, const wmNDOFMotionData *ndof = static_cast(event->customdata); const float pan_speed = NDOF_PIXELS_PER_SECOND; - WM_event_ndof_pan_get(ndof, pan_vec, true); + WM_event_ndof_pan_get(ndof, pan_vec); mul_v3_fl(pan_vec, ndof->dt); mul_v2_fl(pan_vec, pan_speed / sc->zoom); diff --git a/source/blender/editors/space_image/image_ops.cc b/source/blender/editors/space_image/image_ops.cc index 2970ac5a19c..4ce286d15a3 100644 --- a/source/blender/editors/space_image/image_ops.cc +++ b/source/blender/editors/space_image/image_ops.cc @@ -795,7 +795,7 @@ static wmOperatorStatus image_view_ndof_invoke(bContext *C, const wmNDOFMotionData *ndof = static_cast(event->customdata); const float pan_speed = NDOF_PIXELS_PER_SECOND; - WM_event_ndof_pan_get(ndof, pan_vec, true); + WM_event_ndof_pan_get(ndof, pan_vec); mul_v3_fl(pan_vec, ndof->dt); mul_v2_fl(pan_vec, pan_speed / sima->zoom); diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index e87edc98f48..787ba5f7a63 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -1526,7 +1526,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *region) if (U.ndof_flag & NDOF_SHOW_GUIDE_ORBIT_CENTER) { /* Draw this only when orbiting and auto orbit-center is enabled */ - if ((U.ndof_flag & NDOF_MODE_ORBIT) && (U.ndof_flag & NDOF_ORBIT_CENTER_AUTO)) { + if (NDOF_IS_ORBIT_AROUND_CENTER_MODE(&U) && (U.ndof_flag & NDOF_ORBIT_CENTER_AUTO)) { if (rv3d->ndof_flag & RV3D_NDOF_OFS_IS_VALID) { /* When the center is locked, the auto-center is not used. */ if (!(v3d->ob_center_cursor || v3d->ob_center)) { diff --git a/source/blender/editors/space_view3d/view3d_navigate.cc b/source/blender/editors/space_view3d/view3d_navigate.cc index 3d9909d24e6..e9ed8dacb03 100644 --- a/source/blender/editors/space_view3d/view3d_navigate.cc +++ b/source/blender/editors/space_view3d/view3d_navigate.cc @@ -249,7 +249,7 @@ void ViewOpsData::init_navigation(bContext *C, * Logically it doesn't make sense to use the selection as a pivot when the first-person * navigation pivots from the view-point. This also interferes with zoom-speed, * causing zoom-speed scale based on the distance to the selection center, see: #115253. */ - if ((U.ndof_flag & NDOF_MODE_ORBIT) == 0) { + if (U.ndof_navigation_mode == NDOF_NAVIGATION_MODE_FLY) { viewops_flag &= ~VIEWOPS_FLAG_ORBIT_SELECT; } } diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_ndof.cc b/source/blender/editors/space_view3d/view3d_navigate_view_ndof.cc index 6d184c0e2ee..1740dba482c 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_ndof.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_ndof.cc @@ -101,7 +101,7 @@ static float view3d_ndof_pan_speed_calc_from_dist(RegionView3D *rv3d, const floa static float view3d_ndof_pan_speed_calc(RegionView3D *rv3d) { float tvec[3]; - if ((U.ndof_flag & NDOF_MODE_ORBIT) && (U.ndof_flag & NDOF_ORBIT_CENTER_AUTO) && + if (NDOF_IS_ORBIT_AROUND_CENTER_MODE(&U) && (U.ndof_flag & NDOF_ORBIT_CENTER_AUTO) && (rv3d->ndof_flag & RV3D_NDOF_OFS_IS_VALID)) { negate_v3_v3(tvec, rv3d->ndof_ofs); @@ -133,7 +133,7 @@ static void view3d_ndof_pan_zoom(const wmNDOFMotionData *ndof, return; } - WM_event_ndof_pan_get(ndof, pan_vec, false); + WM_event_ndof_pan_get_for_navigation(ndof, pan_vec); if (has_zoom) { /* zoom with Z */ @@ -149,7 +149,7 @@ static void view3d_ndof_pan_zoom(const wmNDOFMotionData *ndof, if (ndof->tvec[2]) { float zoom_distance = rv3d->dist * ndof->dt * ndof->tvec[2]; - if (U.ndof_flag & NDOF_ZOOM_INVERT) { + if (U.ndof_flag & NDOF_PANZ_INVERT_AXIS) { zoom_distance = -zoom_distance; } @@ -202,7 +202,7 @@ static void view3d_ndof_orbit(const wmNDOFMotionData *ndof, invert_qt_qt_normalized(view_inv, rv3d->viewquat); - if (U.ndof_flag & NDOF_TURNTABLE) { + if (U.ndof_flag & NDOF_LOCK_HORIZON) { float rot[3]; /* Turntable view code adapted for 3D mouse use. */ @@ -211,7 +211,7 @@ static void view3d_ndof_orbit(const wmNDOFMotionData *ndof, float yvec[3] = {0, 1, 0}; /* only use XY, ignore Z */ - WM_event_ndof_rotate_get(ndof, rot); + WM_event_ndof_rotate_get_for_navigation(ndof, rot); /* Determine the direction of the X vector (for rotating up and down). */ mul_qt_v3(view_inv, xvec); @@ -301,7 +301,7 @@ void view3d_ndof_fly(const wmNDOFMotionData *ndof, speed *= 0.2f; } - WM_event_ndof_pan_get(ndof, trans, false); + WM_event_ndof_pan_get(ndof, trans); mul_v3_fl(trans, speed * ndof->dt); trans_orig_y = trans[1]; @@ -600,7 +600,7 @@ static wmOperatorStatus view3d_ndof_cameraview_pan_zoom(ViewOpsData *vod, const bool has_zoom = ndof->tvec[2] != 0.0f; float pan_vec[3]; - WM_event_ndof_pan_get(ndof, pan_vec, true); + WM_event_ndof_pan_get_for_navigation(ndof, pan_vec); mul_v3_fl(pan_vec, ndof->dt); /* NOTE: unlike image and clip views, the 2D pan doesn't have to be scaled by the zoom level. @@ -785,7 +785,7 @@ static wmOperatorStatus ndof_orbit_zoom_invoke_impl(bContext *C, /* NOTE: based on feedback from #67579, users want to have pan and orbit enabled at once. * It's arguable that orbit shouldn't pan (since we have a pan only operator), * so if there are users who like to separate orbit/pan operations - it can be a preference. */ - const bool is_orbit_around_pivot = (U.ndof_flag & NDOF_MODE_ORBIT) || + const bool is_orbit_around_pivot = NDOF_IS_ORBIT_AROUND_CENTER_MODE(&U) || ED_view3d_offset_lock_check(v3d, rv3d); const bool has_rotation = ndof_has_rotate(ndof, rv3d); bool has_translate, has_zoom; @@ -954,15 +954,16 @@ static wmOperatorStatus ndof_all_invoke_impl(bContext *C, const wmEvent *event, PointerRNA * /*ptr*/) { - /* weak!, but it works */ - const int ndof_flag = U.ndof_flag; + wmOperatorStatus ret; - U.ndof_flag &= ~NDOF_MODE_ORBIT; + /* weak!, but it works */ + const uint8_t ndof_navigation_mode_backup = U.ndof_navigation_mode; + U.ndof_navigation_mode = NDOF_NAVIGATION_MODE_FLY; ret = ndof_orbit_zoom_invoke_impl(C, vod, event, nullptr); - U.ndof_flag = ndof_flag; + U.ndof_navigation_mode = ndof_navigation_mode_backup; return ret; } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 154b3446b4b..13b1600c4c8 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -516,9 +516,9 @@ typedef struct UserDef { float ndof_deadzone; /** #eNdof_Flag, flags for 3D mouse. */ int ndof_flag; - - /** #eMultiSample_Type, amount of samples for OpenGL FSA, if zero no FSA. */ - short ogl_multisamples; + /** #eNdof_Navigation_Mode, current navigation mode. */ + uint8_t ndof_navigation_mode; + char _pad17[1]; /** eImageDrawMethod, Method to be used to draw the images * (AUTO, GLSL, Textures or DrawPixels) */ @@ -1010,15 +1010,13 @@ typedef enum eNdof_Flag { NDOF_SHOULD_ZOOM = (1 << 4), NDOF_SHOULD_ROTATE = (1 << 5), - /* Orbit navigation modes. */ - - NDOF_MODE_ORBIT = (1 << 6), + // NDOF_UNUSED_6 = (1 << 6), /* Dirty. */ /* actually... users probably don't care about what the mode * is called, just that it feels right */ /* zoom is up/down if this flag is set (otherwise forward/backward) */ NDOF_PAN_YZ_SWAP_AXIS = (1 << 7), - NDOF_ZOOM_INVERT = (1 << 8), + // NDOF_UNUSED_8 = (1 << 8), /* Dirty. */ NDOF_ROTX_INVERT_AXIS = (1 << 9), NDOF_ROTY_INVERT_AXIS = (1 << 10), NDOF_ROTZ_INVERT_AXIS = (1 << 11), @@ -1032,6 +1030,33 @@ typedef enum eNdof_Flag { NDOF_SHOW_GUIDE_ORBIT_CENTER = (1 << 19), } eNdof_Flag; +/** + * NDOF Navigation Modes. + * Each mode describes some style of navigation rather than control a single aspect of navigation. + */ +typedef enum eNdof_Navigation_Mode { + /** + * 3D mouse cap represents objects movement in 3D space. + * Pulling the cap will pull the objects closer to the camera. + */ + NDOF_NAVIGATION_MODE_OBJECT = 0, + /** + * 3D mouse cap controls the movement of the view window + * and allows for flying through the scene. + */ + NDOF_NAVIGATION_MODE_FLY = 1, + /* TODO: implement "Target Camera Mode" and "Drone Mode" */ +} eNdof_Navigation_Mode; + +/** + * Some navigation modes make use of "Auto Center" (#NDOF_ORBIT_CENTER_AUTO) and some don't. + * Instead of testing against all possibilities use a macro. + * + * TODO: Add Target Camera Mode when implemented. + */ +#define NDOF_IS_ORBIT_AROUND_CENTER_MODE(userdef) \ + ((userdef)->ndof_navigation_mode == NDOF_NAVIGATION_MODE_OBJECT) + #define NDOF_PIXELS_PER_SECOND 600.0f /** UserDef.ogl_multisamples */ diff --git a/source/blender/makesrna/intern/rna_userdef.cc b/source/blender/makesrna/intern/rna_userdef.cc index e7a237c1e5c..c2543906a96 100644 --- a/source/blender/makesrna/intern/rna_userdef.cc +++ b/source/blender/makesrna/intern/rna_userdef.cc @@ -6470,18 +6470,33 @@ static void rna_def_userdef_input(BlenderRNA *brna) # ifdef WITH_INPUT_NDOF static const EnumPropertyItem ndof_view_navigation_items[] = { - {0, "FREE", 0, "Free", "Use full 6 degrees of freedom by default"}, - {NDOF_MODE_ORBIT, "ORBIT", 0, "Orbit", "Orbit about the view center by default"}, + {NDOF_NAVIGATION_MODE_OBJECT, + "OBJECT", + 0, + "Object", + "This mode is like reaching into the screen and holding the model in your hand. " + "Push the 3D Mouse cap left, and the model moves left. Push right and the model " + "moves right"}, + {NDOF_NAVIGATION_MODE_FLY, + "FLY", + 0, + "Fly", + "Enables using the 3D Mouse as if it is a camera. Push into the scene and the camera " + "moves forward into the scene. You are entering the scene as if flying around in it"}, {0, nullptr, 0, nullptr, nullptr}, }; - static const EnumPropertyItem ndof_view_rotation_items[] = { - {NDOF_TURNTABLE, - "TURNTABLE", + static const EnumPropertyItem ndof_zoom_direction_items[] = { + {0, + "NDOF_ZOOM_FORWARD", 0, - "Turntable", - "Use turntable style rotation in the viewport"}, - {0, "TRACKBALL", 0, "Trackball", "Use trackball style rotation in the viewport"}, + "Forward/Backward", + "Zoom by pulling the 3D Mouse cap upwards or pushing the cap downwards"}, + {NDOF_PAN_YZ_SWAP_AXIS, + "NDOF_ZOOM_UP", + 0, + "Up/Down", + "Zoom by pulling the 3D Mouse cap upwards or pushing the cap downwards"}, {0, nullptr, 0, nullptr, nullptr}, }; # endif /* WITH_INPUT_NDOF */ @@ -6714,14 +6729,11 @@ static void rna_def_userdef_input(BlenderRNA *brna) prop, "Deadzone", "Threshold of initial movement needed from the device's rest position"); RNA_def_property_update(prop, 0, "rna_userdef_ndof_deadzone_update"); - prop = RNA_def_property(srna, "ndof_pan_yz_swap_axis", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "ndof_flag", NDOF_PAN_YZ_SWAP_AXIS); + prop = RNA_def_property(srna, "ndof_zoom_direction", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, nullptr, "ndof_flag"); + RNA_def_property_enum_items(prop, ndof_zoom_direction_items); RNA_def_property_ui_text( - prop, "Y/Z Swap Axis", "Pan using up/down on the device (otherwise forward/backward)"); - - prop = RNA_def_property(srna, "ndof_zoom_invert", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "ndof_flag", NDOF_ZOOM_INVERT); - RNA_def_property_ui_text(prop, "Invert Zoom", "Zoom using opposite direction"); + prop, "Zoom direction", "Which axis of the 3D Mouse cap zooms the view"); /* 3D view */ prop = RNA_def_property(srna, "ndof_show_guide_orbit_axis", PROP_BOOLEAN, PROP_NONE); @@ -6738,15 +6750,16 @@ static void rna_def_userdef_input(BlenderRNA *brna) prop, "Show Orbit Center Guide", "Display the orbit center during rotation"); /* 3D view */ - prop = RNA_def_property(srna, "ndof_view_navigate_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, nullptr, "ndof_flag"); + prop = RNA_def_property(srna, "ndof_navigation_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, ndof_view_navigation_items); - RNA_def_property_ui_text(prop, "NDOF View Navigate", "Navigation style in the viewport"); + RNA_def_property_ui_text(prop, "NDOF View Navigate", "3D Mouse Navigation Mode"); - prop = RNA_def_property(srna, "ndof_view_rotate_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, nullptr, "ndof_flag"); - RNA_def_property_enum_items(prop, ndof_view_rotation_items); - RNA_def_property_ui_text(prop, "NDOF View Rotation", "Rotation style in the viewport"); + prop = RNA_def_property(srna, "ndof_lock_horizon", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, nullptr, "ndof_flag", NDOF_LOCK_HORIZON); + RNA_def_property_ui_text( + prop, + "NDOF Lock Horizon", + "Lock Horizon forces the horizon to be kept leveled as it currently is"); prop = RNA_def_property(srna, "ndof_orbit_center_auto", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "ndof_flag", NDOF_ORBIT_CENTER_AUTO); @@ -6761,8 +6774,8 @@ static void rna_def_userdef_input(BlenderRNA *brna) prop = RNA_def_property(srna, "ndof_orbit_center_selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "ndof_flag", NDOF_ORBIT_CENTER_SELECTED); RNA_def_property_ui_text(prop, - "Use Selected Items", - "Use selected item forces the orbit center " + "Selected Items", + "Selected Item forces the orbit center " "to only take the currently selected objects into account."); /* 3D view: yaw */ @@ -6796,10 +6809,6 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Invert Z Axis", ""); /* 3D view: fly */ - prop = RNA_def_property(srna, "ndof_lock_horizon", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "ndof_flag", NDOF_LOCK_HORIZON); - RNA_def_property_ui_text(prop, "Lock Horizon", "Keep horizon level while flying with 3D Mouse"); - prop = RNA_def_property(srna, "ndof_fly_helicopter", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "ndof_flag", NDOF_FLY_HELICOPTER); RNA_def_property_ui_text(prop, @@ -6810,7 +6819,7 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, nullptr, "ndof_flag", NDOF_CAMERA_PAN_ZOOM); RNA_def_property_ui_text( prop, - "Lock Camera Pan/Zoom", + "Pan / Zoom Camera View", "Pan/zoom the camera view instead of leaving the camera view when orbiting"); # endif /* WITH_INPUT_NDOF */ diff --git a/source/blender/makesrna/intern/rna_wm.cc b/source/blender/makesrna/intern/rna_wm.cc index 592f9a18b49..7daf548c183 100644 --- a/source/blender/makesrna/intern/rna_wm.cc +++ b/source/blender/makesrna/intern/rna_wm.cc @@ -811,7 +811,7 @@ static void rna_NDOFMotionEventData_translation_get(PointerRNA *ptr, float *valu { # ifdef WITH_INPUT_NDOF const wmNDOFMotionData *ndof = static_cast(ptr->data); - WM_event_ndof_pan_get(ndof, values, false); + WM_event_ndof_pan_get(ndof, values); # else UNUSED_VARS(ptr); ARRAY_SET_ITEMS(values, 0, 0, 0); diff --git a/source/blender/windowmanager/WM_api.hh b/source/blender/windowmanager/WM_api.hh index 8ab91a2df3e..7f21cad4167 100644 --- a/source/blender/windowmanager/WM_api.hh +++ b/source/blender/windowmanager/WM_api.hh @@ -2011,7 +2011,9 @@ int WM_userdef_event_map(int kmitype); int WM_userdef_event_type_from_keymap_type(int kmitype); #ifdef WITH_INPUT_NDOF -void WM_event_ndof_pan_get(const wmNDOFMotionData *ndof, float r_pan[3], bool use_zoom); +void WM_event_ndof_pan_get_for_navigation(const wmNDOFMotionData *ndof, float r_pan[3]); +void WM_event_ndof_rotate_get_for_navigation(const wmNDOFMotionData *ndof, float r_rot[3]); +void WM_event_ndof_pan_get(const wmNDOFMotionData *ndof, float r_pan[3]); void WM_event_ndof_rotate_get(const wmNDOFMotionData *ndof, float r_rot[3]); float WM_event_ndof_to_axis_angle(const wmNDOFMotionData *ndof, float axis[3]); diff --git a/source/blender/windowmanager/intern/wm_event_query.cc b/source/blender/windowmanager/intern/wm_event_query.cc index 4f0c332251a..120f0d6e31f 100644 --- a/source/blender/windowmanager/intern/wm_event_query.cc +++ b/source/blender/windowmanager/intern/wm_event_query.cc @@ -511,12 +511,27 @@ int WM_userdef_event_type_from_keymap_type(int kmitype) #ifdef WITH_INPUT_NDOF -void WM_event_ndof_pan_get(const wmNDOFMotionData *ndof, float r_pan[3], const bool use_zoom) +void WM_event_ndof_pan_get_for_navigation(const wmNDOFMotionData *ndof, float r_pan[3]) +{ + const float sign = (U.ndof_navigation_mode == NDOF_NAVIGATION_MODE_OBJECT) ? -1.0f : 1.0f; + r_pan[0] = ndof->tvec[0] * ((U.ndof_flag & NDOF_PANX_INVERT_AXIS) ? -sign : sign); + r_pan[1] = ndof->tvec[1] * ((U.ndof_flag & NDOF_PANY_INVERT_AXIS) ? -sign : sign); + r_pan[2] = ndof->tvec[2] * ((U.ndof_flag & NDOF_PANZ_INVERT_AXIS) ? -sign : sign); +} + +void WM_event_ndof_rotate_get_for_navigation(const wmNDOFMotionData *ndof, float r_rot[3]) +{ + const float sign = (U.ndof_navigation_mode == NDOF_NAVIGATION_MODE_OBJECT) ? -1.0f : 1.0f; + r_rot[0] = ndof->rvec[0] * ((U.ndof_flag & NDOF_ROTX_INVERT_AXIS) ? -sign : sign); + r_rot[1] = ndof->rvec[1] * ((U.ndof_flag & NDOF_ROTY_INVERT_AXIS) ? -sign : sign); + r_rot[2] = ndof->rvec[2] * ((U.ndof_flag & NDOF_ROTZ_INVERT_AXIS) ? -sign : sign); +} + +void WM_event_ndof_pan_get(const wmNDOFMotionData *ndof, float r_pan[3]) { - int z_flag = use_zoom ? NDOF_ZOOM_INVERT : NDOF_PANZ_INVERT_AXIS; r_pan[0] = ndof->tvec[0] * ((U.ndof_flag & NDOF_PANX_INVERT_AXIS) ? -1.0f : 1.0f); r_pan[1] = ndof->tvec[1] * ((U.ndof_flag & NDOF_PANY_INVERT_AXIS) ? -1.0f : 1.0f); - r_pan[2] = ndof->tvec[2] * ((U.ndof_flag & z_flag) ? -1.0f : 1.0f); + r_pan[2] = ndof->tvec[2] * ((U.ndof_flag & NDOF_PANZ_INVERT_AXIS) ? -1.0f : 1.0f); } void WM_event_ndof_rotate_get(const wmNDOFMotionData *ndof, float r_rot[3])