Cleanup 3

This commit is contained in:
W2.Wizard
2021-02-21 11:09:04 +01:00
parent 92fafe877c
commit 20ba37e223
24 changed files with 181 additions and 119 deletions

View File

@@ -32,7 +32,7 @@ namespace FlaxEditor.Content.Import
var result = 0; var result = 0;
for (int i = 0; i < _rootNode.ChildrenCount; i++) for (int i = 0; i < _rootNode.ChildrenCount; i++)
{ {
if (_rootNode.Children[i].Tag is ImportFileEntry fileEntry) if (_rootNode.Children[i].Tag is ImportFileEntry)
result++; result++;
} }
return result; return result;

View File

@@ -261,13 +261,17 @@ namespace FlaxEditor.CustomEditors.Editors
// Ensure to have valid drag helpers (uses lazy init) // Ensure to have valid drag helpers (uses lazy init)
if (_dragActors == null) if (_dragActors == null)
_dragActors = new DragActors(x => IsValid(TypeUtils.GetObjectType(x.Actor))); _dragActors = new DragActors(x => IsValid(TypeUtils.GetObjectType(x.Actor)));
if (_dragScripts == null) if (_dragScripts == null)
_dragScripts = new DragScripts(x => IsValid(TypeUtils.GetObjectType(x))); _dragScripts = new DragScripts(x => IsValid(TypeUtils.GetObjectType(x)));
if (_dragHandlers == null) if (_dragHandlers == null)
{ {
_dragHandlers = new DragHandlers(); _dragHandlers = new DragHandlers
_dragHandlers.Add(_dragActors); {
_dragHandlers.Add(_dragScripts); _dragActors,
_dragScripts
};
} }
_hasValidDragOver = _dragHandlers.OnDragEnter(data) != DragDropEffect.None; _hasValidDragOver = _dragHandlers.OnDragEnter(data) != DragDropEffect.None;

View File

@@ -68,7 +68,6 @@ namespace FlaxEditor.GUI.Timeline.Tracks
var e = (ParticleEmitterTrack)track; var e = (ParticleEmitterTrack)track;
Guid id = new Guid(stream.ReadBytes(16)); Guid id = new Guid(stream.ReadBytes(16));
e.Asset = FlaxEngine.Content.LoadAsync<ParticleEmitter>(id); e.Asset = FlaxEngine.Content.LoadAsync<ParticleEmitter>(id);
var emitterIndex = stream.ReadInt32();
var m = e.TrackMedia; var m = e.TrackMedia;
m.StartFrame = stream.ReadInt32(); m.StartFrame = stream.ReadInt32();
m.DurationFrames = stream.ReadInt32(); m.DurationFrames = stream.ReadInt32();

View File

