diff --git a/Source/Editor/Cooker/Platform/Android/AndroidPlatformTools.cpp b/Source/Editor/Cooker/Platform/Android/AndroidPlatformTools.cpp index 52273ec45..29726dd88 100644 --- a/Source/Editor/Cooker/Platform/Android/AndroidPlatformTools.cpp +++ b/Source/Editor/Cooker/Platform/Android/AndroidPlatformTools.cpp @@ -280,17 +280,25 @@ bool AndroidPlatformTools::OnPostProcess(CookingData& data) const Char* gradlew = TEXT("gradlew"); #endif #if PLATFORM_LINUX - Platform::RunProcess(String::Format(TEXT("chmod +x \"{0}/gradlew\""), data.OriginalOutputPath), data.OriginalOutputPath, Dictionary(), true); + { + CreateProcessSettings procSettings; + procSettings.FileName = String::Format(TEXT("chmod +x \"{0}/gradlew\""), data.OriginalOutputPath); + procSettings.WorkingDirectory = data.OriginalOutputPath; + procSettings.HiddenWindow = true; + Platform::CreateProcess(procSettings); + } #endif const bool distributionPackage = buildSettings->ForDistribution; - CreateProcessSettings procSettings; - procSettings.FileName = String::Format(TEXT("\"{0}\" {1}"), data.OriginalOutputPath / gradlew, distributionPackage ? TEXT("assemble") : TEXT("assembleDebug")); - procSettings.WorkingDirectory = data.OriginalOutputPath; - const int32 result = Platform::CreateProcess(procSettings); - if (result != 0) { - data.Error(String::Format(TEXT("Failed to build Gradle project into package (result code: {0}). See log for more info."), result)); - return true; + CreateProcessSettings procSettings; + procSettings.FileName = String::Format(TEXT("\"{0}\" {1}"), data.OriginalOutputPath / gradlew, distributionPackage ? TEXT("assemble") : TEXT("assembleDebug")); + procSettings.WorkingDirectory = data.OriginalOutputPath; + const int32 result = Platform::CreateProcess(procSettings); + if (result != 0) + { + data.Error(String::Format(TEXT("Failed to build Gradle project into package (result code: {0}). See log for more info."), result)); + return true; + } } // Copy result package diff --git a/Source/Editor/CustomEditors/Dedicated/MissingScriptEditor.cs b/Source/Editor/CustomEditors/Dedicated/MissingScriptEditor.cs index 8fb742b5e..7e0c6f38c 100644 --- a/Source/Editor/CustomEditors/Dedicated/MissingScriptEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/MissingScriptEditor.cs @@ -37,41 +37,32 @@ public class MissingScriptEditor : GenericEditor Parent = _dropPanel, Height = 64, }; - _replaceScriptButton = new Button { Text = "Replace Script", TooltipText = "Replaces the missing script with a given script type", AnchorPreset = AnchorPresets.TopCenter, - Width = 240, - Height = 24, - X = -120, - Y = 0, + Bounds = new Rectangle(-120, 0, 240, 24), Parent = replaceScriptPanel, }; _replaceScriptButton.Clicked += OnReplaceScriptButtonClicked; - var replaceAllLabel = new Label { Text = "Replace all matching missing scripts", TooltipText = "Whether or not to apply this script change to all scripts missing the same type.", AnchorPreset = AnchorPresets.BottomCenter, - Y = -34, + Y = -38, Parent = replaceScriptPanel, }; - replaceAllLabel.X -= FlaxEngine.GUI.Style.Current.FontSmall.MeasureText(replaceAllLabel.Text).X; - _shouldReplaceAllCheckbox = new CheckBox { TooltipText = replaceAllLabel.TooltipText, AnchorPreset = AnchorPresets.BottomCenter, - Y = -34, + Y = -38, Parent = replaceScriptPanel, }; - - float centerDifference = (_shouldReplaceAllCheckbox.Right - replaceAllLabel.Left) / 2; - replaceAllLabel.X += centerDifference; - _shouldReplaceAllCheckbox.X += centerDifference; + _shouldReplaceAllCheckbox.X -= _replaceScriptButton.Width * 0.5f + 0.5f; + replaceAllLabel.X -= 52; base.Initialize(layout); } diff --git a/Source/Editor/GUI/Docking/DockPanelProxy.cs b/Source/Editor/GUI/Docking/DockPanelProxy.cs index 15ff2cad0..e6e57de8e 100644 --- a/Source/Editor/GUI/Docking/DockPanelProxy.cs +++ b/Source/Editor/GUI/Docking/DockPanelProxy.cs @@ -13,6 +13,7 @@ namespace FlaxEditor.GUI.Docking public class DockPanelProxy : ContainerControl { private DockPanel _panel; + private double _dragEnterTime = -1; /// /// The is mouse down flag (left button). @@ -256,8 +257,8 @@ namespace FlaxEditor.GUI.Docking else { tabColor = style.BackgroundHighlighted; - Render2D.DrawLine(tabRect.BottomLeft - new Float2(0 , 1), tabRect.UpperLeft, tabColor); - Render2D.DrawLine(tabRect.BottomRight - new Float2(0 , 1), tabRect.UpperRight, tabColor); + Render2D.DrawLine(tabRect.BottomLeft - new Float2(0, 1), tabRect.UpperLeft, tabColor); + Render2D.DrawLine(tabRect.BottomRight - new Float2(0, 1), tabRect.UpperRight, tabColor); } if (tab.Icon.IsValid) @@ -477,11 +478,7 @@ namespace FlaxEditor.GUI.Docking var result = base.OnDragEnter(ref location, data); if (result != DragDropEffect.None) return result; - - if (TrySelectTabUnderLocation(ref location)) - return DragDropEffect.Move; - - return DragDropEffect.None; + return TrySelectTabUnderLocation(ref location); } /// @@ -490,11 +487,15 @@ namespace FlaxEditor.GUI.Docking var result = base.OnDragMove(ref location, data); if (result != DragDropEffect.None) return result; + return TrySelectTabUnderLocation(ref location); + } - if (TrySelectTabUnderLocation(ref location)) - return DragDropEffect.Move; + /// + public override void OnDragLeave() + { + _dragEnterTime = -1; - return DragDropEffect.None; + base.OnDragLeave(); } /// @@ -503,17 +504,25 @@ namespace FlaxEditor.GUI.Docking rect = new Rectangle(0, DockPanel.DefaultHeaderHeight, Width, Height - DockPanel.DefaultHeaderHeight); } - private bool TrySelectTabUnderLocation(ref Float2 location) + private DragDropEffect TrySelectTabUnderLocation(ref Float2 location) { var tab = GetTabAtPos(location, out _); if (tab != null) { + // Auto-select tab only if drag takes some time + var time = Platform.TimeSeconds; + if (_dragEnterTime < 0) + _dragEnterTime = time; + if (time - _dragEnterTime < 0.3f) + return DragDropEffect.Link; + _dragEnterTime = -1; + _panel.SelectTab(tab); Update(0); // Fake update - return true; + return DragDropEffect.Move; } - - return false; + _dragEnterTime = -1; + return DragDropEffect.None; } private void ShowContextMenu(DockWindow tab, ref Float2 location) diff --git a/Source/Editor/Gizmo/IGizmoOwner.cs b/Source/Editor/Gizmo/IGizmoOwner.cs index ff653196e..3ab0a917b 100644 --- a/Source/Editor/Gizmo/IGizmoOwner.cs +++ b/Source/Editor/Gizmo/IGizmoOwner.cs @@ -106,5 +106,11 @@ namespace FlaxEditor.Gizmo /// /// The nodes to select void Select(List nodes); + + /// + /// Spawns the actor in the viewport hierarchy. + /// + /// The new actor to spawn. + void Spawn(Actor actor); } } diff --git a/Source/Editor/Modules/SceneModule.cs b/Source/Editor/Modules/SceneModule.cs index 4fb28ac76..954e3bd50 100644 --- a/Source/Editor/Modules/SceneModule.cs +++ b/Source/Editor/Modules/SceneModule.cs @@ -242,7 +242,6 @@ namespace FlaxEditor.Modules /// True if don't close opened scenes and just add new scene to them, otherwise will release current scenes and load single one. public void OpenScene(Guid sceneId, bool additive = false) { - // Check if cannot change scene now if (!Editor.StateMachine.CurrentState.CanChangeScene) return; @@ -271,11 +270,21 @@ namespace FlaxEditor.Modules /// public void ReloadScenes() { + if (!Editor.StateMachine.CurrentState.CanChangeScene) + return; + + if (!Editor.IsPlayMode) + { + if (CheckSaveBeforeClose()) + return; + } + + // Reload scenes foreach (var scene in Level.Scenes) { var sceneId = scene.ID; - if (!Level.UnloadScene(scene)) - Level.LoadScene(sceneId); + Level.UnloadScene(scene); + Level.LoadScene(sceneId); } } @@ -285,7 +294,6 @@ namespace FlaxEditor.Modules /// The scene. public void CloseScene(Scene scene) { - // Check if cannot change scene now if (!Editor.StateMachine.CurrentState.CanChangeScene) return; @@ -309,7 +317,6 @@ namespace FlaxEditor.Modules /// public void CloseAllScenes() { - // Check if cannot change scene now if (!Editor.StateMachine.CurrentState.CanChangeScene) return; @@ -334,7 +341,6 @@ namespace FlaxEditor.Modules /// The scene to not close. public void CloseAllScenesExcept(Scene scene) { - // Check if cannot change scene now if (!Editor.StateMachine.CurrentState.CanChangeScene) return; diff --git a/Source/Editor/Scripting/CodeEditors/VisualStudioCodeEditor.cpp b/Source/Editor/Scripting/CodeEditors/VisualStudioCodeEditor.cpp index adccbba54..93fe7b300 100644 --- a/Source/Editor/Scripting/CodeEditors/VisualStudioCodeEditor.cpp +++ b/Source/Editor/Scripting/CodeEditors/VisualStudioCodeEditor.cpp @@ -78,7 +78,10 @@ void VisualStudioCodeEditor::FindEditors(Array* output) // Detect Flatpak installations { - if (Platform::RunProcess(TEXT("/bin/bash -c \"flatpak list --app --columns=application | grep com.visualstudio.code -c\""), String::Empty) == 0) + CreateProcessSettings procSettings; + procSettings.FileName = TEXT("/bin/bash -c \"flatpak list --app --columns=application | grep com.visualstudio.code -c\""); + procSettings.HiddenWindow = true; + if (Platform::CreateProcess(procSettings) == 0) { const String runPath(TEXT("flatpak run com.visualstudio.code")); output->Add(New(runPath, false)); diff --git a/Source/Editor/Surface/Archetypes/Parameters.cs b/Source/Editor/Surface/Archetypes/Parameters.cs index 6ed5a61e6..4cf1af4f6 100644 --- a/Source/Editor/Surface/Archetypes/Parameters.cs +++ b/Source/Editor/Surface/Archetypes/Parameters.cs @@ -1084,7 +1084,7 @@ namespace FlaxEditor.Surface.Archetypes }, Elements = new[] { - NodeElementArchetype.Factory.Input(0, string.Empty, true, typeof(void), 0), + NodeElementArchetype.Factory.Input(0, string.Empty, false, typeof(void), 0), NodeElementArchetype.Factory.Input(1, string.Empty, true, ScriptType.Null, 1, 1), NodeElementArchetype.Factory.Output(0, string.Empty, typeof(void), 2, true), NodeElementArchetype.Factory.ComboBox(2 + 20, 0, 116) diff --git a/Source/Editor/Viewport/EditorGizmoViewport.cs b/Source/Editor/Viewport/EditorGizmoViewport.cs index a24dd2f38..fe579e7e5 100644 --- a/Source/Editor/Viewport/EditorGizmoViewport.cs +++ b/Source/Editor/Viewport/EditorGizmoViewport.cs @@ -86,6 +86,9 @@ namespace FlaxEditor.Viewport /// public abstract void Select(List nodes); + /// + public abstract void Spawn(Actor actor); + /// protected override bool IsControllingMouse => Gizmos.Active?.IsControllingMouse ?? false; diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index e85b6c2b3..24c8f1c4c 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -5,9 +5,7 @@ using System.Collections.Generic; using FlaxEditor.Content; using FlaxEditor.Gizmo; using FlaxEditor.GUI.ContextMenu; -using FlaxEditor.GUI.Drag; using FlaxEditor.SceneGraph; -using FlaxEditor.SceneGraph.Actors; using FlaxEditor.Scripting; using FlaxEditor.Viewport.Cameras; using FlaxEditor.Viewport.Modes; @@ -37,28 +35,8 @@ namespace FlaxEditor.Viewport private readonly ViewportWidgetButton _rotateSnapping; private readonly ViewportWidgetButton _scaleSnapping; - private readonly DragAssets _dragAssets; - private readonly DragActorType _dragActorType = new DragActorType(ValidateDragActorType); - private SelectionOutline _customSelectionOutline; - /// - /// The custom drag drop event arguments. - /// - /// - public class DragDropEventArgs : DragEventArgs - { - /// - /// The hit. - /// - public SceneGraphNode Hit; - - /// - /// The hit location. - /// - public Vector3 HitLocation; - } - /// /// The editor sprites rendering effect. /// @@ -137,15 +115,12 @@ namespace FlaxEditor.Viewport private bool _lockedFocus; private double _lockedFocusOffset; private readonly ViewportDebugDrawData _debugDrawData = new ViewportDebugDrawData(32); - private StaticModel _previewStaticModel; - private int _previewModelEntryIndex; - private BrushSurface _previewBrushSurface; private EditorSpritesRenderer _editorSpritesRenderer; /// /// Drag and drop handlers /// - public readonly DragHandlers DragHandlers = new DragHandlers(); + public readonly ViewportDragHandlers DragHandlers; /// /// The transform gizmo. @@ -219,7 +194,7 @@ namespace FlaxEditor.Viewport : base(Object.New(), editor.Undo, editor.Scene.Root) { _editor = editor; - _dragAssets = new DragAssets(ValidateDragItem); + DragHandlers = new ViewportDragHandlers(this, this, ValidateDragItem, ValidateDragActorType); var inputOptions = editor.Options.Options.Input; // Prepare rendering task @@ -408,9 +383,6 @@ namespace FlaxEditor.Viewport ViewWidgetButtonMenu.AddSeparator(); ViewWidgetButtonMenu.AddButton("Create camera here", CreateCameraAtView); - DragHandlers.Add(_dragActorType); - DragHandlers.Add(_dragAssets); - // Init gizmo modes { // Add default modes used by the editor @@ -430,7 +402,11 @@ namespace FlaxEditor.Viewport InputActions.Add(options => options.TranslateMode, () => TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Translate); InputActions.Add(options => options.RotateMode, () => TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Rotate); InputActions.Add(options => options.ScaleMode, () => TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Scale); - InputActions.Add(options => options.ToggleTransformSpace, () => { OnTransformSpaceToggle(transformSpaceToggle); transformSpaceToggle.Checked = !transformSpaceToggle.Checked; }); + InputActions.Add(options => options.ToggleTransformSpace, () => + { + OnTransformSpaceToggle(transformSpaceToggle); + transformSpaceToggle.Checked = !transformSpaceToggle.Checked; + }); InputActions.Add(options => options.LockFocusSelection, LockFocusSelection); InputActions.Add(options => options.FocusSelection, FocusSelection); InputActions.Add(options => options.RotateSelection, RotateSelection); @@ -530,20 +506,9 @@ namespace FlaxEditor.Viewport private void OnCollectDrawCalls(ref RenderContext renderContext) { - if (_previewStaticModel) - { - _debugDrawData.HighlightModel(_previewStaticModel, _previewModelEntryIndex); - } - if (_previewBrushSurface.Brush != null) - { - _debugDrawData.HighlightBrushSurface(_previewBrushSurface); - } - + DragHandlers.CollectDrawCalls(_debugDrawData, ref renderContext); if (ShowNavigation) - { Editor.Internal_DrawNavMesh(); - } - _debugDrawData.OnDraw(ref renderContext); } @@ -942,78 +907,14 @@ namespace FlaxEditor.Viewport base.OnLeftMouseButtonUp(); } - private void GetHitLocation(ref Float2 location, out SceneGraphNode hit, out Vector3 hitLocation, out Vector3 hitNormal) - { - // Get mouse ray and try to hit any object - var ray = ConvertMouseToRay(ref location); - var view = new Ray(ViewPosition, ViewDirection); - var gridPlane = new Plane(Vector3.Zero, Vector3.Up); - var flags = SceneGraphNode.RayCastData.FlagTypes.SkipColliders | SceneGraphNode.RayCastData.FlagTypes.SkipEditorPrimitives; - hit = Editor.Instance.Scene.Root.RayCast(ref ray, ref view, out var closest, out var normal, flags); - if (hit != null) - { - // Use hit location - hitLocation = ray.Position + ray.Direction * closest; - hitNormal = normal; - } - else if (Grid.Enabled && CollisionsHelper.RayIntersectsPlane(ref ray, ref gridPlane, out closest) && closest < 4000.0f) - { - // Use grid location - hitLocation = ray.Position + ray.Direction * closest; - hitNormal = Vector3.Up; - } - else - { - // Use area in front of the viewport - hitLocation = ViewPosition + ViewDirection * 100; - hitNormal = Vector3.Up; - } - } - - private void SetDragEffects(ref Float2 location) - { - if (_dragAssets.HasValidDrag && _dragAssets.Objects[0].IsOfType()) - { - GetHitLocation(ref location, out var hit, out _, out _); - ClearDragEffects(); - var material = FlaxEngine.Content.LoadAsync(_dragAssets.Objects[0].ID); - if (material.IsDecal) - return; - - if (hit is StaticModelNode staticModelNode) - { - _previewStaticModel = (StaticModel)staticModelNode.Actor; - var ray = ConvertMouseToRay(ref location); - _previewStaticModel.IntersectsEntry(ref ray, out _, out _, out _previewModelEntryIndex); - } - else if (hit is BoxBrushNode.SideLinkNode brushSurfaceNode) - { - _previewBrushSurface = brushSurfaceNode.Surface; - } - } - } - - private void ClearDragEffects() - { - _previewStaticModel = null; - _previewModelEntryIndex = -1; - _previewBrushSurface = new BrushSurface(); - } - /// public override DragDropEffect OnDragEnter(ref Float2 location, DragData data) { - ClearDragEffects(); - + DragHandlers.ClearDragEffects(); var result = base.OnDragEnter(ref location, data); if (result != DragDropEffect.None) return result; - - result = DragHandlers.OnDragEnter(data); - - SetDragEffects(ref location); - - return result; + return DragHandlers.DragEnter(ref location, data); } private bool ValidateDragItem(ContentItem contentItem) @@ -1042,167 +943,29 @@ namespace FlaxEditor.Viewport /// public override DragDropEffect OnDragMove(ref Float2 location, DragData data) { - ClearDragEffects(); - + DragHandlers.ClearDragEffects(); var result = base.OnDragMove(ref location, data); if (result != DragDropEffect.None) return result; - - SetDragEffects(ref location); - - return DragHandlers.Effect; + return DragHandlers.DragEnter(ref location, data); } /// public override void OnDragLeave() { - ClearDragEffects(); - + DragHandlers.ClearDragEffects(); DragHandlers.OnDragLeave(); - base.OnDragLeave(); } - private Vector3 PostProcessSpawnedActorLocation(Actor actor, ref Vector3 hitLocation) - { - // Refresh actor position to ensure that cached bounds are valid - actor.Position = Vector3.One; - actor.Position = Vector3.Zero; - - // Place the object - //var location = hitLocation - (box.Size.Length * 0.5f) * ViewDirection; - var editorBounds = actor.EditorBoxChildren; - var bottomToCenter = actor.Position.Y - editorBounds.Minimum.Y; - var location = hitLocation + new Vector3(0, bottomToCenter, 0); - - // Apply grid snapping if enabled - if (UseSnapping || TransformGizmo.TranslationSnapEnable) - { - float snapValue = TransformGizmo.TranslationSnapValue; - location = new Vector3( - (int)(location.X / snapValue) * snapValue, - (int)(location.Y / snapValue) * snapValue, - (int)(location.Z / snapValue) * snapValue); - } - - return location; - } - - private void Spawn(Actor actor, ref Vector3 hitLocation, ref Vector3 hitNormal) - { - actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); - var parent = actor.Parent ?? Level.GetScene(0); - actor.Name = Utilities.Utils.IncrementNameNumber(actor.Name, x => parent.GetChild(x) == null); - Editor.Instance.SceneEditing.Spawn(actor); - Focus(); - } - - private void Spawn(AssetItem item, SceneGraphNode hit, ref Float2 location, ref Vector3 hitLocation, ref Vector3 hitNormal) - { - if (item.IsOfType()) - { - var material = FlaxEngine.Content.LoadAsync(item.ID); - if (material && !material.WaitForLoaded(100) && material.IsDecal) - { - var actor = new Decal - { - Material = material, - LocalOrientation = RootNode.RaycastNormalRotation(ref hitNormal), - Name = item.ShortName - }; - DebugDraw.DrawWireArrow(PostProcessSpawnedActorLocation(actor, ref hitNormal), actor.LocalOrientation, 1.0f, Color.Red, 1000000); - Spawn(actor, ref hitLocation, ref hitNormal); - } - else if (hit is StaticModelNode staticModelNode) - { - var staticModel = (StaticModel)staticModelNode.Actor; - var ray = ConvertMouseToRay(ref location); - if (staticModel.IntersectsEntry(ref ray, out _, out _, out var entryIndex)) - { - using (new UndoBlock(Undo, staticModel, "Change material")) - staticModel.SetMaterial(entryIndex, material); - } - } - else if (hit is BoxBrushNode.SideLinkNode brushSurfaceNode) - { - using (new UndoBlock(Undo, brushSurfaceNode.Brush, "Change material")) - { - var surface = brushSurfaceNode.Surface; - surface.Material = material; - brushSurfaceNode.Surface = surface; - } - } - return; - } - if (item.IsOfType()) - { - Editor.Instance.Scene.OpenScene(item.ID, true); - return; - } - { - var actor = item.OnEditorDrop(this); - actor.Name = item.ShortName; - Spawn(actor, ref hitLocation, ref hitNormal); - } - } - - private void Spawn(ScriptType item, SceneGraphNode hit, ref Float2 location, ref Vector3 hitLocation, ref Vector3 hitNormal) - { - var actor = item.CreateInstance() as Actor; - if (actor == null) - { - Editor.LogWarning("Failed to spawn actor of type " + item.TypeName); - return; - } - actor.Name = item.Name; - Spawn(actor, ref hitLocation, ref hitNormal); - } - /// public override DragDropEffect OnDragDrop(ref Float2 location, DragData data) { - ClearDragEffects(); - + DragHandlers.ClearDragEffects(); var result = base.OnDragDrop(ref location, data); if (result != DragDropEffect.None) return result; - - // Check if drag sth - Vector3 hitLocation = ViewPosition, hitNormal = -ViewDirection; - SceneGraphNode hit = null; - if (DragHandlers.HasValidDrag) - { - GetHitLocation(ref location, out hit, out hitLocation, out hitNormal); - } - - // Drag assets - if (_dragAssets.HasValidDrag) - { - result = _dragAssets.Effect; - - // Process items - for (int i = 0; i < _dragAssets.Objects.Count; i++) - { - var item = _dragAssets.Objects[i]; - Spawn(item, hit, ref location, ref hitLocation, ref hitNormal); - } - } - // Drag actor type - else if (_dragActorType.HasValidDrag) - { - result = _dragActorType.Effect; - - // Process items - for (int i = 0; i < _dragActorType.Objects.Count; i++) - { - var item = _dragActorType.Objects[i]; - Spawn(item, hit, ref location, ref hitLocation, ref hitNormal); - } - } - - DragHandlers.OnDragDrop(new DragDropEventArgs { Hit = hit, HitLocation = hitLocation }); - - return result; + return DragHandlers.DragDrop(ref location, data); } /// @@ -1211,6 +974,14 @@ namespace FlaxEditor.Viewport _editor.SceneEditing.Select(nodes); } + /// + public override void Spawn(Actor actor) + { + var parent = actor.Parent ?? Level.GetScene(0); + actor.Name = Utilities.Utils.IncrementNameNumber(actor.Name, x => parent.GetChild(x) == null); + Editor.Instance.SceneEditing.Spawn(actor); + } + /// public override void OnDestroy() { diff --git a/Source/Editor/Viewport/PrefabWindowViewport.cs b/Source/Editor/Viewport/PrefabWindowViewport.cs index eb462deb1..6e111f588 100644 --- a/Source/Editor/Viewport/PrefabWindowViewport.cs +++ b/Source/Editor/Viewport/PrefabWindowViewport.cs @@ -5,9 +5,7 @@ using System.Collections.Generic; using FlaxEditor.Content; using FlaxEditor.Gizmo; using FlaxEditor.GUI.ContextMenu; -using FlaxEditor.GUI.Drag; using FlaxEditor.SceneGraph; -using FlaxEditor.SceneGraph.Actors; using FlaxEditor.Scripting; using FlaxEditor.Viewport.Cameras; using FlaxEditor.Viewport.Previews; @@ -56,9 +54,11 @@ namespace FlaxEditor.Viewport private readonly ViewportDebugDrawData _debugDrawData = new ViewportDebugDrawData(32); private PrefabSpritesRenderer _spritesRenderer; - private readonly DragAssets _dragAssets; - private readonly DragActorType _dragActorType = new DragActorType(ValidateDragActorType); - private readonly DragHandlers _dragHandlers = new DragHandlers(); + + /// + /// Drag and drop handlers + /// + public readonly ViewportDragHandlers DragHandlers; /// /// The transform gizmo. @@ -81,7 +81,7 @@ namespace FlaxEditor.Viewport _window.SelectionChanged += OnSelectionChanged; Undo = window.Undo; ViewportCamera = new FPSCamera(); - _dragAssets = new DragAssets(ValidateDragItem); + DragHandlers = new ViewportDragHandlers(this, this, ValidateDragItem, ValidateDragActorType); ShowDebugDraw = true; ShowEditorPrimitives = true; Gizmos = new GizmosCollection(this); @@ -228,14 +228,15 @@ namespace FlaxEditor.Viewport _gizmoModeScale.Toggled += OnGizmoModeToggle; gizmoMode.Parent = this; - _dragHandlers.Add(_dragActorType); - _dragHandlers.Add(_dragAssets); - // Setup input actions InputActions.Add(options => options.TranslateMode, () => TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Translate); InputActions.Add(options => options.RotateMode, () => TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Rotate); InputActions.Add(options => options.ScaleMode, () => TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Scale); - InputActions.Add(options => options.ToggleTransformSpace, () => { OnTransformSpaceToggle(transformSpaceToggle); transformSpaceToggle.Checked = !transformSpaceToggle.Checked; }); + InputActions.Add(options => options.ToggleTransformSpace, () => + { + OnTransformSpaceToggle(transformSpaceToggle); + transformSpaceToggle.Checked = !transformSpaceToggle.Checked; + }); InputActions.Add(options => options.FocusSelection, ShowSelectedActors); SetUpdate(ref _update, OnUpdate); @@ -267,6 +268,7 @@ namespace FlaxEditor.Viewport private void OnCollectDrawCalls(ref RenderContext renderContext) { + DragHandlers.CollectDrawCalls(_debugDrawData, ref renderContext); _debugDrawData.OnDraw(ref renderContext); } @@ -306,6 +308,7 @@ namespace FlaxEditor.Viewport var orient = ViewOrientation; ((FPSCamera)ViewportCamera).ShowActors(TransformGizmo.SelectedParents, ref orient); } + /// public EditorViewport Viewport => this; @@ -354,6 +357,12 @@ namespace FlaxEditor.Viewport _window.Select(nodes); } + /// + public void Spawn(Actor actor) + { + _window.Spawn(actor); + } + /// protected override bool IsControllingMouse => Gizmos.Active?.IsControllingMouse ?? false; @@ -669,11 +678,11 @@ namespace FlaxEditor.Viewport /// public override DragDropEffect OnDragEnter(ref Float2 location, DragData data) { + DragHandlers.ClearDragEffects(); var result = base.OnDragEnter(ref location, data); if (result != DragDropEffect.None) return result; - - return _dragHandlers.OnDragEnter(data); + return DragHandlers.DragEnter(ref location, data); } private bool ValidateDragItem(ContentItem contentItem) @@ -685,7 +694,6 @@ namespace FlaxEditor.Viewport if (assetItem.IsOfType()) return true; } - return false; } @@ -697,86 +705,21 @@ namespace FlaxEditor.Viewport /// public override DragDropEffect OnDragMove(ref Float2 location, DragData data) { + DragHandlers.ClearDragEffects(); var result = base.OnDragMove(ref location, data); if (result != DragDropEffect.None) return result; - - return _dragHandlers.Effect; + return DragHandlers.DragEnter(ref location, data); } /// public override void OnDragLeave() { - _dragHandlers.OnDragLeave(); - + DragHandlers.ClearDragEffects(); + DragHandlers.OnDragLeave(); base.OnDragLeave(); } - private Vector3 PostProcessSpawnedActorLocation(Actor actor, ref Vector3 hitLocation) - { - // Place the object - //var location = hitLocation - (box.Size.Length * 0.5f) * ViewDirection; - var location = hitLocation; - - // Apply grid snapping if enabled - if (UseSnapping || TransformGizmo.TranslationSnapEnable) - { - float snapValue = TransformGizmo.TranslationSnapValue; - location = new Vector3( - (int)(location.X / snapValue) * snapValue, - (int)(location.Y / snapValue) * snapValue, - (int)(location.Z / snapValue) * snapValue); - } - - return location; - } - - private void Spawn(AssetItem item, SceneGraphNode hit, ref Float2 location, ref Vector3 hitLocation) - { - if (item is BinaryAssetItem binaryAssetItem) - { - if (typeof(MaterialBase).IsAssignableFrom(binaryAssetItem.Type)) - { - if (hit is StaticModelNode staticModelNode) - { - var staticModel = (StaticModel)staticModelNode.Actor; - var ray = ConvertMouseToRay(ref location); - if (staticModel.IntersectsEntry(ref ray, out _, out _, out var entryIndex)) - { - var material = FlaxEngine.Content.LoadAsync(item.ID); - using (new UndoBlock(Undo, staticModel, "Change material")) - staticModel.SetMaterial(entryIndex, material); - } - } - return; - } - } - { - var actor = item.OnEditorDrop(this); - actor.Name = item.ShortName; - Spawn(actor, ref hitLocation); - } - } - - private void Spawn(Actor actor, ref Vector3 hitLocation) - { - actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); - _window.Spawn(actor); - Focus(); - } - - private void Spawn(ScriptType item, SceneGraphNode hit, ref Vector3 hitLocation) - { - var actor = item.CreateInstance() as Actor; - if (actor == null) - { - Editor.LogWarning("Failed to spawn actor of type " + item.TypeName); - return; - } - actor.Name = item.Name; - Spawn(actor, ref hitLocation); - } - /// /// Focuses the viewport on the current selection of the gizmo. /// @@ -814,57 +757,11 @@ namespace FlaxEditor.Viewport /// public override DragDropEffect OnDragDrop(ref Float2 location, DragData data) { + DragHandlers.ClearDragEffects(); var result = base.OnDragDrop(ref location, data); if (result != DragDropEffect.None) return result; - - // Check if drag sth - Vector3 hitLocation = ViewPosition; - SceneGraphNode hit = null; - if (_dragHandlers.HasValidDrag) - { - // Get mouse ray and try to hit any object - var ray = ConvertMouseToRay(ref location); - var view = new Ray(ViewPosition, ViewDirection); - hit = _window.Graph.Root.RayCast(ref ray, ref view, out var closest, SceneGraphNode.RayCastData.FlagTypes.SkipColliders); - if (hit != null) - { - // Use hit location - hitLocation = ray.Position + ray.Direction * closest; - } - else - { - // Use area in front of the viewport - hitLocation = ViewPosition + ViewDirection * 100; - } - } - - // Drag assets - if (_dragAssets.HasValidDrag) - { - result = _dragAssets.Effect; - - // Process items - for (int i = 0; i < _dragAssets.Objects.Count; i++) - { - var item = _dragAssets.Objects[i]; - Spawn(item, hit, ref location, ref hitLocation); - } - } - // Drag actor type - else if (_dragActorType.HasValidDrag) - { - result = _dragActorType.Effect; - - // Process items - for (int i = 0; i < _dragActorType.Objects.Count; i++) - { - var item = _dragActorType.Objects[i]; - Spawn(item, hit, ref hitLocation); - } - } - - return result; + return DragHandlers.DragDrop(ref location, data); } /// diff --git a/Source/Editor/Viewport/ViewportDraggingHelper.cs b/Source/Editor/Viewport/ViewportDraggingHelper.cs new file mode 100644 index 000000000..8a1b4f183 --- /dev/null +++ b/Source/Editor/Viewport/ViewportDraggingHelper.cs @@ -0,0 +1,257 @@ +// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. + +using System; +using System.Linq; +using FlaxEditor.Content; +using FlaxEditor.Gizmo; +using FlaxEditor.GUI.Drag; +using FlaxEditor.SceneGraph; +using FlaxEditor.SceneGraph.Actors; +using FlaxEditor.Scripting; +using FlaxEngine; +using FlaxEngine.GUI; + +namespace FlaxEditor.Viewport +{ + /// + /// Utility to help managing dragging assets, actors and other objects into the editor viewport. + /// + public class ViewportDragHandlers : DragHandlers + { + /// + /// The custom drag drop event arguments. + /// + /// + public class DragDropEventArgs : DragEventArgs + { + /// + /// The hit. + /// + public SceneGraphNode Hit; + + /// + /// The hit location. + /// + public Vector3 HitLocation; + } + + private readonly IGizmoOwner _owner; + private readonly EditorViewport _viewport; + private readonly DragAssets _dragAssets; + private readonly DragActorType _dragActorType; + + private StaticModel _previewStaticModel; + private int _previewModelEntryIndex; + private BrushSurface _previewBrushSurface; + + internal ViewportDragHandlers(IGizmoOwner owner, EditorViewport viewport, Func validateAsset, Func validateDragActorType) + { + _owner = owner; + _viewport = viewport; + Add(_dragAssets = new DragAssets(validateAsset)); + Add(_dragActorType = new DragActorType(validateDragActorType)); + } + + internal void ClearDragEffects() + { + _previewStaticModel = null; + _previewModelEntryIndex = -1; + _previewBrushSurface = new BrushSurface(); + } + + internal void CollectDrawCalls(ViewportDebugDrawData debugDrawData, ref RenderContext renderContext) + { + if (_previewStaticModel) + debugDrawData.HighlightModel(_previewStaticModel, _previewModelEntryIndex); + if (_previewBrushSurface.Brush != null) + debugDrawData.HighlightBrushSurface(_previewBrushSurface); + } + + internal DragDropEffect DragEnter(ref Float2 location, DragData data) + { + var result = OnDragEnter(data); + SetDragEffects(ref location); + return result; + } + + internal DragDropEffect DragMove(ref Float2 location, DragData data) + { + SetDragEffects(ref location); + return Effect; + } + + internal DragDropEffect DragDrop(ref Float2 location, DragData data) + { + Vector3 hitLocation = _viewport.ViewPosition, hitNormal = -_viewport.ViewDirection; + SceneGraphNode hit = null; + if (HasValidDrag) + { + GetHitLocation(ref location, out hit, out hitLocation, out hitNormal); + } + + var result = DragDropEffect.None; + if (_dragAssets.HasValidDrag) + { + result = _dragAssets.Effect; + foreach (var asset in _dragAssets.Objects) + Spawn(asset, hit, ref location, ref hitLocation, ref hitNormal); + } + else if (_dragActorType.HasValidDrag) + { + result = _dragActorType.Effect; + foreach (var actorType in _dragActorType.Objects) + Spawn(actorType, hit, ref location, ref hitLocation, ref hitNormal); + } + + OnDragDrop(new DragDropEventArgs { Hit = hit, HitLocation = hitLocation }); + + return result; + } + + private void SetDragEffects(ref Float2 location) + { + if (_dragAssets.HasValidDrag && _dragAssets.Objects[0].IsOfType()) + { + GetHitLocation(ref location, out var hit, out _, out _); + ClearDragEffects(); + var material = FlaxEngine.Content.LoadAsync(_dragAssets.Objects[0].ID); + if (material.IsDecal) + return; + + if (hit is StaticModelNode staticModelNode) + { + _previewStaticModel = (StaticModel)staticModelNode.Actor; + var ray = _viewport.ConvertMouseToRay(ref location); + _previewStaticModel.IntersectsEntry(ref ray, out _, out _, out _previewModelEntryIndex); + } + else if (hit is BoxBrushNode.SideLinkNode brushSurfaceNode) + { + _previewBrushSurface = brushSurfaceNode.Surface; + } + } + } + + private void GetHitLocation(ref Float2 location, out SceneGraphNode hit, out Vector3 hitLocation, out Vector3 hitNormal) + { + // Get mouse ray and try to hit any object + var ray = _viewport.ConvertMouseToRay(ref location); + var view = new Ray(_viewport.ViewPosition, _viewport.ViewDirection); + var gridPlane = new Plane(Vector3.Zero, Vector3.Up); + var flags = SceneGraphNode.RayCastData.FlagTypes.SkipColliders | SceneGraphNode.RayCastData.FlagTypes.SkipEditorPrimitives; + hit = _owner.SceneGraphRoot.RayCast(ref ray, ref view, out var closest, out var normal, flags); + var girdGizmo = (GridGizmo)_owner.Gizmos.FirstOrDefault(x => x is GridGizmo); + if (hit != null) + { + // Use hit location + hitLocation = ray.Position + ray.Direction * closest; + hitNormal = normal; + } + else if (girdGizmo != null && girdGizmo.Enabled && CollisionsHelper.RayIntersectsPlane(ref ray, ref gridPlane, out closest) && closest < 4000.0f) + { + // Use grid location + hitLocation = ray.Position + ray.Direction * closest; + hitNormal = Vector3.Up; + } + else + { + // Use area in front of the viewport + hitLocation = view.GetPoint(100); + hitNormal = Vector3.Up; + } + } + + private Vector3 PostProcessSpawnedActorLocation(Actor actor, ref Vector3 hitLocation) + { + // Refresh actor position to ensure that cached bounds are valid + actor.Position = Vector3.One; + actor.Position = Vector3.Zero; + + // Place the object + //var location = hitLocation - (box.Size.Length * 0.5f) * ViewDirection; + var editorBounds = actor.EditorBoxChildren; + var bottomToCenter = actor.Position.Y - editorBounds.Minimum.Y; + var location = hitLocation + new Vector3(0, bottomToCenter, 0); + + // Apply grid snapping if enabled + var transformGizmo = (TransformGizmo)_owner.Gizmos.FirstOrDefault(x => x is TransformGizmo); + if (transformGizmo != null && (_owner.UseSnapping || transformGizmo.TranslationSnapEnable)) + { + float snapValue = transformGizmo.TranslationSnapValue; + location = new Vector3( + (int)(location.X / snapValue) * snapValue, + (int)(location.Y / snapValue) * snapValue, + (int)(location.Z / snapValue) * snapValue); + } + + return location; + } + + private void Spawn(Actor actor, ref Vector3 hitLocation, ref Vector3 hitNormal) + { + actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation); + _owner.Spawn(actor); + _viewport.Focus(); + } + + private void Spawn(ScriptType item, SceneGraphNode hit, ref Float2 location, ref Vector3 hitLocation, ref Vector3 hitNormal) + { + var actor = item.CreateInstance() as Actor; + if (actor == null) + { + Editor.LogWarning("Failed to spawn actor of type " + item.TypeName); + return; + } + actor.Name = item.Name; + Spawn(actor, ref hitLocation, ref hitNormal); + } + + private void Spawn(AssetItem item, SceneGraphNode hit, ref Float2 location, ref Vector3 hitLocation, ref Vector3 hitNormal) + { + if (item.IsOfType()) + { + var material = FlaxEngine.Content.LoadAsync(item.ID); + if (material && !material.WaitForLoaded(500) && material.IsDecal) + { + var actor = new Decal + { + Material = material, + LocalOrientation = RootNode.RaycastNormalRotation(ref hitNormal), + Name = item.ShortName + }; + DebugDraw.DrawWireArrow(PostProcessSpawnedActorLocation(actor, ref hitNormal), actor.LocalOrientation, 1.0f, Color.Red, 1000000); + Spawn(actor, ref hitLocation, ref hitNormal); + } + else if (hit is StaticModelNode staticModelNode) + { + var staticModel = (StaticModel)staticModelNode.Actor; + var ray = _viewport.ConvertMouseToRay(ref location); + if (staticModel.IntersectsEntry(ref ray, out _, out _, out var entryIndex)) + { + using (new UndoBlock(_owner.Undo, staticModel, "Change material")) + staticModel.SetMaterial(entryIndex, material); + } + } + else if (hit is BoxBrushNode.SideLinkNode brushSurfaceNode) + { + using (new UndoBlock(_owner.Undo, brushSurfaceNode.Brush, "Change material")) + { + var surface = brushSurfaceNode.Surface; + surface.Material = material; + brushSurfaceNode.Surface = surface; + } + } + return; + } + if (item.IsOfType()) + { + Editor.Instance.Scene.OpenScene(item.ID, true); + return; + } + { + var actor = item.OnEditorDrop(this); + actor.Name = item.ShortName; + Spawn(actor, ref hitLocation, ref hitNormal); + } + } + } +} diff --git a/Source/Editor/Windows/PluginsWindow.cs b/Source/Editor/Windows/PluginsWindow.cs index c5ec02b31..268c22581 100644 --- a/Source/Editor/Windows/PluginsWindow.cs +++ b/Source/Editor/Windows/PluginsWindow.cs @@ -190,7 +190,7 @@ namespace FlaxEditor.Windows }; _addPluginProjectButton = new Button { - Text = "Create Plugin Project", + Text = "Create Project", TooltipText = "Add new plugin project.", AnchorPreset = AnchorPresets.TopLeft, LocalLocation = new Float2(70, 18), @@ -201,7 +201,7 @@ namespace FlaxEditor.Windows _cloneProjectButton = new Button { - Text = "Clone Plugin Project", + Text = "Clone Project", TooltipText = "Git Clone a plugin project.", AnchorPreset = AnchorPresets.TopLeft, LocalLocation = new Float2(70 + _addPluginProjectButton.Size.X + 8, 18), diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index 250bd2301..63ba7b960 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -423,6 +423,7 @@ namespace FlaxEditor.Windows var actor = item.OnEditorDrop(this); actor.Name = item.ShortName; Level.SpawnActor(actor); + Editor.Scene.MarkSceneEdited(actor.Scene); } result = DragDropEffect.Move; } @@ -440,6 +441,7 @@ namespace FlaxEditor.Windows } actor.Name = item.Name; Level.SpawnActor(actor); + Editor.Scene.MarkSceneEdited(actor.Scene); } result = DragDropEffect.Move; } diff --git a/Source/Editor/Windows/Search/ContentSearchWindow.cs b/Source/Editor/Windows/Search/ContentSearchWindow.cs index e6e407247..305fa16d6 100644 --- a/Source/Editor/Windows/Search/ContentSearchWindow.cs +++ b/Source/Editor/Windows/Search/ContentSearchWindow.cs @@ -72,6 +72,7 @@ namespace FlaxEngine.Windows.Search /// /// The content searching window. Allows to search inside Visual Scripts, Materials, Particles and other assets. /// + [HideInEditor] internal class ContentSearchWindow : EditorWindow { /// @@ -115,6 +116,7 @@ namespace FlaxEngine.Windows.Search } } + [HideInEditor] private sealed class SearchResultTreeNode : TreeNode { public Action Navigate; diff --git a/Source/Engine/Core/Math/Math.h b/Source/Engine/Core/Math/Math.h index 276f64884..a3c05fce4 100644 --- a/Source/Engine/Core/Math/Math.h +++ b/Source/Engine/Core/Math/Math.h @@ -728,9 +728,7 @@ namespace Math /// /// Returns value based on comparand. The main purpose of this function is to avoid branching based on floating point comparison which can be avoided via compiler intrinsics. /// - /// - /// Please note that this doesn't define what happens in the case of NaNs as there might be platform specific differences. - /// + /// Please note that this doesn't define what happens in the case of NaNs as there might be platform specific differences. /// Comparand the results are based on. /// The result value if comparand >= 0. /// The result value if comparand < 0. @@ -891,6 +889,18 @@ namespace Math return Lerp(a, b, alpha < 0.5f ? InterpCircularIn(0.f, 1.f, alpha * 2.f) * 0.5f : InterpCircularOut(0.f, 1.f, alpha * 2.f - 1.f) * 0.5f + 0.5f); } + /// + /// Ping pongs the value , so that it is never larger than and never smaller than 0. + /// + /// + /// + /// + template + static FORCE_INLINE T PingPong(const T& t, T length) + { + return length - Abs(Repeat(t, length * 2.0f) - length); + } + // Rotates position about the given axis by the given angle, in radians, and returns the offset to position Vector3 FLAXENGINE_API RotateAboutAxis(const Vector3& normalizedRotationAxis, float angle, const Vector3& positionOnAxis, const Vector3& position); diff --git a/Source/Engine/Core/Types/StringBuilder.h b/Source/Engine/Core/Types/StringBuilder.h index 051554a23..068f245d0 100644 --- a/Source/Engine/Core/Types/StringBuilder.h +++ b/Source/Engine/Core/Types/StringBuilder.h @@ -3,6 +3,7 @@ #pragma once #include "String.h" +#include "StringView.h" #include "Engine/Core/Collections/Array.h" /// @@ -138,6 +139,11 @@ public: _data.Add(*str, str.Length()); return *this; } + StringBuilder& Append(const StringView& str) + { + _data.Add(*str, str.Length()); + return *this; + } // Append int to the string // @param val Value to append diff --git a/Source/Engine/Graphics/Enums.h b/Source/Engine/Graphics/Enums.h index 4d1422f96..bbf9c0de8 100644 --- a/Source/Engine/Graphics/Enums.h +++ b/Source/Engine/Graphics/Enums.h @@ -591,37 +591,37 @@ API_ENUM() enum class Quality : byte API_ENUM() enum class MaterialPostFxLocation : byte { /// - /// The 'after' post processing pass using LDR input frame. + /// Render the material after the post processing pass using *LDR* input frame. /// AfterPostProcessingPass = 0, /// - /// The 'before' post processing pass using HDR input frame. + /// Render the material before the post processing pass using *HDR* input frame. /// BeforePostProcessingPass = 1, /// - /// The 'before' forward pass but after GBuffer with HDR input frame. + /// Render the material before the forward pass but after *GBuffer* with *HDR* input frame. /// BeforeForwardPass = 2, /// - /// The 'after' custom post effects. + /// Render the material after custom post effects (scripted). /// AfterCustomPostEffects = 3, /// - /// The 'before' Reflections pass. After the Light pass. Can be used to implement a custom light types that accumulate lighting to the light buffer. + /// Render the material before the reflections pass but after the lighting pass using *HDR* input frame. It can be used to implement a custom light types that accumulate lighting to the light buffer. /// BeforeReflectionsPass = 4, /// - /// The 'after' AA filter pass. Rendering is done to the output backbuffer. + /// Render the material after anti-aliasing into the output backbuffer. /// AfterAntiAliasingPass = 5, /// - /// The 'after' forward pass but before any post processing. + /// Render the material after the forward pass but before any post processing. /// AfterForwardPass = 6, diff --git a/Source/Engine/Graphics/Graphics.cpp b/Source/Engine/Graphics/Graphics.cpp index fa03fb7cd..f91c58cea 100644 --- a/Source/Engine/Graphics/Graphics.cpp +++ b/Source/Engine/Graphics/Graphics.cpp @@ -67,7 +67,8 @@ void GraphicsSettings::Apply() Graphics::AllowCSMBlending = AllowCSMBlending; Graphics::GlobalSDFQuality = GlobalSDFQuality; Graphics::GIQuality = GIQuality; - Graphics::PostProcessSettings = PostProcessSettings; + Graphics::PostProcessSettings = ::PostProcessSettings(); + Graphics::PostProcessSettings.BlendWith(PostProcessSettings, 1.0f); } void Graphics::DisposeDevice() diff --git a/Source/Engine/Graphics/PostProcessSettings.h b/Source/Engine/Graphics/PostProcessSettings.h index d2ace6cea..1d695f353 100644 --- a/Source/Engine/Graphics/PostProcessSettings.h +++ b/Source/Engine/Graphics/PostProcessSettings.h @@ -447,13 +447,13 @@ API_STRUCT() struct FLAXENGINE_API BloomSettings : ISerializable bool Enabled = true; /// - /// Bloom effect strength. Value 0 disabled is, while higher values increase the effect. + /// Bloom effect strength. Set a value of 0 to disabled it, while higher values increase the effect. /// API_FIELD(Attributes="Limit(0, 20.0f, 0.01f), EditorOrder(1), PostProcessSetting((int)BloomSettingsOverride.Intensity)") float Intensity = 1.0f; /// - /// Minimum pixel brightness value to start blowing. Values below the threshold are skipped. + /// Minimum pixel brightness value to start blooming. Values below this threshold are skipped. /// API_FIELD(Attributes="Limit(0, 15.0f, 0.01f), EditorOrder(2), PostProcessSetting((int)BloomSettingsOverride.Threshold)") float Threshold = 3.0f; @@ -987,13 +987,13 @@ API_STRUCT() struct FLAXENGINE_API EyeAdaptationSettings : ISerializable float MaxBrightness = 2.0f; /// - /// The lower bound for the luminance histogram of the scene color. Value is in percent and limits the pixels below this brightness. Use values from range 60-80. Used only in AutomaticHistogram mode. + /// The lower bound for the luminance histogram of the scene color. This value is in percent and limits the pixels below this brightness. Use values in the range of 60-80. Used only in AutomaticHistogram mode. /// API_FIELD(Attributes="Limit(1, 99, 0.001f), EditorOrder(3), PostProcessSetting((int)EyeAdaptationSettingsOverride.HistogramLowPercent)") float HistogramLowPercent = 70.0f; /// - /// The upper bound for the luminance histogram of the scene color. Value is in percent and limits the pixels above this brightness. Use values from range 80-95. Used only in AutomaticHistogram mode. + /// The upper bound for the luminance histogram of the scene color. This value is in percent and limits the pixels above this brightness. Use values in the range of 80-95. Used only in AutomaticHistogram mode. /// API_FIELD(Attributes="Limit(1, 99, 0.001f), EditorOrder(3), PostProcessSetting((int)EyeAdaptationSettingsOverride.HistogramHighPercent)") float HistogramHighPercent = 98.0f; @@ -1091,13 +1091,13 @@ API_STRUCT() struct FLAXENGINE_API CameraArtifactsSettings : ISerializable Float3 VignetteColor = Float3(0, 0, 0.001f); /// - /// Controls shape of the vignette. Values near 0 produce rectangle shape. Higher values result in round shape. The default value is 0.125. + /// Controls the shape of the vignette. Values near 0 produce a rectangular shape. Higher values result in a rounder shape. The default value is 0.125. /// API_FIELD(Attributes="Limit(0.0001f, 2.0f, 0.001f), EditorOrder(2), PostProcessSetting((int)CameraArtifactsSettingsOverride.VignetteShapeFactor)") float VignetteShapeFactor = 0.125f; /// - /// Intensity of the grain filter. Value 0 hides it. The default value is 0.005. + /// Intensity of the grain filter. A value of 0 hides it. The default value is 0.005. /// API_FIELD(Attributes="Limit(0.0f, 2.0f, 0.005f), EditorOrder(3), PostProcessSetting((int)CameraArtifactsSettingsOverride.GrainAmount)") float GrainAmount = 0.006f; @@ -1109,19 +1109,19 @@ API_STRUCT() struct FLAXENGINE_API CameraArtifactsSettings : ISerializable float GrainParticleSize = 1.6f; /// - /// Speed of the grain particles animation. + /// Speed of the grain particle animation. /// API_FIELD(Attributes="Limit(0.0f, 10.0f, 0.01f), EditorOrder(5), PostProcessSetting((int)CameraArtifactsSettingsOverride.GrainSpeed)") float GrainSpeed = 1.0f; /// - /// Controls chromatic aberration effect strength. Value 0 hides it. + /// Controls the chromatic aberration effect strength. A value of 0 hides it. /// API_FIELD(Attributes="Limit(0.0f, 1.0f, 0.01f), EditorOrder(6), PostProcessSetting((int)CameraArtifactsSettingsOverride.ChromaticDistortion)") float ChromaticDistortion = 0.0f; /// - /// Screen tint color (alpha channel defines the blending factor). + /// Screen tint color (the alpha channel defines the blending factor). /// API_FIELD(Attributes="DefaultValue(typeof(Color), \"0,0,0,0\"), EditorOrder(7), PostProcessSetting((int)CameraArtifactsSettingsOverride.ScreenFadeColor)") Color ScreenFadeColor = Color::Transparent; @@ -1227,7 +1227,7 @@ API_STRUCT() struct FLAXENGINE_API LensFlaresSettings : ISerializable LensFlaresSettingsOverride OverrideFlags = Override::None; /// - /// Strength of the effect. Value 0 disabled it. + /// Strength of the effect. A value of 0 disables it. /// API_FIELD(Attributes="Limit(0, 10.0f, 0.01f), EditorOrder(0), PostProcessSetting((int)LensFlaresSettingsOverride.Intensity)") float Intensity = 1.0f; @@ -1281,7 +1281,7 @@ API_STRUCT() struct FLAXENGINE_API LensFlaresSettings : ISerializable SoftAssetReference LensDirt; /// - /// Fullscreen lens dirt intensity parameter. Allows to tune dirt visibility. + /// Fullscreen lens dirt intensity parameter. Allows tuning dirt visibility. /// API_FIELD(Attributes="Limit(0, 100, 0.01f), EditorOrder(9), PostProcessSetting((int)LensFlaresSettingsOverride.LensDirtIntensity)") float LensDirtIntensity = 1.0f; @@ -1419,13 +1419,13 @@ API_STRUCT() struct FLAXENGINE_API DepthOfFieldSettings : ISerializable DepthOfFieldSettingsOverride OverrideFlags = Override::None; /// - /// If checked, depth of field effect will be visible. + /// If checked, the depth of field effect will be visible. /// API_FIELD(Attributes="EditorOrder(0), PostProcessSetting((int)DepthOfFieldSettingsOverride.Enabled)") bool Enabled = false; /// - /// The blur intensity in the out-of-focus areas. Allows reducing blur amount by scaling down the Gaussian Blur radius. Normalized to range 0-1. + /// The blur intensity in the out-of-focus areas. Allows reducing the blur amount by scaling down the Gaussian Blur radius. Normalized to range 0-1. /// API_FIELD(Attributes="Limit(0, 1, 0.01f), EditorOrder(1), PostProcessSetting((int)DepthOfFieldSettingsOverride.BlurStrength)") float BlurStrength = 1.0f; @@ -1479,7 +1479,7 @@ API_STRUCT() struct FLAXENGINE_API DepthOfFieldSettings : ISerializable float BokehBrightness = 1.0f; /// - /// Defines bokeh shapes type. + /// Defines the type of the bokeh shapes. /// API_FIELD(Attributes="EditorOrder(10), PostProcessSetting((int)DepthOfFieldSettingsOverride.BokehShape)") BokehShapeType BokehShape = BokehShapeType::Octagon; @@ -1491,19 +1491,19 @@ API_STRUCT() struct FLAXENGINE_API DepthOfFieldSettings : ISerializable SoftAssetReference BokehShapeCustom; /// - /// The minimum pixel brightness to create bokeh. Pixels with lower brightness will be skipped. + /// The minimum pixel brightness to create the bokeh. Pixels with lower brightness will be skipped. /// API_FIELD(Attributes="Limit(0, 10000.0f, 0.01f), EditorOrder(12), PostProcessSetting((int)DepthOfFieldSettingsOverride.BokehBrightnessThreshold)") float BokehBrightnessThreshold = 3.0f; /// - /// Depth of Field bokeh shapes blur threshold. + /// Depth of Field bokeh shape blur threshold. /// API_FIELD(Attributes="Limit(0, 1.0f, 0.001f), EditorOrder(13), PostProcessSetting((int)DepthOfFieldSettingsOverride.BokehBlurThreshold)") float BokehBlurThreshold = 0.05f; /// - /// Controls bokeh shapes brightness falloff. Higher values reduce bokeh visibility. + /// Controls bokeh shape brightness falloff. Higher values reduce bokeh visibility. /// API_FIELD(Attributes="Limit(0, 2.0f, 0.001f), EditorOrder(14), PostProcessSetting((int)DepthOfFieldSettingsOverride.BokehFalloff)") float BokehFalloff = 0.5f; @@ -1575,25 +1575,25 @@ API_STRUCT() struct FLAXENGINE_API MotionBlurSettings : ISerializable MotionBlurSettingsOverride OverrideFlags = Override::None; /// - /// If checked, motion blur effect will be rendered. + /// If checked, the motion blur effect will be rendered. /// API_FIELD(Attributes="EditorOrder(0), PostProcessSetting((int)MotionBlurSettingsOverride.Enabled)") bool Enabled = true; /// - /// The blur effect strength. Value 0 disabled is, while higher values increase the effect. + /// The blur effect strength. A value of 0 disables it, while higher values increase the effect. /// API_FIELD(Attributes="Limit(0, 5, 0.01f), EditorOrder(1), PostProcessSetting((int)MotionBlurSettingsOverride.Scale)") float Scale = 1.0f; /// - /// The amount of sample points used during motion blur rendering. It affects quality and performance. + /// The amount of sample points used during motion blur rendering. It affects blur quality and performance. /// API_FIELD(Attributes="Limit(4, 32, 0.1f), EditorOrder(2), PostProcessSetting((int)MotionBlurSettingsOverride.SampleCount)") int32 SampleCount = 10; /// - /// The motion vectors texture resolution. Motion blur uses per-pixel motion vectors buffer that contains objects movement information. Use lower resolution to improve performance. + /// The motion vectors texture resolution. Motion blur uses a per-pixel motion vector buffer that contains an objects movement information. Use a lower resolution to improve performance. /// API_FIELD(Attributes="EditorOrder(3), PostProcessSetting((int)MotionBlurSettingsOverride.MotionVectorsResolution)") ResolutionMode MotionVectorsResolution = ResolutionMode::Half; @@ -1898,13 +1898,13 @@ API_STRUCT() struct FLAXENGINE_API AntiAliasingSettings : ISerializable float TAA_Sharpness = 0.0f; /// - /// The blend coefficient for stationary fragments. Controls the percentage of history sample blended into final color for fragments with minimal active motion. + /// The blend coefficient for stationary fragments. Controls the percentage of history samples blended into the final color for fragments with minimal active motion. /// API_FIELD(Attributes="Limit(0, 0.99f, 0.001f), EditorOrder(3), PostProcessSetting((int)AntiAliasingSettingsOverride.TAA_StationaryBlending), EditorDisplay(null, \"TAA Stationary Blending\")") float TAA_StationaryBlending = 0.95f; /// - /// The blending coefficient for moving fragments. Controls the percentage of history sample blended into the final color for fragments with significant active motion. + /// The blending coefficient for moving fragments. Controls the percentage of history samples blended into the final color for fragments with significant active motion. /// API_FIELD(Attributes="Limit(0, 0.99f, 0.001f), EditorOrder(4), PostProcessSetting((int)AntiAliasingSettingsOverride.TAA_MotionBlending), EditorDisplay(null, \"TAA Motion Blending\")") float TAA_MotionBlending = 0.7f; diff --git a/Source/Engine/Level/Actors/ExponentialHeightFog.h b/Source/Engine/Level/Actors/ExponentialHeightFog.h index b0e5751d9..7b400fe4e 100644 --- a/Source/Engine/Level/Actors/ExponentialHeightFog.h +++ b/Source/Engine/Level/Actors/ExponentialHeightFog.h @@ -29,7 +29,7 @@ public: float FogDensity = 0.02f; /// - /// The fog height density factor that controls how the density increases as height decreases. The smaller values produce more visible transition larger. + /// The fog height density factor that controls how the density increases as height decreases. Smaller values produce a more visible transition layer. /// API_FIELD(Attributes="EditorOrder(20), DefaultValue(0.2f), Limit(0.0001f, 10.0f, 0.001f), EditorDisplay(\"Exponential Height Fog\")") float FogHeightFalloff = 0.2f; @@ -55,7 +55,7 @@ public: float StartDistance = 0.0f; /// - /// Scene elements past this distance will not have fog applied. This is useful for excluding skyboxes which already have fog baked in. + /// Scene elements past this distance will not have fog applied. This is useful for excluding skyboxes which already have fog baked in. Setting this value to 0 disables it. /// API_FIELD(Attributes="EditorOrder(60), DefaultValue(0.0f), Limit(0), EditorDisplay(\"Exponential Height Fog\")") float FogCutoffDistance = 0.0f; @@ -111,7 +111,7 @@ public: Color VolumetricFogAlbedo = Color::White; /// - /// Light emitted by height fog. This is a density so more light is emitted the further you are looking through the fog. + /// Light emitted by height fog. This is a density value so more light is emitted the further you are looking through the fog. /// In most cases using a Skylight is a better choice, however, it may be useful in certain scenarios. /// API_FIELD(Attributes="EditorOrder(330), DefaultValue(typeof(Color), \"0,0,0,1\"), EditorDisplay(\"Volumetric Fog\", \"Emissive\")") diff --git a/Source/Engine/Level/Actors/Sky.h b/Source/Engine/Level/Actors/Sky.h index 81aca3653..6d0935f78 100644 --- a/Source/Engine/Level/Actors/Sky.h +++ b/Source/Engine/Level/Actors/Sky.h @@ -31,19 +31,19 @@ public: /// /// Directional light that is used to simulate the sun. /// - API_FIELD(Attributes="EditorOrder(10), DefaultValue(null), EditorDisplay(\"Sun\")") + API_FIELD(Attributes="EditorOrder(10), DefaultValue(null), EditorDisplay(\"Sky\")") ScriptingObjectReference SunLight; /// /// The sun disc scale. /// - API_FIELD(Attributes="EditorOrder(20), DefaultValue(2.0f), EditorDisplay(\"Sun\"), Limit(0, 100, 0.01f)") + API_FIELD(Attributes="EditorOrder(20), DefaultValue(2.0f), EditorDisplay(\"Sky\"), Limit(0, 100, 0.01f)") float SunDiscScale = 2.0f; /// /// The sun power. /// - API_FIELD(Attributes="EditorOrder(30), DefaultValue(8.0f), EditorDisplay(\"Sun\"), Limit(0, 1000, 0.01f)") + API_FIELD(Attributes="EditorOrder(30), DefaultValue(8.0f), EditorDisplay(\"Sky\"), Limit(0, 1000, 0.01f)") float SunPower = 8.0f; private: diff --git a/Source/Engine/Level/Components/MissingScript.h b/Source/Engine/Level/Components/MissingScript.h index bfb73498f..7b351bd82 100644 --- a/Source/Engine/Level/Components/MissingScript.h +++ b/Source/Engine/Level/Components/MissingScript.h @@ -42,24 +42,7 @@ public: /// /// Field for assigning new script to transfer data to. /// - API_PROPERTY() void SetReferenceScript(const ScriptingObjectReference