Merge remote-tracking branch 'origin/master' into 1.6

This commit is contained in:
Wojtek Figat
2023-04-13 12:12:33 +02:00
22 changed files with 131 additions and 38 deletions

View File

@@ -35,6 +35,7 @@
#include "Engine/Engine/Base/GameBase.h"
#include "Engine/Engine/Globals.h"
#include "Engine/Tools/TextureTool/TextureTool.h"
#include "Engine/Scripting/Enums.h"
#if PLATFORM_TOOLS_WINDOWS
#include "Engine/Platform/Windows/WindowsPlatformSettings.h"
#endif
@@ -656,7 +657,7 @@ bool ProcessTextureBase(CookAssetsStep::AssetCookData& data)
// Convert texture data to the target format
if (TextureTool::Convert(textureDataTmp1, *textureData, targetFormat))
{
LOG(Error, "Failed to convert texture {0} from format {1} to {2}", asset->ToString(), (int32)format, (int32)targetFormat);
LOG(Error, "Failed to convert texture {0} from format {1} to {2}", asset->ToString(), ScriptingEnum::ToString(format), ScriptingEnum::ToString(targetFormat));
return true;
}
textureData = &textureDataTmp1;

View File

@@ -106,6 +106,13 @@ namespace FlaxEditor.Options
[DefaultValue(60.0f), Limit(0, 666)]
[EditorDisplay("General", "Editor FPS"), EditorOrder(110), Tooltip("Limit for the editor draw/update frames per second rate (FPS). Use higher values if you need more responsive interface or lower values to use less device power. Value 0 disables any limits.")]
public float EditorFPS { get; set; } = 60.0f;
/// <summary>
/// Gets or sets The FPS of the editor when the editor window is not focused. Usually set to lower then the editor FPS.
/// </summary>
[DefaultValue(15.0f), Limit(0, 666)]
[EditorDisplay("General", "Editor FPS When Not Focused"), EditorOrder(111), Tooltip("The FPS of the editor when the editor window is not focused. Usually set to lower then the editor FPS.")]
public float EditorFPSWhenNotFocused { get; set; } = 15.0f;
/// <summary>
/// Gets or sets the sequence of actions to perform when using Build Scenes button. Can be used to configure this as button (eg. compile code or just update navmesh).

View File

@@ -93,12 +93,13 @@ namespace FlaxEditor.States
/// </summary>
public virtual void UpdateFPS()
{
var editorFps = Editor.Options.Options.General.EditorFPS;
var generalOptions = Editor.Options.Options.General;
var editorFps = generalOptions.EditorFPS;
if (!Platform.HasFocus)
{
// Drop performance if app has no focus
Time.DrawFPS = 15;
Time.UpdateFPS = 15;
Time.DrawFPS = generalOptions.EditorFPSWhenNotFocused;
Time.UpdateFPS = generalOptions.EditorFPSWhenNotFocused;
}
else if (editorFps < 1)
{

View File

@@ -127,12 +127,34 @@ namespace FlaxEditor.Surface.ContextMenu
_parameterSetNodeArchetype = info.ParameterSetNodeArchetype ?? Archetypes.Parameters.Nodes[3];
// Context menu dimensions
Size = new Float2(320, 220);
Size = new Float2(320, 248);
var headerPanel = new Panel(ScrollBars.None)
{
Parent = this,
Height = 20,
Width = Width - 4,
X = 2,
Y = 1,
BackgroundColor = Style.Current.BackgroundNormal,
};
// Title bar
var titleLabel = new Label
{
Width = Width - 8,
Height = 20,
X = 4,
Parent = headerPanel,
Text = "Select Node",
HorizontalAlignment = TextAlignment.Center,
Font = new FontReference(Style.Current.FontLarge.Asset, 10),
};
// Search box
_searchBox = new SearchBox(false, 1, 1)
_searchBox = new SearchBox(false, 2, 22)
{
Width = Width - 3,
Width = Width - 4,
Parent = this
};
_searchBox.TextChanged += OnSearchFilterChanged;
@@ -549,6 +571,8 @@ namespace FlaxEditor.Surface.ContextMenu
};
var group = CreateGroup(groupArchetype);
group.ArrowImageOpened = new SpriteBrush(Style.Current.ArrowDown);
group.ArrowImageClosed = new SpriteBrush(Style.Current.ArrowRight);
group.Close(false);
archetypeIndex = 0;
for (int i = 0; i < parameters.Count; i++)

View File

@@ -46,6 +46,11 @@ namespace FlaxEditor.Surface.ContextMenu
ContextMenu = cm;
Archetypes.Add(archetype);
Name = archetype.Name;
EnableDropDownIcon = true;
HeaderColor = Style.Current.Background;
ArrowImageOpened = new SpriteBrush(Style.Current.ArrowDown);
ArrowImageClosed = new SpriteBrush(Style.Current.ArrowRight);
CloseAnimationTime = 0;
}
/// <summary>

