Add mouse centering in Editor Viewport if initial location is too close to the edge

This commit is contained in:
Wojtek Figat
2021-03-18 18:23:58 +01:00
parent f32ea92336
commit 544a11562c
3 changed files with 28 additions and 3 deletions

View File

@@ -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);
}
}
/// <summary>

View File

@@ -197,6 +197,16 @@ namespace FlaxEngine
/// </summary>
public float ValuesSum => X + Y;
/// <summary>
/// Gets a vector with values being absolute values of that vector.
/// </summary>
public Vector2 Absolute => new Vector2(Mathf.Abs(X), Mathf.Abs(Y));
/// <summary>
/// Gets a vector with values being opposite to values of that vector.
/// </summary>
public Vector2 Negative => new Vector2(-X, -Y);
/// <summary>
/// Gets or sets the component at the specified index.
/// </summary>

View File

@@ -227,6 +227,16 @@ namespace FlaxEngine
/// </summary>
public float ValuesSum => X + Y + Z + W;
/// <summary>
/// Gets a vector with values being absolute values of that vector.
/// </summary>
public Vector4 Absolute => new Vector4(Mathf.Abs(X), Mathf.Abs(Y), Mathf.Abs(Z), Mathf.Abs(W));
/// <summary>
/// Gets a vector with values being opposite to values of that vector.
/// </summary>
public Vector4 Negative => new Vector4(-X, -Y, -Z, -W);
/// <summary>
/// Gets or sets the component at the specified index.
/// </summary>