Cleanup 8

This commit is contained in:
W2.Wizard
2021-02-21 14:27:44 +01:00
parent a4409c729b
commit 68f6e0251c
13 changed files with 73 additions and 84 deletions

View File

@@ -134,7 +134,7 @@ namespace FlaxEditor.GUI.Docking
}); });
// Link to the master panel // Link to the master panel
_masterPanel?.linkWindow(this); _masterPanel?.LinkWindow(this);
} }
/// <summary> /// <summary>
@@ -409,7 +409,7 @@ namespace FlaxEditor.GUI.Docking
Undock(); Undock();
// Unlink from the master panel // Unlink from the master panel
_masterPanel?.unlinkWindow(this); _masterPanel?.UnlinkWindow(this);
base.OnDestroy(); base.OnDestroy();
} }

View File

@@ -97,13 +97,13 @@ namespace FlaxEditor.GUI.Docking
return base.HitTest(ref position); return base.HitTest(ref position);
} }
internal void linkWindow(DockWindow window) internal void LinkWindow(DockWindow window)
{ {
// Add to the windows list // Add to the windows list
Windows.Add(window); Windows.Add(window);
} }
internal void unlinkWindow(DockWindow window) internal void UnlinkWindow(DockWindow window)
{ {
// Call event to the window // Call event to the window
window.OnUnlinkInternal(); window.OnUnlinkInternal();

View File

@@ -96,17 +96,17 @@ namespace FlaxEditor.GUI.Timeline.Tracks
/// <param name="req">The request data.</param> /// <param name="req">The request data.</param>
public void OnThumbnailRenderingBegin(SceneRenderTask task, GPUContext context, ref CameraCutThumbnailRenderer.Request req) public void OnThumbnailRenderingBegin(SceneRenderTask task, GPUContext context, ref CameraCutThumbnailRenderer.Request req)
{ {
var view = new RenderView(); RenderView view = new RenderView();
var track = (CameraCutTrack)Track; var track = (CameraCutTrack)Track;
var cam = track.Camera; Camera cam = track.Camera;
var viewport = new FlaxEngine.Viewport(Vector2.Zero, task.Buffers.Size); var viewport = new FlaxEngine.Viewport(Vector2.Zero, task.Buffers.Size);
var orientation = Quaternion.Identity; Quaternion orientation = Quaternion.Identity;
view.Near = 10.0f; view.Near = 10.0f;
view.Far = 20000.0f; view.Far = 20000.0f;
var usePerspective = true; bool usePerspective = true;
var orthoScale = 1.0f; float orthoScale = 1.0f;
var fov = 60.0f; float fov = 60.0f;
var customAspectRatio = 0.0f; float customAspectRatio = 0.0f;
// Try to evaluate camera properties based on the initial camera state // Try to evaluate camera properties based on the initial camera state
if (cam) if (cam)
@@ -122,7 +122,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
} }
// Try to evaluate camera properties based on the animated tracks // Try to evaluate camera properties based on the animated tracks
var time = req.ThumbnailIndex == 0 ? Start : Start + Duration; float time = req.ThumbnailIndex == 0 ? Start : Start + Duration;
foreach (var subTrack in track.SubTracks) foreach (var subTrack in track.SubTracks)
{ {
if (subTrack is MemberTrack memberTrack) if (subTrack is MemberTrack memberTrack)
@@ -133,18 +133,25 @@ namespace FlaxEditor.GUI.Timeline.Tracks
// TODO: try to make it better // TODO: try to make it better
if (memberTrack.MemberName == "Position" && value is Vector3 asPosition) if (memberTrack.MemberName == "Position" && value is Vector3 asPosition)
view.Position = asPosition; view.Position = asPosition;
else if (memberTrack.MemberName == "Orientation" && value is Quaternion asRotation) else if (memberTrack.MemberName == "Orientation" && value is Quaternion asRotation)
orientation = asRotation; orientation = asRotation;
else if (memberTrack.MemberName == "NearPlane" && value is float asNearPlane) else if (memberTrack.MemberName == "NearPlane" && value is float asNearPlane)
view.Near = asNearPlane; view.Near = asNearPlane;
else if (memberTrack.MemberName == "FarPlane" && value is float asFarPlane) else if (memberTrack.MemberName == "FarPlane" && value is float asFarPlane)
view.Far = asFarPlane; view.Far = asFarPlane;
else if (memberTrack.MemberName == "UsePerspective" && value is bool asUsePerspective) else if (memberTrack.MemberName == "UsePerspective" && value is bool asUsePerspective)
usePerspective = asUsePerspective; usePerspective = asUsePerspective;
else if (memberTrack.MemberName == "FieldOfView" && value is float asFieldOfView) else if (memberTrack.MemberName == "FieldOfView" && value is float asFieldOfView)
fov = asFieldOfView; fov = asFieldOfView;
else if (memberTrack.MemberName == "CustomAspectRatio" && value is float asCustomAspectRatio) else if (memberTrack.MemberName == "CustomAspectRatio" && value is float asCustomAspectRatio)
customAspectRatio = asCustomAspectRatio; customAspectRatio = asCustomAspectRatio;
else if (memberTrack.MemberName == "OrthographicScale" && value is float asOrthographicScale) else if (memberTrack.MemberName == "OrthographicScale" && value is float asOrthographicScale)
orthoScale = asOrthographicScale; orthoScale = asOrthographicScale;
} }
@@ -162,6 +169,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
{ {
view.Projection = Matrix.Ortho(viewport.Width * orthoScale, viewport.Height * orthoScale, view.Near, view.Far); view.Projection = Matrix.Ortho(viewport.Width * orthoScale, viewport.Height * orthoScale, view.Near, view.Far);
} }
Vector3 target = view.Position + view.Direction; Vector3 target = view.Position + view.Direction;
var up = Vector3.Transform(Vector3.Up, orientation); var up = Vector3.Transform(Vector3.Up, orientation);
view.View = Matrix.LookAt(view.Position, target, up); view.View = Matrix.LookAt(view.Position, target, up);
@@ -186,19 +194,23 @@ namespace FlaxEditor.GUI.Timeline.Tracks
if (image == null) if (image == null)
{ {
if (req.ThumbnailIndex == 0) if (req.ThumbnailIndex == 0)
{
image = new Image image = new Image
{ {
AnchorPreset = AnchorPresets.MiddleLeft, AnchorPreset = AnchorPresets.MiddleLeft,
Parent = this, Parent = this,
Bounds = new Rectangle(2, 2, CameraCutThumbnailRenderer.Width, CameraCutThumbnailRenderer.Height), Bounds = new Rectangle(2, 2, CameraCutThumbnailRenderer.Width, CameraCutThumbnailRenderer.Height),
}; };
}
else else
{
image = new Image image = new Image
{ {
AnchorPreset = AnchorPresets.MiddleRight, AnchorPreset = AnchorPresets.MiddleRight,
Parent = this, Parent = this,
Bounds = new Rectangle(Width - 2 - CameraCutThumbnailRenderer.Width, 2, CameraCutThumbnailRenderer.Width, CameraCutThumbnailRenderer.Height), Bounds = new Rectangle(Width - 2 - CameraCutThumbnailRenderer.Width, 2, CameraCutThumbnailRenderer.Width, CameraCutThumbnailRenderer.Height),
}; };
}
image.UnlockChildrenRecursive(); image.UnlockChildrenRecursive();
_thumbnails[req.ThumbnailIndex] = image; _thumbnails[req.ThumbnailIndex] = image;
UpdateUI(); UpdateUI();

View File

@@ -297,7 +297,7 @@ namespace FlaxEditor.GUI.Tree
} }
} }
private void walkSelectExpandedTree(List<TreeNode> selection, TreeNode node) private void WalkSelectExpandedTree(List<TreeNode> selection, TreeNode node)
{ {
for (int i = 0; i < node.ChildrenCount; i++) for (int i = 0; i < node.ChildrenCount; i++)
{ {
@@ -305,7 +305,7 @@ namespace FlaxEditor.GUI.Tree
{ {
selection.Add(child); selection.Add(child);
if (child.IsExpanded) if (child.IsExpanded)
walkSelectExpandedTree(selection, child); WalkSelectExpandedTree(selection, child);
} }
} }
} }
@@ -322,7 +322,7 @@ namespace FlaxEditor.GUI.Tree
// Update selection // Update selection
Selection.Clear(); Selection.Clear();
walkSelectExpandedTree(Selection, _children[0] as TreeNode); WalkSelectExpandedTree(Selection, _children[0] as TreeNode);
// Check if changed // Check if changed
if (Selection.Count != prev.Count || !Selection.SequenceEqual(prev)) if (Selection.Count != prev.Count || !Selection.SequenceEqual(prev))