View File

@@ -87,6 +87,11 @@ namespace FlaxEditor.Surface.ContextMenu
SortScore += 5;
}
private void GetTextRectangle(out Rectangle textRect)
{
textRect = new Rectangle(22, 0, Width - 24, Height);
}
private bool CanConnectTo(Box startBox, NodeArchetype nodeArchetype)
{
if (startBox == null)
@@ -123,6 +128,7 @@ namespace FlaxEditor.Surface.ContextMenu
}
else
{
GetTextRectangle(out var textRect);
if (QueryFilterHelper.Match(filterText, _archetype.Title, out var ranges))
{
// Update highlights
@@ -136,7 +142,7 @@ namespace FlaxEditor.Surface.ContextMenu
{
var start = font.GetCharPosition(_archetype.Title, ranges[i].StartIndex);
var end = font.GetCharPosition(_archetype.Title, ranges[i].EndIndex);
_highlights.Add(new Rectangle(start.X + 2, 0, end.X - start.X, Height));
_highlights.Add(new Rectangle(start.X + textRect.X, 0, end.X - start.X, Height));
if (ranges[i].StartIndex <= 0)
{
@@ -158,7 +164,7 @@ namespace FlaxEditor.Surface.ContextMenu
var font = style.FontSmall;
var start = font.GetCharPosition(_archetype.Title, 0);
var end = font.GetCharPosition(_archetype.Title, _archetype.Title.Length - 1);
_highlights.Add(new Rectangle(start.X + 2, 0, end.X - start.X, Height));
_highlights.Add(new Rectangle(start.X + textRect.X, 0, end.X - start.X, Height));
_isFullMatch = true;
Visible = true;
}
@@ -173,7 +179,7 @@ namespace FlaxEditor.Surface.ContextMenu
var font = style.FontSmall;
var start = font.GetCharPosition(_archetype.Title, 0);
var end = font.GetCharPosition(_archetype.Title, _archetype.Title.Length - 1);
_highlights.Add(new Rectangle(start.X + 2, 0, end.X - start.X, Height));
_highlights.Add(new Rectangle(start.X + textRect.X, 0, end.X - start.X, Height));
Visible = true;
Data = data;
@@ -192,7 +198,7 @@ namespace FlaxEditor.Surface.ContextMenu
{
var style = Style.Current;
var rect = new Rectangle(Float2.Zero, Size);
var textRect = new Rectangle(2, 0, rect.Width - 4, rect.Height);
GetTextRectangle(out var textRect);
var showScoreHit = SortScore > 0.1f;
// Overlay

View File

@@ -69,7 +69,6 @@ namespace FlaxEditor.Windows
// Update UI
UpdateUI();
_view.SelectFirstItem();
}
}

View File

@@ -942,6 +942,17 @@ namespace FlaxEditor.Windows
return true;
}
if (button == MouseButton.Left)
{
// Find control that is under the mouse
var c = GetChildAtRecursive(location);
if (c is ContentView)
{
_view.ClearSelection();
return true;
}
}
return base.OnMouseUp(location, button);
}

View File

@@ -228,8 +228,9 @@ public:
/// </summary>
Vector2Base GetNormalized() const
{
const T rcp = 1.0f / Length();
return Vector2Base(X * rcp, Y * rcp);
Vector2Base result(X, Y);
result.Normalize();
return result;
}
public:

View File

@@ -254,8 +254,9 @@ public:
/// </summary>
Vector3Base GetNormalized() const
{
const T rcp = 1.0f / Length();
return Vector3Base(X * rcp, Y * rcp, Z * rcp);
Vector3Base result(X, Y, Z);
result.Normalize();
return result;
}
public:

View File

