From ccef5f0d73a4a57ac845465f8acceb706d2f67de Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Perrier Date: Sat, 29 May 2021 18:53:30 +0200 Subject: [PATCH] Fix viewpoints. --- .../Editor/Viewport/MainEditorGizmoViewport.cs | 18 ++++++++++++++---- Source/Editor/Viewport/PrefabWindowViewport.cs | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index 8bc6b4c02..6202a8d6e 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -656,11 +656,20 @@ namespace FlaxEditor.Viewport /// Focuses the viewport on the current selection of the gizmo. /// public void FocusSelection() + { + var orientation = ViewOrientation; + FocusSelection(ref orientation); + } + + /// + /// Focuses the viewport on the current selection of the gizmo. + /// + /// The target view orientation. + public void FocusSelection(ref Quaternion orientation) { if (TransformGizmo.SelectedParents.Count == 0) return; - var orientation = ViewOrientation; var gizmoBounds = Gizmos.Active.FocusBounds; if (gizmoBounds != BoundingSphere.Empty) ((FPSCamera)ViewportCamera).ShowSphere(ref gizmoBounds, ref orientation); @@ -725,9 +734,10 @@ namespace FlaxEditor.Viewport /// protected override void OrientViewport(ref Quaternion orientation) { - FocusSelection(); - - base.OrientViewport(ref orientation); + if (TransformGizmo.SelectedParents.Count != 0) + FocusSelection(ref orientation); + else + base.OrientViewport(ref orientation); } /// diff --git a/Source/Editor/Viewport/PrefabWindowViewport.cs b/Source/Editor/Viewport/PrefabWindowViewport.cs index 1c337cc25..946cf3620 100644 --- a/Source/Editor/Viewport/PrefabWindowViewport.cs +++ b/Source/Editor/Viewport/PrefabWindowViewport.cs @@ -787,11 +787,20 @@ namespace FlaxEditor.Viewport /// Focuses the viewport on the current selection of the gizmo. /// public void FocusSelection() + { + var orientation = ViewOrientation; + FocusSelection(ref orientation); + } + + /// + /// Focuses the viewport on the current selection of the gizmo. + /// + /// The target view orientation. + public void FocusSelection(ref Quaternion orientation) { if (TransformGizmo.SelectedParents.Count == 0) return; - var orientation = ViewOrientation; var gizmoBounds = Gizmos.Active.FocusBounds; if (gizmoBounds != BoundingSphere.Empty) ((FPSCamera)ViewportCamera).ShowSphere(ref gizmoBounds, ref orientation); @@ -802,9 +811,10 @@ namespace FlaxEditor.Viewport /// protected override void OrientViewport(ref Quaternion orientation) { - FocusSelection(); - - base.OrientViewport(ref orientation); + if (TransformGizmo.SelectedParents.Count != 0) + FocusSelection(ref orientation); + else + base.OrientViewport(ref orientation); } ///