View File

@@ -215,20 +215,17 @@ namespace FlaxEditor.Windows.Assets
{ {
if (actor == null) if (actor == null)
throw new ArgumentNullException(nameof(actor)); throw new ArgumentNullException(nameof(actor));
if (parent == null)
throw new ArgumentNullException(nameof(parent));
// Link it // Link it
actor.Parent = parent; actor.Parent = parent ?? throw new ArgumentNullException(nameof(parent));
// Peek spawned node // Peek spawned node
var actorNode = SceneGraphFactory.FindNode(actor.ID) as ActorNode ?? SceneGraphFactory.BuildActorNode(actor); var actorNode = SceneGraphFactory.FindNode(actor.ID) as ActorNode ?? SceneGraphFactory.BuildActorNode(actor);
if (actorNode == null) if (actorNode == null)
throw new InvalidOperationException("Failed to create scene node for the spawned actor."); throw new InvalidOperationException("Failed to create scene node for the spawned actor.");
var parentNode = SceneGraphFactory.FindNode(parent.ID) as ActorNode; var parentNode = SceneGraphFactory.FindNode(parent.ID) as ActorNode;
if (parentNode == null) actorNode.ParentNode = parentNode ?? throw new InvalidOperationException("Missing scene graph node for the spawned parent actor.");
throw new InvalidOperationException("Missing scene graph node for the spawned parent actor.");
actorNode.ParentNode = parentNode;
// Call post spawn action (can possibly setup custom default values) // Call post spawn action (can possibly setup custom default values)
actorNode.PostSpawn(); actorNode.PostSpawn();

View File

@@ -587,8 +587,7 @@ namespace FlaxEngine
/// <returns>A new <see cref="Vector4" /> containing the 4D Cartesian coordinates of the specified point.</returns> /// <returns>A new <see cref="Vector4" /> containing the 4D Cartesian coordinates of the specified point.</returns>
public static Vector4 Barycentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2) public static Vector4 Barycentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2)
{ {
Vector4 result; Barycentric(ref value1, ref value2, ref value3, amount1, amount2, out Vector4 result);
Barycentric(ref value1, ref value2, ref value3, amount1, amount2, out result);
return result; return result;
} }
@@ -629,8 +628,7 @@ namespace FlaxEngine
/// <returns>The clamped value.</returns> /// <returns>The clamped value.</returns>
public static Vector4 Clamp(Vector4 value, Vector4 min, Vector4 max) public static Vector4 Clamp(Vector4 value, Vector4 min, Vector4 max)
{ {
Vector4 result; Clamp(ref value, ref min, ref max, out Vector4 result);
Clamp(ref value, ref min, ref max, out result);
return result; return result;
} }
@@ -826,8 +824,7 @@ namespace FlaxEngine
/// </remarks> /// </remarks>
public static Vector4 Lerp(Vector4 start, Vector4 end, float amount) public static Vector4 Lerp(Vector4 start, Vector4 end, float amount)
{ {
Vector4 result; Lerp(ref start, ref end, amount, out Vector4 result);
Lerp(ref start, ref end, amount, out result);
return result; return result;
} }
@@ -853,8 +850,7 @@ namespace FlaxEngine
/// <returns>The cubic interpolation of the two vectors.</returns> /// <returns>The cubic interpolation of the two vectors.</returns>
public static Vector4 SmoothStep(Vector4 start, Vector4 end, float amount) public static Vector4 SmoothStep(Vector4 start, Vector4 end, float amount)
{ {
Vector4 result; SmoothStep(ref start, ref end, amount, out Vector4 result);
SmoothStep(ref start, ref end, amount, out result);
return result; return result;
} }
@@ -893,8 +889,7 @@ namespace FlaxEngine
/// <returns>The result of the Hermite spline interpolation.</returns> /// <returns>The result of the Hermite spline interpolation.</returns>
public static Vector4 Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount) public static Vector4 Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount)
{ {
Vector4 result; Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out Vector4 result);
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result);
return result; return result;
} }
@@ -929,8 +924,7 @@ namespace FlaxEngine
/// <returns>A vector that is the result of the Catmull-Rom interpolation.</returns> /// <returns>A vector that is the result of the Catmull-Rom interpolation.</returns>
public static Vector4 CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount) public static Vector4 CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount)
{ {
Vector4 result; CatmullRom(ref value1, ref value2, ref value3, ref value4, amount, out Vector4 result);
CatmullRom(ref value1, ref value2, ref value3, ref value4, amount, out result);
return result; return result;
} }
@@ -959,8 +953,7 @@ namespace FlaxEngine
/// <returns>A vector containing the largest components of the source vectors.</returns> /// <returns>A vector containing the largest components of the source vectors.</returns>
public static Vector4 Max(Vector4 left, Vector4 right) public static Vector4 Max(Vector4 left, Vector4 right)
{ {
Vector4 result; Max(ref left, ref right, out Vector4 result);
Max(ref left, ref right, out result);
return result; return result;
} }
@@ -989,8 +982,7 @@ namespace FlaxEngine
/// <returns>A vector containing the smallest components of the source vectors.</returns> /// <returns>A vector containing the smallest components of the source vectors.</returns>
public static Vector4 Min(Vector4 left, Vector4 right) public static Vector4 Min(Vector4 left, Vector4 right)
{ {
Vector4 result; Min(ref left, ref right, out Vector4 result);
Min(ref left, ref right, out result);
return result; return result;
} }
@@ -1041,8 +1033,10 @@ namespace FlaxEngine
if (source == null) if (source == null)
throw new ArgumentNullException(nameof(source)); throw new ArgumentNullException(nameof(source));
if (destination == null) if (destination == null)
throw new ArgumentNullException(nameof(destination)); throw new ArgumentNullException(nameof(destination));
if (destination.Length < source.Length) if (destination.Length < source.Length)
throw new ArgumentOutOfRangeException(nameof(destination), "The destination array must be of same length or larger length than the source array."); throw new ArgumentOutOfRangeException(nameof(destination), "The destination array must be of same length or larger length than the source array.");
@@ -1096,8 +1090,10 @@ namespace FlaxEngine
if (source == null) if (source == null)
throw new ArgumentNullException(nameof(source)); throw new ArgumentNullException(nameof(source));
if (destination == null) if (destination == null)
throw new ArgumentNullException(nameof(destination)); throw new ArgumentNullException(nameof(destination));
if (destination.Length < source.Length) if (destination.Length < source.Length)
throw new ArgumentOutOfRangeException(nameof(destination), "The destination array must be of same length or larger length than the source array."); throw new ArgumentOutOfRangeException(nameof(destination), "The destination array must be of same length or larger length than the source array.");
@@ -1149,8 +1145,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Vector4" />.</returns> /// <returns>The transformed <see cref="Vector4" />.</returns>
public static Vector4 Transform(Vector4 vector, Quaternion rotation) public static Vector4 Transform(Vector4 vector, Quaternion rotation)
{ {
Vector4 result; Transform(ref vector, ref rotation, out Vector4 result);
Transform(ref vector, ref rotation, out result);
return result; return result;
} }
@@ -1175,8 +1170,10 @@ namespace FlaxEngine
{ {
if (source == null) if (source == null)
throw new ArgumentNullException(nameof(source)); throw new ArgumentNullException(nameof(source));
if (destination == null) if (destination == null)
throw new ArgumentNullException(nameof(destination)); throw new ArgumentNullException(nameof(destination));
if (destination.Length < source.Length) if (destination.Length < source.Length)
throw new ArgumentOutOfRangeException(nameof(destination), "The destination array must be of same length or larger length than the source array."); throw new ArgumentOutOfRangeException(nameof(destination), "The destination array must be of same length or larger length than the source array.");
@@ -1234,8 +1231,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Vector4" />.</returns> /// <returns>The transformed <see cref="Vector4" />.</returns>
public static Vector4 Transform(Vector4 vector, Matrix transform) public static Vector4 Transform(Vector4 vector, Matrix transform)
{ {
Vector4 result; Transform(ref vector, ref transform, out Vector4 result);
Transform(ref vector, ref transform, out result);
return result; return result;
} }
@@ -1260,8 +1256,10 @@ namespace FlaxEngine
{ {
if (source == null) if (source == null)
throw new ArgumentNullException(nameof(source)); throw new ArgumentNullException(nameof(source));
if (destination == null) if (destination == null)
throw new ArgumentNullException(nameof(destination)); throw new ArgumentNullException(nameof(destination));
if (destination.Length < source.Length) if (destination.Length < source.Length)
throw new ArgumentOutOfRangeException(nameof(destination), "The destination array must be of same length or larger length than the source array."); throw new ArgumentOutOfRangeException(nameof(destination), "The destination array must be of same length or larger length than the source array.");

View File

@@ -270,12 +270,10 @@ namespace FlaxEngine
/// <returns>The projected vector.</returns> /// <returns>The projected vector.</returns>
public Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world) public Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world)
{ {
Matrix matrix; Matrix.Multiply(ref world, ref view, out Matrix matrix);
Matrix.Multiply(ref world, ref view, out matrix);
Matrix.Multiply(ref matrix, ref projection, out matrix); Matrix.Multiply(ref matrix, ref projection, out matrix);
Vector3 vector; Project(ref source, ref matrix, out Vector3 vector);
Project(ref source, ref matrix, out vector);
return vector; return vector;
} }
@@ -310,13 +308,11 @@ namespace FlaxEngine
/// <returns>The unprojected Vector.</returns> /// <returns>The unprojected Vector.</returns>
public Vector3 Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world) public Vector3 Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world)
{ {
Matrix matrix; Matrix.Multiply(ref world, ref view, out Matrix matrix);
Matrix.Multiply(ref world, ref view, out matrix);
Matrix.Multiply(ref matrix, ref projection, out matrix); Matrix.Multiply(ref matrix, ref projection, out matrix);
Matrix.Invert(ref matrix, out matrix); Matrix.Invert(ref matrix, out matrix);
Vector3 vector; Unproject(ref source, ref matrix, out Vector3 vector);
Unproject(ref source, ref matrix, out vector);
return vector; return vector;
} }