@@ -12,6 +12,7 @@
#include "Engine/Debug/Exceptions/InvalidOperationException.h"
#include "Engine/Debug/Exceptions/ArgumentNullException.h"
#include "Engine/Debug/Exceptions/ArgumentOutOfRangeException.h"
#include "Engine/Scripting/Enums.h"
#include "Engine/Threading/ThreadPoolTask.h"
#include "Engine/Threading/Threading.h"
@@ -107,7 +108,7 @@ String GPUBufferDescription::ToString() const
Size,
Stride,
flags,
(int32)Format,
ScriptingEnum::ToString(Format),
(int32)Usage);
}

View File

@@ -273,7 +273,7 @@ void MaterialParameter::SetValue(const Variant& value)
}
if (invalidType)
{
LOG(Error, "Invalid material parameter value type {0} to set (param type: {1})", value.Type, ScriptingEnum::ToString<MaterialParameterType>(_type));
LOG(Error, "Invalid material parameter value type {0} to set (param type: {1})", value.Type, ScriptingEnum::ToString(_type));
}
}
@@ -530,7 +530,7 @@ bool MaterialParameter::operator==(const MaterialParameter& other) const
String MaterialParameter::ToString() const
{
return String::Format(TEXT("\'{0}\' ({1}:{2}:{3})"), _name, ScriptingEnum::ToString<MaterialParameterType>(_type), _paramId, _isPublic);
return String::Format(TEXT("\'{0}\' ({1}:{2}:{3})"), _name, ScriptingEnum::ToString(_type), _paramId, _isPublic);
}
MaterialParameter* MaterialParams::Get(const Guid& id)

View File

@@ -15,6 +15,7 @@
#include "Engine/Graphics/GPULimits.h"
#include "Engine/Threading/ThreadPoolTask.h"
#include "Engine/Graphics/GPUDevice.h"
#include "Engine/Scripting/Enums.h"
namespace
{
@@ -187,7 +188,7 @@ String GPUTextureDescription::ToString() const
ArraySize,
::ToString(Dimensions),
MipLevels,
(int32)Format,
ScriptingEnum::ToString(Format),
::ToString(MultiSampleLevel),
flags,
(int32)Usage);

View File

@@ -9,6 +9,7 @@
#include "Engine/Graphics/GPUDevice.h"
#include "Engine/Graphics/RenderTools.h"
#include "Engine/Graphics/Async/Tasks/GPUUploadTextureMipTask.h"
#include "Engine/Scripting/Enums.h"
TextureHeader_Deprecated::TextureHeader_Deprecated()
{
@@ -354,7 +355,7 @@ protected:
// Ensure that texture has been allocated before this task and has proper format
if (!texture->IsAllocated() || texture->Format() != _streamingTexture->GetHeader()->Format)
{
LOG(Error, "Cannot stream texture {0} (streaming format: {1})", texture->ToString(), (int32)_streamingTexture->GetHeader()->Format);
LOG(Error, "Cannot stream texture {0} (streaming format: {1})", texture->ToString(), ScriptingEnum::ToString(_streamingTexture->GetHeader()->Format));
return Result::Failed;
}

View File

@@ -11,6 +11,7 @@
#include "Engine/Debug/Exceptions/InvalidOperationException.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Content/Factories/BinaryAssetFactory.h"
#include "Engine/Scripting/Enums.h"
#include "Engine/Tools/TextureTool/TextureTool.h"
#include "Engine/Threading/Threading.h"
@@ -85,7 +86,7 @@ bool TextureMipData::GetPixels(Array<Color32>& pixels, int32 width, int32 height
case PixelFormat::B8G8R8X8_UNorm:
case PixelFormat::B8G8R8X8_UNorm_sRGB:
if (srcRowSize == dstRowSize)
Platform::MemoryCopy(dst, src, size);
Platform::MemoryCopy(dst, src, RowPitch * Lines);
else
{
for (uint32 row = 0; row < Lines; row++)
@@ -112,7 +113,7 @@ bool TextureMipData::GetPixels(Array<Color32>& pixels, int32 width, int32 height
}
return false;
}
LOG(Error, "Unsupported texture data format {0}.", (int32)format);
LOG(Error, "Unsupported texture data format {0}.", ScriptingEnum::ToString(format));
return true;
}
}
@@ -134,7 +135,7 @@ bool TextureMipData::GetPixels(Array<Color>& pixels, int32 width, int32 height,
case PixelFormat::R32G32B32A32_Typeless:
case PixelFormat::R32G32B32A32_Float:
if (srcRowSize == dstRowSize)
Platform::MemoryCopy(dst, src, size);
Platform::MemoryCopy(dst, src, RowPitch * Lines);
else
{
for (uint32 row = 0; row < Lines; row++)
@@ -161,7 +162,7 @@ bool TextureMipData::GetPixels(Array<Color>& pixels, int32 width, int32 height,
}
return false;
}
LOG(Error, "Unsupported texture data format {0}.", (int32)format);
LOG(Error, "Unsupported texture data format {0}.", ScriptingEnum::ToString(format));
return true;
}
}
@@ -453,7 +454,7 @@ bool TextureBase::SetPixels(const Span<Color32>& pixels, int32 mipIndex, int32 a
}
if (error)
{
LOG(Error, "Unsupported texture data format {0}.", (int32)format);
LOG(Error, "Unsupported texture data format {0}.", ScriptingEnum::ToString(format));
return true;
}
@@ -531,7 +532,7 @@ bool TextureBase::SetPixels(const Span<Color>& pixels, int32 mipIndex, int32 arr
}
if (error)
{
LOG(Error, "Unsupported texture data format {0}.", (int32)format);
LOG(Error, "Unsupported texture data format {0}.", ScriptingEnum::ToString(format));
return true;
}
@@ -844,7 +845,7 @@ bool TextureBase::InitData::GenerateMip(int32 mipIndex, bool linear)
break;
}
default:
LOG(Error, "Unsupported texture data format {0}.", (int32)Format);
LOG(Error, "Unsupported texture data format {0}.", ScriptingEnum::ToString(Format));
return true;
}
}

