From 5ed527d8b886498f2270c23a92ccd2e0cfc74cf0 Mon Sep 17 00:00:00 2001 From: marynate Date: Mon, 31 Mar 2014 11:07:21 +0800 Subject: Add maya style navigation scheme to 3d vieewport --- tools/editor/plugins/spatial_editor_plugin.cpp | 75 +++++++++++++++++++------- tools/editor/plugins/spatial_editor_plugin.h | 13 ++++- 2 files changed, 68 insertions(+), 20 deletions(-) (limited to 'tools/editor/plugins') diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 0014c5a68a..992ca0e36e 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -526,6 +526,14 @@ static int _get_key_modifier(const String& p_property) { return 0; } +SpatialEditorViewport::NavigationScheme SpatialEditorViewport::_get_navigation_schema(const String& p_property) { + switch(EditorSettings::get_singleton()->get(p_property).operator int()) { + case 1: return NAVIGATION_MAYA; + case 0: + default: + return NAVIGATION_GODOT; + } +} bool SpatialEditorViewport::_gizmo_select(const Vector2& p_screenpos,bool p_hilite_only) { @@ -1005,6 +1013,8 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { } + NavigationScheme nav_scheme = _get_navigation_schema("3d_editor/navigation_schema"); + NavigationMode nav_mode = NAVIGATION_NONE; if (_edit.gizmo.is_valid()) { @@ -1025,6 +1035,10 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { } else if (m.button_mask&1) { + if (nav_scheme == NAVIGATION_MAYA && m.mod.alt) { + nav_mode = NAVIGATION_ORBIT; + } + if (clicked) { if (!clicked_includes_current) { @@ -1041,16 +1055,17 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { } - if (cursor.region_select) { + if (cursor.region_select && nav_mode == NAVIGATION_NONE) { cursor.region_end=Point2(m.x,m.y); surface->update(); return; } - if (_edit.mode==TRANSFORM_NONE) + if (_edit.mode==TRANSFORM_NONE && nav_mode == NAVIGATION_NONE) break; + Vector3 ray_pos=_get_ray_pos( Vector2( m.x, m.y ) ); Vector3 ray=_get_ray( Vector2( m.x, m.y ) ); @@ -1277,23 +1292,41 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { default:{} } - } else if (m.button_mask&4) { - - - int mod = 0; - if (m.mod.shift) - mod=KEY_SHIFT; - if (m.mod.alt) - mod=KEY_ALT; - if (m.mod.control) - mod=KEY_CONTROL; - if (m.mod.meta) - mod=KEY_META; + } else if (m.button_mask&2) { + if (nav_scheme == NAVIGATION_MAYA && m.mod.alt) { + nav_mode = NAVIGATION_ZOOM; + } + } else if (m.button_mask&4) { - if (mod == _get_key_modifier("3d_editor/pan_modifier")) { + if (nav_scheme == NAVIGATION_GODOT) { + + int mod = 0; + if (m.mod.shift) + mod=KEY_SHIFT; + if (m.mod.alt) + mod=KEY_ALT; + if (m.mod.control) + mod=KEY_CONTROL; + if (m.mod.meta) + mod=KEY_META; + + if (mod == _get_key_modifier("3d_editor/pan_modifier")) + nav_mode = NAVIGATION_PAN; + else if (mod == _get_key_modifier("3d_editor/zoom_modifier")) + nav_mode = NAVIGATION_ZOOM; + else if (mod == _get_key_modifier("3d_editor/orbit_modifier")) + nav_mode = NAVIGATION_ORBIT; + + } else if (nav_scheme == NAVIGATION_MAYA) { + if (m.mod.alt) + nav_mode = NAVIGATION_PAN; + } + } + switch(nav_mode) { + case NAVIGATION_PAN:{ Transform camera_transform; @@ -1305,24 +1338,28 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { camera_transform.translate(translation); cursor.pos=camera_transform.origin; - } else if (mod == _get_key_modifier("3d_editor/zoom_modifier")) { + } break; + + case NAVIGATION_ZOOM: { if ( m.relative_y > 0) cursor.distance*=1+m.relative_y/80.0; else if (m.relative_y < 0) cursor.distance/=1-m.relative_y/80.0; - } else if (mod == _get_key_modifier("3d_editor/orbit_modifier")) { + } break; + + case NAVIGATION_ORBIT: { cursor.x_rot+=m.relative_y/80.0; cursor.y_rot+=m.relative_x/80.0; if (cursor.x_rot>Math_PI/2.0) cursor.x_rot=Math_PI/2.0; if (cursor.x_rot<-Math_PI/2.0) cursor.x_rot=-Math_PI/2.0; + } break; - } + default: {} } - } break; case InputEvent::KEY: { diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h index 308590ecea..30eba5facc 100644 --- a/tools/editor/plugins/spatial_editor_plugin.h +++ b/tools/editor/plugins/spatial_editor_plugin.h @@ -110,7 +110,6 @@ class SpatialEditorViewport : public Control { void _update_selection(); bool _gizmo_select(const Vector2& p_screenpos,bool p_hilite_only=false); - float get_znear() const; float get_zfar() const; float get_fov() const; @@ -119,6 +118,18 @@ class SpatialEditorViewport : public Control { bool clicked_includes_current; bool clicked_wants_append; + enum NavigationScheme { + NAVIGATION_GODOT, + NAVIGATION_MAYA + }; + NavigationScheme _get_navigation_schema(const String& p_property); + + enum NavigationMode { + NAVIGATION_NONE, + NAVIGATION_PAN, + NAVIGATION_ZOOM, + NAVIGATION_ORBIT + }; enum TransformMode { TRANSFORM_NONE, TRANSFORM_ROTATE, -- cgit v1.2.3 From eb294bb6eadc3dcb4e7c91459d5261ce10885c5d Mon Sep 17 00:00:00 2001 From: marynate Date: Mon, 31 Mar 2014 11:59:42 +0800 Subject: Disable transform operation when navigation --- tools/editor/plugins/spatial_editor_plugin.cpp | 361 +++++++++++++------------ 1 file changed, 181 insertions(+), 180 deletions(-) (limited to 'tools/editor/plugins') diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 992ca0e36e..600d4f5103 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -1037,259 +1037,260 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { if (nav_scheme == NAVIGATION_MAYA && m.mod.alt) { nav_mode = NAVIGATION_ORBIT; - } - - if (clicked) { + } else { + if (clicked) { - if (!clicked_includes_current) { - - _select_clicked(clicked_wants_append,true); - //clickd processing was deferred - } + if (!clicked_includes_current) { + _select_clicked(clicked_wants_append,true); + //clickd processing was deferred + } - _compute_edit(_edit.mouse_pos); - clicked=0; - - _edit.mode=TRANSFORM_TRANSLATE; - } + _compute_edit(_edit.mouse_pos); + clicked=0; - if (cursor.region_select && nav_mode == NAVIGATION_NONE) { + _edit.mode=TRANSFORM_TRANSLATE; - cursor.region_end=Point2(m.x,m.y); - surface->update(); - return; - } + } - if (_edit.mode==TRANSFORM_NONE && nav_mode == NAVIGATION_NONE) - break; + if (cursor.region_select && nav_mode == NAVIGATION_NONE) { + cursor.region_end=Point2(m.x,m.y); + surface->update(); + return; + } - Vector3 ray_pos=_get_ray_pos( Vector2( m.x, m.y ) ); - Vector3 ray=_get_ray( Vector2( m.x, m.y ) ); + if (_edit.mode==TRANSFORM_NONE && nav_mode == NAVIGATION_NONE) + break; - switch(_edit.mode) { + Vector3 ray_pos=_get_ray_pos( Vector2( m.x, m.y ) ); + Vector3 ray=_get_ray( Vector2( m.x, m.y ) ); - case TRANSFORM_SCALE: { + switch(_edit.mode) { - Plane plane=Plane(_edit.center,_get_camera_normal()); + case TRANSFORM_SCALE: { - Vector3 intersection; - if (!plane.intersects_ray(ray_pos,ray,&intersection)) - break; + Plane plane=Plane(_edit.center,_get_camera_normal()); - Vector3 click; - if (!plane.intersects_ray(_edit.click_ray_pos,_edit.click_ray,&click)) - break; - float center_click_dist = click.distance_to(_edit.center); - float center_inters_dist = intersection.distance_to(_edit.center); - if (center_click_dist==0) - break; + Vector3 intersection; + if (!plane.intersects_ray(ray_pos,ray,&intersection)) + break; - float scale = (center_inters_dist / center_click_dist)*100.0; + Vector3 click; + if (!plane.intersects_ray(_edit.click_ray_pos,_edit.click_ray,&click)) + break; - if (_edit.snap || spatial_editor->is_snap_enabled()) { + float center_click_dist = click.distance_to(_edit.center); + float center_inters_dist = intersection.distance_to(_edit.center); + if (center_click_dist==0) + break; - scale = Math::stepify(scale,spatial_editor->get_scale_snap()); - } + float scale = (center_inters_dist / center_click_dist)*100.0; - set_message("Scaling to "+String::num(scale,1)+"%."); - scale/=100.0; + if (_edit.snap || spatial_editor->is_snap_enabled()) { - Transform r; - r.basis.scale(Vector3(scale,scale,scale)); + scale = Math::stepify(scale,spatial_editor->get_scale_snap()); + } + set_message("Scaling to "+String::num(scale,1)+"%."); + scale/=100.0; - List &selection = editor_selection->get_selected_node_list(); + Transform r; + r.basis.scale(Vector3(scale,scale,scale)); - for(List::Element *E=selection.front();E;E=E->next()) { - Spatial *sp = E->get()->cast_to(); - if (!sp) - continue; + List &selection = editor_selection->get_selected_node_list(); - SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data(sp); - if (!se) - continue; + for(List::Element *E=selection.front();E;E=E->next()) { + Spatial *sp = E->get()->cast_to(); + if (!sp) + continue; - Transform original=se->original; + SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data(sp); + if (!se) + continue; - Transform base=Transform( Matrix3(), _edit.center); - Transform t=base * (r * (base.inverse() * original)); - sp->set_global_transform(t); - } + Transform original=se->original; - surface->update(); + Transform base=Transform( Matrix3(), _edit.center); + Transform t=base * (r * (base.inverse() * original)); - } break; + sp->set_global_transform(t); + } - case TRANSFORM_TRANSLATE: { + surface->update(); + } break; + + case TRANSFORM_TRANSLATE: { + + + Vector3 motion_mask; + Plane plane; + + switch( _edit.plane ) { + case TRANSFORM_VIEW: + motion_mask=Vector3(0,0,0); + plane=Plane(_edit.center,_get_camera_normal()); + break; + case TRANSFORM_X_AXIS: + motion_mask=spatial_editor->get_gizmo_transform().basis.get_axis(0); + plane=Plane(_edit.center,motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); + break; + case TRANSFORM_Y_AXIS: + motion_mask=spatial_editor->get_gizmo_transform().basis.get_axis(1); + plane=Plane(_edit.center,motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); + break; + case TRANSFORM_Z_AXIS: + motion_mask=spatial_editor->get_gizmo_transform().basis.get_axis(2); + plane=Plane(_edit.center,motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); + break; + } - Vector3 motion_mask; - Plane plane; + Vector3 intersection; + if (!plane.intersects_ray(ray_pos,ray,&intersection)) + break; - switch( _edit.plane ) { - case TRANSFORM_VIEW: - motion_mask=Vector3(0,0,0); - plane=Plane(_edit.center,_get_camera_normal()); - break; - case TRANSFORM_X_AXIS: - motion_mask=spatial_editor->get_gizmo_transform().basis.get_axis(0); - plane=Plane(_edit.center,motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); - break; - case TRANSFORM_Y_AXIS: - motion_mask=spatial_editor->get_gizmo_transform().basis.get_axis(1); - plane=Plane(_edit.center,motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); - break; - case TRANSFORM_Z_AXIS: - motion_mask=spatial_editor->get_gizmo_transform().basis.get_axis(2); - plane=Plane(_edit.center,motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); - break; - } + Vector3 click; + if (!plane.intersects_ray(_edit.click_ray_pos,_edit.click_ray,&click)) + break; - Vector3 intersection; - if (!plane.intersects_ray(ray_pos,ray,&intersection)) - break; + //_validate_selection(); + Vector3 motion = intersection-click; + if (motion_mask!=Vector3()) { + motion=motion_mask.dot(motion)*motion_mask; + } - Vector3 click; - if (!plane.intersects_ray(_edit.click_ray_pos,_edit.click_ray,&click)) - break; + float snap=0; - //_validate_selection(); - Vector3 motion = intersection-click; - if (motion_mask!=Vector3()) { - motion=motion_mask.dot(motion)*motion_mask; - } + if (_edit.snap || spatial_editor->is_snap_enabled()) { - float snap=0; + snap = spatial_editor->get_translate_snap(); + motion.snap(snap); + } - if (_edit.snap || spatial_editor->is_snap_enabled()) { + //set_message("Translating: "+motion); - snap = spatial_editor->get_translate_snap(); - motion.snap(snap); - } + List &selection = editor_selection->get_selected_node_list(); - //set_message("Translating: "+motion); + for(List::Element *E=selection.front();E;E=E->next()) { - List &selection = editor_selection->get_selected_node_list(); + Spatial *sp = E->get()->cast_to(); + if (!sp) { + continue; + } - for(List::Element *E=selection.front();E;E=E->next()) { + SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data(sp); + if (!se) { + continue; + } - Spatial *sp = E->get()->cast_to(); - if (!sp) { - continue; + Transform t=se->original; + t.origin+=motion; + sp->set_global_transform(t); } - - SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data(sp); - if (!se) { - continue; + } break; + + case TRANSFORM_ROTATE: { + + + Plane plane; + + switch( _edit.plane ) { + case TRANSFORM_VIEW: + plane=Plane(_edit.center,_get_camera_normal()); + break; + case TRANSFORM_X_AXIS: + plane=Plane(_edit.center,spatial_editor->get_gizmo_transform().basis.get_axis(0)); + break; + case TRANSFORM_Y_AXIS: + plane=Plane(_edit.center,spatial_editor->get_gizmo_transform().basis.get_axis(1)); + break; + case TRANSFORM_Z_AXIS: + plane=Plane(_edit.center,spatial_editor->get_gizmo_transform().basis.get_axis(2)); + break; } - Transform t=se->original; - t.origin+=motion; - sp->set_global_transform(t); - } - } break; + Vector3 intersection; + if (!plane.intersects_ray(ray_pos,ray,&intersection)) + break; - case TRANSFORM_ROTATE: { + Vector3 click; + if (!plane.intersects_ray(_edit.click_ray_pos,_edit.click_ray,&click)) + break; - Plane plane; + Vector3 y_axis=(click-_edit.center).normalized(); + Vector3 x_axis=plane.normal.cross(y_axis).normalized(); - switch( _edit.plane ) { - case TRANSFORM_VIEW: - plane=Plane(_edit.center,_get_camera_normal()); - break; - case TRANSFORM_X_AXIS: - plane=Plane(_edit.center,spatial_editor->get_gizmo_transform().basis.get_axis(0)); - break; - case TRANSFORM_Y_AXIS: - plane=Plane(_edit.center,spatial_editor->get_gizmo_transform().basis.get_axis(1)); - break; - case TRANSFORM_Z_AXIS: - plane=Plane(_edit.center,spatial_editor->get_gizmo_transform().basis.get_axis(2)); - break; - } - - Vector3 intersection; - if (!plane.intersects_ray(ray_pos,ray,&intersection)) - break; - - Vector3 click; - if (!plane.intersects_ray(_edit.click_ray_pos,_edit.click_ray,&click)) - break; + float angle=Math::atan2( x_axis.dot(intersection-_edit.center), y_axis.dot(intersection-_edit.center) ); + if (_edit.snap || spatial_editor->is_snap_enabled()) { + float snap = spatial_editor->get_rotate_snap(); - Vector3 y_axis=(click-_edit.center).normalized(); - Vector3 x_axis=plane.normal.cross(y_axis).normalized(); + if (snap) { + angle=Math::rad2deg(angle)+snap*0.5; //else it wont reach +180 + angle-=Math::fmod(angle,snap); + set_message("Rotating "+rtos(angle)+" degrees."); + angle=Math::deg2rad(angle); + } else + set_message("Rotating "+rtos(Math::rad2deg(angle))+" degrees."); - float angle=Math::atan2( x_axis.dot(intersection-_edit.center), y_axis.dot(intersection-_edit.center) ); - if (_edit.snap || spatial_editor->is_snap_enabled()) { - - float snap = spatial_editor->get_rotate_snap(); - - if (snap) { - angle=Math::rad2deg(angle)+snap*0.5; //else it wont reach +180 - angle-=Math::fmod(angle,snap); - set_message("Rotating "+rtos(angle)+" degrees."); - angle=Math::deg2rad(angle); - } else + } else { set_message("Rotating "+rtos(Math::rad2deg(angle))+" degrees."); + } - } else { - set_message("Rotating "+rtos(Math::rad2deg(angle))+" degrees."); - } + Transform r; + r.basis.rotate(plane.normal,-angle); - Transform r; - r.basis.rotate(plane.normal,-angle); + List &selection = editor_selection->get_selected_node_list(); - List &selection = editor_selection->get_selected_node_list(); + for(List::Element *E=selection.front();E;E=E->next()) { - for(List::Element *E=selection.front();E;E=E->next()) { + Spatial *sp = E->get()->cast_to(); + if (!sp) + continue; - Spatial *sp = E->get()->cast_to(); - if (!sp) - continue; + SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data(sp); + if (!se) + continue; - SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data(sp); - if (!se) - continue; + Transform original=se->original; - Transform original=se->original; + Transform base=Transform( Matrix3(), _edit.center); + Transform t=base * (r * (base.inverse() * original)); - Transform base=Transform( Matrix3(), _edit.center); - Transform t=base * (r * (base.inverse() * original)); + sp->set_global_transform(t); + } - sp->set_global_transform(t); - } + surface->update(); + /* + VisualServer::get_singleton()->poly_clear(indicators); + + Vector points; + Vector empty; + Vector colors; + points.push_back(intersection); + points.push_back(_edit.original.origin); + colors.push_back( Color(255,155,100) ); + colors.push_back( Color(255,155,100) ); + VisualServer::get_singleton()->poly_add_primitive(indicators,points,empty,colors,empty); + */ + } break; + default:{} + } - surface->update(); - /* - VisualServer::get_singleton()->poly_clear(indicators); - - Vector points; - Vector empty; - Vector colors; - points.push_back(intersection); - points.push_back(_edit.original.origin); - colors.push_back( Color(255,155,100) ); - colors.push_back( Color(255,155,100) ); - VisualServer::get_singleton()->poly_add_primitive(indicators,points,empty,colors,empty); - */ - } break; - default:{} } } else if (m.button_mask&2) { -- cgit v1.2.3 From 35bf23859a145989ef79c8cfac20d8c8eefe371c Mon Sep 17 00:00:00 2001 From: marynate Date: Mon, 31 Mar 2014 15:52:27 +0800 Subject: Fix bug in 3d navigation scheme selection; Add modo navigation scheme --- tools/editor/plugins/spatial_editor_plugin.cpp | 14 ++++++++++---- tools/editor/plugins/spatial_editor_plugin.h | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'tools/editor/plugins') diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 600d4f5103..5c019d9f20 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -528,11 +528,11 @@ static int _get_key_modifier(const String& p_property) { SpatialEditorViewport::NavigationScheme SpatialEditorViewport::_get_navigation_schema(const String& p_property) { switch(EditorSettings::get_singleton()->get(p_property).operator int()) { + case 0: return NAVIGATION_GODOT; case 1: return NAVIGATION_MAYA; - case 0: - default: - return NAVIGATION_GODOT; + case 2: return NAVIGATION_MODO; } + return NAVIGATION_GODOT; } bool SpatialEditorViewport::_gizmo_select(const Vector2& p_screenpos,bool p_hilite_only) { @@ -1013,7 +1013,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { } - NavigationScheme nav_scheme = _get_navigation_schema("3d_editor/navigation_schema"); + NavigationScheme nav_scheme = _get_navigation_schema("3d_editor/navigation_scheme"); NavigationMode nav_mode = NAVIGATION_NONE; if (_edit.gizmo.is_valid()) { @@ -1036,6 +1036,12 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { } else if (m.button_mask&1) { if (nav_scheme == NAVIGATION_MAYA && m.mod.alt) { + nav_mode = NAVIGATION_ORBIT; + } else if (nav_scheme == NAVIGATION_MODO && m.mod.alt && m.mod.shift) { + nav_mode = NAVIGATION_PAN; + } else if (nav_scheme == NAVIGATION_MODO && m.mod.alt && m.mod.control) { + nav_mode = NAVIGATION_ZOOM; + } else if (nav_scheme == NAVIGATION_MODO && m.mod.alt) { nav_mode = NAVIGATION_ORBIT; } else { if (clicked) { diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h index 30eba5facc..94711a5f02 100644 --- a/tools/editor/plugins/spatial_editor_plugin.h +++ b/tools/editor/plugins/spatial_editor_plugin.h @@ -120,7 +120,8 @@ class SpatialEditorViewport : public Control { enum NavigationScheme { NAVIGATION_GODOT, - NAVIGATION_MAYA + NAVIGATION_MAYA, + NAVIGATION_MODO, }; NavigationScheme _get_navigation_schema(const String& p_property); -- cgit v1.2.3 From 4dbf26cba26811878cafff6b54ec91cece792b92 Mon Sep 17 00:00:00 2001 From: marynate Date: Mon, 31 Mar 2014 16:27:41 +0800 Subject: Keep selection from been cleared when navigating in 3d viewport Conflicts: tools/editor/plugins/spatial_editor_plugin.cpp --- tools/editor/plugins/spatial_editor_plugin.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tools/editor/plugins') diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 5c019d9f20..9bd9a5cff0 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -844,6 +844,11 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { if (b.pressed) { + NavigationScheme nav_scheme = _get_navigation_schema("3d_editor/navigation_scheme"); + if ( (nav_scheme==NAVIGATION_MAYA || nav_scheme==NAVIGATION_MODO) && b.mod.alt) { + break; + } + _edit.mouse_pos=Point2(b.x,b.y); _edit.snap=false; _edit.mode=TRANSFORM_NONE; -- cgit v1.2.3 From 145d069da0e394c4b685a16fe0392fdcf931df4e Mon Sep 17 00:00:00 2001 From: marynate Date: Mon, 31 Mar 2014 17:28:59 +0800 Subject: Hold shift to speedup pan/zoom in maya navigation scheme --- tools/editor/plugins/spatial_editor_plugin.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'tools/editor/plugins') diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 9bd9a5cff0..3b8a068cac 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -1340,12 +1340,17 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { switch(nav_mode) { case NAVIGATION_PAN:{ + real_t pan_speed = 1/150.0; + int pan_speed_modifier = 10; + if (nav_scheme==NAVIGATION_MAYA && m.mod.shift) + pan_speed *= pan_speed_modifier; + Transform camera_transform; camera_transform.translate(cursor.pos); camera_transform.basis.rotate(Vector3(0,1,0),cursor.y_rot); camera_transform.basis.rotate(Vector3(1,0,0),cursor.x_rot); - Vector3 translation(-m.relative_x/150.0,m.relative_y/150.0,0); + Vector3 translation(-m.relative_x*pan_speed,m.relative_y*pan_speed,0); translation*=cursor.distance/DISTANCE_DEFAULT; camera_transform.translate(translation); cursor.pos=camera_transform.origin; @@ -1353,11 +1358,15 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { } break; case NAVIGATION_ZOOM: { + real_t zoom_speed = 1/80.0; + int zoom_speed_modifier = 10; + if (nav_scheme==NAVIGATION_MAYA && m.mod.shift) + zoom_speed *= zoom_speed_modifier; if ( m.relative_y > 0) - cursor.distance*=1+m.relative_y/80.0; + cursor.distance*=1+m.relative_y*zoom_speed; else if (m.relative_y < 0) - cursor.distance/=1-m.relative_y/80.0; + cursor.distance/=1-m.relative_y*zoom_speed; } break; -- cgit v1.2.3