summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/editor/editor_settings.cpp2
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp75
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.h13
3 files changed, 70 insertions, 20 deletions
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index 09d55650c8..c5270753f0 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -403,6 +403,8 @@ void EditorSettings::_load_defaults() {
set("3d_editor/default_z_near",0.1);
set("3d_editor/default_z_far",500.0);
+ set("3d_editor/navigation_scheme",0);
+ hints["3d_editor/navigation_scheme"]=PropertyInfo(Variant::INT,"3d_editor/navigation_scheme",PROPERTY_HINT_ENUM,"Godot,Maya");
set("3d_editor/orbit_modifier",0);
hints["3d_editor/orbit_modifier"]=PropertyInfo(Variant::INT,"3d_editor/orbit_modifier",PROPERTY_HINT_ENUM,"None,Shift,Alt,Meta,Ctrl");
set("3d_editor/pan_modifier",1);
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,