@@ -29,7 +29,6 @@ namespace FlaxEditor.Gizmo
private bool IntersectsRotateCircle(Vector3 normal, ref Ray ray, out float distance) private bool IntersectsRotateCircle(Vector3 normal, ref Ray ray, out float distance)
{ {
distance = float.MaxValue;
var plane = new Plane(Vector3.Zero, normal); var plane = new Plane(Vector3.Zero, normal);
if (!plane.Intersects(ref ray, out distance)) if (!plane.Intersects(ref ray, out distance))

View File

@@ -393,7 +393,7 @@ namespace FlaxEditor.Surface.Archetypes
int count = 0; int count = 0;
if (ExtractNumber(ref filterText, out vec[count])) if (ExtractNumber(ref filterText, out vec[count]))
{ {
count = count + 1; count++;
while (count < 4) while (count < 4)
{ {
if (ExtractComma(ref filterText) && ExtractNumber(ref filterText, out vec[count])) if (ExtractComma(ref filterText) && ExtractNumber(ref filterText, out vec[count]))

View File

@@ -305,8 +305,11 @@ namespace FlaxEditor.Surface.Elements
if (HasAnyConnection) if (HasAnyConnection)
{ {
// Remove all connections // Remove all connections
var toUpdate = new List<Box>(1 + Connections.Count); var toUpdate = new List<Box>(1 + Connections.Count)
toUpdate.Add(this); {
this
};
for (int i = 0; i < Connections.Count; i++) for (int i = 0; i < Connections.Count; i++)
{ {
var targetBox = Connections[i]; var targetBox = Connections[i];

View File

@@ -146,9 +146,10 @@ namespace FlaxEditor.Surface
for (int i = 0; i < entries; i++) for (int i = 0; i < entries; i++)
{ {
Entry e = new Entry(); Entry e = new Entry
{
e.TypeID = stream.ReadInt32(); TypeID = stream.ReadInt32()
};
stream.ReadInt64(); // don't use CreationTime stream.ReadInt64(); // don't use CreationTime
uint dataSize = stream.ReadUInt32(); uint dataSize = stream.ReadUInt32();

View File

@@ -76,9 +76,11 @@ namespace FlaxEditor.Surface.Undo
var iB = _input.Get(context); var iB = _input.Get(context);
var oB = _output.Get(context); var oB = _output.Get(context);
var toUpdate = new HashSet<Box>(); var toUpdate = new HashSet<Box>
toUpdate.Add(iB); {
toUpdate.Add(oB); iB,
oB
};
toUpdate.AddRange(iB.Connections); toUpdate.AddRange(iB.Connections);
toUpdate.AddRange(oB.Connections); toUpdate.AddRange(oB.Connections);

View File

@@ -56,8 +56,10 @@ namespace FlaxEditor.Tools.Foliage
if (!_staticModel) if (!_staticModel)
{ {
_staticModel = new StaticModel(); _staticModel = new StaticModel
_staticModel.StaticFlags = StaticFlags.None; {
StaticFlags = StaticFlags.None
};
} }
_staticModel.Model = model; _staticModel.Model = model;

View File

@@ -179,9 +179,11 @@ namespace FlaxEditor.Tools.Foliage
private void OnCreateNewFoliageClicked() private void OnCreateNewFoliageClicked()
{ {
// Create // Create
var actor = new FlaxEngine.Foliage(); var actor = new FlaxEngine.Foliage
actor.StaticFlags = StaticFlags.FullyStatic; {
actor.Name = "Foliage"; StaticFlags = StaticFlags.FullyStatic,
Name = "Foliage"
};
// Spawn // Spawn
Editor.SceneEditing.Spawn(actor); Editor.SceneEditing.Spawn(actor);

View File

@@ -84,7 +84,7 @@ namespace FlaxEditor.Utilities
while (bytes >= 1024 && order < MemorySizePostfixes.Length - 1) while (bytes >= 1024 && order < MemorySizePostfixes.Length - 1)
{ {
order++; order++;
bytes = bytes / 1024; bytes /= 1024;
} }
return string.Format("{0:0.##} {1}", bytes, MemorySizePostfixes[order]); return string.Format("{0:0.##} {1}", bytes, MemorySizePostfixes[order]);
@@ -101,7 +101,7 @@ namespace FlaxEditor.Utilities
while (bytes >= 1024 && order < MemorySizePostfixes.Length - 1) while (bytes >= 1024 && order < MemorySizePostfixes.Length - 1)
{ {
order++; order++;
bytes = bytes / 1024; bytes /= 1024;
} }
return string.Format("{0:0.##} {1}", bytes, MemorySizePostfixes[order]); return string.Format("{0:0.##} {1}", bytes, MemorySizePostfixes[order]);

View File

@@ -453,9 +453,11 @@ namespace FlaxEditor.Viewport
// Camera speed widget // Camera speed widget
var camSpeed = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight); var camSpeed = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight);
var camSpeedCM = new ContextMenu(); var camSpeedCM = new ContextMenu();
var camSpeedButton = new ViewportWidgetButton(_movementSpeed.ToString(), Editor.Instance.Icons.ArrowRightBorder16, camSpeedCM); var camSpeedButton = new ViewportWidgetButton(_movementSpeed.ToString(), Editor.Instance.Icons.ArrowRightBorder16, camSpeedCM)
camSpeedButton.Tag = this; {
camSpeedButton.TooltipText = "Camera speed scale"; Tag = this,
TooltipText = "Camera speed scale"
};
_speedWidget = camSpeedButton; _speedWidget = camSpeedButton;
for (int i = 0; i < EditorViewportCameraSpeedValues.Length; i++) for (int i = 0; i < EditorViewportCameraSpeedValues.Length; i++)
{ {
@@ -471,9 +473,11 @@ namespace FlaxEditor.Viewport
// View mode widget // View mode widget
var viewMode = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperLeft); var viewMode = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperLeft);
ViewWidgetButtonMenu = new ContextMenu(); ViewWidgetButtonMenu = new ContextMenu();
var viewModeButton = new ViewportWidgetButton("View", SpriteHandle.Invalid, ViewWidgetButtonMenu); var viewModeButton = new ViewportWidgetButton("View", SpriteHandle.Invalid, ViewWidgetButtonMenu)
viewModeButton.TooltipText = "View properties"; {
viewModeButton.Parent = viewMode; TooltipText = "View properties",
Parent = viewMode
};
viewMode.Parent = this; viewMode.Parent = this;
// Show // Show
@@ -524,8 +528,10 @@ namespace FlaxEditor.Viewport
// Orthographic // Orthographic
{ {
var ortho = ViewWidgetButtonMenu.AddButton("Orthographic"); var ortho = ViewWidgetButtonMenu.AddButton("Orthographic");
var orthoValue = new CheckBox(90, 2, _isOrtho); var orthoValue = new CheckBox(90, 2, _isOrtho)
orthoValue.Parent = ortho; {
Parent = ortho
};
orthoValue.StateChanged += checkBox => orthoValue.StateChanged += checkBox =>
{ {
if (checkBox.Checked != _isOrtho) if (checkBox.Checked != _isOrtho)
@@ -552,8 +558,11 @@ namespace FlaxEditor.Viewport
// Field of View // Field of View
{ {
var fov = ViewWidgetButtonMenu.AddButton("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); var fovValue = new FloatValueBox(1, 90, 2, 70.0f, 35.0f, 160.0f, 0.1f)
fovValue.Parent = fov; {
Parent = fov
};
fovValue.ValueChanged += () => _fieldOfView = fovValue.Value; fovValue.ValueChanged += () => _fieldOfView = fovValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => ViewWidgetButtonMenu.VisibleChanged += control =>
{ {
@@ -565,8 +574,11 @@ namespace FlaxEditor.Viewport
// Ortho Scale // Ortho Scale
{ {
var orthoSize = ViewWidgetButtonMenu.AddButton("Ortho Scale"); var orthoSize = ViewWidgetButtonMenu.AddButton("Ortho Scale");
var orthoSizeValue = new FloatValueBox(_orthoSize, 90, 2, 70.0f, 0.001f, 100000.0f, 0.01f); var orthoSizeValue = new FloatValueBox(_orthoSize, 90, 2, 70.0f, 0.001f, 100000.0f, 0.01f)
orthoSizeValue.Parent = orthoSize; {
Parent = orthoSize
};
orthoSizeValue.ValueChanged += () => _orthoSize = orthoSizeValue.Value; orthoSizeValue.ValueChanged += () => _orthoSize = orthoSizeValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => ViewWidgetButtonMenu.VisibleChanged += control =>
{ {
@@ -578,8 +590,10 @@ namespace FlaxEditor.Viewport
// Near Plane // Near Plane
{ {
var nearPlane = ViewWidgetButtonMenu.AddButton("Near Plane"); var nearPlane = ViewWidgetButtonMenu.AddButton("Near Plane");
var nearPlaneValue = new FloatValueBox(2.0f, 90, 2, 70.0f, 0.001f, 1000.0f); var nearPlaneValue = new FloatValueBox(2.0f, 90, 2, 70.0f, 0.001f, 1000.0f)
nearPlaneValue.Parent = nearPlane; {
Parent = nearPlane
};
nearPlaneValue.ValueChanged += () => _nearPlane = nearPlaneValue.Value; nearPlaneValue.ValueChanged += () => _nearPlane = nearPlaneValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => nearPlaneValue.Value = _nearPlane; ViewWidgetButtonMenu.VisibleChanged += control => nearPlaneValue.Value = _nearPlane;
} }
@@ -587,8 +601,10 @@ namespace FlaxEditor.Viewport
// Far Plane // Far Plane
{ {
var farPlane = ViewWidgetButtonMenu.AddButton("Far Plane"); var farPlane = ViewWidgetButtonMenu.AddButton("Far Plane");
var farPlaneValue = new FloatValueBox(1000, 90, 2, 70.0f, 10.0f); var farPlaneValue = new FloatValueBox(1000, 90, 2, 70.0f, 10.0f)
farPlaneValue.Parent = farPlane; {
Parent = farPlane
};
farPlaneValue.ValueChanged += () => _farPlane = farPlaneValue.Value; farPlaneValue.ValueChanged += () => _farPlane = farPlaneValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => farPlaneValue.Value = _farPlane; ViewWidgetButtonMenu.VisibleChanged += control => farPlaneValue.Value = _farPlane;
} }
@@ -596,8 +612,10 @@ namespace FlaxEditor.Viewport
// Brightness // Brightness
{ {
var brightness = ViewWidgetButtonMenu.AddButton("Brightness"); var brightness = ViewWidgetButtonMenu.AddButton("Brightness");
var brightnessValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.001f, 10.0f, 0.001f); var brightnessValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.001f, 10.0f, 0.001f)
brightnessValue.Parent = brightness; {
Parent = brightness
};
brightnessValue.ValueChanged += () => Brightness = brightnessValue.Value; brightnessValue.ValueChanged += () => Brightness = brightnessValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => brightnessValue.Value = Brightness; ViewWidgetButtonMenu.VisibleChanged += control => brightnessValue.Value = Brightness;
} }
@@ -605,8 +623,10 @@ namespace FlaxEditor.Viewport
// Resolution // Resolution
{ {
var resolution = ViewWidgetButtonMenu.AddButton("Resolution"); var resolution = ViewWidgetButtonMenu.AddButton("Resolution");
var resolutionValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.1f, 4.0f, 0.001f); var resolutionValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.1f, 4.0f, 0.001f)
resolutionValue.Parent = resolution; {
Parent = resolution
};
resolutionValue.ValueChanged += () => ResolutionScale = resolutionValue.Value; resolutionValue.ValueChanged += () => ResolutionScale = resolutionValue.Value;
ViewWidgetButtonMenu.VisibleChanged += control => resolutionValue.Value = ResolutionScale; ViewWidgetButtonMenu.VisibleChanged += control => resolutionValue.Value = ResolutionScale;
} }
@@ -614,8 +634,11 @@ namespace FlaxEditor.Viewport
// Invert Panning // Invert Panning
{ {
var invert = ViewWidgetButtonMenu.AddButton("Invert Panning"); var invert = ViewWidgetButtonMenu.AddButton("Invert Panning");
var invertValue = new CheckBox(90, 2, _invertPanning); var invertValue = new CheckBox(90, 2, _invertPanning)
invertValue.Parent = invert; {
Parent = invert
};
invertValue.StateChanged += checkBox => invertValue.StateChanged += checkBox =>
{ {
if (checkBox.Checked != _invertPanning) if (checkBox.Checked != _invertPanning)
@@ -690,10 +713,12 @@ namespace FlaxEditor.Viewport
private void InitFpsCounter() private void InitFpsCounter()
{ {
_fpsCounter = new FpsCounter(10, ViewportWidgetsContainer.WidgetsHeight + 14); _fpsCounter = new FpsCounter(10, ViewportWidgetsContainer.WidgetsHeight + 14)
_fpsCounter.Visible = false; {
_fpsCounter.Enabled = false; Visible = false,
_fpsCounter.Parent = this; Enabled = false,
Parent = this
};
} }
#endregion #endregion
@@ -1085,7 +1110,7 @@ namespace FlaxEditor.Viewport
{ {
// Accelerate the delta // Accelerate the delta
var currentDelta = mouseDelta; var currentDelta = mouseDelta;
mouseDelta = mouseDelta + _mouseDeltaRightLast * _mouseAccelerationScale; mouseDelta += _mouseDeltaRightLast * _mouseAccelerationScale;
_mouseDeltaRightLast = currentDelta; _mouseDeltaRightLast = currentDelta;
} }

View File

@@ -228,9 +228,13 @@ namespace FlaxEditor.Viewport
Parent = scaleSnappingWidget Parent = scaleSnappingWidget
}; };
enableScaleSnapping.Toggled += OnScaleSnappingToggle; enableScaleSnapping.Toggled += OnScaleSnappingToggle;
var scaleSnappingCM = new ContextMenu(); var scaleSnappingCM = new ContextMenu();
_scaleSnapping = new ViewportWidgetButton(TransformGizmo.ScaleSnapValue.ToString(), SpriteHandle.Invalid, scaleSnappingCM); _scaleSnapping = new ViewportWidgetButton(TransformGizmo.ScaleSnapValue.ToString(), SpriteHandle.Invalid, scaleSnappingCM)
_scaleSnapping.TooltipText = "Scale snapping values"; {
TooltipText = "Scale snapping values"
};
for (int i = 0; i < EditorViewportScaleSnapValues.Length; i++) for (int i = 0; i < EditorViewportScaleSnapValues.Length; i++)
{ {
var v = EditorViewportScaleSnapValues[i]; var v = EditorViewportScaleSnapValues[i];
@@ -251,9 +255,13 @@ namespace FlaxEditor.Viewport
Parent = rotateSnappingWidget Parent = rotateSnappingWidget
}; };
enableRotateSnapping.Toggled += OnRotateSnappingToggle; enableRotateSnapping.Toggled += OnRotateSnappingToggle;
var rotateSnappingCM = new ContextMenu(); var rotateSnappingCM = new ContextMenu();
_rotateSnapping = new ViewportWidgetButton(TransformGizmo.RotationSnapValue.ToString(), SpriteHandle.Invalid, rotateSnappingCM); _rotateSnapping = new ViewportWidgetButton(TransformGizmo.RotationSnapValue.ToString(), SpriteHandle.Invalid, rotateSnappingCM)
_rotateSnapping.TooltipText = "Rotation snapping values"; {
TooltipText = "Rotation snapping values"
};
for (int i = 0; i < EditorViewportRotateSnapValues.Length; i++) for (int i = 0; i < EditorViewportRotateSnapValues.Length; i++)
{ {
var v = EditorViewportRotateSnapValues[i]; var v = EditorViewportRotateSnapValues[i];
@@ -274,9 +282,13 @@ namespace FlaxEditor.Viewport
Parent = translateSnappingWidget Parent = translateSnappingWidget
}; };
enableTranslateSnapping.Toggled += OnTranslateSnappingToggle; enableTranslateSnapping.Toggled += OnTranslateSnappingToggle;
var translateSnappingCM = new ContextMenu(); var translateSnappingCM = new ContextMenu();
_translateSnapping = new ViewportWidgetButton(TransformGizmo.TranslationSnapValue.ToString(), SpriteHandle.Invalid, translateSnappingCM); _translateSnapping = new ViewportWidgetButton(TransformGizmo.TranslationSnapValue.ToString(), SpriteHandle.Invalid, translateSnappingCM)
_translateSnapping.TooltipText = "Position snapping values"; {
TooltipText = "Position snapping values"
};
for (int i = 0; i < EditorViewportTranslateSnapValues.Length; i++) for (int i = 0; i < EditorViewportTranslateSnapValues.Length; i++)
{ {
var v = EditorViewportTranslateSnapValues[i]; var v = EditorViewportTranslateSnapValues[i];
@@ -368,15 +380,17 @@ namespace FlaxEditor.Viewport
return; return;
// Create actor // Create actor
var actor = new Camera(); var actor = new Camera
actor.StaticFlags = StaticFlags.None; {
actor.Name = "Camera"; StaticFlags = StaticFlags.None,
actor.Transform = ViewTransform; Name = "Camera",
actor.NearPlane = NearPlane; Transform = ViewTransform,
actor.FarPlane = FarPlane; NearPlane = NearPlane,
actor.OrthographicScale = OrthographicScale; FarPlane = FarPlane,
actor.UsePerspective = !UseOrthographicProjection; OrthographicScale = OrthographicScale,
actor.FieldOfView = FieldOfView; UsePerspective = !UseOrthographicProjection,
FieldOfView = FieldOfView
};
// Spawn // Spawn
Editor.Instance.SceneEditing.Spawn(actor); Editor.Instance.SceneEditing.Spawn(actor);
@@ -846,9 +860,11 @@ namespace FlaxEditor.Viewport
if (assetItem.IsOfType<ParticleSystem>()) if (assetItem.IsOfType<ParticleSystem>())
{ {
var asset = FlaxEngine.Content.LoadAsync<ParticleSystem>(item.ID); var asset = FlaxEngine.Content.LoadAsync<ParticleSystem>(item.ID);
var actor = new ParticleEffect(); var actor = new ParticleEffect
actor.Name = item.ShortName; {
actor.ParticleSystem = asset; Name = item.ShortName,
ParticleSystem = asset
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Editor.Instance.SceneEditing.Spawn(actor); Editor.Instance.SceneEditing.Spawn(actor);
return; return;
@@ -856,9 +872,11 @@ namespace FlaxEditor.Viewport
if (assetItem.IsOfType<SceneAnimation>()) if (assetItem.IsOfType<SceneAnimation>())
{ {
var asset = FlaxEngine.Content.LoadAsync<SceneAnimation>(item.ID); var asset = FlaxEngine.Content.LoadAsync<SceneAnimation>(item.ID);
var actor = new SceneAnimationPlayer(); var actor = new SceneAnimationPlayer
actor.Name = item.ShortName; {
actor.Animation = asset; Name = item.ShortName,
Animation = asset
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Editor.Instance.SceneEditing.Spawn(actor); Editor.Instance.SceneEditing.Spawn(actor);
return; return;
@@ -891,9 +909,11 @@ namespace FlaxEditor.Viewport
if (assetItem.IsOfType<SkinnedModel>()) if (assetItem.IsOfType<SkinnedModel>())
{ {
var model = FlaxEngine.Content.LoadAsync<SkinnedModel>(item.ID); var model = FlaxEngine.Content.LoadAsync<SkinnedModel>(item.ID);
var actor = new AnimatedModel(); var actor = new AnimatedModel
actor.Name = item.ShortName; {
actor.SkinnedModel = model; Name = item.ShortName,
SkinnedModel = model
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Editor.Instance.SceneEditing.Spawn(actor); Editor.Instance.SceneEditing.Spawn(actor);
return; return;
@@ -901,9 +921,11 @@ namespace FlaxEditor.Viewport
if (assetItem.IsOfType<Model>()) if (assetItem.IsOfType<Model>())
{ {
var model = FlaxEngine.Content.LoadAsync<Model>(item.ID); var model = FlaxEngine.Content.LoadAsync<Model>(item.ID);
var actor = new StaticModel(); var actor = new StaticModel
actor.Name = item.ShortName; {
actor.Model = model; Name = item.ShortName,
Model = model
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Editor.Instance.SceneEditing.Spawn(actor); Editor.Instance.SceneEditing.Spawn(actor);
return; return;
@@ -911,9 +933,11 @@ namespace FlaxEditor.Viewport
if (assetItem.IsOfType<AudioClip>()) if (assetItem.IsOfType<AudioClip>())
{ {
var clip = FlaxEngine.Content.LoadAsync<AudioClip>(item.ID); var clip = FlaxEngine.Content.LoadAsync<AudioClip>(item.ID);
var actor = new AudioSource(); var actor = new AudioSource
actor.Name = item.ShortName; {
actor.Clip = clip; Name = item.ShortName,
Clip = clip
};
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
Editor.Instance.SceneEditing.Spawn(actor); Editor.Instance.SceneEditing.Spawn(actor);
return; return;

View File

@@ -313,7 +313,7 @@ namespace FlaxEngine
if (time < start) if (time < start)
{ {
if (loop) if (loop)
time = time + (Mathf.Floor(end - time) / length) * length; time += (Mathf.Floor(end - time) / length) * length;
else else
time = start; time = start;
} }
@@ -322,7 +322,7 @@ namespace FlaxEngine
if (time > end) if (time > end)
{ {
if (loop) if (loop)
time = time - Mathf.Floor((time - start) / length) * length; time -= Mathf.Floor((time - start) / length) * length;
else else
time = end; time = end;
} }
@@ -420,7 +420,7 @@ namespace FlaxEngine
{ {
if (Keyframes.Length == 0) if (Keyframes.Length == 0)
{ {
result = new Keyframe(time, default(T)); result = new Keyframe(time, default);
return; return;
} }
@@ -621,7 +621,7 @@ namespace FlaxEngine
{ {
Time = time; Time = time;
Value = value; Value = value;
TangentIn = TangentOut = default(T); TangentIn = TangentOut = default;
} }
/// <summary> /// <summary>
@@ -696,7 +696,7 @@ namespace FlaxEngine
{ {
if (Keyframes.Length == 0) if (Keyframes.Length == 0)
{ {
result = new Keyframe(time, default(T)); result = new Keyframe(time, default);
return; return;
} }

View File

@@ -307,7 +307,7 @@ namespace FlaxEngine.Collections
return true; return true;
} }
value = default(TValue); value = default;
return false; return false;
} }

View File

@@ -553,7 +553,7 @@ namespace FlaxEngine
return true; return true;
} }
denominator = denominator * denominator; denominator *= denominator;
//3x3 matrix for the first ray. //3x3 matrix for the first ray.
float m11 = ray2.Position.X - ray1.Position.X; float m11 = ray2.Position.X - ray1.Position.X;

View File

@@ -782,9 +782,9 @@ namespace FlaxEngine
s = vv / v; s = vv / v;
h = offset + (colorone - colortwo) / vv; h = offset + (colorone - colortwo) / vv;
} }
h = h / 6f; h /= 6f;
if (h < 0f) if (h < 0f)
h = h + 1f; h++;
} }
} }

View File

@@ -154,7 +154,7 @@ namespace FlaxEngine
{ {
float t = Repeat(target - current, 360f); float t = Repeat(target - current, 360f);
if (t > 180f) if (t > 180f)
t = t - 360f; t -= 360f;
return t; return t;
} }
@@ -222,7 +222,7 @@ namespace FlaxEngine
{ {
float c = Repeat(b - a, 360f); float c = Repeat(b - a, 360f);
if (c > 180f) if (c > 180f)
c = c - 360f; c -= 360f;
return a + c * Saturate(t); return a + c * Saturate(t);
} }

View File

@@ -1205,7 +1205,7 @@ namespace FlaxEngine
while (true) while (true)
{ {
if ((exponent & 1) != 0) if ((exponent & 1) != 0)
identity = identity * temp; identity *= temp;
exponent /= 2; exponent /= 2;
@@ -1517,14 +1517,14 @@ namespace FlaxEngine
//By separating the above algorithm into multiple lines, we actually increase accuracy. //By separating the above algorithm into multiple lines, we actually increase accuracy.
result = value; 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 -= 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.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 -= 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 -= 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.Row3, result.Row4) / Vector4.Dot(result.Row3, result.Row3) * result.Row3;
} }
/// <summary> /// <summary>
@@ -1594,16 +1594,16 @@ namespace FlaxEngine
result.Row1 = Vector4.Normalize(result.Row1); 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.Row2 = Vector4.Normalize(result.Row2);
result.Row3 = result.Row3 - Vector4.Dot(result.Row1, result.Row3) * result.Row1; 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.Row2, result.Row3) * result.Row2;
result.Row3 = Vector4.Normalize(result.Row3); result.Row3 = Vector4.Normalize(result.Row3);
result.Row4 = result.Row4 - Vector4.Dot(result.Row1, result.Row4) * result.Row1; result.Row4 -= Vector4.Dot(result.Row1, result.Row4) * result.Row1;
result.Row4 = result.Row4 - Vector4.Dot(result.Row2, result.Row4) * result.Row2; 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.Row3, result.Row4) * result.Row3;
result.Row4 = Vector4.Normalize(result.Row4); result.Row4 = Vector4.Normalize(result.Row4);
} }

View File

@@ -901,7 +901,7 @@ namespace FlaxEngine
while (true) while (true)
{ {
if ((exponent & 1) != 0) if ((exponent & 1) != 0)
identity = identity * temp; identity *= temp;
exponent /= 2; exponent /= 2;
@@ -1154,10 +1154,10 @@ namespace FlaxEngine
//By separating the above algorithm into multiple lines, we actually increase accuracy. //By separating the above algorithm into multiple lines, we actually increase accuracy.
result = value; 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 -= (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.Row2, result.Row3) / Vector3.Dot(result.Row2, result.Row2)) * result.Row2;
} }
/// <summary> /// <summary>
@@ -1215,11 +1215,11 @@ namespace FlaxEngine
result.Row1 = Vector3.Normalize(result.Row1); 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.Row2 = Vector3.Normalize(result.Row2);
result.Row3 = result.Row3 - Vector3.Dot(result.Row1, result.Row3) * result.Row1; 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.Row2, result.Row3) * result.Row2;
result.Row3 = Vector3.Normalize(result.Row3); result.Row3 = Vector3.Normalize(result.Row3);
} }

View File

@@ -337,7 +337,7 @@ namespace FlaxEngine
X = -X * lengthSq; X = -X * lengthSq;
Y = -Y * lengthSq; Y = -Y * lengthSq;
Z = -Z * lengthSq; Z = -Z * lengthSq;
W = W * lengthSq; W *= lengthSq;
} }
} }

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 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); 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); float alpha = Mathf.Min(1.0f, Mathf.Cos(_animateTime * BackgroundSelectedFlashSpeed) * 0.5f + 1.3f);
alpha = alpha * alpha; alpha *= alpha;
Color selectionColor = Color.White * alpha; Color selectionColor = Color.White * alpha;
Rectangle selectionRect = new Rectangle(leftEdge.X, leftEdge.Y, rightEdge.X - leftEdge.X, font.Height); Rectangle selectionRect = new Rectangle(leftEdge.X, leftEdge.Y, rightEdge.X - leftEdge.X, font.Height);
textBlock.Style.BackgroundSelectedBrush.Draw(selectionRect, selectionColor); textBlock.Style.BackgroundSelectedBrush.Draw(selectionRect, selectionColor);

View File

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

View File

@@ -116,12 +116,13 @@ namespace FlaxEngine
var size = max - min; var size = max - min;
// Calculate bounds // Calculate bounds
OrientedBoundingBox bounds = new OrientedBoundingBox(); OrientedBoundingBox bounds = new OrientedBoundingBox
bounds.Extents = new Vector3(size * 0.5f, Mathf.Epsilon); {
Matrix world; Extents = new Vector3(size * 0.5f, Mathf.Epsilon)
canvasRoot.Canvas.GetWorldMatrix(out world); };
Matrix offset;
Matrix.Translation(min.X + size.X * 0.5f, min.Y + size.Y * 0.5f, 0, out offset); 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); Matrix.Multiply(ref offset, ref world, out bounds.Transformation);
return bounds; return bounds;
} }