View File

@@ -34,6 +34,7 @@
#include "Engine/Utilities/StringConverter.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Threading/Threading.h"
#include "Engine/Scripting/Enums.h"
#if !USE_EDITOR && (PLATFORM_WINDOWS || PLATFORM_LINUX)
#include "Engine/Core/Config/PlatformSettings.h"
@@ -1385,7 +1386,7 @@ PixelFormat GPUDeviceVulkan::GetClosestSupportedPixelFormat(PixelFormat format,
#if !BUILD_RELEASE
if (format != remap)
{
LOG(Warning, "Unsupported Vulkan format {0}. Remapping to {1}", (int32)format, (int32)remap);
LOG(Warning, "Unsupported Vulkan format {0}. Remapping to {1}", ScriptingEnum::ToString(format), ScriptingEnum::ToString(remap));
format = GetClosestSupportedPixelFormat(remap, flags, optimalTiling);
}
#endif

View File

@@ -10,6 +10,7 @@
#include "CmdBufferVulkan.h"
#include "Engine/Core/Log.h"
#include "Engine/Graphics/GPULimits.h"
#include "Engine/Scripting/Enums.h"
void BackBufferVulkan::Setup(GPUSwapChainVulkan* window, VkImage backbuffer, PixelFormat format, VkExtent3D extent)
{
@@ -231,13 +232,13 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height)
if (!found)
{
LOG(Warning, "Requested pixel format {0} not supported by this swapchain. Falling back to supported swapchain formats...", (uint32)resultFormat);
LOG(Warning, "Requested pixel format {0} not supported by this swapchain. Falling back to supported swapchain formats...", ScriptingEnum::ToString(resultFormat));
resultFormat = PixelFormat::Unknown;
}
}
else
{
LOG(Warning, "Requested pixel format {0} is not supported by this Vulkan implementation", (uint32)resultFormat);
LOG(Warning, "Requested pixel format {0} is not supported by this Vulkan implementation", ScriptingEnum::ToString(resultFormat));
resultFormat = PixelFormat::Unknown;
}
}

View File

