Merge remote-tracking branch 'origin/master' into linux-editor

# Conflicts:
#	Source/Engine/Core/Math/Color.cs
#	Source/Engine/Navigation/Navigation.cpp
#	Source/Engine/Platform/Win32/Win32Platform.cpp
This commit is contained in:
Wojtek Figat
2021-02-23 22:29:07 +01:00
147 changed files with 1740 additions and 1311 deletions

View File

@@ -32,8 +32,11 @@ namespace FlaxEngine.GUI
private bool IntersectsChildContent(CanvasRootControl child, ref Ray ray, out Vector2 childSpaceLocation)
{
// Inline bounds calculations (it will reuse world matrix)
OrientedBoundingBox bounds = new OrientedBoundingBox();
bounds.Extents = new Vector3(child.Size * 0.5f, Mathf.Epsilon);
OrientedBoundingBox bounds = new OrientedBoundingBox
{
Extents = new Vector3(child.Size * 0.5f, Mathf.Epsilon)
};
child.Canvas.GetWorldMatrix(out var world);
Matrix.Translation(bounds.Extents.X, bounds.Extents.Y, 0, out var offset);
Matrix.Multiply(ref offset, ref world, out bounds.Transformation);

View File

@@ -123,11 +123,9 @@ namespace FlaxEngine.GUI
return location;
// Transform canvas local-space point to the game root location
Matrix world;
_canvas.GetWorldMatrix(out world);
Vector3 locationWorldSpace;
_canvas.GetWorldMatrix(out Matrix world);
Vector3 locationCanvasSpace = new Vector3(location, 0.0f);
Vector3.Transform(ref locationCanvasSpace, ref world, out locationWorldSpace);
Vector3.Transform(ref locationCanvasSpace, ref world, out Vector3 locationWorldSpace);
camera.ProjectPoint(locationWorldSpace, out location);
return location;
}

View File

@@ -281,7 +281,7 @@ namespace FlaxEngine.GUI
Vector2 leftEdge = selection.StartIndex <= textBlock.Range.StartIndex ? textBlock.Bounds.UpperLeft : font.GetCharPosition(_text, selection.StartIndex);
Vector2 rightEdge = selection.EndIndex >= textBlock.Range.EndIndex ? textBlock.Bounds.UpperRight : font.GetCharPosition(_text, selection.EndIndex);
float alpha = Mathf.Min(1.0f, Mathf.Cos(_animateTime * BackgroundSelectedFlashSpeed) * 0.5f + 1.3f);
alpha = alpha * alpha;
alpha *= alpha;
Color selectionColor = Color.White * alpha;
Rectangle selectionRect = new Rectangle(leftEdge.X, leftEdge.Y, rightEdge.X - leftEdge.X, font.Height);
textBlock.Style.BackgroundSelectedBrush.Draw(selectionRect, selectionColor);

View File

@@ -165,7 +165,7 @@ namespace FlaxEngine.GUI
// Draw selection background
float alpha = Mathf.Min(1.0f, Mathf.Cos(_animateTime * BackgroundSelectedFlashSpeed) * 0.5f + 1.3f);
alpha = alpha * alpha;
alpha *= alpha;
Color selectionColor = SelectionColor * alpha;
//
int selectedLinesCount = 1 + Mathf.FloorToInt((rightEdge.Y - leftEdge.Y) / fontHeight);

View File

