From 20ba37e22353867832d2bf51ed30b67db96b8134 Mon Sep 17 00:00:00 2001 From: "W2.Wizard" Date: Sun, 21 Feb 2021 11:09:04 +0100 Subject: [PATCH] Cleanup 3 --- .../Content/Import/ImportFilesDialog.cs | 2 +- .../CustomEditors/Editors/TypeEditor.cs | 10 ++- .../Timeline/Tracks/ParticleEmitterTrack.cs | 1 - .../Gizmo/TransformGizmoBase.Selection.cs | 1 - Source/Editor/Surface/Archetypes/Constants.cs | 2 +- Source/Editor/Surface/Elements/Box.cs | 7 +- Source/Editor/Surface/SurfaceMeta.cs | 7 +- .../Editor/Surface/Undo/ConnectBoxesAction.cs | 8 +- .../Foliage/EditFoliageSelectionOutline.cs | 6 +- Source/Editor/Tools/Foliage/FoliageTab.cs | 8 +- Source/Editor/Utilities/Utils.cs | 4 +- Source/Editor/Viewport/EditorViewport.cs | 79 +++++++++++------ .../Viewport/MainEditorGizmoViewport.cs | 84 ++++++++++++------- Source/Engine/Animations/Curve.cs | 10 +-- .../Core/Collections/OrderedDictionary.cs | 2 +- Source/Engine/Core/Math/CollisionsHelper.cs | 2 +- Source/Engine/Core/Math/Color.cs | 4 +- Source/Engine/Core/Math/Mathf.cs | 4 +- Source/Engine/Core/Math/Matrix.cs | 26 +++--- Source/Engine/Core/Math/Matrix3x3.cs | 14 ++-- Source/Engine/Core/Math/Quaternion.cs | 2 +- .../Engine/UI/GUI/Common/RichTextBoxBase.cs | 2 +- Source/Engine/UI/GUI/Common/TextBox.cs | 2 +- Source/Engine/UI/UIControl.cs | 13 +-- 24 files changed, 181 insertions(+), 119 deletions(-) diff --git a/Source/Editor/Content/Import/ImportFilesDialog.cs b/Source/Editor/Content/Import/ImportFilesDialog.cs index 2e3633d3b..6ccb28846 100644 --- a/Source/Editor/Content/Import/ImportFilesDialog.cs +++ b/Source/Editor/Content/Import/ImportFilesDialog.cs @@ -32,7 +32,7 @@ namespace FlaxEditor.Content.Import var result = 0; for (int i = 0; i < _rootNode.ChildrenCount; i++) { - if (_rootNode.Children[i].Tag is ImportFileEntry fileEntry) + if (_rootNode.Children[i].Tag is ImportFileEntry) result++; } return result; diff --git a/Source/Editor/CustomEditors/Editors/TypeEditor.cs b/Source/Editor/CustomEditors/Editors/TypeEditor.cs index 885109c00..95b9d0f9d 100644 --- a/Source/Editor/CustomEditors/Editors/TypeEditor.cs +++ b/Source/Editor/CustomEditors/Editors/TypeEditor.cs @@ -261,13 +261,17 @@ namespace FlaxEditor.CustomEditors.Editors // Ensure to have valid drag helpers (uses lazy init) if (_dragActors == null) _dragActors = new DragActors(x => IsValid(TypeUtils.GetObjectType(x.Actor))); + if (_dragScripts == null) _dragScripts = new DragScripts(x => IsValid(TypeUtils.GetObjectType(x))); + if (_dragHandlers == null) { - _dragHandlers = new DragHandlers(); - _dragHandlers.Add(_dragActors); - _dragHandlers.Add(_dragScripts); + _dragHandlers = new DragHandlers + { + _dragActors, + _dragScripts + }; } _hasValidDragOver = _dragHandlers.OnDragEnter(data) != DragDropEffect.None; diff --git a/Source/Editor/GUI/Timeline/Tracks/ParticleEmitterTrack.cs b/Source/Editor/GUI/Timeline/Tracks/ParticleEmitterTrack.cs index e7fa9e0ba..733664411 100644 --- a/Source/Editor/GUI/Timeline/Tracks/ParticleEmitterTrack.cs +++ b/Source/Editor/GUI/Timeline/Tracks/ParticleEmitterTrack.cs @@ -68,7 +68,6 @@ namespace FlaxEditor.GUI.Timeline.Tracks var e = (ParticleEmitterTrack)track; Guid id = new Guid(stream.ReadBytes(16)); e.Asset = FlaxEngine.Content.LoadAsync(id); - var emitterIndex = stream.ReadInt32(); var m = e.TrackMedia; m.StartFrame = stream.ReadInt32(); m.DurationFrames = stream.ReadInt32(); diff --git a/Source/Editor/Gizmo/TransformGizmoBase.Selection.cs b/Source/Editor/Gizmo/TransformGizmoBase.Selection.cs index d39447a34..b3e9211e2 100644 --- a/Source/Editor/Gizmo/TransformGizmoBase.Selection.cs +++ b/Source/Editor/Gizmo/TransformGizmoBase.Selection.cs @@ -29,7 +29,6 @@ namespace FlaxEditor.Gizmo private bool IntersectsRotateCircle(Vector3 normal, ref Ray ray, out float distance) { - distance = float.MaxValue; var plane = new Plane(Vector3.Zero, normal); if (!plane.Intersects(ref ray, out distance)) diff --git a/Source/Editor/Surface/Archetypes/Constants.cs b/Source/Editor/Surface/Archetypes/Constants.cs index 3ae9d6a8a..0b8defee0 100644 --- a/Source/Editor/Surface/Archetypes/Constants.cs +++ b/Source/Editor/Surface/Archetypes/Constants.cs @@ -393,7 +393,7 @@ namespace FlaxEditor.Surface.Archetypes int count = 0; if (ExtractNumber(ref filterText, out vec[count])) { - count = count + 1; + count++; while (count < 4) { if (ExtractComma(ref filterText) && ExtractNumber(ref filterText, out vec[count])) diff --git a/Source/Editor/Surface/Elements/Box.cs b/Source/Editor/Surface/Elements/Box.cs index b8d88741f..2a460013c 100644 --- a/Source/Editor/Surface/Elements/Box.cs +++ b/Source/Editor/Surface/Elements/Box.cs @@ -305,8 +305,11 @@ namespace FlaxEditor.Surface.Elements if (HasAnyConnection) { // Remove all connections - var toUpdate = new List(1 + Connections.Count); - toUpdate.Add(this); + var toUpdate = new List(1 + Connections.Count) + { + this + }; + for (int i = 0; i < Connections.Count; i++) { var targetBox = Connections[i]; diff --git a/Source/Editor/Surface/SurfaceMeta.cs b/Source/Editor/Surface/SurfaceMeta.cs index 4cd8405e4..c69981461 100644 --- a/Source/Editor/Surface/SurfaceMeta.cs +++ b/Source/Editor/Surface/SurfaceMeta.cs @@ -146,9 +146,10 @@ namespace FlaxEditor.Surface for (int i = 0; i < entries; i++) { - Entry e = new Entry(); - - e.TypeID = stream.ReadInt32(); + Entry e = new Entry + { + TypeID = stream.ReadInt32() + }; stream.ReadInt64(); // don't use CreationTime uint dataSize = stream.ReadUInt32(); diff --git a/Source/Editor/Surface/Undo/ConnectBoxesAction.cs b/Source/Editor/Surface/Undo/ConnectBoxesAction.cs index 6627364ed..c200f147d 100644 --- a/Source/Editor/Surface/Undo/ConnectBoxesAction.cs +++ b/Source/Editor/Surface/Undo/ConnectBoxesAction.cs @@ -76,9 +76,11 @@ namespace FlaxEditor.Surface.Undo var iB = _input.Get(context); var oB = _output.Get(context); - var toUpdate = new HashSet(); - toUpdate.Add(iB); - toUpdate.Add(oB); + var toUpdate = new HashSet + { + iB, + oB + }; toUpdate.AddRange(iB.Connections); toUpdate.AddRange(oB.Connections); diff --git a/Source/Editor/Tools/Foliage/EditFoliageSelectionOutline.cs b/Source/Editor/Tools/Foliage/EditFoliageSelectionOutline.cs index b79a4847a..0a3db1842 100644 --- a/Source/Editor/Tools/Foliage/EditFoliageSelectionOutline.cs +++ b/Source/Editor/Tools/Foliage/EditFoliageSelectionOutline.cs @@ -56,8 +56,10 @@ namespace FlaxEditor.Tools.Foliage if (!_staticModel) { - _staticModel = new StaticModel(); - _staticModel.StaticFlags = StaticFlags.None; + _staticModel = new StaticModel + { + StaticFlags = StaticFlags.None + }; } _staticModel.Model = model; diff --git a/Source/Editor/Tools/Foliage/FoliageTab.cs b/Source/Editor/Tools/Foliage/FoliageTab.cs index fe4120035..00a5c4312 100644 --- a/Source/Editor/Tools/Foliage/FoliageTab.cs +++ b/Source/Editor/Tools/Foliage/FoliageTab.cs @@ -179,9 +179,11 @@ namespace FlaxEditor.Tools.Foliage private void OnCreateNewFoliageClicked() { // Create - var actor = new FlaxEngine.Foliage(); - actor.StaticFlags = StaticFlags.FullyStatic; - actor.Name = "Foliage"; + var actor = new FlaxEngine.Foliage + { + StaticFlags = StaticFlags.FullyStatic, + Name = "Foliage" + }; // Spawn Editor.SceneEditing.Spawn(actor); diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs index 26c5ec92b..b81096120 100644 --- a/Source/Editor/Utilities/Utils.cs +++ b/Source/Editor/Utilities/Utils.cs @@ -84,7 +84,7 @@ namespace FlaxEditor.Utilities while (bytes >= 1024 && order < MemorySizePostfixes.Length - 1) { order++; - bytes = bytes / 1024; + bytes /= 1024; } return string.Format("{0:0.##} {1}", bytes, MemorySizePostfixes[order]); @@ -101,7 +101,7 @@ namespace FlaxEditor.Utilities while (bytes >= 1024 && order < MemorySizePostfixes.Length - 1) { order++; - bytes = bytes / 1024; + bytes /= 1024; } return string.Format("{0:0.##} {1}", bytes, MemorySizePostfixes[order]); diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs index a19589c05..00da69343 100644 --- a/Source/Editor/Viewport/EditorViewport.cs +++ b/Source/Editor/Viewport/EditorViewport.cs @@ -453,9 +453,11 @@ namespace FlaxEditor.Viewport // Camera speed widget var camSpeed = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight); var camSpeedCM = new ContextMenu(); - var camSpeedButton = new ViewportWidgetButton(_movementSpeed.ToString(), Editor.Instance.Icons.ArrowRightBorder16, camSpeedCM); - camSpeedButton.Tag = this; - camSpeedButton.TooltipText = "Camera speed scale"; + var camSpeedButton = new ViewportWidgetButton(_movementSpeed.ToString(), Editor.Instance.Icons.ArrowRightBorder16, camSpeedCM) + { + Tag = this, + TooltipText = "Camera speed scale" + }; _speedWidget = camSpeedButton; for (int i = 0; i < EditorViewportCameraSpeedValues.Length; i++) { @@ -471,9 +473,11 @@ namespace FlaxEditor.Viewport // View mode widget var viewMode = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperLeft); ViewWidgetButtonMenu = new ContextMenu(); - var viewModeButton = new ViewportWidgetButton("View", SpriteHandle.Invalid, ViewWidgetButtonMenu); - viewModeButton.TooltipText = "View properties"; - viewModeButton.Parent = viewMode; + var viewModeButton = new ViewportWidgetButton("View", SpriteHandle.Invalid, ViewWidgetButtonMenu) + { + TooltipText = "View properties", + Parent = viewMode + }; viewMode.Parent = this; // Show @@ -524,8 +528,10 @@ namespace FlaxEditor.Viewport // Orthographic { var ortho = ViewWidgetButtonMenu.AddButton("Orthographic"); - var orthoValue = new CheckBox(90, 2, _isOrtho); - orthoValue.Parent = ortho; + var orthoValue = new CheckBox(90, 2, _isOrtho) + { + Parent = ortho + }; orthoValue.StateChanged += checkBox => { if (checkBox.Checked != _isOrtho) @@ -552,8 +558,11 @@ namespace FlaxEditor.Viewport // Field of View { var fov = ViewWidgetButtonMenu.AddButton("Field Of View"); - var fovValue = new FloatValueBox(1, 90, 2, 70.0f, 35.0f, 160.0f, 0.1f); - fovValue.Parent = fov; + var fovValue = new FloatValueBox(1, 90, 2, 70.0f, 35.0f, 160.0f, 0.1f) + { + Parent = fov + }; + fovValue.ValueChanged += () => _fieldOfView = fovValue.Value; ViewWidgetButtonMenu.VisibleChanged += control => { @@ -565,8 +574,11 @@ namespace FlaxEditor.Viewport // Ortho Scale { var orthoSize = ViewWidgetButtonMenu.AddButton("Ortho Scale"); - var orthoSizeValue = new FloatValueBox(_orthoSize, 90, 2, 70.0f, 0.001f, 100000.0f, 0.01f); - orthoSizeValue.Parent = orthoSize; + var orthoSizeValue = new FloatValueBox(_orthoSize, 90, 2, 70.0f, 0.001f, 100000.0f, 0.01f) + { + Parent = orthoSize + }; + orthoSizeValue.ValueChanged += () => _orthoSize = orthoSizeValue.Value; ViewWidgetButtonMenu.VisibleChanged += control => { @@ -578,8 +590,10 @@ namespace FlaxEditor.Viewport // Near Plane { var nearPlane = ViewWidgetButtonMenu.AddButton("Near Plane"); - var nearPlaneValue = new FloatValueBox(2.0f, 90, 2, 70.0f, 0.001f, 1000.0f); - nearPlaneValue.Parent = nearPlane; + var nearPlaneValue = new FloatValueBox(2.0f, 90, 2, 70.0f, 0.001f, 1000.0f) + { + Parent = nearPlane + }; nearPlaneValue.ValueChanged += () => _nearPlane = nearPlaneValue.Value; ViewWidgetButtonMenu.VisibleChanged += control => nearPlaneValue.Value = _nearPlane; } @@ -587,8 +601,10 @@ namespace FlaxEditor.Viewport // Far Plane { var farPlane = ViewWidgetButtonMenu.AddButton("Far Plane"); - var farPlaneValue = new FloatValueBox(1000, 90, 2, 70.0f, 10.0f); - farPlaneValue.Parent = farPlane; + var farPlaneValue = new FloatValueBox(1000, 90, 2, 70.0f, 10.0f) + { + Parent = farPlane + }; farPlaneValue.ValueChanged += () => _farPlane = farPlaneValue.Value; ViewWidgetButtonMenu.VisibleChanged += control => farPlaneValue.Value = _farPlane; } @@ -596,8 +612,10 @@ namespace FlaxEditor.Viewport // Brightness { var brightness = ViewWidgetButtonMenu.AddButton("Brightness"); - var brightnessValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.001f, 10.0f, 0.001f); - brightnessValue.Parent = brightness; + var brightnessValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.001f, 10.0f, 0.001f) + { + Parent = brightness + }; brightnessValue.ValueChanged += () => Brightness = brightnessValue.Value; ViewWidgetButtonMenu.VisibleChanged += control => brightnessValue.Value = Brightness; } @@ -605,8 +623,10 @@ namespace FlaxEditor.Viewport // Resolution { var resolution = ViewWidgetButtonMenu.AddButton("Resolution"); - var resolutionValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.1f, 4.0f, 0.001f); - resolutionValue.Parent = resolution; + var resolutionValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.1f, 4.0f, 0.001f) + { + Parent = resolution + }; resolutionValue.ValueChanged += () => ResolutionScale = resolutionValue.Value; ViewWidgetButtonMenu.VisibleChanged += control => resolutionValue.Value = ResolutionScale; } @@ -614,8 +634,11 @@ namespace FlaxEditor.Viewport // Invert Panning { var invert = ViewWidgetButtonMenu.AddButton("Invert Panning"); - var invertValue = new CheckBox(90, 2, _invertPanning); - invertValue.Parent = invert; + var invertValue = new CheckBox(90, 2, _invertPanning) + { + Parent = invert + }; + invertValue.StateChanged += checkBox => { if (checkBox.Checked != _invertPanning) @@ -690,10 +713,12 @@ namespace FlaxEditor.Viewport private void InitFpsCounter() { - _fpsCounter = new FpsCounter(10, ViewportWidgetsContainer.WidgetsHeight + 14); - _fpsCounter.Visible = false; - _fpsCounter.Enabled = false; - _fpsCounter.Parent = this; + _fpsCounter = new FpsCounter(10, ViewportWidgetsContainer.WidgetsHeight + 14) + { + Visible = false, + Enabled = false, + Parent = this + }; } #endregion @@ -1085,7 +1110,7 @@ namespace FlaxEditor.Viewport { // Accelerate the delta var currentDelta = mouseDelta; - mouseDelta = mouseDelta + _mouseDeltaRightLast * _mouseAccelerationScale; + mouseDelta += _mouseDeltaRightLast * _mouseAccelerationScale; _mouseDeltaRightLast = currentDelta; } diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index 7906cc6e5..1eda01e41 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -228,9 +228,13 @@ namespace FlaxEditor.Viewport Parent = scaleSnappingWidget }; enableScaleSnapping.Toggled += OnScaleSnappingToggle; + var scaleSnappingCM = new ContextMenu(); - _scaleSnapping = new ViewportWidgetButton(TransformGizmo.ScaleSnapValue.ToString(), SpriteHandle.Invalid, scaleSnappingCM); - _scaleSnapping.TooltipText = "Scale snapping values"; + _scaleSnapping = new ViewportWidgetButton(TransformGizmo.ScaleSnapValue.ToString(), SpriteHandle.Invalid, scaleSnappingCM) + { + TooltipText = "Scale snapping values" + }; + for (int i = 0; i < EditorViewportScaleSnapValues.Length; i++) { var v = EditorViewportScaleSnapValues[i]; @@ -251,9 +255,13 @@ namespace FlaxEditor.Viewport Parent = rotateSnappingWidget }; enableRotateSnapping.Toggled += OnRotateSnappingToggle; + var rotateSnappingCM = new ContextMenu(); - _rotateSnapping = new ViewportWidgetButton(TransformGizmo.RotationSnapValue.ToString(), SpriteHandle.Invalid, rotateSnappingCM); - _rotateSnapping.TooltipText = "Rotation snapping values"; + _rotateSnapping = new ViewportWidgetButton(TransformGizmo.RotationSnapValue.ToString(), SpriteHandle.Invalid, rotateSnappingCM) + { + TooltipText = "Rotation snapping values" + }; + for (int i = 0; i < EditorViewportRotateSnapValues.Length; i++) { var v = EditorViewportRotateSnapValues[i]; @@ -274,9 +282,13 @@ namespace FlaxEditor.Viewport Parent = translateSnappingWidget }; enableTranslateSnapping.Toggled += OnTranslateSnappingToggle; + var translateSnappingCM = new ContextMenu(); - _translateSnapping = new ViewportWidgetButton(TransformGizmo.TranslationSnapValue.ToString(), SpriteHandle.Invalid, translateSnappingCM); - _translateSnapping.TooltipText = "Position snapping values"; + _translateSnapping = new ViewportWidgetButton(TransformGizmo.TranslationSnapValue.ToString(), SpriteHandle.Invalid, translateSnappingCM) + { + TooltipText = "Position snapping values" + }; + for (int i = 0; i < EditorViewportTranslateSnapValues.Length; i++) { var v = EditorViewportTranslateSnapValues[i]; @@ -368,15 +380,17 @@ namespace FlaxEditor.Viewport return; // Create actor - var actor = new Camera(); - actor.StaticFlags = StaticFlags.None; - actor.Name = "Camera"; - actor.Transform = ViewTransform; - actor.NearPlane = NearPlane; - actor.FarPlane = FarPlane; - actor.OrthographicScale = OrthographicScale; - actor.UsePerspective = !UseOrthographicProjection; - actor.FieldOfView = FieldOfView; + var actor = new Camera + { + StaticFlags = StaticFlags.None, + Name = "Camera", + Transform = ViewTransform, + NearPlane = NearPlane, + FarPlane = FarPlane, + OrthographicScale = OrthographicScale, + UsePerspective = !UseOrthographicProjection, + FieldOfView = FieldOfView + }; // Spawn Editor.Instance.SceneEditing.Spawn(actor); @@ -846,9 +860,11 @@ namespace FlaxEditor.Viewport if (assetItem.IsOfType()) { var asset = FlaxEngine.Content.LoadAsync(item.ID); - var actor = new ParticleEffect(); - actor.Name = item.ShortName; - actor.ParticleSystem = asset; + var actor = new ParticleEffect + { + Name = item.ShortName, + ParticleSystem = asset + }; actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); Editor.Instance.SceneEditing.Spawn(actor); return; @@ -856,9 +872,11 @@ namespace FlaxEditor.Viewport if (assetItem.IsOfType()) { var asset = FlaxEngine.Content.LoadAsync(item.ID); - var actor = new SceneAnimationPlayer(); - actor.Name = item.ShortName; - actor.Animation = asset; + var actor = new SceneAnimationPlayer + { + Name = item.ShortName, + Animation = asset + }; actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); Editor.Instance.SceneEditing.Spawn(actor); return; @@ -891,9 +909,11 @@ namespace FlaxEditor.Viewport if (assetItem.IsOfType()) { var model = FlaxEngine.Content.LoadAsync(item.ID); - var actor = new AnimatedModel(); - actor.Name = item.ShortName; - actor.SkinnedModel = model; + var actor = new AnimatedModel + { + Name = item.ShortName, + SkinnedModel = model + }; actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); Editor.Instance.SceneEditing.Spawn(actor); return; @@ -901,9 +921,11 @@ namespace FlaxEditor.Viewport if (assetItem.IsOfType()) { var model = FlaxEngine.Content.LoadAsync(item.ID); - var actor = new StaticModel(); - actor.Name = item.ShortName; - actor.Model = model; + var actor = new StaticModel + { + Name = item.ShortName, + Model = model + }; actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); Editor.Instance.SceneEditing.Spawn(actor); return; @@ -911,9 +933,11 @@ namespace FlaxEditor.Viewport if (assetItem.IsOfType()) { var clip = FlaxEngine.Content.LoadAsync(item.ID); - var actor = new AudioSource(); - actor.Name = item.ShortName; - actor.Clip = clip; + var actor = new AudioSource + { + Name = item.ShortName, + Clip = clip + }; actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); Editor.Instance.SceneEditing.Spawn(actor); return; diff --git a/Source/Engine/Animations/Curve.cs b/Source/Engine/Animations/Curve.cs index d9762d05f..56b6a1758 100644 --- a/Source/Engine/Animations/Curve.cs +++ b/Source/Engine/Animations/Curve.cs @@ -313,7 +313,7 @@ namespace FlaxEngine if (time < start) { if (loop) - time = time + (Mathf.Floor(end - time) / length) * length; + time += (Mathf.Floor(end - time) / length) * length; else time = start; } @@ -322,7 +322,7 @@ namespace FlaxEngine if (time > end) { if (loop) - time = time - Mathf.Floor((time - start) / length) * length; + time -= Mathf.Floor((time - start) / length) * length; else time = end; } @@ -420,7 +420,7 @@ namespace FlaxEngine { if (Keyframes.Length == 0) { - result = new Keyframe(time, default(T)); + result = new Keyframe(time, default); return; } @@ -621,7 +621,7 @@ namespace FlaxEngine { Time = time; Value = value; - TangentIn = TangentOut = default(T); + TangentIn = TangentOut = default; } /// @@ -696,7 +696,7 @@ namespace FlaxEngine { if (Keyframes.Length == 0) { - result = new Keyframe(time, default(T)); + result = new Keyframe(time, default); return; } diff --git a/Source/Engine/Core/Collections/OrderedDictionary.cs b/Source/Engine/Core/Collections/OrderedDictionary.cs index dc427193c..bd62d3451 100644 --- a/Source/Engine/Core/Collections/OrderedDictionary.cs +++ b/Source/Engine/Core/Collections/OrderedDictionary.cs @@ -307,7 +307,7 @@ namespace FlaxEngine.Collections return true; } - value = default(TValue); + value = default; return false; } diff --git a/Source/Engine/Core/Math/CollisionsHelper.cs b/Source/Engine/Core/Math/CollisionsHelper.cs index 22a3846f5..3500ee5a6 100644 --- a/Source/Engine/Core/Math/CollisionsHelper.cs +++ b/Source/Engine/Core/Math/CollisionsHelper.cs @@ -553,7 +553,7 @@ namespace FlaxEngine return true; } - denominator = denominator * denominator; + denominator *= denominator; //3x3 matrix for the first ray. float m11 = ray2.Position.X - ray1.Position.X; diff --git a/Source/Engine/Core/Math/Color.cs b/Source/Engine/Core/Math/Color.cs index a865bde15..cb1d8f379 100644 --- a/Source/Engine/Core/Math/Color.cs +++ b/Source/Engine/Core/Math/Color.cs @@ -782,9 +782,9 @@ namespace FlaxEngine s = vv / v; h = offset + (colorone - colortwo) / vv; } - h = h / 6f; + h /= 6f; if (h < 0f) - h = h + 1f; + h++; } } diff --git a/Source/Engine/Core/Math/Mathf.cs b/Source/Engine/Core/Math/Mathf.cs index 529bd6ab0..93e0ff8a4 100644 --- a/Source/Engine/Core/Math/Mathf.cs +++ b/Source/Engine/Core/Math/Mathf.cs @@ -154,7 +154,7 @@ namespace FlaxEngine { float t = Repeat(target - current, 360f); if (t > 180f) - t = t - 360f; + t -= 360f; return t; } @@ -222,7 +222,7 @@ namespace FlaxEngine { float c = Repeat(b - a, 360f); if (c > 180f) - c = c - 360f; + c -= 360f; return a + c * Saturate(t); } diff --git a/Source/Engine/Core/Math/Matrix.cs b/Source/Engine/Core/Math/Matrix.cs index a6ce7cb22..50863a3c9 100644 --- a/Source/Engine/Core/Math/Matrix.cs +++ b/Source/Engine/Core/Math/Matrix.cs @@ -1205,7 +1205,7 @@ namespace FlaxEngine while (true) { if ((exponent & 1) != 0) - identity = identity * temp; + identity *= temp; exponent /= 2; @@ -1517,14 +1517,14 @@ namespace FlaxEngine //By separating the above algorithm into multiple lines, we actually increase accuracy. result = value; - result.Row2 = result.Row2 - Vector4.Dot(result.Row1, result.Row2) / Vector4.Dot(result.Row1, result.Row1) * result.Row1; + result.Row2 -= Vector4.Dot(result.Row1, result.Row2) / Vector4.Dot(result.Row1, result.Row1) * result.Row1; - result.Row3 = result.Row3 - Vector4.Dot(result.Row1, result.Row3) / Vector4.Dot(result.Row1, result.Row1) * result.Row1; - result.Row3 = result.Row3 - Vector4.Dot(result.Row2, result.Row3) / Vector4.Dot(result.Row2, result.Row2) * result.Row2; + result.Row3 -= Vector4.Dot(result.Row1, result.Row3) / Vector4.Dot(result.Row1, result.Row1) * result.Row1; + result.Row3 -= Vector4.Dot(result.Row2, result.Row3) / Vector4.Dot(result.Row2, result.Row2) * result.Row2; - result.Row4 = result.Row4 - Vector4.Dot(result.Row1, result.Row4) / Vector4.Dot(result.Row1, result.Row1) * result.Row1; - result.Row4 = result.Row4 - Vector4.Dot(result.Row2, result.Row4) / Vector4.Dot(result.Row2, result.Row2) * result.Row2; - result.Row4 = result.Row4 - Vector4.Dot(result.Row3, result.Row4) / Vector4.Dot(result.Row3, result.Row3) * result.Row3; + result.Row4 -= Vector4.Dot(result.Row1, result.Row4) / Vector4.Dot(result.Row1, result.Row1) * result.Row1; + result.Row4 -= Vector4.Dot(result.Row2, result.Row4) / Vector4.Dot(result.Row2, result.Row2) * result.Row2; + result.Row4 -= Vector4.Dot(result.Row3, result.Row4) / Vector4.Dot(result.Row3, result.Row3) * result.Row3; } /// @@ -1594,16 +1594,16 @@ namespace FlaxEngine result.Row1 = Vector4.Normalize(result.Row1); - result.Row2 = result.Row2 - Vector4.Dot(result.Row1, result.Row2) * result.Row1; + result.Row2 -= Vector4.Dot(result.Row1, result.Row2) * result.Row1; result.Row2 = Vector4.Normalize(result.Row2); - result.Row3 = result.Row3 - Vector4.Dot(result.Row1, result.Row3) * result.Row1; - result.Row3 = result.Row3 - Vector4.Dot(result.Row2, result.Row3) * result.Row2; + result.Row3 -= Vector4.Dot(result.Row1, result.Row3) * result.Row1; + result.Row3 -= Vector4.Dot(result.Row2, result.Row3) * result.Row2; result.Row3 = Vector4.Normalize(result.Row3); - result.Row4 = result.Row4 - Vector4.Dot(result.Row1, result.Row4) * result.Row1; - result.Row4 = result.Row4 - Vector4.Dot(result.Row2, result.Row4) * result.Row2; - result.Row4 = result.Row4 - Vector4.Dot(result.Row3, result.Row4) * result.Row3; + result.Row4 -= Vector4.Dot(result.Row1, result.Row4) * result.Row1; + result.Row4 -= Vector4.Dot(result.Row2, result.Row4) * result.Row2; + result.Row4 -= Vector4.Dot(result.Row3, result.Row4) * result.Row3; result.Row4 = Vector4.Normalize(result.Row4); } diff --git a/Source/Engine/Core/Math/Matrix3x3.cs b/Source/Engine/Core/Math/Matrix3x3.cs index 4ef12383e..c18edc31e 100644 --- a/Source/Engine/Core/Math/Matrix3x3.cs +++ b/Source/Engine/Core/Math/Matrix3x3.cs @@ -901,7 +901,7 @@ namespace FlaxEngine while (true) { if ((exponent & 1) != 0) - identity = identity * temp; + identity *= temp; exponent /= 2; @@ -1154,10 +1154,10 @@ namespace FlaxEngine //By separating the above algorithm into multiple lines, we actually increase accuracy. result = value; - result.Row2 = result.Row2 - (Vector3.Dot(result.Row1, result.Row2) / Vector3.Dot(result.Row1, result.Row1)) * result.Row1; + result.Row2 -= (Vector3.Dot(result.Row1, result.Row2) / Vector3.Dot(result.Row1, result.Row1)) * result.Row1; - result.Row3 = result.Row3 - (Vector3.Dot(result.Row1, result.Row3) / Vector3.Dot(result.Row1, result.Row1)) * result.Row1; - result.Row3 = result.Row3 - (Vector3.Dot(result.Row2, result.Row3) / Vector3.Dot(result.Row2, result.Row2)) * result.Row2; + result.Row3 -= (Vector3.Dot(result.Row1, result.Row3) / Vector3.Dot(result.Row1, result.Row1)) * result.Row1; + result.Row3 -= (Vector3.Dot(result.Row2, result.Row3) / Vector3.Dot(result.Row2, result.Row2)) * result.Row2; } /// @@ -1215,11 +1215,11 @@ namespace FlaxEngine result.Row1 = Vector3.Normalize(result.Row1); - result.Row2 = result.Row2 - Vector3.Dot(result.Row1, result.Row2) * result.Row1; + result.Row2 -= Vector3.Dot(result.Row1, result.Row2) * result.Row1; result.Row2 = Vector3.Normalize(result.Row2); - result.Row3 = result.Row3 - Vector3.Dot(result.Row1, result.Row3) * result.Row1; - result.Row3 = result.Row3 - Vector3.Dot(result.Row2, result.Row3) * result.Row2; + result.Row3 -= Vector3.Dot(result.Row1, result.Row3) * result.Row1; + result.Row3 -= Vector3.Dot(result.Row2, result.Row3) * result.Row2; result.Row3 = Vector3.Normalize(result.Row3); } diff --git a/Source/Engine/Core/Math/Quaternion.cs b/Source/Engine/Core/Math/Quaternion.cs index bc86fa2c9..a87c8d413 100644 --- a/Source/Engine/Core/Math/Quaternion.cs +++ b/Source/Engine/Core/Math/Quaternion.cs @@ -337,7 +337,7 @@ namespace FlaxEngine X = -X * lengthSq; Y = -Y * lengthSq; Z = -Z * lengthSq; - W = W * lengthSq; + W *= lengthSq; } } diff --git a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs index 58e5bdaac..6bbcf6e1f 100644 --- a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs @@ -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); diff --git a/Source/Engine/UI/GUI/Common/TextBox.cs b/Source/Engine/UI/GUI/Common/TextBox.cs index 8c7db6e19..36460130f 100644 --- a/Source/Engine/UI/GUI/Common/TextBox.cs +++ b/Source/Engine/UI/GUI/Common/TextBox.cs @@ -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); diff --git a/Source/Engine/UI/UIControl.cs b/Source/Engine/UI/UIControl.cs index b31d9cab0..4222c13ca 100644 --- a/Source/Engine/UI/UIControl.cs +++ b/Source/Engine/UI/UIControl.cs @@ -116,12 +116,13 @@ namespace FlaxEngine var size = max - min; // Calculate bounds - OrientedBoundingBox bounds = new OrientedBoundingBox(); - bounds.Extents = new Vector3(size * 0.5f, Mathf.Epsilon); - Matrix world; - canvasRoot.Canvas.GetWorldMatrix(out world); - Matrix offset; - Matrix.Translation(min.X + size.X * 0.5f, min.Y + size.Y * 0.5f, 0, out offset); + OrientedBoundingBox bounds = new OrientedBoundingBox + { + Extents = new Vector3(size * 0.5f, Mathf.Epsilon) + }; + + canvasRoot.Canvas.GetWorldMatrix(out Matrix world); + Matrix.Translation(min.X + size.X * 0.5f, min.Y + size.Y * 0.5f, 0, out Matrix offset); Matrix.Multiply(ref offset, ref world, out bounds.Transformation); return bounds; }