@@ -9,6 +9,7 @@
#include "Engine/Core/Log.h"
#include "Engine/Graphics/PixelFormatExtensions.h"
#include "Engine/Graphics/Textures/TextureData.h"
#include "Engine/Scripting/Enums.h"
void GPUTextureViewVulkan::Init(GPUDeviceVulkan* device, ResourceOwnerVulkan* owner, VkImage image, int32 totalMipLevels, PixelFormat format, MSAALevel msaa, VkExtent3D extent, VkImageViewType viewType, int32 mipLevels, int32 firstMipIndex, int32 arraySize, int32 firstArraySlice, bool readOnlyDepth)
{
@@ -241,7 +242,7 @@ bool GPUTextureVulkan::OnInit()
_desc.Format = _device->GetClosestSupportedPixelFormat(format, _desc.Flags, optimalTiling);
if (_desc.Format == PixelFormat::Unknown)
{
LOG(Error, "Unsupported texture format {0}.", (int32)format);
LOG(Error, "Unsupported texture format {0}.", ScriptingEnum::ToString(format));
return true;
}

View File

@@ -18,11 +18,31 @@ TaskGraphSystem::TaskGraphSystem(const SpawnParams& params)
{
}
TaskGraphSystem::~TaskGraphSystem()
{
// Cleanup any outstanding dependencies
for (auto* e : _reverseDependencies)
e->_dependencies.Remove(this);
}
void TaskGraphSystem::AddDependency(TaskGraphSystem* system)
{
CHECK(system);
if (_dependencies.Contains(system))
return;
system->_reverseDependencies.Add(this);
_dependencies.Add(system);
}
void TaskGraphSystem::RemoveDependency(TaskGraphSystem* system)
{
CHECK(system);
if (!_dependencies.Contains(system))
return;
system->_reverseDependencies.Remove(this);
_dependencies.Remove(system);
}
void TaskGraphSystem::PreExecute(TaskGraph* graph)
{
}

View File

@@ -16,6 +16,7 @@ DECLARE_SCRIPTING_TYPE(TaskGraphSystem);
friend TaskGraph;
private:
Array<TaskGraphSystem*, InlinedAllocation<16>> _dependencies;
Array<TaskGraphSystem*, InlinedAllocation<16>> _reverseDependencies;
public:
/// <summary>
@@ -24,12 +25,20 @@ public:
API_FIELD() int32 Order = 0;
public:
~TaskGraphSystem();
/// <summary>
/// Adds the dependency on the system execution. Before this system can be executed the given dependant system has to be executed first.
/// </summary>
/// <param name="system">The system to depend on.</param>
API_FUNCTION() void AddDependency(TaskGraphSystem* system);
/// <summary>
/// Removes the dependency on the system execution.
/// </summary>
/// <param name="system">The system to not depend on anymore.</param>
API_FUNCTION() void RemoveDependency(TaskGraphSystem* system);
/// <summary>
/// Called before executing any systems of the graph. Can be used to initialize data (synchronous).
/// </summary>

View File

@@ -263,6 +263,7 @@ bool TextureTool::ExportTextureStb(ImageType type, const StringView& path, const
if (ptr)
{
file->WriteBytes(ptr, ptrSize);
STBIW_FREE(ptr);
result = 0;
}
else

View File

@@ -19,11 +19,11 @@ namespace FlaxEngine.GUI
/// <summary>
/// The default minimum opacity.
/// </summary>
public const float DefaultMinimumOpacity = 0.7f;
public const float DefaultMinimumOpacity = 0.75f;
// Scrolling
private float _clickChange = 20, _scrollChange = 75;
private float _clickChange = 20, _scrollChange = 100;
private float _minimum, _maximum = 100;
private float _value, _targetValue;
private readonly Orientation _orientation;
@@ -51,17 +51,17 @@ namespace FlaxEngine.GUI
/// <summary>
/// Gets or sets the thumb box thickness.
/// </summary>
public float ThumbThickness { get; set; } = 6;
public float ThumbThickness { get; set; } = 8;
/// <summary>
/// Gets or sets the track line thickness.
/// </summary>
public float TrackThickness { get; set; } = 1;
public float TrackThickness { get; set; } = 2.0f;
/// <summary>
/// Gets or sets the value smoothing scale (0 to not use it).
/// </summary>
public float SmoothingScale { get; set; } = 1;
public float SmoothingScale { get; set; } = 0.6f;
/// <summary>
/// Gets a value indicating whether use scroll value smoothing.
@@ -246,7 +246,7 @@ namespace FlaxEngine.GUI
var height = Height;
float trackSize = TrackSize;
float range = _maximum - _minimum;
_thumbSize = Mathf.Min(trackSize, Mathf.Max(trackSize / range * 10.0f, 30.0f));
_thumbSize = Mathf.Min(trackSize - 10, Mathf.Max(trackSize / range * 100.0f, 50.0f));
float pixelRange = trackSize - _thumbSize;
float percentage = (_value - _minimum) / range;
float thumbPosition = (int)(percentage * pixelRange);