@@ -368,9 +368,8 @@ namespace FlaxEngine.GUI
public void UpdateTransform()
{
// Actual pivot and negative pivot
Vector2 v1, v2;
Vector2.Multiply(ref _pivot, ref _bounds.Size, out v1);
Vector2.Negate(ref v1, out v2);
Vector2.Multiply(ref _pivot, ref _bounds.Size, out Vector2 v1);
Vector2.Negate(ref v1, out Vector2 v2);
Vector2.Add(ref v1, ref _bounds.Location, out v1);
// ------ Matrix3x3 based version:
@@ -400,16 +399,14 @@ namespace FlaxEngine.GUI
// ------ Matrix2x2 based version:
// 2D transformation
Matrix2x2 m1, m2;
Matrix2x2.Scale(ref _scale, out m1);
Matrix2x2.Shear(ref _shear, out m2);
Matrix2x2.Scale(ref _scale, out Matrix2x2 m1);
Matrix2x2.Shear(ref _shear, out Matrix2x2 m2);
Matrix2x2.Multiply(ref m1, ref m2, out m1);
Matrix2x2.Rotation(Mathf.DegreesToRadians * _rotation, out m2);
Matrix2x2.Multiply(ref m1, ref m2, out m1);
// Mix all the stuff
Matrix3x3 m3;
Matrix3x3.Translation2D(ref v2, out m3);
Matrix3x3.Translation2D(ref v2, out Matrix3x3 m3);
Matrix3x3 m4 = (Matrix3x3)m1;
Matrix3x3.Multiply(ref m3, ref m4, out m3);
Matrix3x3.Translation2D(ref v1, out m4);

View File

@@ -40,9 +40,7 @@ namespace FlaxEngine.GUI
get => _cellsV;
set
{
if (value == null)
throw new ArgumentNullException();
_cellsV = value;
_cellsV = value ?? throw new ArgumentNullException();
PerformLayout();
}
}
@@ -56,9 +54,7 @@ namespace FlaxEngine.GUI
get => _cellsH;
set
{
if (value == null)
throw new ArgumentNullException();
_cellsH = value;
_cellsH = value ?? throw new ArgumentNullException();
PerformLayout();
}
}

View File

@@ -64,8 +64,10 @@ namespace FlaxEngine.GUI
VScrollBar = GetChild<VScrollBar>();
if (VScrollBar == null)
{
VScrollBar = new VScrollBar(this, Width - ScrollBar.DefaultSize, Height);
VScrollBar.AnchorPreset = AnchorPresets.TopLeft;
VScrollBar = new VScrollBar(this, Width - ScrollBar.DefaultSize, Height)
{
AnchorPreset = AnchorPresets.TopLeft
};
//VScrollBar.X += VScrollBar.Width;
VScrollBar.ValueChanged += () => SetViewOffset(Orientation.Vertical, VScrollBar.Value);
}
@@ -82,8 +84,10 @@ namespace FlaxEngine.GUI
HScrollBar = GetChild<HScrollBar>();
if (HScrollBar == null)
{
HScrollBar = new HScrollBar(this, Height - ScrollBar.DefaultSize, Width);
HScrollBar.AnchorPreset = AnchorPresets.TopLeft;
HScrollBar = new HScrollBar(this, Height - ScrollBar.DefaultSize, Width)
{
AnchorPreset = AnchorPresets.TopLeft
};
//HScrollBar.Y += HScrollBar.Height;
//HScrollBar.Offsets += new Margin(0, 0, HScrollBar.Height * 0.5f, 0);
HScrollBar.ValueChanged += () => SetViewOffset(Orientation.Horizontal, HScrollBar.Value);

View File

@@ -89,13 +89,11 @@ namespace FlaxEngine.GUI
/// <exception cref="System.ArgumentNullException">Invalid task.</exception>
public RenderOutputControl(SceneRenderTask task)
{
if (task == null)
throw new ArgumentNullException();
_task = task ?? throw new ArgumentNullException();
_backBuffer = GPUDevice.Instance.CreateTexture();
_resizeTime = ResizeCheckTime;
_task = task;
_task.Output = _backBuffer;
_task.End += OnEnd;

View File

@@ -162,9 +162,7 @@ namespace FlaxEngine.GUI
if (_timeToPopupLeft <= 0.0f)
{
Vector2 location;
Rectangle area;
if (_lastTarget.OnShowTooltip(out _currentText, out location, out area))
if (_lastTarget.OnShowTooltip(out _currentText, out Vector2 location, out Rectangle area))
{
Show(_lastTarget, location, area);
}
@@ -223,8 +221,6 @@ namespace FlaxEngine.GUI
TextAlignment.Center,
TextWrapping.WrapWords
);
base.Draw();
}
/// <inheritdoc />