Fix regression bugs in new rubber band when using different gizmos
This commit is contained in:
@@ -38,7 +38,7 @@ public class ViewportRubberBandSelector
|
|||||||
/// <returns>True if selection started, otherwise false.</returns>
|
/// <returns>True if selection started, otherwise false.</returns>
|
||||||
public bool TryStartingRubberBandSelection()
|
public bool TryStartingRubberBandSelection()
|
||||||
{
|
{
|
||||||
if (!_isRubberBandSpanning && !_owner.Gizmos.Active.IsControllingMouse && !_owner.IsRightMouseButtonDown)
|
if (!_isRubberBandSpanning && _owner.Gizmos.Active != null && !_owner.Gizmos.Active.IsControllingMouse && !_owner.IsRightMouseButtonDown)
|
||||||
{
|
{
|
||||||
_tryStartRubberBand = true;
|
_tryStartRubberBand = true;
|
||||||
return true;
|
return true;
|
||||||
@@ -90,7 +90,7 @@ public class ViewportRubberBandSelector
|
|||||||
_rubberBandRect = new Rectangle(_cachedStartingMousePosition, Float2.Zero);
|
_rubberBandRect = new Rectangle(_cachedStartingMousePosition, Float2.Zero);
|
||||||
_tryStartRubberBand = false;
|
_tryStartRubberBand = false;
|
||||||
}
|
}
|
||||||
else if (_isRubberBandSpanning && !_owner.Gizmos.Active.IsControllingMouse && !_owner.IsRightMouseButtonDown)
|
else if (_isRubberBandSpanning && _owner.Gizmos.Active != null && !_owner.Gizmos.Active.IsControllingMouse && !_owner.IsRightMouseButtonDown)
|
||||||
{
|
{
|
||||||
_rubberBandRect.Width = mousePosition.X - _cachedStartingMousePosition.X;
|
_rubberBandRect.Width = mousePosition.X - _cachedStartingMousePosition.X;
|
||||||
_rubberBandRect.Height = mousePosition.Y - _cachedStartingMousePosition.Y;
|
_rubberBandRect.Height = mousePosition.Y - _cachedStartingMousePosition.Y;
|
||||||
|
|||||||
@@ -7,14 +7,11 @@ using FlaxEditor.Gizmo;
|
|||||||
using FlaxEditor.GUI.ContextMenu;
|
using FlaxEditor.GUI.ContextMenu;
|
||||||
using FlaxEditor.SceneGraph;
|
using FlaxEditor.SceneGraph;
|
||||||
using FlaxEditor.Scripting;
|
using FlaxEditor.Scripting;
|
||||||
using FlaxEditor.Tools;
|
|
||||||
using FlaxEditor.Viewport.Modes;
|
using FlaxEditor.Viewport.Modes;
|
||||||
using FlaxEditor.Windows;
|
using FlaxEditor.Windows;
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
using FlaxEngine.Gizmo;
|
using FlaxEngine.Gizmo;
|
||||||
using FlaxEngine.GUI;
|
using FlaxEngine.GUI;
|
||||||
using FlaxEngine.Tools;
|
|
||||||
|
|
||||||
using Object = FlaxEngine.Object;
|
using Object = FlaxEngine.Object;
|
||||||
|
|
||||||
namespace FlaxEditor.Viewport
|
namespace FlaxEditor.Viewport
|
||||||
@@ -26,10 +23,8 @@ namespace FlaxEditor.Viewport
|
|||||||
public class MainEditorGizmoViewport : EditorGizmoViewport, IEditorPrimitivesOwner
|
public class MainEditorGizmoViewport : EditorGizmoViewport, IEditorPrimitivesOwner
|
||||||
{
|
{
|
||||||
private readonly Editor _editor;
|
private readonly Editor _editor;
|
||||||
|
|
||||||
private readonly ContextMenuButton _showGridButton;
|
private readonly ContextMenuButton _showGridButton;
|
||||||
private readonly ContextMenuButton _showNavigationButton;
|
private readonly ContextMenuButton _showNavigationButton;
|
||||||
|
|
||||||
private SelectionOutline _customSelectionOutline;
|
private SelectionOutline _customSelectionOutline;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -218,7 +213,7 @@ namespace FlaxEditor.Viewport
|
|||||||
TransformGizmo.ApplyTransformation += ApplyTransform;
|
TransformGizmo.ApplyTransformation += ApplyTransform;
|
||||||
TransformGizmo.Duplicate += _editor.SceneEditing.Duplicate;
|
TransformGizmo.Duplicate += _editor.SceneEditing.Duplicate;
|
||||||
Gizmos.Active = TransformGizmo;
|
Gizmos.Active = TransformGizmo;
|
||||||
|
|
||||||
// Add rubber band selector
|
// Add rubber band selector
|
||||||
_rubberBandSelector = new ViewportRubberBandSelector(this);
|
_rubberBandSelector = new ViewportRubberBandSelector(this);
|
||||||
|
|
||||||
@@ -375,10 +370,10 @@ namespace FlaxEditor.Viewport
|
|||||||
{
|
{
|
||||||
Gizmos[i].Draw(ref renderContext);
|
Gizmos[i].Draw(ref renderContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw RubberBand for rect selection
|
// Draw RubberBand for rect selection
|
||||||
_rubberBandSelector.Draw(context, target, targetDepth);
|
_rubberBandSelector.Draw(context, target, targetDepth);
|
||||||
|
|
||||||
// Draw selected objects debug shapes and visuals
|
// Draw selected objects debug shapes and visuals
|
||||||
if (DrawDebugDraw && (renderContext.View.Flags & ViewFlags.DebugDraw) == ViewFlags.DebugDraw)
|
if (DrawDebugDraw && (renderContext.View.Flags & ViewFlags.DebugDraw) == ViewFlags.DebugDraw)
|
||||||
{
|
{
|
||||||
@@ -609,7 +604,8 @@ namespace FlaxEditor.Viewport
|
|||||||
base.OnMouseMove(location);
|
base.OnMouseMove(location);
|
||||||
|
|
||||||
// Don't allow rubber band selection when gizmo is controlling mouse, vertex painting mode, or cloth painting is enabled
|
// Don't allow rubber band selection when gizmo is controlling mouse, vertex painting mode, or cloth painting is enabled
|
||||||
bool canStart = !((Gizmos.Active.IsControllingMouse || Gizmos.Active is VertexPaintingGizmo || Gizmos.Active is ClothPaintingGizmo) || IsControllingMouse || IsRightMouseButtonDown || IsAltKeyDown);
|
bool canStart = !(IsControllingMouse || IsRightMouseButtonDown || IsAltKeyDown) &&
|
||||||
|
Gizmos.Active is TransformGizmo && !Gizmos.Active.IsControllingMouse;
|
||||||
_rubberBandSelector.TryCreateRubberBand(canStart, _viewMousePos, ViewFrustum);
|
_rubberBandSelector.TryCreateRubberBand(canStart, _viewMousePos, ViewFrustum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user