View File

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

View File

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

View File

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

View File

@@ -162,9 +162,7 @@ namespace FlaxEngine.GUI
if (_timeToPopupLeft <= 0.0f) if (_timeToPopupLeft <= 0.0f)
{ {
Vector2 location; if (_lastTarget.OnShowTooltip(out _currentText, out Vector2 location, out Rectangle area))
Rectangle area;
if (_lastTarget.OnShowTooltip(out _currentText, out location, out area))
{ {
Show(_lastTarget, location, area); Show(_lastTarget, location, area);
} }

View File

@@ -62,12 +62,9 @@ namespace FlaxEngine
Profiler.BeginEventGPU("UI Canvas"); Profiler.BeginEventGPU("UI Canvas");
// Calculate rendering matrix (world*view*projection) // Calculate rendering matrix (world*view*projection)
Matrix viewProjectionMatrix; Canvas.GetWorldMatrix(out Matrix worldMatrix);
Matrix worldMatrix; Matrix.Multiply(ref worldMatrix, ref renderContext.View.View, out Matrix viewMatrix);
Canvas.GetWorldMatrix(out worldMatrix); Matrix.Multiply(ref viewMatrix, ref renderContext.View.Projection, out Matrix viewProjectionMatrix);
Matrix viewMatrix;
Matrix.Multiply(ref worldMatrix, ref renderContext.View.View, out viewMatrix);
Matrix.Multiply(ref viewMatrix, ref renderContext.View.Projection, out viewProjectionMatrix);
// Pick a depth buffer // Pick a depth buffer
GPUTexture depthBuffer = Canvas.IgnoreDepth ? null : renderContext.Buffers.DepthBuffer; GPUTexture depthBuffer = Canvas.IgnoreDepth ? null : renderContext.Buffers.DepthBuffer;

View File

@@ -97,11 +97,11 @@ namespace FlaxEngine
return new OrientedBoundingBox(); return new OrientedBoundingBox();
// Find control bounds limit points in canvas-space // Find control bounds limit points in canvas-space
var p1 = Vector2.Zero; Vector2 p1 = Vector2.Zero;
var p2 = new Vector2(0, Control.Height); Vector2 p2 = new Vector2(0, Control.Height);
var p3 = new Vector2(Control.Width, 0); Vector2 p3 = new Vector2(Control.Width, 0);
var p4 = Control.Size; Vector2 p4 = Control.Size;
var c = Control; Control c = Control;
while (c != canvasRoot) while (c != canvasRoot)
{ {
p1 = c.PointToParent(ref p1); p1 = c.PointToParent(ref p1);
@@ -111,9 +111,9 @@ namespace FlaxEngine
c = c.Parent; c = c.Parent;
} }
var min = Vector2.Min(Vector2.Min(p1, p2), Vector2.Min(p3, p4)); Vector2 min = Vector2.Min(Vector2.Min(p1, p2), Vector2.Min(p3, p4));
var max = Vector2.Max(Vector2.Max(p1, p2), Vector2.Max(p3, p4)); Vector2 max = Vector2.Max(Vector2.Max(p1, p2), Vector2.Max(p3, p4));
var size = max - min; Vector2 size = max - min;
// Calculate bounds // Calculate bounds
OrientedBoundingBox bounds = new OrientedBoundingBox OrientedBoundingBox bounds = new OrientedBoundingBox