diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs index c4e2ddce2..7e1c3d887 100644 --- a/Source/Editor/Viewport/EditorViewport.cs +++ b/Source/Editor/Viewport/EditorViewport.cs @@ -865,9 +865,14 @@ namespace FlaxEditor.Viewport win.StartTrackingMouse(false); win.Cursor = CursorType.Hidden; - // Center mouse position - //_viewMousePos = Center; - //win.MousePosition = PointToWindow(_viewMousePos); + // Center mouse position if it's too close to the edge + var size = Size; + var center = size * 0.5f; + if (Mathf.Abs(_viewMousePos.X - center.X) > center.X * 0.8f || Mathf.Abs(_viewMousePos.Y - center.Y) > center.Y * 0.8f) + { + _viewMousePos = center; + win.MousePosition = PointToWindow(_viewMousePos); + } } /// diff --git a/Source/Engine/Core/Math/Vector2.cs b/Source/Engine/Core/Math/Vector2.cs index c0b84ca04..bc193a034 100644 --- a/Source/Engine/Core/Math/Vector2.cs +++ b/Source/Engine/Core/Math/Vector2.cs @@ -197,6 +197,16 @@ namespace FlaxEngine /// public float ValuesSum => X + Y; + /// + /// Gets a vector with values being absolute values of that vector. + /// + public Vector2 Absolute => new Vector2(Mathf.Abs(X), Mathf.Abs(Y)); + + /// + /// Gets a vector with values being opposite to values of that vector. + /// + public Vector2 Negative => new Vector2(-X, -Y); + /// /// Gets or sets the component at the specified index. /// diff --git a/Source/Engine/Core/Math/Vector4.cs b/Source/Engine/Core/Math/Vector4.cs index 99430072d..2a62df067 100644 --- a/Source/Engine/Core/Math/Vector4.cs +++ b/Source/Engine/Core/Math/Vector4.cs @@ -227,6 +227,16 @@ namespace FlaxEngine /// public float ValuesSum => X + Y + Z + W; + /// + /// Gets a vector with values being absolute values of that vector. + /// + public Vector4 Absolute => new Vector4(Mathf.Abs(X), Mathf.Abs(Y), Mathf.Abs(Z), Mathf.Abs(W)); + + /// + /// Gets a vector with values being opposite to values of that vector. + /// + public Vector4 Negative => new Vector4(-X, -Y, -Z, -W); + /// /// Gets or sets the component at the specified index. ///