From fc0befd7730fd0d9e711b315a369761d2b98b259 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 23 Dec 2022 11:08:14 -0600 Subject: [PATCH 01/18] Fixed some CM buttons that shouldnt close when clicked. --- Source/Editor/Viewport/Previews/AnimatedModelPreview.cs | 1 + Source/Editor/Viewport/Previews/ModelBasePreview.cs | 1 + Source/Editor/Viewport/Previews/ModelPreview.cs | 1 + Source/Editor/Windows/ContentWindow.cs | 1 + 4 files changed, 4 insertions(+) diff --git a/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs b/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs index fdd685439..f6fa47c61 100644 --- a/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs +++ b/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs @@ -198,6 +198,7 @@ namespace FlaxEditor.Viewport.Previews // Preview LOD { var previewLOD = ViewWidgetButtonMenu.AddButton("Preview LOD"); + previewLOD.CloseMenuOnClick = false; var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f) { Parent = previewLOD diff --git a/Source/Editor/Viewport/Previews/ModelBasePreview.cs b/Source/Editor/Viewport/Previews/ModelBasePreview.cs index 445cc0250..388cf8a41 100644 --- a/Source/Editor/Viewport/Previews/ModelBasePreview.cs +++ b/Source/Editor/Viewport/Previews/ModelBasePreview.cs @@ -62,6 +62,7 @@ namespace FlaxEditor.Viewport.Previews // Preview LOD { var previewLOD = ViewWidgetButtonMenu.AddButton("Preview LOD"); + previewLOD.CloseMenuOnClick = false; var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f) { Parent = previewLOD diff --git a/Source/Editor/Viewport/Previews/ModelPreview.cs b/Source/Editor/Viewport/Previews/ModelPreview.cs index 59dbbecb4..4b0439572 100644 --- a/Source/Editor/Viewport/Previews/ModelPreview.cs +++ b/Source/Editor/Viewport/Previews/ModelPreview.cs @@ -201,6 +201,7 @@ namespace FlaxEditor.Viewport.Previews // Preview LOD { var previewLOD = ViewWidgetButtonMenu.AddButton("Preview LOD"); + previewLOD.CloseMenuOnClick = false; var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f) { Parent = previewLOD diff --git a/Source/Editor/Windows/ContentWindow.cs b/Source/Editor/Windows/ContentWindow.cs index 22808a1f1..8bb0d22c3 100644 --- a/Source/Editor/Windows/ContentWindow.cs +++ b/Source/Editor/Windows/ContentWindow.cs @@ -205,6 +205,7 @@ namespace FlaxEditor.Windows showFileExtensionsButton.AutoCheck = true; var viewScale = menu.AddButton("View Scale"); + viewScale.CloseMenuOnClick = false; var scaleValue = new FloatValueBox(1, 75, 2, 50.0f, 0.3f, 3.0f, 0.01f) { Parent = viewScale From bdbf931046b3ff4d99fc741d144dd808589adf88 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Tue, 27 Dec 2022 23:08:16 -0600 Subject: [PATCH 02/18] Added CM button in ParticleEmitterPreview --- Source/Editor/Viewport/Previews/ParticleEmitterPreview.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Editor/Viewport/Previews/ParticleEmitterPreview.cs b/Source/Editor/Viewport/Previews/ParticleEmitterPreview.cs index c1289509e..e59016856 100644 --- a/Source/Editor/Viewport/Previews/ParticleEmitterPreview.cs +++ b/Source/Editor/Viewport/Previews/ParticleEmitterPreview.cs @@ -67,6 +67,7 @@ namespace FlaxEditor.Viewport.Previews if (useWidgets) { var playbackDuration = ViewWidgetButtonMenu.AddButton("Duration"); + playbackDuration.CloseMenuOnClick = false; var playbackDurationValue = new FloatValueBox(_playbackDuration, 90, 2, 70.0f, 0.1f, 1000000.0f, 0.1f) { Parent = playbackDuration From 46b65bc5461f491e194c2270825a36ef0f2e168a Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 28 Dec 2022 18:51:13 +0100 Subject: [PATCH 03/18] Format code --- Source/Engine/Level/Actor.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Level/Actor.cs b/Source/Engine/Level/Actor.cs index cd774fca6..76e95810f 100644 --- a/Source/Engine/Level/Actor.cs +++ b/Source/Engine/Level/Actor.cs @@ -125,7 +125,7 @@ namespace FlaxEngine { if (type.IsAbstract) return null; - + var result = (Actor)New(type); result.SetParent(this, false, false); return result; @@ -180,7 +180,7 @@ namespace FlaxEngine { if (typeof(T).IsAbstract) return null; - + result = New(); result.SetParent(this, false, false); } @@ -196,7 +196,7 @@ namespace FlaxEngine { if (type.IsAbstract) return null; - + var script = (Script)New(type); script.Parent = this; return script; @@ -211,7 +211,7 @@ namespace FlaxEngine { if (typeof(T).IsAbstract) return null; - + var script = New(); script.Parent = this; return script; From ae700cfbb8adf52608863df0aedfeec0a2cc23a6 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 28 Dec 2022 19:34:25 +0100 Subject: [PATCH 04/18] Add new editor icons for actors from #866 --- Content/Editor/Icons/Textures/AudioListner.flax | 4 ++-- Content/Editor/Icons/Textures/AudioSource.flax | 4 ++-- Content/Editor/Icons/Textures/Decal.flax | 4 ++-- Content/Editor/Icons/Textures/DirectionalLight.flax | 4 ++-- Content/Editor/Icons/Textures/EnvironmentProbe.flax | 4 ++-- Content/Editor/Icons/Textures/ParticleEffect.flax | 4 ++-- Content/Editor/Icons/Textures/PointLight.flax | 4 ++-- Content/Editor/Icons/Textures/SceneAnimationPlayer.flax | 4 ++-- Content/Editor/Icons/Textures/SkyLight.flax | 4 ++-- Content/Editor/Icons/Textures/Skybox.flax | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Content/Editor/Icons/Textures/AudioListner.flax b/Content/Editor/Icons/Textures/AudioListner.flax index 8c8c4920d..cafe7a63e 100644 --- a/Content/Editor/Icons/Textures/AudioListner.flax +++ b/Content/Editor/Icons/Textures/AudioListner.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6eeba8388149269d67ab06fd52eb8e8e1411f187393b6160f20750d565e12f32 -size 22576 +oid sha256:71244c864e5f1ca5232a5800ecb36379fad9bc75d3e0fb735a6105accf274fb0 +size 88362 diff --git a/Content/Editor/Icons/Textures/AudioSource.flax b/Content/Editor/Icons/Textures/AudioSource.flax index 059b900c8..a630a1052 100644 --- a/Content/Editor/Icons/Textures/AudioSource.flax +++ b/Content/Editor/Icons/Textures/AudioSource.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:84afd860b8ebcaf166846220f275ea16bb69729ec5abfdf07fa9985e355539fe -size 22575 +oid sha256:0ba27db325a9d3c33f7b030b61730d03cca1727ed2477122a1a60de5578c1d22 +size 88361 diff --git a/Content/Editor/Icons/Textures/Decal.flax b/Content/Editor/Icons/Textures/Decal.flax index 73b661465..8e1028b54 100644 --- a/Content/Editor/Icons/Textures/Decal.flax +++ b/Content/Editor/Icons/Textures/Decal.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:22a3d53ddc4792fa4cf127da5d6a3e4d8a95757cb51fa04d7cb6b5abae2a643c -size 22569 +oid sha256:c6d258e04be1835c8164e93289bd496dd9b9bdb2cc9f7633db6b9929f08575ed +size 88355 diff --git a/Content/Editor/Icons/Textures/DirectionalLight.flax b/Content/Editor/Icons/Textures/DirectionalLight.flax index 1e4b650c4..6a26009d3 100644 --- a/Content/Editor/Icons/Textures/DirectionalLight.flax +++ b/Content/Editor/Icons/Textures/DirectionalLight.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0d16e0df628d13c72aef9f214c9459536832b9c8c21293444a6fb0f75d40a411 -size 22251 +oid sha256:742bd2c5755db7672e8a1fe27f1db013ebe885f495956b4406226f25c0c49536 +size 88366 diff --git a/Content/Editor/Icons/Textures/EnvironmentProbe.flax b/Content/Editor/Icons/Textures/EnvironmentProbe.flax index dfd69645f..d3c6b136a 100644 --- a/Content/Editor/Icons/Textures/EnvironmentProbe.flax +++ b/Content/Editor/Icons/Textures/EnvironmentProbe.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2386df0b9a39ab819f166f5a48c0d859f2f3aaeb1c98451565446fd9f35f70c4 -size 22251 +oid sha256:d9c4e7a93cb5548253270063226452cedc6648edd95b0227a4146cee5013eae2 +size 88366 diff --git a/Content/Editor/Icons/Textures/ParticleEffect.flax b/Content/Editor/Icons/Textures/ParticleEffect.flax index fa4788651..7a6211e39 100644 --- a/Content/Editor/Icons/Textures/ParticleEffect.flax +++ b/Content/Editor/Icons/Textures/ParticleEffect.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eced258052ad7aad0abcdb1abc7a811087b9688688eb0923d01b62277111e319 -size 22633 +oid sha256:ad12b06bd7e64460f43442e8700d5f7862c1dd522e5e7335b21bd8fef1b7f1c1 +size 88364 diff --git a/Content/Editor/Icons/Textures/PointLight.flax b/Content/Editor/Icons/Textures/PointLight.flax index 5bc463f7c..caa8a09f6 100644 --- a/Content/Editor/Icons/Textures/PointLight.flax +++ b/Content/Editor/Icons/Textures/PointLight.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:205c29a130708367cfd920c02dad1ff5ce029bca2e4ba8b846ee924db6ed5ce8 -size 22245 +oid sha256:ccf4443326fc4efa30acce040684f620b1ec55b2e22081184b28abb7e4a5a45e +size 88360 diff --git a/Content/Editor/Icons/Textures/SceneAnimationPlayer.flax b/Content/Editor/Icons/Textures/SceneAnimationPlayer.flax index 498aa4a2c..2f20de087 100644 --- a/Content/Editor/Icons/Textures/SceneAnimationPlayer.flax +++ b/Content/Editor/Icons/Textures/SceneAnimationPlayer.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:42a79e33f6237ff570ec799cf21859bde252280120a460d117a46c64e171f131 -size 22639 +oid sha256:419fd82bce8ffbb155ddcb5bd7387279571283555b212b374a18d95be88d5c62 +size 88370 diff --git a/Content/Editor/Icons/Textures/SkyLight.flax b/Content/Editor/Icons/Textures/SkyLight.flax index 9e557e37a..caa94f5b1 100644 --- a/Content/Editor/Icons/Textures/SkyLight.flax +++ b/Content/Editor/Icons/Textures/SkyLight.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:821d8878412cdaebf1472f7a8afc8f081dd4bf7818c3824d6d02d18c474e4355 -size 22243 +oid sha256:3c5d5f9ec5a3e9bff677b18b420ac8cc83aeeee778033471aa6677092c1e9f6d +size 88358 diff --git a/Content/Editor/Icons/Textures/Skybox.flax b/Content/Editor/Icons/Textures/Skybox.flax index c252d2fbf..ec3060c98 100644 --- a/Content/Editor/Icons/Textures/Skybox.flax +++ b/Content/Editor/Icons/Textures/Skybox.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:54e8d8520f6d1e6dea5c4596309700358d97692fefbfea68ff76a058f4161e32 -size 22241 +oid sha256:2ebe5c47347d28484a4cbc0eca7f727bc93a3f9e90b781b72bc34bb44046fe75 +size 88356 From 0220c8ced15728a8fa18917f5e0b077fa3f638bf Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 28 Dec 2022 12:53:08 -0600 Subject: [PATCH 05/18] fixed skylight to use skylight icon --- Source/Editor/Utilities/ViewportIconsRenderer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Utilities/ViewportIconsRenderer.cpp b/Source/Editor/Utilities/ViewportIconsRenderer.cpp index 8b8e0d74f..72533d6dc 100644 --- a/Source/Editor/Utilities/ViewportIconsRenderer.cpp +++ b/Source/Editor/Utilities/ViewportIconsRenderer.cpp @@ -29,6 +29,7 @@ enum class IconTypes DirectionalLight, EnvironmentProbe, Skybox, + SkyLight, AudioListener, AudioSource, Decal, @@ -155,6 +156,7 @@ bool ViewportIconsRendererService::Init() INIT(DirectionalLight, "Editor/Icons/DirectionalLight"); INIT(EnvironmentProbe, "Editor/Icons/EnvironmentProbe"); INIT(Skybox, "Editor/Icons/Skybox"); + INIT(SkyLight, "Editor/Icons/SkyLight"); INIT(AudioListener, "Editor/Icons/AudioListener"); INIT(AudioSource, "Editor/Icons/AudioSource"); INIT(Decal, "Editor/Icons/Decal"); @@ -173,7 +175,7 @@ bool ViewportIconsRendererService::Init() MAP_TYPE(SceneAnimationPlayer, SceneAnimationPlayer); MAP_TYPE(ExponentialHeightFog, Skybox); MAP_TYPE(Sky, Skybox); - MAP_TYPE(SkyLight, PointLight); + MAP_TYPE(SkyLight, SkyLight); MAP_TYPE(SpotLight, PointLight); #undef MAP_TYPE From 7539504a8cf156e89f724e1fe83dddc87dded67a Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 28 Dec 2022 19:54:27 +0100 Subject: [PATCH 06/18] Fix typo --- Source/Engine/Streaming/Streaming.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Engine/Streaming/Streaming.cpp b/Source/Engine/Streaming/Streaming.cpp index d11724fe8..f9866f111 100644 --- a/Source/Engine/Streaming/Streaming.cpp +++ b/Source/Engine/Streaming/Streaming.cpp @@ -320,7 +320,7 @@ GPUSampler* Streaming::GetTextureGroupSampler(int32 index) { FallbackSampler = GPUSampler::New(); #if GPU_ENABLE_RESOURCE_NAMING - sampler->SetName(TEXT("FallbackSampler")); + FallbackSampler->SetName(TEXT("FallbackSampler")); #endif FallbackSampler->Init(GPUSamplerDescription::New(GPUSamplerFilter::Trilinear)); } From 4eb2ac854ec8fdff7db3f9f341b07b27f12b5f9e Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 28 Dec 2022 13:00:58 -0600 Subject: [PATCH 07/18] Fixed more CMs that shouldnt close --- Source/Editor/Windows/GameWindow.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Editor/Windows/GameWindow.cs b/Source/Editor/Windows/GameWindow.cs index 23558c396..c800692f7 100644 --- a/Source/Editor/Windows/GameWindow.cs +++ b/Source/Editor/Windows/GameWindow.cs @@ -353,6 +353,7 @@ namespace FlaxEditor.Windows // Viewport Brightness { var brightness = menu.AddButton("Viewport Brightness"); + brightness.CloseMenuOnClick = false; var brightnessValue = new FloatValueBox(_viewport.Brightness, 140, 2, 50.0f, 0.001f, 10.0f, 0.001f) { Parent = brightness @@ -363,6 +364,7 @@ namespace FlaxEditor.Windows // Viewport Resolution { var resolution = menu.AddButton("Viewport Resolution"); + resolution.CloseMenuOnClick = false; var resolutionValue = new FloatValueBox(_viewport.ResolutionScale, 140, 2, 50.0f, 0.1f, 4.0f, 0.001f) { Parent = resolution @@ -381,6 +383,7 @@ namespace FlaxEditor.Windows // Show GUI { var button = menu.AddButton("Show GUI"); + button.CloseMenuOnClick = false; var checkbox = new CheckBox(140, 2, ShowGUI) { Parent = button }; checkbox.StateChanged += x => ShowGUI = x.Checked; } @@ -388,6 +391,7 @@ namespace FlaxEditor.Windows // Show Debug Draw { var button = menu.AddButton("Show Debug Draw"); + button.CloseMenuOnClick = false; var checkbox = new CheckBox(140, 2, ShowDebugDraw) { Parent = button }; checkbox.StateChanged += x => ShowDebugDraw = x.Checked; } From 6ef49349ffbaa8b8b4a32ceea439b3b3b9f2043e Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Thu, 29 Dec 2022 11:20:39 +0100 Subject: [PATCH 08/18] Fix assertion on thread double-free from registry (not harmful) --- Source/Engine/Threading/ThreadRegistry.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Engine/Threading/ThreadRegistry.cpp b/Source/Engine/Threading/ThreadRegistry.cpp index b6844e13f..3dafb4f87 100644 --- a/Source/Engine/Threading/ThreadRegistry.cpp +++ b/Source/Engine/Threading/ThreadRegistry.cpp @@ -47,7 +47,6 @@ void ThreadRegistry::KillEmAll() void ThreadRegistry::Add(Thread* thread) { ASSERT(thread && thread->GetID() != 0); - Locker.Lock(); ASSERT(!Registry.ContainsKey(thread->GetID()) && !Registry.ContainsValue(thread)); Registry.Add(thread->GetID(), thread); @@ -57,9 +56,11 @@ void ThreadRegistry::Add(Thread* thread) void ThreadRegistry::Remove(Thread* thread) { ASSERT(thread && thread->GetID() != 0); - Locker.Lock(); - ASSERT_LOW_LAYER(Registry.ContainsKey(thread->GetID()) && Registry[thread->GetID()] == thread); +#if ENABLE_ASSERTION_LOW_LAYERS + Thread** currentValue = Registry.TryGet(thread->GetID()); + ASSERT_LOW_LAYER(!currentValue || *currentValue == thread); +#endif Registry.Remove(thread->GetID()); Locker.Unlock(); } From e7cf10aea8e50e38f79128e5ab5395b72e54b843 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 29 Dec 2022 21:51:57 +0100 Subject: [PATCH 09/18] Minor tweaks --- Source/Engine/Core/ObjectsRemovalService.cpp | 16 ++++++++-------- Source/Engine/Core/ObjectsRemovalService.h | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Source/Engine/Core/ObjectsRemovalService.cpp b/Source/Engine/Core/ObjectsRemovalService.cpp index f3ef498ef..7d79a9523 100644 --- a/Source/Engine/Core/ObjectsRemovalService.cpp +++ b/Source/Engine/Core/ObjectsRemovalService.cpp @@ -22,11 +22,10 @@ namespace ObjectsRemovalServiceImpl using namespace ObjectsRemovalServiceImpl; -class ObjectsRemovalServiceService : public EngineService +class ObjectsRemoval : public EngineService { public: - - ObjectsRemovalServiceService() + ObjectsRemoval() : EngineService(TEXT("Objects Removal Service"), -1000) { } @@ -36,7 +35,7 @@ public: void Dispose() override; }; -ObjectsRemovalServiceService ObjectsRemovalServiceServiceInstance; +ObjectsRemoval ObjectsRemovalInstance; bool ObjectsRemovalService::IsInPool(Object* obj) { @@ -63,7 +62,6 @@ bool ObjectsRemovalService::HasNewItemsForFlush() NewItemsLocker.Lock(); const bool result = NewItemsPool.HasItems(); NewItemsLocker.Unlock(); - return result; } @@ -95,6 +93,8 @@ void ObjectsRemovalService::Add(Object* obj, float timeToLive, bool useGameTime) void ObjectsRemovalService::Flush(float dt, float gameDelta) { + PROFILE_CPU(); + // Add new items { ScopeLock lock(NewItemsLocker); @@ -173,14 +173,14 @@ void ObjectsRemovalService::Flush(float dt, float gameDelta) } } -bool ObjectsRemovalServiceService::Init() +bool ObjectsRemoval::Init() { LastUpdate = DateTime::NowUTC(); LastUpdateGameTime = 0; return false; } -void ObjectsRemovalServiceService::LateUpdate() +void ObjectsRemoval::LateUpdate() { PROFILE_CPU(); @@ -194,7 +194,7 @@ void ObjectsRemovalServiceService::LateUpdate() LastUpdate = now; } -void ObjectsRemovalServiceService::Dispose() +void ObjectsRemoval::Dispose() { // Collect new objects ObjectsRemovalService::Flush(); diff --git a/Source/Engine/Core/ObjectsRemovalService.h b/Source/Engine/Core/ObjectsRemovalService.h index 92a5bd1af..e9120a6dd 100644 --- a/Source/Engine/Core/ObjectsRemovalService.h +++ b/Source/Engine/Core/ObjectsRemovalService.h @@ -10,7 +10,6 @@ class FLAXENGINE_API ObjectsRemovalService { public: - /// /// Determines whether object has been registered in the pool for the removing. /// From da08b18ec5b4d993a9f0ca84a2fcf7adb3380974 Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Sat, 17 Dec 2022 12:58:58 +0100 Subject: [PATCH 10/18] Fix `VisualStudioInstance.GetInstances()` to be sorted from newest to oldest (cherry picked from commit 6eaecc87933a1941abf3fd0b06a386e9b74e6ce3) --- .../VisualStudio/VisualStudioInstance.cs | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Source/Tools/Flax.Build/Projects/VisualStudio/VisualStudioInstance.cs b/Source/Tools/Flax.Build/Projects/VisualStudio/VisualStudioInstance.cs index b719fc17f..b4b0d7ab3 100644 --- a/Source/Tools/Flax.Build/Projects/VisualStudio/VisualStudioInstance.cs +++ b/Source/Tools/Flax.Build/Projects/VisualStudio/VisualStudioInstance.cs @@ -12,7 +12,7 @@ namespace Flax.Build.Projects.VisualStudio /// /// The Visual Studio instance utility. /// - public sealed class VisualStudioInstance + public sealed class VisualStudioInstance : IComparable { private static List _installDirs; private static int _hasFlaxVS; @@ -173,9 +173,32 @@ namespace Flax.Build.Projects.VisualStudio } } + // Sort from the latest to the oldest + _installDirs.Sort(); + foreach (var e in _installDirs) Log.Verbose($"Found {e.Version} at {e.Path}"); return _installDirs; } + + /// + public int CompareTo(VisualStudioInstance other) + { + if (Version == other.Version) + return Path.CompareTo(other.Path); + return (int)Version < (int)other.Version ? 1 : -1; + } + + /// + public override int GetHashCode() + { + return Path.GetHashCode(); + } + + /// + public override string ToString() + { + return $"{Version} at {Path}"; + } } } From 4b79bcb8d264d4e073db9fabcbcf5b94cf765bb0 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 29 Dec 2022 23:02:54 +0100 Subject: [PATCH 11/18] Add VS2022 support for building for UWP platform --- Source/Tools/Flax.Build/Platforms/UWP/UWPPlatform.cs | 4 +--- Source/Tools/Flax.Build/Platforms/UWP/UWPToolchain.cs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/Tools/Flax.Build/Platforms/UWP/UWPPlatform.cs b/Source/Tools/Flax.Build/Platforms/UWP/UWPPlatform.cs index 3eb2ed123..165a2f6fe 100644 --- a/Source/Tools/Flax.Build/Platforms/UWP/UWPPlatform.cs +++ b/Source/Tools/Flax.Build/Platforms/UWP/UWPPlatform.cs @@ -28,7 +28,7 @@ namespace Flax.Build.Platforms } // Visual Studio 2017+ supported only - var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019); + var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019 || x.Version == VisualStudioVersion.VisualStudio2022); if (visualStudio == null) _hasRequiredSDKsInstalled = false; @@ -43,9 +43,7 @@ namespace Flax.Build.Platforms if (!toolsets.ContainsKey(WindowsPlatformToolset.v141) && !toolsets.ContainsKey(WindowsPlatformToolset.v142) && !toolsets.ContainsKey(WindowsPlatformToolset.v143)) - { _hasRequiredSDKsInstalled = false; - } } /// diff --git a/Source/Tools/Flax.Build/Platforms/UWP/UWPToolchain.cs b/Source/Tools/Flax.Build/Platforms/UWP/UWPToolchain.cs index 3a5c63c90..32df8ce82 100644 --- a/Source/Tools/Flax.Build/Platforms/UWP/UWPToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/UWP/UWPToolchain.cs @@ -29,7 +29,7 @@ namespace Flax.Build.Platforms public UWPToolchain(UWPPlatform platform, TargetArchitecture architecture, WindowsPlatformToolset toolsetVer = WindowsPlatformToolset.Latest, WindowsPlatformSDK sdkVer = WindowsPlatformSDK.Latest) : base(platform, architecture, toolsetVer, sdkVer) { - var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019); + var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019 || x.Version == VisualStudioVersion.VisualStudio2022); if (visualStudio == null) throw new Exception("Missing Visual Studio 2017 or newer. It's required to build for UWP."); _usingDirs.Add(Path.Combine(visualStudio.Path, "VC", "vcpackages")); From 5a1192df16f456937f9059d196d7894439478555 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 29 Dec 2022 23:03:28 +0100 Subject: [PATCH 12/18] Update shaders --- Content/Shaders/GI/DDGI.flax | 4 ++-- Content/Shaders/GI/GlobalSurfaceAtlas.flax | 4 ++-- Content/Shaders/TAA.flax | 4 ++-- Content/Shaders/VolumetricFog.flax | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Content/Shaders/GI/DDGI.flax b/Content/Shaders/GI/DDGI.flax index 5e5b5c8be..42ebad4c0 100644 --- a/Content/Shaders/GI/DDGI.flax +++ b/Content/Shaders/GI/DDGI.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a5e9fd224618c4b2b6850a843bf9452d49099bfc44549662c1544cf40510294c -size 24284 +oid sha256:ef0c2a2ed4d447d7439dcb3410b5cda0d7d164ae3704f3ef836153d6e24d64f7 +size 23702 diff --git a/Content/Shaders/GI/GlobalSurfaceAtlas.flax b/Content/Shaders/GI/GlobalSurfaceAtlas.flax index baf00844c..5f8f33c5c 100644 --- a/Content/Shaders/GI/GlobalSurfaceAtlas.flax +++ b/Content/Shaders/GI/GlobalSurfaceAtlas.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3e56bf2cd056460a987fb98529e9a78ffa0bd7326ad9cae82145aa169c2dae4f -size 12952 +oid sha256:eab4a83e97b445fa657ad96dcfaaa87845055027a8b2db42795c8ed4311271be +size 12612 diff --git a/Content/Shaders/TAA.flax b/Content/Shaders/TAA.flax index 6f30a121b..9c08bdd99 100644 --- a/Content/Shaders/TAA.flax +++ b/Content/Shaders/TAA.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:382c4754367afadc761e6ea3c3d61ad5be249cd4b55e959382f0476259e68367 -size 3343 +oid sha256:b66d30235d2eb02af44df7c5f6a6d4aafc8a1177c788dab331d84692f11b7e16 +size 3257 diff --git a/Content/Shaders/VolumetricFog.flax b/Content/Shaders/VolumetricFog.flax index f4990d1cc..0e780413c 100644 --- a/Content/Shaders/VolumetricFog.flax +++ b/Content/Shaders/VolumetricFog.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1a3f3207746368c6d516d51e1053c08cbd4beea71703fa540b4229aa836cff14 -size 14255 +oid sha256:6a2dbc9352900c45d20d80af203f34bae5b6ace3e3ff85305c068a9849f5ccbb +size 13841 From 418aeb281c86fef76877885bcce8540121ffd1b7 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 29 Dec 2022 23:03:37 +0100 Subject: [PATCH 13/18] Add warning to UWP build tool --- Source/Tools/Flax.Build/Platforms/UWP/UWPToolchain.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/Tools/Flax.Build/Platforms/UWP/UWPToolchain.cs b/Source/Tools/Flax.Build/Platforms/UWP/UWPToolchain.cs index 32df8ce82..c6690d678 100644 --- a/Source/Tools/Flax.Build/Platforms/UWP/UWPToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/UWP/UWPToolchain.cs @@ -45,6 +45,14 @@ namespace Flax.Build.Platforms _usingDirs.Add(Path.Combine(sdk10, "UnionMetadata", sdk10Ver)); } + /// + public override void LogInfo() + { + base.LogInfo(); + + Log.Error("UWP (Windows Store) platform has been deprecated and soon will be removed!"); + } + /// protected override void SetupCompileCppFilesArgs(TaskGraph graph, BuildOptions options, List args) { From c6bbfdc7f0c45d085cf3a2e51287e8600bc45334 Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Thu, 29 Dec 2022 13:56:25 +0100 Subject: [PATCH 14/18] Fixes for networking change in 762f460e2391ba750e61cb3b1fd94cafc95fb681 --- Source/Engine/Networking/NetworkManager.cpp | 2 +- Source/Engine/Networking/NetworkReplicator.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Networking/NetworkManager.cpp b/Source/Engine/Networking/NetworkManager.cpp index a16d46ea3..3860a91d5 100644 --- a/Source/Engine/Networking/NetworkManager.cpp +++ b/Source/Engine/Networking/NetworkManager.cpp @@ -316,7 +316,6 @@ void NetworkManager::Stop() client->State = NetworkConnectionState::Disconnecting; StateChanged(); - NetworkInternal::NetworkReplicatorClear(); for (int32 i = Clients.Count() - 1; i >= 0; i--) { NetworkClient* client = Clients[i]; @@ -330,6 +329,7 @@ void NetworkManager::Stop() ClientDisconnected(LocalClient); LocalClient->State = NetworkConnectionState::Disconnected; } + NetworkInternal::NetworkReplicatorClear(); StopPeer(); if (LocalClient) { diff --git a/Source/Engine/Networking/NetworkReplicator.cpp b/Source/Engine/Networking/NetworkReplicator.cpp index 0b3202b60..532e148c1 100644 --- a/Source/Engine/Networking/NetworkReplicator.cpp +++ b/Source/Engine/Networking/NetworkReplicator.cpp @@ -735,7 +735,20 @@ void NetworkReplicator::DespawnObject(ScriptingObject* obj) ScopeLock lock(ObjectsLock); const auto it = Objects.Find(obj->GetID()); if (it == Objects.End()) + { + // Special case if we're just spawning this object + for (int32 i = 0; i < SpawnQueue.Count(); i++) + { + auto& item = SpawnQueue[i]; + if (item.Object == obj) + { + SpawnQueue.RemoveAt(i); + DeleteNetworkObject(obj); + break; + } + } return; + } auto& item = it->Item; if (item.Object != obj || !item.Spawned || item.OwnerClientId != NetworkManager::LocalClientId) return; From 1d47374758183fd10101da956819ecbbb572a863 Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Thu, 29 Dec 2022 14:01:01 +0100 Subject: [PATCH 15/18] Cache managed serializers for networking replication to prevent from being collected by GC --- Source/Engine/Networking/NetworkReplicator.cs | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Source/Engine/Networking/NetworkReplicator.cs b/Source/Engine/Networking/NetworkReplicator.cs index b730f9403..730179fb3 100644 --- a/Source/Engine/Networking/NetworkReplicator.cs +++ b/Source/Engine/Networking/NetworkReplicator.cs @@ -52,22 +52,20 @@ namespace FlaxEngine.Networking [Unmanaged] public static void AddSerializer(Type type, SerializeFunc serialize, SerializeFunc deserialize) { + if (_managedSerializers == null) + { + _managedSerializers = new Dictionary>(); +#if FLAX_EDITOR + FlaxEditor.ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin; +#endif + } + _managedSerializers[type] = new KeyValuePair(serialize, deserialize); + // C#-only types (eg. custom C# structures) cannot use native serializers due to missing ScriptingType if (typeof(FlaxEngine.Object).IsAssignableFrom(type)) { Internal_AddSerializer(type, Marshal.GetFunctionPointerForDelegate(serialize), Marshal.GetFunctionPointerForDelegate(deserialize)); } - else - { - if (_managedSerializers == null) - { - _managedSerializers = new Dictionary>(); -#if FLAX_EDITOR - FlaxEditor.ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin; -#endif - } - _managedSerializers[type] = new KeyValuePair(serialize, deserialize); - } } /// From 0e1da59f0c425bb012ed7122d8fb7f67e5dd6046 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 29 Dec 2022 23:35:47 +0100 Subject: [PATCH 16/18] Fix loading materials when using Null renderer Regression from dbcb333ba932840b04841d2502ffedbcb0aba592 --- Source/Engine/Content/Assets/Material.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Engine/Content/Assets/Material.cpp b/Source/Engine/Content/Assets/Material.cpp index f6de35df7..7dd338633 100644 --- a/Source/Engine/Content/Assets/Material.cpp +++ b/Source/Engine/Content/Assets/Material.cpp @@ -126,7 +126,7 @@ Asset::LoadResult Material::load() FlaxChunk* materialParamsChunk; // Wait for the GPU Device to be ready (eg. case when loading material before GPU init) -#define IS_GPU_NOT_READY() (GPUDevice::Instance == nullptr || GPUDevice::Instance->GetState() != GPUDevice::DeviceState::Ready || GPUDevice::Instance->QuadShader == nullptr) +#define IS_GPU_NOT_READY() (GPUDevice::Instance == nullptr || GPUDevice::Instance->GetState() != GPUDevice::DeviceState::Ready) if (!IsInMainThread() && IS_GPU_NOT_READY()) { int32 timeout = 1000; From a5e7ff6fc01c285a01182d8567154b01df299314 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 30 Dec 2022 00:08:04 +0100 Subject: [PATCH 17/18] Add unit test for scripting features --- Source/Engine/Tests/TestScripting.cpp | 40 +++++++++++++++++++++++++++ Source/Engine/Tests/TestScripting.cs | 23 +++++++++++++++ Source/Engine/Tests/TestScripting.h | 23 +++++++++++++++ Source/FlaxTests.Build.cs | 2 ++ 4 files changed, 88 insertions(+) create mode 100644 Source/Engine/Tests/TestScripting.cpp create mode 100644 Source/Engine/Tests/TestScripting.cs create mode 100644 Source/Engine/Tests/TestScripting.h diff --git a/Source/Engine/Tests/TestScripting.cpp b/Source/Engine/Tests/TestScripting.cpp new file mode 100644 index 000000000..ecea80db7 --- /dev/null +++ b/Source/Engine/Tests/TestScripting.cpp @@ -0,0 +1,40 @@ +// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. + +#include "TestScripting.h" +#include "Engine/Scripting/Scripting.h" +#include + +TestClassNative::TestClassNative(const SpawnParams& params) + : ScriptingObject(params) +{ +} + +TEST_CASE("Scripting") +{ + SECTION("Test Class") + { + // Test native class + ScriptingTypeHandle type = Scripting::FindScriptingType("FlaxEngine.TestClassNative"); + CHECK(type == TestClassNative::TypeInitializer); + ScriptingObject* object = Scripting::NewObject(type.GetType().ManagedClass); + CHECK(object); + CHECK(object->Is()); + TestClassNative* testClass = (TestClassNative*)object; + CHECK(testClass->SimpleField == 1); + int32 methodResult = testClass->Test(TEXT("123")); + CHECK(methodResult == 3); + + // Test managed class + type = Scripting::FindScriptingType("FlaxEngine.TestClassManaged"); + CHECK(type); + object = Scripting::NewObject(type.GetType().ManagedClass); + CHECK(object); + CHECK(object->Is()); + testClass = (TestClassNative*)object; + MObject* managed = testClass->GetOrCreateManagedInstance(); // Ensure to create C# object and run it's ctor + CHECK(managed); + CHECK(testClass->SimpleField == 2); + methodResult = testClass->Test(TEXT("123")); + CHECK(methodResult == 6); + } +} diff --git a/Source/Engine/Tests/TestScripting.cs b/Source/Engine/Tests/TestScripting.cs new file mode 100644 index 000000000..6abc667a1 --- /dev/null +++ b/Source/Engine/Tests/TestScripting.cs @@ -0,0 +1,23 @@ +// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. + +#if FLAX_TESTS +namespace FlaxEngine +{ + /// + /// Test class. + /// + public class TestClassManaged : TestClassNative + { + TestClassManaged() + { + SimpleField = 2; + } + + /// + public override int Test(string str) + { + return str.Length + base.Test(str); + } + } +} +#endif diff --git a/Source/Engine/Tests/TestScripting.h b/Source/Engine/Tests/TestScripting.h new file mode 100644 index 000000000..06b5dddb5 --- /dev/null +++ b/Source/Engine/Tests/TestScripting.h @@ -0,0 +1,23 @@ +// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. + +#pragma once + +#include "Engine/Core/ISerializable.h" +#include "Engine/Scripting/ScriptingObject.h" + +// Test class. +API_CLASS() class TestClassNative : public ScriptingObject, public ISerializable +{ + API_AUTO_SERIALIZATION(); + DECLARE_SCRIPTING_TYPE(TestClassNative); + +public: + // Test value + API_FIELD() int32 SimpleField = 1; + + // Test virtual method + API_FUNCTION() virtual int32 Test(const String& str) + { + return str.Length(); + } +}; diff --git a/Source/FlaxTests.Build.cs b/Source/FlaxTests.Build.cs index 1c02439f7..06bc06d23 100644 --- a/Source/FlaxTests.Build.cs +++ b/Source/FlaxTests.Build.cs @@ -45,6 +45,8 @@ public class FlaxTestsTarget : FlaxEditor { base.SetupTargetEnvironment(options); + options.ScriptingAPI.Defines.Add("FLAX_TESTS"); + // Produce console program options.LinkEnv.LinkAsConsoleProgram = true; } From e2e66e0eec59e8692f95977f2a867ed8f9d67785 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 30 Dec 2022 00:08:32 +0100 Subject: [PATCH 18/18] Fix crash when unboxing integer value type from managed callback via generated bindings --- .../Bindings/BindingsGenerator.Cpp.cs | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs index 624f54d39..0fd5ead49 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs @@ -1277,7 +1277,8 @@ namespace Flax.Build.Bindings thunkCall += GenerateCppWrapperNativeToBox(buildData, parameterInfo.Type, classInfo, parameterInfo.Name); } - if (functionInfo.ReturnType.IsVoid) + var returnType = functionInfo.ReturnType; + if (returnType.IsVoid) { contents.AppendLine($" typedef void (*Thunk)(void* instance{thunkParams}, MonoObject** exception);"); contents.AppendLine(" const auto thunk = (Thunk)method->GetThunk();"); @@ -1295,18 +1296,30 @@ namespace Flax.Build.Bindings contents.AppendLine(" if (exception)"); contents.AppendLine(" DebugLog::LogException(exception);"); - if (!functionInfo.ReturnType.IsVoid) + if (!returnType.IsVoid) { - if (functionInfo.ReturnType.IsRef) + if (returnType.IsRef) throw new NotSupportedException($"Passing return value by reference is not supported for virtual API methods. Used on method '{functionInfo}'."); - switch (functionInfo.ReturnType.Type) + switch (returnType.Type) { case "bool": - contents.AppendLine($" return __result != 0;"); + contents.AppendLine(" return __result != 0;"); + break; + case "int8": + case "int16": + case "int32": + case "int64": + contents.AppendLine($" return ({returnType.Type})(intptr)__result;"); + break; + case "uint8": + case "uint16": + case "uint32": + case "uint64": + contents.AppendLine($" return ({returnType.Type})(uintptr)__result;"); break; default: - contents.AppendLine($" return MUtils::Unbox<{functionInfo.ReturnType}>(__result);"); + contents.AppendLine($" return MUtils::Unbox<{returnType}>(__result);"); break; } }