Merge branch 'viewpoint-shortcuts' of git://github.com/jb-perrier/FlaxEngine into jb-perrier-viewpoint-shortcuts
This commit is contained in:
@@ -151,6 +151,30 @@ namespace FlaxEditor.Options
|
|||||||
[DefaultValue(typeof(InputBinding), "Q")]
|
[DefaultValue(typeof(InputBinding), "Q")]
|
||||||
[EditorDisplay("Viewport"), EditorOrder(1550)]
|
[EditorDisplay("Viewport"), EditorOrder(1550)]
|
||||||
public InputBinding Down = new InputBinding(KeyboardKeys.Q);
|
public InputBinding Down = new InputBinding(KeyboardKeys.Q);
|
||||||
|
|
||||||
|
[DefaultValue(typeof(InputBinding), "Numpad0")]
|
||||||
|
[EditorDisplay("Viewport"), EditorOrder(1600)]
|
||||||
|
public InputBinding ViewpointFront = new InputBinding(KeyboardKeys.Numpad0);
|
||||||
|
|
||||||
|
[DefaultValue(typeof(InputBinding), "Numpad5")]
|
||||||
|
[EditorDisplay("Viewport"), EditorOrder(1610)]
|
||||||
|
public InputBinding ViewpointBack = new InputBinding(KeyboardKeys.Numpad5);
|
||||||
|
|
||||||
|
[DefaultValue(typeof(InputBinding), "Numpad4")]
|
||||||
|
[EditorDisplay("Viewport"), EditorOrder(1620)]
|
||||||
|
public InputBinding ViewpointLeft = new InputBinding(KeyboardKeys.Numpad4);
|
||||||
|
|
||||||
|
[DefaultValue(typeof(InputBinding), "Numpad6")]
|
||||||
|
[EditorDisplay("Viewport"), EditorOrder(1630)]
|
||||||
|
public InputBinding ViewpointRight = new InputBinding(KeyboardKeys.Numpad6);
|
||||||
|
|
||||||
|
[DefaultValue(typeof(InputBinding), "Numpad8")]
|
||||||
|
[EditorDisplay("Viewport"), EditorOrder(1640)]
|
||||||
|
public InputBinding ViewpointTop = new InputBinding(KeyboardKeys.Numpad8);
|
||||||
|
|
||||||
|
[DefaultValue(typeof(InputBinding), "Numpad2")]
|
||||||
|
[EditorDisplay("Viewport"), EditorOrder(1650)]
|
||||||
|
public InputBinding ViewpointBottom = new InputBinding(KeyboardKeys.Numpad2);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using FlaxEditor.GUI.ContextMenu;
|
using FlaxEditor.GUI.ContextMenu;
|
||||||
using FlaxEditor.GUI.Input;
|
using FlaxEditor.GUI.Input;
|
||||||
using FlaxEditor.Options;
|
using FlaxEditor.Options;
|
||||||
@@ -649,6 +650,13 @@ namespace FlaxEditor.Viewport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InputActions.Add(options => options.ViewpointTop, () => OrientViewport(Quaternion.Euler(EditorViewportCameraViewpointValues.First(vp => vp.Name == "Top").Orientation)));
|
||||||
|
InputActions.Add(options => options.ViewpointBottom, () => OrientViewport(Quaternion.Euler(EditorViewportCameraViewpointValues.First(vp => vp.Name == "Bottom").Orientation)));
|
||||||
|
InputActions.Add(options => options.ViewpointFront, () => OrientViewport(Quaternion.Euler(EditorViewportCameraViewpointValues.First(vp => vp.Name == "Front").Orientation)));
|
||||||
|
InputActions.Add(options => options.ViewpointBack, () => OrientViewport(Quaternion.Euler(EditorViewportCameraViewpointValues.First(vp => vp.Name == "Back").Orientation)));
|
||||||
|
InputActions.Add(options => options.ViewpointRight, () => OrientViewport(Quaternion.Euler(EditorViewportCameraViewpointValues.First(vp => vp.Name == "Right").Orientation)));
|
||||||
|
InputActions.Add(options => options.ViewpointLeft, () => OrientViewport(Quaternion.Euler(EditorViewportCameraViewpointValues.First(vp => vp.Name == "Left").Orientation)));
|
||||||
|
|
||||||
// Link for task event
|
// Link for task event
|
||||||
task.Begin += OnRenderBegin;
|
task.Begin += OnRenderBegin;
|
||||||
}
|
}
|
||||||
@@ -658,6 +666,16 @@ namespace FlaxEditor.Viewport
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual bool IsControllingMouse => false;
|
protected virtual bool IsControllingMouse => false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Orients the viewport.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orientation">The orientation.</param>
|
||||||
|
protected void OrientViewport(Quaternion orientation)
|
||||||
|
{
|
||||||
|
var quat = orientation;
|
||||||
|
OrientViewport(ref quat);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Orients the viewport.
|
/// Orients the viewport.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -656,11 +656,20 @@ namespace FlaxEditor.Viewport
|
|||||||
/// Focuses the viewport on the current selection of the gizmo.
|
/// Focuses the viewport on the current selection of the gizmo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void FocusSelection()
|
public void FocusSelection()
|
||||||
|
{
|
||||||
|
var orientation = ViewOrientation;
|
||||||
|
FocusSelection(ref orientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Focuses the viewport on the current selection of the gizmo.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orientation">The target view orientation.</param>
|
||||||
|
public void FocusSelection(ref Quaternion orientation)
|
||||||
{
|
{
|
||||||
if (TransformGizmo.SelectedParents.Count == 0)
|
if (TransformGizmo.SelectedParents.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var orientation = ViewOrientation;
|
|
||||||
var gizmoBounds = Gizmos.Active.FocusBounds;
|
var gizmoBounds = Gizmos.Active.FocusBounds;
|
||||||
if (gizmoBounds != BoundingSphere.Empty)
|
if (gizmoBounds != BoundingSphere.Empty)
|
||||||
((FPSCamera)ViewportCamera).ShowSphere(ref gizmoBounds, ref orientation);
|
((FPSCamera)ViewportCamera).ShowSphere(ref gizmoBounds, ref orientation);
|
||||||
@@ -725,9 +734,10 @@ namespace FlaxEditor.Viewport
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void OrientViewport(ref Quaternion orientation)
|
protected override void OrientViewport(ref Quaternion orientation)
|
||||||
{
|
{
|
||||||
FocusSelection();
|
if (TransformGizmo.SelectedParents.Count != 0)
|
||||||
|
FocusSelection(ref orientation);
|
||||||
base.OrientViewport(ref orientation);
|
else
|
||||||
|
base.OrientViewport(ref orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -787,11 +787,20 @@ namespace FlaxEditor.Viewport
|
|||||||
/// Focuses the viewport on the current selection of the gizmo.
|
/// Focuses the viewport on the current selection of the gizmo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void FocusSelection()
|
public void FocusSelection()
|
||||||
|
{
|
||||||
|
var orientation = ViewOrientation;
|
||||||
|
FocusSelection(ref orientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Focuses the viewport on the current selection of the gizmo.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orientation">The target view orientation.</param>
|
||||||
|
public void FocusSelection(ref Quaternion orientation)
|
||||||
{
|
{
|
||||||
if (TransformGizmo.SelectedParents.Count == 0)
|
if (TransformGizmo.SelectedParents.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var orientation = ViewOrientation;
|
|
||||||
var gizmoBounds = Gizmos.Active.FocusBounds;
|
var gizmoBounds = Gizmos.Active.FocusBounds;
|
||||||
if (gizmoBounds != BoundingSphere.Empty)
|
if (gizmoBounds != BoundingSphere.Empty)
|
||||||
((FPSCamera)ViewportCamera).ShowSphere(ref gizmoBounds, ref orientation);
|
((FPSCamera)ViewportCamera).ShowSphere(ref gizmoBounds, ref orientation);
|
||||||
@@ -802,9 +811,10 @@ namespace FlaxEditor.Viewport
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void OrientViewport(ref Quaternion orientation)
|
protected override void OrientViewport(ref Quaternion orientation)
|
||||||
{
|
{
|
||||||
FocusSelection();
|
if (TransformGizmo.SelectedParents.Count != 0)
|
||||||
|
FocusSelection(ref orientation);
|
||||||
base.OrientViewport(ref orientation);
|
else
|
||||||
|
base.OrientViewport(ref orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
Reference in New Issue
Block a user