Cleanup 8
This commit is contained in:
@@ -134,7 +134,7 @@ namespace FlaxEditor.GUI.Docking
|
||||
});
|
||||
|
||||
// Link to the master panel
|
||||
_masterPanel?.linkWindow(this);
|
||||
_masterPanel?.LinkWindow(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -409,7 +409,7 @@ namespace FlaxEditor.GUI.Docking
|
||||
Undock();
|
||||
|
||||
// Unlink from the master panel
|
||||
_masterPanel?.unlinkWindow(this);
|
||||
_masterPanel?.UnlinkWindow(this);
|
||||
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
@@ -97,13 +97,13 @@ namespace FlaxEditor.GUI.Docking
|
||||
return base.HitTest(ref position);
|
||||
}
|
||||
|
||||
internal void linkWindow(DockWindow window)
|
||||
internal void LinkWindow(DockWindow window)
|
||||
{
|
||||
// Add to the windows list
|
||||
Windows.Add(window);
|
||||
}
|
||||
|
||||
internal void unlinkWindow(DockWindow window)
|
||||
internal void UnlinkWindow(DockWindow window)
|
||||
{
|
||||
// Call event to the window
|
||||
window.OnUnlinkInternal();
|
||||
|
||||
@@ -96,17 +96,17 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
/// <param name="req">The request data.</param>
|
||||
public void OnThumbnailRenderingBegin(SceneRenderTask task, GPUContext context, ref CameraCutThumbnailRenderer.Request req)
|
||||
{
|
||||
var view = new RenderView();
|
||||
RenderView view = new RenderView();
|
||||
var track = (CameraCutTrack)Track;
|
||||
var cam = track.Camera;
|
||||
Camera cam = track.Camera;
|
||||
var viewport = new FlaxEngine.Viewport(Vector2.Zero, task.Buffers.Size);
|
||||
var orientation = Quaternion.Identity;
|
||||
Quaternion orientation = Quaternion.Identity;
|
||||
view.Near = 10.0f;
|
||||
view.Far = 20000.0f;
|
||||
var usePerspective = true;
|
||||
var orthoScale = 1.0f;
|
||||
var fov = 60.0f;
|
||||
var customAspectRatio = 0.0f;
|
||||
bool usePerspective = true;
|
||||
float orthoScale = 1.0f;
|
||||
float fov = 60.0f;
|
||||
float customAspectRatio = 0.0f;
|
||||
|
||||
// Try to evaluate camera properties based on the initial camera state
|
||||
if (cam)
|
||||
@@ -122,7 +122,7 @@ namespace FlaxEditor.GUI.Timeline.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)
|
||||
{
|
||||
if (subTrack is MemberTrack memberTrack)
|
||||
@@ -133,18 +133,25 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
// TODO: try to make it better
|
||||
if (memberTrack.MemberName == "Position" && value is Vector3 asPosition)
|
||||
view.Position = asPosition;
|
||||
|
||||
else if (memberTrack.MemberName == "Orientation" && value is Quaternion asRotation)
|
||||
orientation = asRotation;
|
||||
|
||||
else if (memberTrack.MemberName == "NearPlane" && value is float asNearPlane)
|
||||
view.Near = asNearPlane;
|
||||
|
||||
else if (memberTrack.MemberName == "FarPlane" && value is float asFarPlane)
|
||||
view.Far = asFarPlane;
|
||||
|
||||
else if (memberTrack.MemberName == "UsePerspective" && value is bool asUsePerspective)
|
||||
usePerspective = asUsePerspective;
|
||||
|
||||
else if (memberTrack.MemberName == "FieldOfView" && value is float asFieldOfView)
|
||||
fov = asFieldOfView;
|
||||
|
||||
else if (memberTrack.MemberName == "CustomAspectRatio" && value is float asCustomAspectRatio)
|
||||
customAspectRatio = asCustomAspectRatio;
|
||||
|
||||
else if (memberTrack.MemberName == "OrthographicScale" && value is float 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);
|
||||
}
|
||||
|
||||
Vector3 target = view.Position + view.Direction;
|
||||
var up = Vector3.Transform(Vector3.Up, orientation);
|
||||
view.View = Matrix.LookAt(view.Position, target, up);
|
||||
@@ -186,19 +194,23 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
if (image == null)
|
||||
{
|
||||
if (req.ThumbnailIndex == 0)
|
||||
{
|
||||
image = new Image
|
||||
{
|
||||
AnchorPreset = AnchorPresets.MiddleLeft,
|
||||
Parent = this,
|
||||
Bounds = new Rectangle(2, 2, CameraCutThumbnailRenderer.Width, CameraCutThumbnailRenderer.Height),
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
image = new Image
|
||||
{
|
||||
AnchorPreset = AnchorPresets.MiddleRight,
|
||||
Parent = this,
|
||||
Bounds = new Rectangle(Width - 2 - CameraCutThumbnailRenderer.Width, 2, CameraCutThumbnailRenderer.Width, CameraCutThumbnailRenderer.Height),
|
||||
};
|
||||
}
|
||||
image.UnlockChildrenRecursive();
|
||||
_thumbnails[req.ThumbnailIndex] = image;
|
||||
UpdateUI();
|
||||
|
||||
@@ -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++)
|
||||
{
|
||||
@@ -305,7 +305,7 @@ namespace FlaxEditor.GUI.Tree
|
||||
{
|
||||
selection.Add(child);
|
||||
if (child.IsExpanded)
|
||||
walkSelectExpandedTree(selection, child);
|
||||
WalkSelectExpandedTree(selection, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -322,7 +322,7 @@ namespace FlaxEditor.GUI.Tree
|
||||
|
||||
// Update selection
|
||||
Selection.Clear();
|
||||
walkSelectExpandedTree(Selection, _children[0] as TreeNode);
|
||||
WalkSelectExpandedTree(Selection, _children[0] as TreeNode);
|
||||
|
||||
// Check if changed
|
||||
if (Selection.Count != prev.Count || !Selection.SequenceEqual(prev))
|
||||
|
||||
@@ -215,20 +215,17 @@ namespace FlaxEditor.Windows.Assets
|
||||
{
|
||||
if (actor == null)
|
||||
throw new ArgumentNullException(nameof(actor));
|
||||
if (parent == null)
|
||||
throw new ArgumentNullException(nameof(parent));
|
||||
|
||||
// Link it
|
||||
actor.Parent = parent;
|
||||
actor.Parent = parent ?? throw new ArgumentNullException(nameof(parent));
|
||||
|
||||
// Peek spawned node
|
||||
var actorNode = SceneGraphFactory.FindNode(actor.ID) as ActorNode ?? SceneGraphFactory.BuildActorNode(actor);
|
||||
if (actorNode == null)
|
||||
throw new InvalidOperationException("Failed to create scene node for the spawned actor.");
|
||||
|
||||
var parentNode = SceneGraphFactory.FindNode(parent.ID) as ActorNode;
|
||||
if (parentNode == null)
|
||||
throw new InvalidOperationException("Missing scene graph node for the spawned parent actor.");
|
||||
actorNode.ParentNode = parentNode;
|
||||
actorNode.ParentNode = parentNode ?? throw new InvalidOperationException("Missing scene graph node for the spawned parent actor.");
|
||||
|
||||
// Call post spawn action (can possibly setup custom default values)
|
||||
actorNode.PostSpawn();
|
||||
|
||||
@@ -587,8 +587,7 @@ namespace FlaxEngine
|
||||
/// <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)
|
||||
{
|
||||
Vector4 result;
|
||||
Barycentric(ref value1, ref value2, ref value3, amount1, amount2, out result);
|
||||
Barycentric(ref value1, ref value2, ref value3, amount1, amount2, out Vector4 result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -629,8 +628,7 @@ namespace FlaxEngine
|
||||
/// <returns>The clamped value.</returns>
|
||||
public static Vector4 Clamp(Vector4 value, Vector4 min, Vector4 max)
|
||||
{
|
||||
Vector4 result;
|
||||
Clamp(ref value, ref min, ref max, out result);
|
||||
Clamp(ref value, ref min, ref max, out Vector4 result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -826,8 +824,7 @@ namespace FlaxEngine
|
||||
/// </remarks>
|
||||
public static Vector4 Lerp(Vector4 start, Vector4 end, float amount)
|
||||
{
|
||||
Vector4 result;
|
||||
Lerp(ref start, ref end, amount, out result);
|
||||
Lerp(ref start, ref end, amount, out Vector4 result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -853,8 +850,7 @@ namespace FlaxEngine
|
||||
/// <returns>The cubic interpolation of the two vectors.</returns>
|
||||
public static Vector4 SmoothStep(Vector4 start, Vector4 end, float amount)
|
||||
{
|
||||
Vector4 result;
|
||||
SmoothStep(ref start, ref end, amount, out result);
|
||||
SmoothStep(ref start, ref end, amount, out Vector4 result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -893,8 +889,7 @@ namespace FlaxEngine
|
||||
/// <returns>The result of the Hermite spline interpolation.</returns>
|
||||
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 result);
|
||||
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out Vector4 result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -929,8 +924,7 @@ namespace FlaxEngine
|
||||
/// <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)
|
||||
{
|
||||
Vector4 result;
|
||||
CatmullRom(ref value1, ref value2, ref value3, ref value4, amount, out result);
|
||||
CatmullRom(ref value1, ref value2, ref value3, ref value4, amount, out Vector4 result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -959,8 +953,7 @@ namespace FlaxEngine
|
||||
/// <returns>A vector containing the largest components of the source vectors.</returns>
|
||||
public static Vector4 Max(Vector4 left, Vector4 right)
|
||||
{
|
||||
Vector4 result;
|
||||
Max(ref left, ref right, out result);
|
||||
Max(ref left, ref right, out Vector4 result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -989,8 +982,7 @@ namespace FlaxEngine
|
||||
/// <returns>A vector containing the smallest components of the source vectors.</returns>
|
||||
public static Vector4 Min(Vector4 left, Vector4 right)
|
||||
{
|
||||
Vector4 result;
|
||||
Min(ref left, ref right, out result);
|
||||
Min(ref left, ref right, out Vector4 result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1041,8 +1033,10 @@ namespace FlaxEngine
|
||||
|
||||
if (source == null)
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
|
||||
if (destination == null)
|
||||
throw new ArgumentNullException(nameof(destination));
|
||||
|
||||
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.");
|
||||
|
||||
@@ -1096,8 +1090,10 @@ namespace FlaxEngine
|
||||
|
||||
if (source == null)
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
|
||||
if (destination == null)
|
||||
throw new ArgumentNullException(nameof(destination));
|
||||
|
||||
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.");
|
||||
|
||||
@@ -1149,8 +1145,7 @@ namespace FlaxEngine
|
||||
/// <returns>The transformed <see cref="Vector4" />.</returns>
|
||||
public static Vector4 Transform(Vector4 vector, Quaternion rotation)
|
||||
{
|
||||
Vector4 result;
|
||||
Transform(ref vector, ref rotation, out result);
|
||||
Transform(ref vector, ref rotation, out Vector4 result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1175,8 +1170,10 @@ namespace FlaxEngine
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
|
||||
if (destination == null)
|
||||
throw new ArgumentNullException(nameof(destination));
|
||||
|
||||
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.");
|
||||
|
||||
@@ -1234,8 +1231,7 @@ namespace FlaxEngine
|
||||
/// <returns>The transformed <see cref="Vector4" />.</returns>
|
||||
public static Vector4 Transform(Vector4 vector, Matrix transform)
|
||||
{
|
||||
Vector4 result;
|
||||
Transform(ref vector, ref transform, out result);
|
||||
Transform(ref vector, ref transform, out Vector4 result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1260,8 +1256,10 @@ namespace FlaxEngine
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
|
||||
if (destination == null)
|
||||
throw new ArgumentNullException(nameof(destination));
|
||||
|
||||
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.");
|
||||
|
||||
|
||||
@@ -270,12 +270,10 @@ namespace FlaxEngine
|
||||
/// <returns>The projected vector.</returns>
|
||||
public Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world)
|
||||
{
|
||||
Matrix matrix;
|
||||
Matrix.Multiply(ref world, ref view, out matrix);
|
||||
Matrix.Multiply(ref world, ref view, out Matrix matrix);
|
||||
Matrix.Multiply(ref matrix, ref projection, out matrix);
|
||||
|
||||
Vector3 vector;
|
||||
Project(ref source, ref matrix, out vector);
|
||||
Project(ref source, ref matrix, out Vector3 vector);
|
||||
return vector;
|
||||
}
|
||||
|
||||
@@ -310,13 +308,11 @@ namespace FlaxEngine
|
||||
/// <returns>The unprojected Vector.</returns>
|
||||
public Vector3 Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world)
|
||||
{
|
||||
Matrix matrix;
|
||||
Matrix.Multiply(ref world, ref view, out matrix);
|
||||
Matrix.Multiply(ref world, ref view, out Matrix matrix);
|
||||
Matrix.Multiply(ref matrix, ref projection, out matrix);
|
||||
Matrix.Invert(ref matrix, out matrix);
|
||||
|
||||
Vector3 vector;
|
||||
Unproject(ref source, ref matrix, out vector);
|
||||
Unproject(ref source, ref matrix, out Vector3 vector);
|
||||
return vector;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -62,12 +62,9 @@ namespace FlaxEngine
|
||||
Profiler.BeginEventGPU("UI Canvas");
|
||||
|
||||
// Calculate rendering matrix (world*view*projection)
|
||||
Matrix viewProjectionMatrix;
|
||||
Matrix worldMatrix;
|
||||
Canvas.GetWorldMatrix(out worldMatrix);
|
||||
Matrix viewMatrix;
|
||||
Matrix.Multiply(ref worldMatrix, ref renderContext.View.View, out viewMatrix);
|
||||
Matrix.Multiply(ref viewMatrix, ref renderContext.View.Projection, out viewProjectionMatrix);
|
||||
Canvas.GetWorldMatrix(out Matrix worldMatrix);
|
||||
Matrix.Multiply(ref worldMatrix, ref renderContext.View.View, out Matrix viewMatrix);
|
||||
Matrix.Multiply(ref viewMatrix, ref renderContext.View.Projection, out Matrix viewProjectionMatrix);
|
||||
|
||||
// Pick a depth buffer
|
||||
GPUTexture depthBuffer = Canvas.IgnoreDepth ? null : renderContext.Buffers.DepthBuffer;
|
||||
|
||||
@@ -97,11 +97,11 @@ namespace FlaxEngine
|
||||
return new OrientedBoundingBox();
|
||||
|
||||
// Find control bounds limit points in canvas-space
|
||||
var p1 = Vector2.Zero;
|
||||
var p2 = new Vector2(0, Control.Height);
|
||||
var p3 = new Vector2(Control.Width, 0);
|
||||
var p4 = Control.Size;
|
||||
var c = Control;
|
||||
Vector2 p1 = Vector2.Zero;
|
||||
Vector2 p2 = new Vector2(0, Control.Height);
|
||||
Vector2 p3 = new Vector2(Control.Width, 0);
|
||||
Vector2 p4 = Control.Size;
|
||||
Control c = Control;
|
||||
while (c != canvasRoot)
|
||||
{
|
||||
p1 = c.PointToParent(ref p1);
|
||||
@@ -111,9 +111,9 @@ namespace FlaxEngine
|
||||
|
||||
c = c.Parent;
|
||||
}
|
||||
var min = Vector2.Min(Vector2.Min(p1, p2), Vector2.Min(p3, p4));
|
||||
var max = Vector2.Max(Vector2.Max(p1, p2), Vector2.Max(p3, p4));
|
||||
var size = max - min;
|
||||
Vector2 min = Vector2.Min(Vector2.Min(p1, p2), Vector2.Min(p3, p4));
|
||||
Vector2 max = Vector2.Max(Vector2.Max(p1, p2), Vector2.Max(p3, p4));
|
||||
Vector2 size = max - min;
|
||||
|
||||
// Calculate bounds
|
||||
OrientedBoundingBox bounds = new OrientedBoundingBox
|
||||
|
||||
Reference in New Issue
Block a user