From 19d9cd282d094e22a1c5d51fdfb0ea7d2114f694 Mon Sep 17 00:00:00 2001 From: Crawcik Date: Wed, 7 Sep 2022 16:53:30 +0200 Subject: [PATCH 01/51] Linux include paths fix --- .../Flax.Build/Platforms/Linux/LinuxPlatform.cs | 2 +- .../Flax.Build/Platforms/Linux/LinuxToolchain.cs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Source/Tools/Flax.Build/Platforms/Linux/LinuxPlatform.cs b/Source/Tools/Flax.Build/Platforms/Linux/LinuxPlatform.cs index 1d0433f50..ced516a54 100644 --- a/Source/Tools/Flax.Build/Platforms/Linux/LinuxPlatform.cs +++ b/Source/Tools/Flax.Build/Platforms/Linux/LinuxPlatform.cs @@ -58,7 +58,7 @@ namespace Flax.Build.Platforms if (Compiler != null) { // System compiler - ToolchainRoot = string.Empty; + ToolchainRoot = "/"; Log.Verbose($"Using native Linux toolchain (compiler {Compiler})"); HasRequiredSDKsInstalled = true; } diff --git a/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs b/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs index ede17b639..2904b89a7 100644 --- a/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs @@ -23,9 +23,16 @@ namespace Flax.Build.Platforms : base(platform, architecture, platform.ToolchainRoot, platform.Compiler) { // Setup system paths - SystemIncludePaths.Add(Path.Combine(ToolsetRoot, "usr", "include")); - SystemIncludePaths.Add(Path.Combine(ToolsetRoot, "include", "c++", "5.2.0")); - SystemIncludePaths.Add(Path.Combine(ToolsetRoot, "lib", "clang", ClangVersion.Major.ToString(), "include")); + var includePath = Path.Combine(ToolsetRoot, "usr", "include"); + SystemIncludePaths.Add(includePath); + var cppIncludePath = Path.Combine(includePath, "c++", ClangVersion.ToString()); + if (Directory.Exists(cppIncludePath)) + SystemIncludePaths.Add(cppIncludePath); + var clangLibPath = Path.Combine(ToolsetRoot, "usr", "lib", "clang"); + var clangIncludePath = Path.Combine(clangLibPath, ClangVersion.Major.ToString(), "include"); + if (!Directory.Exists(clangIncludePath)) + clangIncludePath = Path.Combine(clangLibPath, ClangVersion.ToString(), "include"); + SystemIncludePaths.Add(clangIncludePath); } /// From dd8f923bf506274f654667727f325faf6d71134f Mon Sep 17 00:00:00 2001 From: Crawcik Date: Wed, 7 Sep 2022 16:54:42 +0200 Subject: [PATCH 02/51] VSC dotnet gen & omnisharp flags --- Source/Tools/Flax.Build/Projects/ProjectGenerator.cs | 4 +++- .../VisualStudioCode/VisualStudioCodeProjectGenerator.cs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Tools/Flax.Build/Projects/ProjectGenerator.cs b/Source/Tools/Flax.Build/Projects/ProjectGenerator.cs index f218a9a4f..cb0e5311e 100644 --- a/Source/Tools/Flax.Build/Projects/ProjectGenerator.cs +++ b/Source/Tools/Flax.Build/Projects/ProjectGenerator.cs @@ -138,7 +138,9 @@ namespace Flax.Build.Projects default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } } - case ProjectFormat.VisualStudioCode: return new VisualStudioCodeProjectGenerator(); + case ProjectFormat.VisualStudioCode: return type == TargetType.DotNet + ? (ProjectGenerator)new CSProjectGenerator(VisualStudioVersion.VisualStudio2015) + : (ProjectGenerator)new VisualStudioCodeProjectGenerator(); case ProjectFormat.XCode: return new XCodeProjectGenerator(); case ProjectFormat.Custom: if (CustomProjectTypes.TryGetValue(Configuration.ProjectFormatCustom, out var factory)) diff --git a/Source/Tools/Flax.Build/Projects/VisualStudioCode/VisualStudioCodeProjectGenerator.cs b/Source/Tools/Flax.Build/Projects/VisualStudioCode/VisualStudioCodeProjectGenerator.cs index f726ea0c4..f3a4a0e8e 100644 --- a/Source/Tools/Flax.Build/Projects/VisualStudioCode/VisualStudioCodeProjectGenerator.cs +++ b/Source/Tools/Flax.Build/Projects/VisualStudioCode/VisualStudioCodeProjectGenerator.cs @@ -547,6 +547,10 @@ namespace Flax.Build.Projects.VisualStudioCode json.AddField("**/Output", true); json.AddField("**/*.flax", true); json.EndObject(); + + // Extension settings + json.AddField("omnisharp.useModernNet", false); + json.EndRootObject(); json.Save(Path.Combine(vsCodeFolder, "settings.json")); From 8b0d1b4a8c37f2ee1cb98b7c552ae9007a238d7b Mon Sep 17 00:00:00 2001 From: Crawcik Date: Wed, 7 Sep 2022 17:43:11 +0200 Subject: [PATCH 03/51] Editor compression fix on unix --- .../Flax.Build/Deploy/Deployment.Editor.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs b/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs index ad94da918..6a5e2fb04 100644 --- a/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs +++ b/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using Flax.Build; +using Flax.Build.Platforms; namespace Flax.Deploy { @@ -129,18 +130,18 @@ namespace Flax.Deploy Log.Info(string.Empty); Log.Info("Compressing editor files..."); string editorPackageZipPath; - if (Platform.BuildTargetPlatform == TargetPlatform.Linux) + var unix = Platform.BuildTargetPlatform == TargetPlatform.Linux || Platform.BuildTargetPlatform == TargetPlatform.Mac; + if (unix) { - // Use system tool (preserves executable file attributes and link files) - editorPackageZipPath = Path.Combine(Deployer.PackageOutputPath, "FlaxEditorLinux.zip"); - Utilities.FileDelete(editorPackageZipPath); - Utilities.Run("zip", "Editor.zip -r .", null, OutputPath, Utilities.RunOptions.ThrowExceptionOnError); - File.Move(Path.Combine(OutputPath, "Editor.zip"), editorPackageZipPath); + var zipEofPath = UnixPlatform.Which("zip"); + unix = File.Exists(zipEofPath); + if (!unix) + Log.Verbose("Using .NET compressing"); } - else if (Platform.BuildTargetPlatform == TargetPlatform.Mac) + if (unix) { // Use system tool (preserves executable file attributes and link files) - editorPackageZipPath = Path.Combine(Deployer.PackageOutputPath, "FlaxEditorMac.zip"); + editorPackageZipPath = Path.Combine(Deployer.PackageOutputPath, $"FlaxEditor{Enum.GetName(typeof(TargetPlatform), Platform.BuildTargetPlatform)}.zip"); Utilities.FileDelete(editorPackageZipPath); Utilities.Run("zip", "Editor.zip -r .", null, OutputPath, Utilities.RunOptions.ThrowExceptionOnError); File.Move(Path.Combine(OutputPath, "Editor.zip"), editorPackageZipPath); From f154bfcfc1a16e6e0e67d8d738b7a1aa1a30e6de Mon Sep 17 00:00:00 2001 From: Crawcik Date: Wed, 7 Sep 2022 18:15:14 +0200 Subject: [PATCH 04/51] Flax.Build compress toogle option --- Source/Tools/Flax.Build/Configuration.cs | 6 ++++++ Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs | 3 +++ Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs | 7 ++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Source/Tools/Flax.Build/Configuration.cs b/Source/Tools/Flax.Build/Configuration.cs index 55f3d138d..4c3f63b0c 100644 --- a/Source/Tools/Flax.Build/Configuration.cs +++ b/Source/Tools/Flax.Build/Configuration.cs @@ -39,6 +39,12 @@ namespace Flax.Build [CommandLine("deploy", "Runs the deploy tool.")] public static bool Deploy = false; + /// + /// Compresses deployed files. + /// + [CommandLine("deployDontCompress", "Skips compressing deployed files, and keeps files.")] + public static bool DontCompress = false; + /// /// Builds the targets. Builds all the targets, use to select a custom set of targets for the build. /// diff --git a/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs b/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs index 6a5e2fb04..885282745 100644 --- a/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs +++ b/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs @@ -127,6 +127,9 @@ namespace Flax.Deploy DeployFile(RootPath, OutputPath, "Flax.flaxproj"); // Compress + if (Configuration.DontCompress) + return; + Log.Info(string.Empty); Log.Info("Compressing editor files..."); string editorPackageZipPath; diff --git a/Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs b/Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs index 78e6183bb..9a6d372d2 100644 --- a/Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs +++ b/Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs @@ -63,6 +63,7 @@ namespace Flax.Deploy } // Compress + if (!Configuration.DontCompress) { Log.Info("Compressing platform files..."); @@ -84,10 +85,10 @@ namespace Flax.Deploy #endif Log.Info(string.Format("Compressed {0} package size: {1}", platformName, Utilities.GetFileSize(packageZipPath))); - } - // Remove files (only zip package is used) - Utilities.DirectoryDelete(dst); + // Remove files (only zip package is used) + Utilities.DirectoryDelete(dst); + } Log.Info(string.Empty); } From 2c4d578f7c7a58e21505919fc7a00f6d35d2189e Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 8 Sep 2022 18:49:25 +0200 Subject: [PATCH 05/51] Add deprecation info for users to upgrade the code --- Source/Editor/CustomEditors/Elements/FloatValueElement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/CustomEditors/Elements/FloatValueElement.cs b/Source/Editor/CustomEditors/Elements/FloatValueElement.cs index ff2218a9b..6fc10e967 100644 --- a/Source/Editor/CustomEditors/Elements/FloatValueElement.cs +++ b/Source/Editor/CustomEditors/Elements/FloatValueElement.cs @@ -22,7 +22,7 @@ namespace FlaxEditor.CustomEditors.Elements /// /// [Deprecated on 26.05.2022, expires on 26.05.2024] /// - [System.Obsolete("Deprecated in 1.4")] + [System.Obsolete("Deprecated in 1.4, ValueBox instead")] public FloatValueBox FloatValue => ValueBox; /// From 8694bd6af9eb03be6f5cdbf33ebe3111a1413df0 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 12 Sep 2022 14:48:08 +0200 Subject: [PATCH 06/51] Fix crash on root motion extraction if source animation has no valid root node animated #746 --- Source/Engine/Animations/Graph/AnimGroup.Animation.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp index 02287db35..50dacbb76 100644 --- a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp +++ b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp @@ -42,12 +42,10 @@ int32 AnimGraphExecutor::GetRootNodeIndex(Animation* anim) void AnimGraphExecutor::ExtractRootMotion(const Animation::NodeToChannel* mapping, int32 rootNodeIndex, Animation* anim, float pos, float prevPos, Transform& rootNode, RootMotionData& rootMotion) { - const Transform refPose = GetEmptyNodes()->Nodes[rootNodeIndex]; - if (_rootMotionMode == RootMotionMode::Enable) + const Transform& refPose = GetEmptyNodes()->Nodes[rootNodeIndex]; + const int32 nodeToChannel = mapping->At(rootNodeIndex); + if (_rootMotionMode == RootMotionMode::Enable && nodeToChannel != -1) { - const int32 nodeToChannel = mapping->At(rootNodeIndex); - ASSERT_LOW_LAYER(nodeToChannel != -1); - // Get the root bone transformation Transform rootBefore = refPose; const NodeAnimationData& rootChannel = anim->Data.Channels[nodeToChannel]; From 439f74c5406f8f1bb970065f1efe2dc007a7808f Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Fri, 9 Sep 2022 15:29:17 +0200 Subject: [PATCH 07/51] Fix comparison operators on object reference types --- Source/Engine/Content/AssetReference.h | 8 ++++---- Source/Engine/Content/SoftAssetReference.h | 8 ++++---- Source/Engine/Content/WeakAssetReference.h | 4 ++-- Source/Engine/Scripting/ScriptingObjectReference.h | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/Engine/Content/AssetReference.h b/Source/Engine/Content/AssetReference.h index 82ef5adce..fc347585f 100644 --- a/Source/Engine/Content/AssetReference.h +++ b/Source/Engine/Content/AssetReference.h @@ -150,22 +150,22 @@ public: return *this; } - FORCE_INLINE bool operator==(T* other) + FORCE_INLINE bool operator==(T* other) const { return _asset == other; } - FORCE_INLINE bool operator==(const AssetReference& other) + FORCE_INLINE bool operator==(const AssetReference& other) const { return _asset == other._asset; } - FORCE_INLINE bool operator!=(T* other) + FORCE_INLINE bool operator!=(T* other) const { return _asset != other; } - FORCE_INLINE bool operator!=(const AssetReference& other) + FORCE_INLINE bool operator!=(const AssetReference& other) const { return _asset != other._asset; } diff --git a/Source/Engine/Content/SoftAssetReference.h b/Source/Engine/Content/SoftAssetReference.h index a65099870..dd1251d61 100644 --- a/Source/Engine/Content/SoftAssetReference.h +++ b/Source/Engine/Content/SoftAssetReference.h @@ -105,19 +105,19 @@ public: } public: - FORCE_INLINE bool operator==(T* other) + FORCE_INLINE bool operator==(T* other) const { return Get() == other; } - FORCE_INLINE bool operator==(const SoftAssetReference& other) + FORCE_INLINE bool operator==(const SoftAssetReference& other) const { return GetID() == other.GetID(); } - FORCE_INLINE bool operator!=(T* other) + FORCE_INLINE bool operator!=(T* other) const { return Get() != other; } - FORCE_INLINE bool operator!=(const SoftAssetReference& other) + FORCE_INLINE bool operator!=(const SoftAssetReference& other) const { return GetID() != other.GetID(); } diff --git a/Source/Engine/Content/WeakAssetReference.h b/Source/Engine/Content/WeakAssetReference.h index 1124e9656..7e756211a 100644 --- a/Source/Engine/Content/WeakAssetReference.h +++ b/Source/Engine/Content/WeakAssetReference.h @@ -137,12 +137,12 @@ public: return *this; } - FORCE_INLINE bool operator==(T* other) + FORCE_INLINE bool operator==(T* other) const { return _asset == other; } - FORCE_INLINE bool operator==(const WeakAssetReference& other) + FORCE_INLINE bool operator==(const WeakAssetReference& other) const { return _asset == other._asset; } diff --git a/Source/Engine/Scripting/ScriptingObjectReference.h b/Source/Engine/Scripting/ScriptingObjectReference.h index 3bae0f7a5..26c75687b 100644 --- a/Source/Engine/Scripting/ScriptingObjectReference.h +++ b/Source/Engine/Scripting/ScriptingObjectReference.h @@ -164,19 +164,19 @@ public: public: - FORCE_INLINE bool operator==(T* other) + FORCE_INLINE bool operator==(T* other) const { return _object == other; } - FORCE_INLINE bool operator!=(T* other) + FORCE_INLINE bool operator!=(T* other) const { return _object != other; } - FORCE_INLINE bool operator==(const ScriptingObjectReference& other) + FORCE_INLINE bool operator==(const ScriptingObjectReference& other) const { return _object == other._object; } - FORCE_INLINE bool operator!=(const ScriptingObjectReference& other) + FORCE_INLINE bool operator!=(const ScriptingObjectReference& other) const { return _object != other._object; } From 10d66fb871bb8c238642904dcf234ede55891df5 Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Fri, 9 Sep 2022 15:29:55 +0200 Subject: [PATCH 08/51] Fix displaying Game and Editor plugins to be batched in Editor --- Source/Editor/Windows/PluginsWindow.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/Editor/Windows/PluginsWindow.cs b/Source/Editor/Windows/PluginsWindow.cs index 68c00c281..851a34f19 100644 --- a/Source/Editor/Windows/PluginsWindow.cs +++ b/Source/Editor/Windows/PluginsWindow.cs @@ -201,11 +201,13 @@ namespace FlaxEditor.Windows toRemove.Add(e.Value); } } + if (toRemove != null) { foreach (var plugin in toRemove) OnPluginRemove(plugin); } + foreach (var plugin in gamePlugins) OnPluginAdd(plugin); foreach (var plugin in editorPlugins) @@ -222,6 +224,16 @@ namespace FlaxEditor.Windows if (plugin is EditorPlugin editorPlugin && GetPluginEntry(editorPlugin.GamePluginType) != null) return; + // Special case for game plugins (merge with editor plugin if has linked) + if (plugin is GamePlugin) + { + foreach (var e in _entries.Keys) + { + if (e is EditorPlugin ee && ee.GamePluginType == plugin.GetType()) + return; + } + } + var desc = plugin.Description; var category = _categories.Find(x => string.Equals(x.Text, desc.Category, StringComparison.OrdinalIgnoreCase)); if (category == null) From c553859c3b529adf3abfec27b909b4d75327d0ec Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Wed, 7 Sep 2022 13:44:29 +0200 Subject: [PATCH 09/51] Fix invalid NetworkMessage usage in C++ --- Source/Engine/Networking/NetworkMessage.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Engine/Networking/NetworkMessage.h b/Source/Engine/Networking/NetworkMessage.h index f83f9b828..ed1285ccd 100644 --- a/Source/Engine/Networking/NetworkMessage.h +++ b/Source/Engine/Networking/NetworkMessage.h @@ -72,6 +72,7 @@ public: ASSERT(Position + numBytes < BufferSize); Platform::MemoryCopy(Buffer + Position, bytes, numBytes); Position += numBytes; + Length = Position; } /// From 66b452e90c6ae9f05dc9625b5978ac1aab2d316f Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Tue, 13 Sep 2022 12:55:14 +0200 Subject: [PATCH 10/51] Fix crash on shutdown due to custom JsonAsset C++ instance --- Source/Engine/Content/JsonAsset.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/Engine/Content/JsonAsset.cpp b/Source/Engine/Content/JsonAsset.cpp index 4a6d92c66..af49094bc 100644 --- a/Source/Engine/Content/JsonAsset.cpp +++ b/Source/Engine/Content/JsonAsset.cpp @@ -247,6 +247,9 @@ Asset::LoadResult JsonAsset::loadAsset() Level::ScriptsReloaded.Bind(this); #endif + // Destroy instance on scripting shutdown (eg. asset from scripts) + Scripting::ScriptsUnload.Bind(this); + return LoadResult::Ok; } @@ -256,6 +259,7 @@ void JsonAsset::unload(bool isReloading) Level::ScriptsReloadStart.Unbind(this); Level::ScriptsReloaded.Unbind(this); #endif + Scripting::ScriptsUnload.Unbind(this); DeleteInstance(); JsonAssetBase::unload(isReloading); @@ -263,6 +267,8 @@ void JsonAsset::unload(bool isReloading) bool JsonAsset::CreateInstance() { + ScopeLock lock(Locker); + // Try to scripting type for this data const StringAsANSI<> dataTypeNameAnsi(DataTypeName.Get(), DataTypeName.Length()); const auto typeHandle = Scripting::FindScriptingType(StringAnsiView(dataTypeNameAnsi.Get(), DataTypeName.Length())); @@ -304,6 +310,8 @@ bool JsonAsset::CreateInstance() void JsonAsset::DeleteInstance() { + ScopeLock lock(Locker); + // C# instance if (MObject* object = GetManagedInstance()) { From 21db53e23287255568b72d021224ce3f0040bcb3 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Sat, 17 Sep 2022 11:43:51 -0500 Subject: [PATCH 11/51] Added scaling towards mouse position in Visject surfaces --- Source/Editor/Surface/VisjectSurface.Input.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Surface/VisjectSurface.Input.cs b/Source/Editor/Surface/VisjectSurface.Input.cs index ddd4ae565..02fe835f2 100644 --- a/Source/Editor/Surface/VisjectSurface.Input.cs +++ b/Source/Editor/Surface/VisjectSurface.Input.cs @@ -290,9 +290,23 @@ namespace FlaxEditor.Surface // Change scale (disable scaling during selecting nodes) if (IsMouseOver && !_leftMouseDown && !IsPrimaryMenuOpened) { - var viewCenter = ViewCenterPosition; - ViewScale += delta * 0.1f; - ViewCenterPosition = viewCenter; + var nextViewScale = ViewScale + delta * 0.1f; + + if (delta > 0 && !_rightMouseDown) + { + // Scale towards mouse when zooming in + var nextCenterPosition = ViewPosition + location / ViewScale; + ViewScale = nextViewScale; + ViewPosition = nextCenterPosition - (location / ViewScale); + } + else + { + // Scale while keeping center position when zooming out or when dragging view + var viewCenter = ViewCenterPosition; + ViewScale = nextViewScale; + ViewCenterPosition = viewCenter; + } + return true; } From 5b212bb8bc4c0a6e852fc8f3a3a5ba71b49c4992 Mon Sep 17 00:00:00 2001 From: Crawcik Date: Sat, 24 Sep 2022 17:52:59 +0200 Subject: [PATCH 12/51] Fixing mac/linux csharp binaries referencing --- .../Flax.Build/Build/Builder.Projects.cs | 2 +- Source/Tools/Flax.Build/Build/Platform.cs | 18 +++++++++++++++ .../Flax.Build/Deploy/Deployment.Editor.cs | 23 ++++--------------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Source/Tools/Flax.Build/Build/Builder.Projects.cs b/Source/Tools/Flax.Build/Build/Builder.Projects.cs index 21aa25788..42bda3ea5 100644 --- a/Source/Tools/Flax.Build/Build/Builder.Projects.cs +++ b/Source/Tools/Flax.Build/Build/Builder.Projects.cs @@ -433,7 +433,7 @@ namespace Flax.Build else if (dependencyModule.BinaryModuleName == "FlaxEngine") { // TODO: instead of this hack find a way to reference the prebuilt target bindings binary (example: game C# project references FlaxEngine C# prebuilt dll) - project.CSharp.FileReferences.Add(Path.Combine(Globals.EngineRoot, "Binaries/Editor/Win64/Development/FlaxEngine.CSharp.dll")); + project.CSharp.FileReferences.Add(Path.Combine(Globals.EngineRoot, Platform.GetEditorBinaryDirectory(), "Development/FlaxEngine.CSharp.dll")); } } } diff --git a/Source/Tools/Flax.Build/Build/Platform.cs b/Source/Tools/Flax.Build/Build/Platform.cs index 72e6454a4..99edc7889 100644 --- a/Source/Tools/Flax.Build/Build/Platform.cs +++ b/Source/Tools/Flax.Build/Build/Platform.cs @@ -245,6 +245,24 @@ namespace Flax.Build return toolchain; } + /// + /// Gets path to the current platform binary directory + /// + public static string GetEditorBinaryDirectory() + { + var subdir = "Binaries/Editor/"; + switch (Platform.BuildTargetPlatform) + { + case TargetPlatform.Windows: + return subdir + "Win64"; + case TargetPlatform.Linux: + return subdir + "Linux"; + case TargetPlatform.Mac: + return subdir + "Mac"; + } + throw new NotImplementedException(); + } + /// /// Creates the project files generator for the specified project format. /// diff --git a/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs b/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs index 885282745..c4ca880f7 100644 --- a/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs +++ b/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs @@ -193,13 +193,14 @@ namespace Flax.Deploy private static void DeployEditorBinaries(TargetConfiguration configuration) { + var binariesSubDir = Path.Combine(Platform.GetEditorBinaryDirectory(), configuration.ToString()); + var src = Path.Combine(RootPath, binariesSubDir); + var dst = Path.Combine(OutputPath, binariesSubDir); + Directory.CreateDirectory(dst); + if (Platform.BuildTargetPlatform == TargetPlatform.Windows) { - var binariesSubDir = "Binaries/Editor/Win64/" + configuration; - var src = Path.Combine(RootPath, binariesSubDir); - var dst = Path.Combine(OutputPath, binariesSubDir); var dstDebug = Path.Combine(Deployer.PackageOutputPath, "EditorDebugSymbols/Win64/" + configuration); - Directory.CreateDirectory(dst); Directory.CreateDirectory(dstDebug); // Validate that build editor app has a valid version number @@ -233,11 +234,6 @@ namespace Flax.Deploy } else if (Platform.BuildTargetPlatform == TargetPlatform.Linux) { - var binariesSubDir = "Binaries/Editor/Linux/" + configuration; - var src = Path.Combine(RootPath, binariesSubDir); - var dst = Path.Combine(OutputPath, binariesSubDir); - Directory.CreateDirectory(dst); - // Deploy binaries DeployFile(src, dst, "FlaxEditor"); DeployFile(src, dst, "FlaxEditor.Build.json"); @@ -257,11 +253,6 @@ namespace Flax.Deploy } else if (Platform.BuildTargetPlatform == TargetPlatform.Mac) { - var binariesSubDir = "Binaries/Editor/Mac/" + configuration; - var src = Path.Combine(RootPath, binariesSubDir); - var dst = Path.Combine(OutputPath, binariesSubDir); - Directory.CreateDirectory(dst); - // Deploy binaries DeployFile(src, dst, "FlaxEditor"); DeployFile(src, dst, "FlaxEditor.Build.json"); @@ -278,10 +269,6 @@ namespace Flax.Deploy Utilities.Run("strip", "libmonosgen-2.0.1.dylib", null, dst, Utilities.RunOptions.None); Utilities.Run("strip", "libMoltenVK.dylib", null, dst, Utilities.RunOptions.None); } - else - { - throw new NotImplementedException(); - } } } } From 8f19fde27a551f9926ce1f1224b275f748409c03 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Wed, 28 Sep 2022 19:06:20 -0300 Subject: [PATCH 13/51] Update TimelineEdge.cs --- .../Editor/GUI/Timeline/GUI/TimelineEdge.cs | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs b/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs index 0f1da6e9b..2d93fb79b 100644 --- a/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs +++ b/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs @@ -15,6 +15,8 @@ namespace FlaxEditor.GUI.Timeline.GUI private Timeline _timeline; private bool _isMoving; private Float2 _startMoveLocation; + private Float2 _lastMouseLocation; + private float _flipScreenMoveDelta; private int _startMoveDuration; private bool _isStart; private bool _canEdit; @@ -71,11 +73,30 @@ namespace FlaxEditor.GUI.Timeline.GUI { if (_isMoving) { + Float2 currWndCenter = _timeline.RootWindow.Window.ClientBounds.Center; + Float2 currMonitorSize = Platform.GetMonitorBounds(currWndCenter).Size; var moveLocation = Root.MousePosition; - var moveLocationDelta = moveLocation - _startMoveLocation; + var diffFromLastMoveLocation = Mathf.Max(_lastMouseLocation.X, moveLocation.X) - Mathf.Min(_lastMouseLocation.X, moveLocation.X); + var movePorcentOfXMonitorSize = diffFromLastMoveLocation * 100f / currMonitorSize.X; + + if (movePorcentOfXMonitorSize >= 90f) + { + if (_lastMouseLocation.X > moveLocation.X) + { + _flipScreenMoveDelta += currMonitorSize.X; + } + else + { + _flipScreenMoveDelta -= currMonitorSize.X; + } + } + + var moveLocationDelta = moveLocation - _startMoveLocation + _flipScreenMoveDelta; var moveDelta = (int)(moveLocationDelta.X / (Timeline.UnitsPerSecond * _timeline.Zoom) * _timeline.FramesPerSecond); var durationFrames = _timeline.DurationFrames; + + if (_isStart) { // TODO: editing timeline start frame? @@ -83,12 +104,16 @@ namespace FlaxEditor.GUI.Timeline.GUI else { _timeline.DurationFrames = _startMoveDuration + moveDelta; + _timeline.MediaBackground.HScrollBar.Value = _timeline.MediaBackground.HScrollBar.Maximum; } if (_timeline.DurationFrames != durationFrames) { _timeline.MarkAsEdited(); } + + _lastMouseLocation = moveLocation; + } else { @@ -140,6 +165,8 @@ namespace FlaxEditor.GUI.Timeline.GUI _timeline.DurationFrames = duration; } _isMoving = false; + _flipScreenMoveDelta = 0; + _timeline.MediaBackground.HScrollBar.Value = _timeline.MediaBackground.HScrollBar.Maximum; EndMouseCapture(); } From 5303da4b9067fbe32089d81aea10ebeafff0ec1d Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 28 Sep 2022 22:03:26 -0500 Subject: [PATCH 14/51] Removed double click to rename content item --- Source/Editor/Content/Items/ContentItem.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Source/Editor/Content/Items/ContentItem.cs b/Source/Editor/Content/Items/ContentItem.cs index d887c304e..1cc6d480e 100644 --- a/Source/Editor/Content/Items/ContentItem.cs +++ b/Source/Editor/Content/Items/ContentItem.cs @@ -690,18 +690,9 @@ namespace FlaxEditor.Content public override bool OnMouseDoubleClick(Float2 location, MouseButton button) { Focus(); - - // Check if clicked on name area (and can be renamed) - if (CanRename && TextRectangle.Contains(ref location)) - { - // Rename - (Parent as ContentView).OnItemDoubleClickName(this); - } - else - { - // Open - (Parent as ContentView).OnItemDoubleClick(this); - } + + // Open + (Parent as ContentView).OnItemDoubleClick(this); return true; } From 789ec55dbe7bc20979b02a1f4ac81e1c1ab4d84e Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 28 Sep 2022 22:03:26 -0500 Subject: [PATCH 15/51] Removed double click to rename content item --- Source/Editor/Content/GUI/ContentView.cs | 9 --------- Source/Editor/Content/Items/ContentItem.cs | 15 +++------------ 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/Source/Editor/Content/GUI/ContentView.cs b/Source/Editor/Content/GUI/ContentView.cs index e0affeedc..bf9fb1715 100644 --- a/Source/Editor/Content/GUI/ContentView.cs +++ b/Source/Editor/Content/GUI/ContentView.cs @@ -536,15 +536,6 @@ namespace FlaxEditor.Content.GUI } } - /// - /// Called when user wants to rename item. - /// - /// The item. - public void OnItemDoubleClickName(ContentItem item) - { - OnRename?.Invoke(item); - } - /// /// Called when user wants to open item. /// diff --git a/Source/Editor/Content/Items/ContentItem.cs b/Source/Editor/Content/Items/ContentItem.cs index d887c304e..1cc6d480e 100644 --- a/Source/Editor/Content/Items/ContentItem.cs +++ b/Source/Editor/Content/Items/ContentItem.cs @@ -690,18 +690,9 @@ namespace FlaxEditor.Content public override bool OnMouseDoubleClick(Float2 location, MouseButton button) { Focus(); - - // Check if clicked on name area (and can be renamed) - if (CanRename && TextRectangle.Contains(ref location)) - { - // Rename - (Parent as ContentView).OnItemDoubleClickName(this); - } - else - { - // Open - (Parent as ContentView).OnItemDoubleClick(this); - } + + // Open + (Parent as ContentView).OnItemDoubleClick(this); return true; } From 656fcf984721bed3d95b4f8249a416f2e85c04ce Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 30 Sep 2022 09:22:36 -0500 Subject: [PATCH 16/51] Changed the content window do the search bars do not scroll with the content. --- Source/Editor/Windows/ContentWindow.cs | 47 +++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/Source/Editor/Windows/ContentWindow.cs b/Source/Editor/Windows/ContentWindow.cs index 0f9eba0c0..56681296e 100644 --- a/Source/Editor/Windows/ContentWindow.cs +++ b/Source/Editor/Windows/ContentWindow.cs @@ -27,6 +27,8 @@ namespace FlaxEditor.Windows private const string ProjectDataLastViewedFolder = "LastViewedFolder"; private bool _isWorkspaceDirty; private SplitPanel _split; + private Panel _contentViewPanel; + private Panel _contentTreePanel; private ContentView _view; private readonly ToolStrip _toolStrip; @@ -95,7 +97,7 @@ namespace FlaxEditor.Windows }; // Split panel - _split = new SplitPanel(options.Options.Interface.ContentWindowOrientation, ScrollBars.Both, ScrollBars.Vertical) + _split = new SplitPanel(options.Options.Interface.ContentWindowOrientation, ScrollBars.None, ScrollBars.None) { AnchorPreset = AnchorPresets.StretchAll, Offsets = new Margin(0, 0, _toolStrip.Bottom, 0), @@ -120,11 +122,20 @@ namespace FlaxEditor.Windows }; _foldersSearchBox.TextChanged += OnFoldersSearchBoxTextChanged; + // Content tree panel + _contentTreePanel = new Panel + { + AnchorPreset = AnchorPresets.StretchAll, + Offsets = new Margin(0, 0, headerPanel.Bottom, 0), + IsScrollable = true, + ScrollBars = ScrollBars.Both, + Parent = _split.Panel1, + }; + // Content structure tree _tree = new Tree(false) { - Y = headerPanel.Bottom, - Parent = _split.Panel1, + Parent = _contentTreePanel, }; _tree.SelectedChanged += OnTreeSelectionChanged; headerPanel.Parent = _split.Panel1; @@ -159,13 +170,23 @@ namespace FlaxEditor.Windows _viewDropdown.Items.Add(((ContentItemSearchFilter)i).ToString()); _viewDropdown.PopupCreate += OnViewDropdownPopupCreate; + // Content view panel + _contentViewPanel = new Panel + { + AnchorPreset = AnchorPresets.StretchAll, + Offsets = new Margin(0, 0, contentItemsSearchPanel.Bottom + 4, 0), + IsScrollable = true, + ScrollBars = ScrollBars.Vertical, + Parent = _split.Panel2, + }; + // Content View _view = new ContentView { AnchorPreset = AnchorPresets.HorizontalStretchTop, - Offsets = new Margin(0, 0, contentItemsSearchPanel.Bottom + 4, 0), + Offsets = new Margin(0, 0, 0, 0), IsScrollable = true, - Parent = _split.Panel2, + Parent = _contentViewPanel, }; _view.OnOpen += Open; _view.OnNavigateBack += NavigateBackward; @@ -285,6 +306,14 @@ namespace FlaxEditor.Windows _split.Panel2.VScrollBar.ThumbEnabled = false; if (_split.Panel2.HScrollBar != null) _split.Panel2.HScrollBar.ThumbEnabled = false; + if (_contentViewPanel.VScrollBar != null) + _contentViewPanel.VScrollBar.ThumbEnabled = false; + if (_contentViewPanel.HScrollBar != null) + _contentViewPanel.HScrollBar.ThumbEnabled = false; + if (_contentTreePanel.VScrollBar != null) + _contentTreePanel.VScrollBar.ThumbEnabled = false; + if (_contentTreePanel.HScrollBar != null) + _contentTreePanel.HScrollBar.ThumbEnabled = false; // Show rename popup var popup = RenamePopup.Show(item, item.TextRectangle, item.ShortName, true); @@ -298,6 +327,14 @@ namespace FlaxEditor.Windows _split.Panel2.VScrollBar.ThumbEnabled = true; if (_split.Panel2.HScrollBar != null) _split.Panel2.HScrollBar.ThumbEnabled = true; + if (_contentViewPanel.VScrollBar != null) + _contentViewPanel.VScrollBar.ThumbEnabled = true; + if (_contentViewPanel.HScrollBar != null) + _contentViewPanel.HScrollBar.ThumbEnabled = true; + if (_contentTreePanel.VScrollBar != null) + _contentTreePanel.VScrollBar.ThumbEnabled = true; + if (_contentTreePanel.HScrollBar != null) + _contentTreePanel.HScrollBar.ThumbEnabled = true; // Check if was creating new element if (_newElement != null) From c19ff9b2ef992f50b616ba94365e947959321430 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 30 Sep 2022 19:25:50 -0500 Subject: [PATCH 17/51] Added a change in cursor type to assist in UX for resizing editor panels and changing the values in value boxes --- Source/Editor/GUI/Input/ValueBox.cs | 12 ++++++++++++ Source/Engine/UI/GUI/Panels/SplitPanel.cs | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index ff824d76c..4b9ef8a51 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -172,6 +172,7 @@ namespace FlaxEditor.GUI.Input { _isSliding = false; EndMouseCapture(); + Cursor = CursorType.Default; SlidingEnd?.Invoke(); } @@ -236,6 +237,7 @@ namespace FlaxEditor.GUI.Input _startSlideLocation = location; _startSlideValue = _value; StartMouseCapture(true); + Cursor = CursorType.SizeWE; SlidingStart?.Invoke(); return true; } @@ -256,6 +258,16 @@ namespace FlaxEditor.GUI.Input ApplySliding(Mathf.RoundToInt(slideLocation.X - _startSlideLocation.X) * _slideSpeed); return; } + + // Update cursor type so user knows they can slide value + if (CanUseSliding && SlideRect.Contains(location)) + { + Cursor = CursorType.SizeWE; + } + else if (!_isSliding) + { + Cursor = CursorType.Default; + } base.OnMouseMove(location); } diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index 8772c78e6..563f1974b 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -161,6 +161,15 @@ namespace FlaxEngine.GUI if (_splitterClicked) { SplitterValue = _orientation == Orientation.Horizontal ? location.X / Width : location.Y / Height; + Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; + } + else if (_mouseOverSplitter) + { + Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; + } + else + { + Cursor = CursorType.Default; } base.OnMouseMove(location); From e18002dd03544e686432a666f46fe27d8eda31ab Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 30 Sep 2022 20:01:35 -0500 Subject: [PATCH 18/51] Fixed regression of cursor being stuck in default when trying to change it in viewport --- Source/Engine/UI/GUI/Panels/SplitPanel.cs | 24 ++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index 563f1974b..bf79cb86c 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -23,6 +23,8 @@ namespace FlaxEngine.GUI private float _splitterValue; private Rectangle _splitterRect; private bool _splitterClicked, _mouseOverSplitter; + private bool _leftMouseButtonDown; + private bool _rightMouseButtonDown; /// /// The first panel (left or upper based on Orientation). @@ -167,7 +169,7 @@ namespace FlaxEngine.GUI { Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; } - else + else if (!_leftMouseButtonDown && !_rightMouseButtonDown) { Cursor = CursorType.Default; } @@ -178,6 +180,16 @@ namespace FlaxEngine.GUI /// public override bool OnMouseDown(Float2 location, MouseButton button) { + if (button == MouseButton.Left) + { + _leftMouseButtonDown = true; + } + + if (button == MouseButton.Right) + { + _rightMouseButtonDown = true; + } + if (button == MouseButton.Left && _splitterRect.Contains(location)) { // Start moving splitter @@ -192,6 +204,16 @@ namespace FlaxEngine.GUI /// public override bool OnMouseUp(Float2 location, MouseButton button) { + if (button == MouseButton.Left) + { + _leftMouseButtonDown = false; + } + + if (button == MouseButton.Right) + { + _rightMouseButtonDown = false; + } + if (_splitterClicked) { EndTracking(); From 3867cb5e9758d53b873e3b06776fa163a9da2af1 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 30 Sep 2022 20:52:04 -0500 Subject: [PATCH 19/51] Changed how cursor is set back to default, so it doesnt keep setting itself --- Source/Editor/GUI/Input/ValueBox.cs | 4 +++- Source/Engine/UI/GUI/Panels/SplitPanel.cs | 27 ++++------------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index 4b9ef8a51..4836b41c5 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -56,6 +56,7 @@ namespace FlaxEditor.GUI.Input private Float2 _startSlideLocation; private double _clickStartTime = -1; + private bool _cursorChanged; /// /// Occurs when value gets changed. @@ -263,8 +264,9 @@ namespace FlaxEditor.GUI.Input if (CanUseSliding && SlideRect.Contains(location)) { Cursor = CursorType.SizeWE; + _cursorChanged = true; } - else if (!_isSliding) + else if (_cursorChanged && !_isSliding) { Cursor = CursorType.Default; } diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index bf79cb86c..4b15c38db 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -23,8 +23,7 @@ namespace FlaxEngine.GUI private float _splitterValue; private Rectangle _splitterRect; private bool _splitterClicked, _mouseOverSplitter; - private bool _leftMouseButtonDown; - private bool _rightMouseButtonDown; + private bool _cursorChanged; /// /// The first panel (left or upper based on Orientation). @@ -168,10 +167,12 @@ namespace FlaxEngine.GUI else if (_mouseOverSplitter) { Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; + _cursorChanged = true; } - else if (!_leftMouseButtonDown && !_rightMouseButtonDown) + else if (_cursorChanged) { Cursor = CursorType.Default; + _cursorChanged = false; } base.OnMouseMove(location); @@ -180,16 +181,6 @@ namespace FlaxEngine.GUI /// public override bool OnMouseDown(Float2 location, MouseButton button) { - if (button == MouseButton.Left) - { - _leftMouseButtonDown = true; - } - - if (button == MouseButton.Right) - { - _rightMouseButtonDown = true; - } - if (button == MouseButton.Left && _splitterRect.Contains(location)) { // Start moving splitter @@ -204,16 +195,6 @@ namespace FlaxEngine.GUI /// public override bool OnMouseUp(Float2 location, MouseButton button) { - if (button == MouseButton.Left) - { - _leftMouseButtonDown = false; - } - - if (button == MouseButton.Right) - { - _rightMouseButtonDown = false; - } - if (_splitterClicked) { EndTracking(); From 6af6649f70f9f48d470aa51dd20677dbd90b384d Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Sun, 2 Oct 2022 00:02:56 -0400 Subject: [PATCH 20/51] implement method to check if world position is within camera view --- Source/Engine/Level/Actors/Camera.cpp | 19 +++++++++++++++++++ Source/Engine/Level/Actors/Camera.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/Source/Engine/Level/Actors/Camera.cpp b/Source/Engine/Level/Actors/Camera.cpp index a91074ab5..6a6e9edd8 100644 --- a/Source/Engine/Level/Actors/Camera.cpp +++ b/Source/Engine/Level/Actors/Camera.cpp @@ -5,6 +5,7 @@ #include "Engine/Core/Math/Viewport.h" #include "Engine/Content/Assets/Model.h" #include "Engine/Content/Content.h" +#include "Engine/Engine/Screen.h" #include "Engine/Serialization/Serialization.h" #if USE_EDITOR #include "Editor/Editor.h" @@ -120,6 +121,24 @@ void Camera::ProjectPoint(const Vector3& worldSpaceLocation, Float2& cameraViewp cameraViewportSpaceLocation = Float2(clipSpaceLocation); } +bool Camera::CheckPointIsOnView(const Vector3& worldSpaceLocation) const +{ + Camera* mainCamera = Camera::GetMainCamera(); + + if (!mainCamera) + { + return false; + } + + Float2 windowSpace = Float2(); + Float2 screenSize = Screen::GetSize(); + + mainCamera->ProjectPoint(worldSpaceLocation, windowSpace); + + return (windowSpace.X >= 0 && windowSpace.X <= screenSize.X) && + (windowSpace.Y >= 0 && windowSpace.Y <= screenSize.Y); +} + Ray Camera::ConvertMouseToRay(const Float2& mousePosition) const { return ConvertMouseToRay(mousePosition, GetViewport()); diff --git a/Source/Engine/Level/Actors/Camera.h b/Source/Engine/Level/Actors/Camera.h index 2b59ab323..1e38e5e04 100644 --- a/Source/Engine/Level/Actors/Camera.h +++ b/Source/Engine/Level/Actors/Camera.h @@ -168,6 +168,13 @@ public: /// The viewport. API_FUNCTION() void ProjectPoint(const Vector3& worldSpaceLocation, API_PARAM(Out) Float2& cameraViewportSpaceLocation, API_PARAM(Ref) const Viewport& viewport) const; + /// + /// Checks if the 3d point of the world is in the camera's field of view. + /// + /// World Position (XYZ) + /// Returns true if the point is within the field of view + API_FUNCTION() bool CheckPointIsOnView(const Vector3& worldSpaceLocation) const; + /// /// Converts the mouse position to 3D ray. /// From 61747bef8529e4a1e807b59f15fa86b8f8730cc2 Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Sun, 2 Oct 2022 00:16:25 -0400 Subject: [PATCH 21/51] change method name --- Source/Engine/Level/Actors/Camera.cpp | 4 ++-- Source/Engine/Level/Actors/Camera.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Engine/Level/Actors/Camera.cpp b/Source/Engine/Level/Actors/Camera.cpp index 6a6e9edd8..cd5d13702 100644 --- a/Source/Engine/Level/Actors/Camera.cpp +++ b/Source/Engine/Level/Actors/Camera.cpp @@ -121,7 +121,7 @@ void Camera::ProjectPoint(const Vector3& worldSpaceLocation, Float2& cameraViewp cameraViewportSpaceLocation = Float2(clipSpaceLocation); } -bool Camera::CheckPointIsOnView(const Vector3& worldSpaceLocation) const +bool Camera::IsPointOnView(const Vector3& worldSpaceLocation) const { Camera* mainCamera = Camera::GetMainCamera(); @@ -136,7 +136,7 @@ bool Camera::CheckPointIsOnView(const Vector3& worldSpaceLocation) const mainCamera->ProjectPoint(worldSpaceLocation, windowSpace); return (windowSpace.X >= 0 && windowSpace.X <= screenSize.X) && - (windowSpace.Y >= 0 && windowSpace.Y <= screenSize.Y); + (windowSpace.Y >= 0 && windowSpace.Y <= screenSize.Y); } Ray Camera::ConvertMouseToRay(const Float2& mousePosition) const diff --git a/Source/Engine/Level/Actors/Camera.h b/Source/Engine/Level/Actors/Camera.h index 1e38e5e04..bc412542e 100644 --- a/Source/Engine/Level/Actors/Camera.h +++ b/Source/Engine/Level/Actors/Camera.h @@ -173,7 +173,7 @@ public: /// /// World Position (XYZ) /// Returns true if the point is within the field of view - API_FUNCTION() bool CheckPointIsOnView(const Vector3& worldSpaceLocation) const; + API_FUNCTION() bool IsPointOnView(const Vector3& worldSpaceLocation) const; /// /// Converts the mouse position to 3D ray. From 0a91b8b360b76e0d17e7ae23ca44e66d7c0e962f Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Mon, 3 Oct 2022 18:51:27 -0400 Subject: [PATCH 22/51] fix: isPointOnView doesn't work for long distance positions --- Source/Engine/Level/Actors/Camera.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Level/Actors/Camera.cpp b/Source/Engine/Level/Actors/Camera.cpp index cd5d13702..ab695de5c 100644 --- a/Source/Engine/Level/Actors/Camera.cpp +++ b/Source/Engine/Level/Actors/Camera.cpp @@ -130,10 +130,23 @@ bool Camera::IsPointOnView(const Vector3& worldSpaceLocation) const return false; } + Vector3 cameraUp = mainCamera->GetTransform().GetUp(); + Vector3 cameraForward = mainCamera->GetTransform().GetForward(); + Vector3 directionToPosition = (worldSpaceLocation- mainCamera->GetPosition()).GetNormalized(); + + if (Vector3::Dot(cameraForward, directionToPosition) < 0) + { + return false; + } + + Quaternion lookAt = Quaternion::LookRotation(directionToPosition, cameraUp); + Vector3 lookAtDirection = lookAt * Vector3::Forward; + Vector3 newWorldLocation = mainCamera->GetPosition() + lookAtDirection; + Float2 windowSpace = Float2(); Float2 screenSize = Screen::GetSize(); - mainCamera->ProjectPoint(worldSpaceLocation, windowSpace); + mainCamera->ProjectPoint(newWorldLocation, windowSpace); return (windowSpace.X >= 0 && windowSpace.X <= screenSize.X) && (windowSpace.Y >= 0 && windowSpace.Y <= screenSize.Y); From aca552224580009b3ce129cdcb496c2c55e0eb70 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 5 Oct 2022 21:16:54 -0500 Subject: [PATCH 23/51] Fixed small bug when moving a tab when close to the split panel splitter --- Source/Engine/UI/GUI/Panels/SplitPanel.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index 4b15c38db..65ef60a19 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -24,6 +24,7 @@ namespace FlaxEngine.GUI private Rectangle _splitterRect; private bool _splitterClicked, _mouseOverSplitter; private bool _cursorChanged; + private bool _anyMouseButtonDown; /// /// The first panel (left or upper based on Orientation). @@ -163,8 +164,9 @@ namespace FlaxEngine.GUI { SplitterValue = _orientation == Orientation.Horizontal ? location.X / Width : location.Y / Height; Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; + _cursorChanged = true; } - else if (_mouseOverSplitter) + else if (_mouseOverSplitter && !_anyMouseButtonDown) { Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; _cursorChanged = true; @@ -181,6 +183,7 @@ namespace FlaxEngine.GUI /// public override bool OnMouseDown(Float2 location, MouseButton button) { + _anyMouseButtonDown = true; if (button == MouseButton.Left && _splitterRect.Contains(location)) { // Start moving splitter @@ -195,6 +198,7 @@ namespace FlaxEngine.GUI /// public override bool OnMouseUp(Float2 location, MouseButton button) { + _anyMouseButtonDown = false; if (_splitterClicked) { EndTracking(); From 40f7980c18db9fd782618c751afd341ca1cbaa92 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 5 Oct 2022 22:05:27 -0500 Subject: [PATCH 24/51] hide tooltip while dragging --- Source/Engine/UI/GUI/Control.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Engine/UI/GUI/Control.cs b/Source/Engine/UI/GUI/Control.cs index 8384741bc..351e105a8 100644 --- a/Source/Engine/UI/GUI/Control.cs +++ b/Source/Engine/UI/GUI/Control.cs @@ -960,6 +960,12 @@ namespace FlaxEngine.GUI [NoAnimate] public virtual DragDropEffect OnDragMove(ref Float2 location, DragData data) { + // Update tooltip + if (_tooltipUpdate != null) + { + SetUpdate(ref _tooltipUpdate, null); + Tooltip.Hide(); + } return DragDropEffect.None; } From 020351e56b229a88767ec8f56e5b3ce7d8bd8601 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 6 Oct 2022 00:03:38 -0500 Subject: [PATCH 25/51] Simplified enabling and disabling scrolling and implimented the stop scrolling functionality when renaming in the content tree panel as well --- Source/Editor/Content/Tree/ContentTreeNode.cs | 12 +++++- Source/Editor/Windows/ContentWindow.cs | 42 ++++++++++++------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/Source/Editor/Content/Tree/ContentTreeNode.cs b/Source/Editor/Content/Tree/ContentTreeNode.cs index 2503cde51..1d70a8252 100644 --- a/Source/Editor/Content/Tree/ContentTreeNode.cs +++ b/Source/Editor/Content/Tree/ContentTreeNode.cs @@ -95,11 +95,19 @@ namespace FlaxEditor.Content { if (!_folder.CanRename) return; - + Editor.Instance.Windows.ContentWin.ScrollingOnTreeView(false); // Start renaming the folder var dialog = RenamePopup.Show(this, HeaderRect, _folder.ShortName, false); dialog.Tag = _folder; - dialog.Renamed += popup => Editor.Instance.Windows.ContentWin.Rename((ContentFolder)popup.Tag, popup.Text); + dialog.Renamed += popup => + { + Editor.Instance.Windows.ContentWin.Rename((ContentFolder)popup.Tag, popup.Text); + Editor.Instance.Windows.ContentWin.ScrollingOnTreeView(true); + }; + dialog.Closed += popup => + { + Editor.Instance.Windows.ContentWin.ScrollingOnTreeView(true); + }; } /// diff --git a/Source/Editor/Windows/ContentWindow.cs b/Source/Editor/Windows/ContentWindow.cs index 56681296e..90cd77d11 100644 --- a/Source/Editor/Windows/ContentWindow.cs +++ b/Source/Editor/Windows/ContentWindow.cs @@ -292,6 +292,30 @@ namespace FlaxEditor.Windows RefreshView(SelectedNode); } + /// + /// Enables or disables vertical and horizontal scrolling on the content tree panel + /// + /// The state to set scrolling to + public void ScrollingOnTreeView(bool enabled) + { + if (_contentTreePanel.VScrollBar != null) + _contentTreePanel.VScrollBar.ThumbEnabled = enabled; + if (_contentTreePanel.HScrollBar != null) + _contentTreePanel.HScrollBar.ThumbEnabled = enabled; + } + + /// + /// Enables or disables vertical and horizontal scrolling on the content view panel + /// + /// The state to set scrolling to + public void ScrollingOnContentView(bool enabled) + { + if (_contentViewPanel.VScrollBar != null) + _contentViewPanel.VScrollBar.ThumbEnabled = enabled; + if (_contentViewPanel.HScrollBar != null) + _contentViewPanel.HScrollBar.ThumbEnabled = enabled; + } + /// /// Shows popup dialog with UI to rename content item. /// @@ -306,14 +330,7 @@ namespace FlaxEditor.Windows _split.Panel2.VScrollBar.ThumbEnabled = false; if (_split.Panel2.HScrollBar != null) _split.Panel2.HScrollBar.ThumbEnabled = false; - if (_contentViewPanel.VScrollBar != null) - _contentViewPanel.VScrollBar.ThumbEnabled = false; - if (_contentViewPanel.HScrollBar != null) - _contentViewPanel.HScrollBar.ThumbEnabled = false; - if (_contentTreePanel.VScrollBar != null) - _contentTreePanel.VScrollBar.ThumbEnabled = false; - if (_contentTreePanel.HScrollBar != null) - _contentTreePanel.HScrollBar.ThumbEnabled = false; + ScrollingOnContentView(false); // Show rename popup var popup = RenamePopup.Show(item, item.TextRectangle, item.ShortName, true); @@ -327,14 +344,7 @@ namespace FlaxEditor.Windows _split.Panel2.VScrollBar.ThumbEnabled = true; if (_split.Panel2.HScrollBar != null) _split.Panel2.HScrollBar.ThumbEnabled = true; - if (_contentViewPanel.VScrollBar != null) - _contentViewPanel.VScrollBar.ThumbEnabled = true; - if (_contentViewPanel.HScrollBar != null) - _contentViewPanel.HScrollBar.ThumbEnabled = true; - if (_contentTreePanel.VScrollBar != null) - _contentTreePanel.VScrollBar.ThumbEnabled = true; - if (_contentTreePanel.HScrollBar != null) - _contentTreePanel.HScrollBar.ThumbEnabled = true; + ScrollingOnContentView(true); // Check if was creating new element if (_newElement != null) From 79ccda38837cccf73b119da8e02867be25c1eef4 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 6 Oct 2022 16:49:35 -0500 Subject: [PATCH 26/51] Moved code to on drag enter to minimize calls. --- Source/Engine/UI/GUI/Control.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/Engine/UI/GUI/Control.cs b/Source/Engine/UI/GUI/Control.cs index 351e105a8..19b7761cb 100644 --- a/Source/Engine/UI/GUI/Control.cs +++ b/Source/Engine/UI/GUI/Control.cs @@ -948,6 +948,11 @@ namespace FlaxEngine.GUI { // Set flag _isDragOver = true; + // Update tooltip + if (_tooltipUpdate != null) + { + Tooltip.Hide(); + } return DragDropEffect.None; } @@ -960,12 +965,6 @@ namespace FlaxEngine.GUI [NoAnimate] public virtual DragDropEffect OnDragMove(ref Float2 location, DragData data) { - // Update tooltip - if (_tooltipUpdate != null) - { - SetUpdate(ref _tooltipUpdate, null); - Tooltip.Hide(); - } return DragDropEffect.None; } From 2d42ca522dcc613e6ced8966cad9b75e5613ac86 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 6 Oct 2022 16:51:25 -0500 Subject: [PATCH 27/51] Fixed spacing and comment --- Source/Engine/UI/GUI/Control.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Engine/UI/GUI/Control.cs b/Source/Engine/UI/GUI/Control.cs index 19b7761cb..992194925 100644 --- a/Source/Engine/UI/GUI/Control.cs +++ b/Source/Engine/UI/GUI/Control.cs @@ -948,11 +948,13 @@ namespace FlaxEngine.GUI { // Set flag _isDragOver = true; - // Update tooltip + + // Hide tooltip if (_tooltipUpdate != null) { Tooltip.Hide(); } + return DragDropEffect.None; } From 091fe0a40a44e46b584179282da9794092ed0a0b Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 6 Oct 2022 19:12:46 -0500 Subject: [PATCH 28/51] Simplified tool tip hide --- Source/Engine/UI/GUI/Control.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/Engine/UI/GUI/Control.cs b/Source/Engine/UI/GUI/Control.cs index 992194925..86c242609 100644 --- a/Source/Engine/UI/GUI/Control.cs +++ b/Source/Engine/UI/GUI/Control.cs @@ -950,11 +950,8 @@ namespace FlaxEngine.GUI _isDragOver = true; // Hide tooltip - if (_tooltipUpdate != null) - { - Tooltip.Hide(); - } - + Tooltip?.Hide(); + return DragDropEffect.None; } From 6d6961d9611fdfb4ea88c2ed2f6c57a0ac2e94ce Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 6 Oct 2022 19:59:51 -0500 Subject: [PATCH 29/51] removed mouse button down as it caused issues with focus --- Source/Engine/UI/GUI/Panels/SplitPanel.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index 65ef60a19..5fb8c410a 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -24,7 +24,6 @@ namespace FlaxEngine.GUI private Rectangle _splitterRect; private bool _splitterClicked, _mouseOverSplitter; private bool _cursorChanged; - private bool _anyMouseButtonDown; /// /// The first panel (left or upper based on Orientation). @@ -166,7 +165,7 @@ namespace FlaxEngine.GUI Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; _cursorChanged = true; } - else if (_mouseOverSplitter && !_anyMouseButtonDown) + else if (_mouseOverSplitter) { Cursor = _orientation == Orientation.Horizontal ? CursorType.SizeWE : CursorType.SizeNS; _cursorChanged = true; @@ -183,7 +182,6 @@ namespace FlaxEngine.GUI /// public override bool OnMouseDown(Float2 location, MouseButton button) { - _anyMouseButtonDown = true; if (button == MouseButton.Left && _splitterRect.Contains(location)) { // Start moving splitter @@ -198,7 +196,6 @@ namespace FlaxEngine.GUI /// public override bool OnMouseUp(Float2 location, MouseButton button) { - _anyMouseButtonDown = false; if (_splitterClicked) { EndTracking(); From 133d13ff3ca452701ee2e9d66fc369104f6e6c77 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 10 Oct 2022 11:06:10 -0500 Subject: [PATCH 30/51] Fixed continually setting cursour back to default in value box --- Source/Editor/GUI/Input/ValueBox.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index 4836b41c5..2b13742ee 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -174,6 +174,7 @@ namespace FlaxEditor.GUI.Input _isSliding = false; EndMouseCapture(); Cursor = CursorType.Default; + _cursorChanged = false; SlidingEnd?.Invoke(); } @@ -224,6 +225,8 @@ namespace FlaxEditor.GUI.Input // Update UpdateText(); } + + Cursor = CursorType.Default; ResetViewOffset(); } @@ -239,6 +242,7 @@ namespace FlaxEditor.GUI.Input _startSlideValue = _value; StartMouseCapture(true); Cursor = CursorType.SizeWE; + _cursorChanged = true; SlidingStart?.Invoke(); return true; } @@ -269,6 +273,7 @@ namespace FlaxEditor.GUI.Input else if (_cursorChanged && !_isSliding) { Cursor = CursorType.Default; + _cursorChanged = false; } base.OnMouseMove(location); From ebd88a407d50bcc90503256eba2361daf95fecc0 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 10 Oct 2022 18:47:38 +0200 Subject: [PATCH 31/51] Fix mouse leave event handling to restore cursor #759 --- Source/Editor/GUI/Input/ValueBox.cs | 19 +++++++++++++++++-- Source/Engine/UI/GUI/Panels/SplitPanel.cs | 5 +++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index 2b13742ee..b818c56d5 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -173,8 +173,11 @@ namespace FlaxEditor.GUI.Input { _isSliding = false; EndMouseCapture(); - Cursor = CursorType.Default; - _cursorChanged = false; + if (_cursorChanged) + { + Cursor = CursorType.Default; + _cursorChanged = false; + } SlidingEnd?.Invoke(); } @@ -300,6 +303,18 @@ namespace FlaxEditor.GUI.Input return base.OnMouseUp(location, button); } + /// + public override void OnMouseLeave() + { + if (_cursorChanged) + { + Cursor = CursorType.Default; + _cursorChanged = false; + } + + base.OnMouseLeave(); + } + /// protected override void OnEditBegin() { diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index 5fb8c410a..2a46846e8 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -210,6 +210,11 @@ namespace FlaxEngine.GUI { // Clear flag _mouseOverSplitter = false; + if (_cursorChanged) + { + Cursor = CursorType.Default; + _cursorChanged = false; + } base.OnMouseLeave(); } From 95e60ea68e08fa03d1ea1765e74b72fd3bcba782 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 10 Oct 2022 15:38:30 -0500 Subject: [PATCH 32/51] Added scene panel to seperate the tree from the search bar and made the tree not able to scroll when renaming --- Source/Editor/SceneGraph/GUI/ActorTreeNode.cs | 11 +++++++ Source/Editor/Windows/SceneTreeWindow.cs | 30 ++++++++++++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs index 82e9c3c77..ce64e2071 100644 --- a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs +++ b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs @@ -273,15 +273,26 @@ namespace FlaxEditor.SceneGraph.GUI Select(); + // disable scrolling of scene view + Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(false); + // Start renaming the actor var dialog = RenamePopup.Show(this, HeaderRect, _actorNode.Name, false); dialog.Renamed += OnRenamed; + dialog.Closed += popup => + { + // enable scrolling of scene view + Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(true); + }; } private void OnRenamed(RenamePopup renamePopup) { using (new UndoBlock(ActorNode.Root.Undo, Actor, "Rename")) Actor.Name = renamePopup.Text; + + // enable scrolling of scene view + Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(true); } /// diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index bccba12c2..f348c465e 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -131,6 +131,7 @@ namespace FlaxEditor.Windows private TextBox _searchBox; private Tree _tree; + private Panel _sceneTreePanel; private bool _isUpdatingSelection; private bool _isMouseDown; @@ -143,10 +144,9 @@ namespace FlaxEditor.Windows /// /// The editor. public SceneTreeWindow(Editor editor) - : base(editor, true, ScrollBars.Both) + : base(editor, true, ScrollBars.None) { Title = "Scene"; - ScrollMargin = new Margin(0, 0, 0, 100.0f); // Scene searching query input box var headerPanel = new ContainerControl @@ -165,19 +165,29 @@ namespace FlaxEditor.Windows }; _searchBox.TextChanged += OnSearchBoxTextChanged; + // Scene tree panel + _sceneTreePanel = new Panel + { + AnchorPreset = AnchorPresets.StretchAll, + Offsets = new Margin(0, 0, headerPanel.Bottom, 0), + IsScrollable = true, + ScrollBars = ScrollBars.Both, + Parent = this, + }; + // Create scene structure tree var root = editor.Scene.Root; root.TreeNode.ChildrenIndent = 0; root.TreeNode.Expand(); _tree = new Tree(true) { - Y = headerPanel.Bottom, Margin = new Margin(0.0f, 0.0f, -16.0f, 0.0f), // Hide root node + IsScrollable = true, }; _tree.AddChild(root.TreeNode); _tree.SelectedChanged += Tree_OnSelectedChanged; _tree.RightClick += OnTreeRightClick; - _tree.Parent = this; + _tree.Parent = _sceneTreePanel; headerPanel.Parent = this; // Setup input actions @@ -187,6 +197,18 @@ namespace FlaxEditor.Windows InputActions.Add(options => options.FocusSelection, () => Editor.Windows.EditWin.Viewport.FocusSelection()); InputActions.Add(options => options.Rename, Rename); } + + /// + /// Enables or disables vertical and horizontal scrolling on the scene tree panel + /// + /// The state to set scrolling to + public void ScrollingOnSceneTreeView(bool enabled) + { + if (_sceneTreePanel.VScrollBar != null) + _sceneTreePanel.VScrollBar.ThumbEnabled = enabled; + if (_sceneTreePanel.HScrollBar != null) + _sceneTreePanel.HScrollBar.ThumbEnabled = enabled; + } private void OnSearchBoxTextChanged() { From 67c963f60dca9b51c618a92e227fc19241cf77cc Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Mon, 10 Oct 2022 22:43:00 -0400 Subject: [PATCH 33/51] Optimization Method --- Source/Engine/Level/Actors/Camera.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/Source/Engine/Level/Actors/Camera.cpp b/Source/Engine/Level/Actors/Camera.cpp index ab695de5c..6ba7281c7 100644 --- a/Source/Engine/Level/Actors/Camera.cpp +++ b/Source/Engine/Level/Actors/Camera.cpp @@ -123,16 +123,9 @@ void Camera::ProjectPoint(const Vector3& worldSpaceLocation, Float2& cameraViewp bool Camera::IsPointOnView(const Vector3& worldSpaceLocation) const { - Camera* mainCamera = Camera::GetMainCamera(); - - if (!mainCamera) - { - return false; - } - - Vector3 cameraUp = mainCamera->GetTransform().GetUp(); - Vector3 cameraForward = mainCamera->GetTransform().GetForward(); - Vector3 directionToPosition = (worldSpaceLocation- mainCamera->GetPosition()).GetNormalized(); + Vector3 cameraUp = GetTransform().GetUp(); + Vector3 cameraForward = GetTransform().GetForward(); + Vector3 directionToPosition = (worldSpaceLocation - GetPosition()).GetNormalized(); if (Vector3::Dot(cameraForward, directionToPosition) < 0) { @@ -141,12 +134,12 @@ bool Camera::IsPointOnView(const Vector3& worldSpaceLocation) const Quaternion lookAt = Quaternion::LookRotation(directionToPosition, cameraUp); Vector3 lookAtDirection = lookAt * Vector3::Forward; - Vector3 newWorldLocation = mainCamera->GetPosition() + lookAtDirection; + Vector3 newWorldLocation = GetPosition() + lookAtDirection; Float2 windowSpace = Float2(); - Float2 screenSize = Screen::GetSize(); + Float2 screenSize = GetViewport().Size; - mainCamera->ProjectPoint(newWorldLocation, windowSpace); + ProjectPoint(newWorldLocation, windowSpace); return (windowSpace.X >= 0 && windowSpace.X <= screenSize.X) && (windowSpace.Y >= 0 && windowSpace.Y <= screenSize.Y); From 93dc57c08f9ca68e327d24886a3e603a77d45938 Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Mon, 10 Oct 2022 23:10:25 -0400 Subject: [PATCH 34/51] remove unused include --- Source/Engine/Level/Actors/Camera.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Engine/Level/Actors/Camera.cpp b/Source/Engine/Level/Actors/Camera.cpp index 6ba7281c7..81c0851a9 100644 --- a/Source/Engine/Level/Actors/Camera.cpp +++ b/Source/Engine/Level/Actors/Camera.cpp @@ -5,7 +5,6 @@ #include "Engine/Core/Math/Viewport.h" #include "Engine/Content/Assets/Model.h" #include "Engine/Content/Content.h" -#include "Engine/Engine/Screen.h" #include "Engine/Serialization/Serialization.h" #if USE_EDITOR #include "Editor/Editor.h" From 2af285e9721d7884f04e3d4dae596e92ef35cb0a Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Tue, 11 Oct 2022 11:49:32 -0300 Subject: [PATCH 35/51] feature added --- .../Windows/Assets/SkeletonMaskWindow.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs b/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs index 3627ef70e..a5e3da327 100644 --- a/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs +++ b/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs @@ -7,6 +7,7 @@ using FlaxEditor.CustomEditors; using FlaxEditor.CustomEditors.Editors; using FlaxEditor.CustomEditors.Elements; using FlaxEditor.GUI; +using FlaxEditor.GUI.Tree; using FlaxEditor.Viewport.Cameras; using FlaxEditor.Viewport.Previews; using FlaxEngine; @@ -166,8 +167,25 @@ namespace FlaxEditor.Windows.Assets var proxy = (PropertiesProxy)Values[0]; int nodeIndex = (int)checkBox.Tag; proxy.NodesMask[nodeIndex] = checkBox.Checked; + if(Input.GetKey(KeyboardKeys.Shift)) + SetTreeChecked(checkBox.Parent as TreeNode, checkBox.Checked); proxy.Window.MarkAsEdited(); } + + private void SetTreeChecked(TreeNode tree, bool state) + { + foreach(var node in tree.Children) + { + if(node is TreeNode) + { + SetTreeChecked(node as TreeNode, state); + } + if(node is CheckBox) + { + (node as CheckBox).Checked = state; + } + } + } } } From b626d3047d90052a09825bc49053b24a6394ab45 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Tue, 11 Oct 2022 13:08:52 -0300 Subject: [PATCH 36/51] Update SkeletonMaskWindow.cs --- Source/Editor/Windows/Assets/SkeletonMaskWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs b/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs index a5e3da327..6246d8f66 100644 --- a/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs +++ b/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs @@ -180,7 +180,7 @@ namespace FlaxEditor.Windows.Assets { SetTreeChecked(node as TreeNode, state); } - if(node is CheckBox) + else if(node is CheckBox) { (node as CheckBox).Checked = state; } From 77c6daf2403dbca78762b305c1c7081560c581d4 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Tue, 11 Oct 2022 13:30:49 -0300 Subject: [PATCH 37/51] fix the wrong additional layer in the matrix --- Source/Editor/CustomEditors/Dedicated/LayersMatrixEditor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/CustomEditors/Dedicated/LayersMatrixEditor.cs b/Source/Editor/CustomEditors/Dedicated/LayersMatrixEditor.cs index e6e2338d8..0f6996cc4 100644 --- a/Source/Editor/CustomEditors/Dedicated/LayersMatrixEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/LayersMatrixEditor.cs @@ -24,7 +24,7 @@ namespace FlaxEditor.CustomEditors.Dedicated public override void Initialize(LayoutElementsContainer layout) { string[] layerNames = LayersAndTagsSettings.GetCurrentLayers(); - int layersCount = Math.Max(4, layerNames.Length); + int layersCount = layerNames.Length; _checkBoxes = new List(); _layersCount = layersCount; From 187e56c6bab980d44439c2b35549e8f99cab4582 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Tue, 11 Oct 2022 13:34:46 -0300 Subject: [PATCH 38/51] typo fix in graphics settings --- Source/Engine/Core/Config/GraphicsSettings.h | 2 +- Source/Engine/Renderer/ProbesRenderer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Core/Config/GraphicsSettings.h b/Source/Engine/Core/Config/GraphicsSettings.h index 891061bf5..5cb2c923c 100644 --- a/Source/Engine/Core/Config/GraphicsSettings.h +++ b/Source/Engine/Core/Config/GraphicsSettings.h @@ -73,7 +73,7 @@ public: /// If checked, Environment Probes will use HDR texture format. Improves quality in very bright scenes at cost of higher memory usage. /// API_FIELD(Attributes = "EditorOrder(1502), EditorDisplay(\"Quality\")") - bool UeeHDRProbes = false; + bool UseHDRProbes = false; /// /// If checked, enables Global SDF rendering. This can be used in materials, shaders, and particles. diff --git a/Source/Engine/Renderer/ProbesRenderer.cpp b/Source/Engine/Renderer/ProbesRenderer.cpp index 51791edd3..c1c273de8 100644 --- a/Source/Engine/Renderer/ProbesRenderer.cpp +++ b/Source/Engine/Renderer/ProbesRenderer.cpp @@ -204,7 +204,7 @@ int32 ProbesRenderer::Entry::GetResolution() const PixelFormat ProbesRenderer::Entry::GetFormat() const { - return GraphicsSettings::Get()->UeeHDRProbes ? PixelFormat::R11G11B10_Float : PixelFormat::R8G8B8A8_UNorm; + return GraphicsSettings::Get()->UseHDRProbes ? PixelFormat::R11G11B10_Float : PixelFormat::R8G8B8A8_UNorm; } int32 ProbesRenderer::GetBakeQueueSize() From 0b8a176ff8f9b873a0ab2bddd0d8d7540b1d2044 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Tue, 11 Oct 2022 14:05:30 -0300 Subject: [PATCH 39/51] Revert "Update SkeletonMaskWindow.cs" This reverts commit b626d3047d90052a09825bc49053b24a6394ab45. --- Source/Editor/Windows/Assets/SkeletonMaskWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs b/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs index 6246d8f66..a5e3da327 100644 --- a/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs +++ b/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs @@ -180,7 +180,7 @@ namespace FlaxEditor.Windows.Assets { SetTreeChecked(node as TreeNode, state); } - else if(node is CheckBox) + if(node is CheckBox) { (node as CheckBox).Checked = state; } From b0f4f8d636b3b498ec8d88e95032623072b24b8e Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 12 Oct 2022 18:55:24 +0200 Subject: [PATCH 40/51] Code style fix --- Source/Editor/SceneGraph/GUI/ActorTreeNode.cs | 10 +++++----- Source/Editor/Windows/SceneTreeWindow.cs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs index ce64e2071..63043aa91 100644 --- a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs +++ b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs @@ -273,15 +273,15 @@ namespace FlaxEditor.SceneGraph.GUI Select(); - // disable scrolling of scene view + // Disable scrolling of scene view Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(false); - + // Start renaming the actor var dialog = RenamePopup.Show(this, HeaderRect, _actorNode.Name, false); dialog.Renamed += OnRenamed; dialog.Closed += popup => { - // enable scrolling of scene view + // Enable scrolling of scene view Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(true); }; } @@ -290,8 +290,8 @@ namespace FlaxEditor.SceneGraph.GUI { using (new UndoBlock(ActorNode.Root.Undo, Actor, "Rename")) Actor.Name = renamePopup.Text; - - // enable scrolling of scene view + + // Enable scrolling of scene view Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(true); } diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index f348c465e..b0bed2002 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -174,7 +174,7 @@ namespace FlaxEditor.Windows ScrollBars = ScrollBars.Both, Parent = this, }; - + // Create scene structure tree var root = editor.Scene.Root; root.TreeNode.ChildrenIndent = 0; @@ -197,9 +197,9 @@ namespace FlaxEditor.Windows InputActions.Add(options => options.FocusSelection, () => Editor.Windows.EditWin.Viewport.FocusSelection()); InputActions.Add(options => options.Rename, Rename); } - + /// - /// Enables or disables vertical and horizontal scrolling on the scene tree panel + /// Enables or disables vertical and horizontal scrolling on the scene tree panel. /// /// The state to set scrolling to public void ScrollingOnSceneTreeView(bool enabled) From f528ba59ec6a30cdbf359ae635b1ed16617c850b Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 12 Oct 2022 19:04:22 +0200 Subject: [PATCH 41/51] Code style fix #766 --- .../Editor/Windows/Assets/SkeletonMaskWindow.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs b/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs index a5e3da327..301ccf9b4 100644 --- a/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs +++ b/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs @@ -167,23 +167,19 @@ namespace FlaxEditor.Windows.Assets var proxy = (PropertiesProxy)Values[0]; int nodeIndex = (int)checkBox.Tag; proxy.NodesMask[nodeIndex] = checkBox.Checked; - if(Input.GetKey(KeyboardKeys.Shift)) + if (Input.GetKey(KeyboardKeys.Shift)) SetTreeChecked(checkBox.Parent as TreeNode, checkBox.Checked); proxy.Window.MarkAsEdited(); } private void SetTreeChecked(TreeNode tree, bool state) { - foreach(var node in tree.Children) + foreach (var node in tree.Children) { - if(node is TreeNode) - { - SetTreeChecked(node as TreeNode, state); - } - if(node is CheckBox) - { - (node as CheckBox).Checked = state; - } + if (node is TreeNode treeNode) + SetTreeChecked(treeNode, state); + else if (node is CheckBox checkBox) + checkBox.Checked = state; } } } From 7a969b5d7b4907b1a97dd83af5c8f811d62a8371 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 12 Oct 2022 19:07:48 +0200 Subject: [PATCH 42/51] Code style fix #760 --- Source/Engine/Level/Actors/Camera.cpp | 13 ++++--------- Source/Engine/Level/Actors/Camera.h | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Source/Engine/Level/Actors/Camera.cpp b/Source/Engine/Level/Actors/Camera.cpp index 81c0851a9..142baa745 100644 --- a/Source/Engine/Level/Actors/Camera.cpp +++ b/Source/Engine/Level/Actors/Camera.cpp @@ -125,23 +125,18 @@ bool Camera::IsPointOnView(const Vector3& worldSpaceLocation) const Vector3 cameraUp = GetTransform().GetUp(); Vector3 cameraForward = GetTransform().GetForward(); Vector3 directionToPosition = (worldSpaceLocation - GetPosition()).GetNormalized(); - if (Vector3::Dot(cameraForward, directionToPosition) < 0) - { return false; - } Quaternion lookAt = Quaternion::LookRotation(directionToPosition, cameraUp); Vector3 lookAtDirection = lookAt * Vector3::Forward; Vector3 newWorldLocation = GetPosition() + lookAtDirection; - Float2 windowSpace = Float2(); - Float2 screenSize = GetViewport().Size; + Float2 windowSpace; + const Viewport viewport = GetViewport(); + ProjectPoint(newWorldLocation, windowSpace, viewport); - ProjectPoint(newWorldLocation, windowSpace); - - return (windowSpace.X >= 0 && windowSpace.X <= screenSize.X) && - (windowSpace.Y >= 0 && windowSpace.Y <= screenSize.Y); + return windowSpace.X >= 0 && windowSpace.X <= viewport.Size.X && windowSpace.Y >= 0 && windowSpace.Y <= viewport.Size.Y; } Ray Camera::ConvertMouseToRay(const Float2& mousePosition) const diff --git a/Source/Engine/Level/Actors/Camera.h b/Source/Engine/Level/Actors/Camera.h index bc412542e..465130110 100644 --- a/Source/Engine/Level/Actors/Camera.h +++ b/Source/Engine/Level/Actors/Camera.h @@ -171,8 +171,8 @@ public: /// /// Checks if the 3d point of the world is in the camera's field of view. /// - /// World Position (XYZ) - /// Returns true if the point is within the field of view + /// World Position (XYZ). + /// Returns true if the point is within the field of view. API_FUNCTION() bool IsPointOnView(const Vector3& worldSpaceLocation) const; /// From 607afeee5009140fd30f7222fc6ca77c1cfb8672 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 12 Oct 2022 20:38:59 +0200 Subject: [PATCH 43/51] Add proper deserialization of old values pre-renaming #767 --- Source/Engine/Core/Config/GraphicsSettings.h | 15 +++++++++++++++ Source/Engine/Platform/SettingsBase.cs | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Core/Config/GraphicsSettings.h b/Source/Engine/Core/Config/GraphicsSettings.h index 5cb2c923c..8099e8437 100644 --- a/Source/Engine/Core/Config/GraphicsSettings.h +++ b/Source/Engine/Core/Config/GraphicsSettings.h @@ -119,6 +119,21 @@ public: API_FIELD(Attributes="EditorOrder(10000), EditorDisplay(\"Post Process Settings\", EditorDisplayAttribute.InlineStyle)") PostProcessSettings PostProcessSettings; +private: + /// + /// Renamed UeeHDRProbes into UseHDRProbes + /// [Deprecated on 12.10.2022, expires on 12.10.2024] + /// + API_PROPERTY(Attributes="Serialize, Obsolete, NoUndo") bool GetUeeHDRProbes() const + { + return UseHDRProbes; + } + + API_PROPERTY(Attributes="Serialize, Obsolete, NoUndo") void SetUeeHDRProbes(bool value) + { + UseHDRProbes = value; + } + public: /// /// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use. diff --git a/Source/Engine/Platform/SettingsBase.cs b/Source/Engine/Platform/SettingsBase.cs index 505195819..ab25592a5 100644 --- a/Source/Engine/Platform/SettingsBase.cs +++ b/Source/Engine/Platform/SettingsBase.cs @@ -1,5 +1,8 @@ // Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. +using System; +using FlaxEngine; + namespace FlaxEditor.Content.Settings { /// @@ -11,13 +14,24 @@ namespace FlaxEditor.Content.Settings partial class GraphicsSettings { + /// + /// Renamed UeeHDRProbes into UseHDRProbes + /// [Deprecated on 12.10.2022, expires on 12.10.2024] + /// + [Serialize, Obsolete, NoUndo] + private bool UeeHDRProbes + { + get => UseHDRProbes; + set => UseHDRProbes = value; + } + /// /// Initializes a new instance of the . /// public GraphicsSettings() { // Initialize PostFx settings with default options (C# structs don't support it) - PostProcessSettings = FlaxEngine.PostProcessSettings.Default; + PostProcessSettings = PostProcessSettings.Default; } } } From 3c9d9cd8d6d64a9717e02ddc285fc21839cf1d58 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 12 Oct 2022 20:39:40 +0200 Subject: [PATCH 44/51] Add support for deserialization of deprecated properties in scripting types --- .../Bindings/BindingsGenerator.CSharp.cs | 4 +--- .../Bindings/BindingsGenerator.Cpp.cs | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs index eaafcc615..ac22fb16a 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs @@ -919,10 +919,8 @@ namespace Flax.Build.Bindings // Properties foreach (var propertyInfo in classInfo.Properties) { - if (propertyInfo.IsHidden) + if (propertyInfo.IsHidden || !useUnmanaged) continue; - if (!useUnmanaged) - throw new NotImplementedException("TODO: support properties inside non-static and non-scripting API class types."); contents.AppendLine(); GenerateCSharpComment(contents, indent, propertyInfo.Comment, true); diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs index dc5190f36..921043e1d 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs @@ -1440,6 +1440,11 @@ namespace Flax.Build.Bindings continue; if (GenerateCppAutoSerializationSkip(buildData, typeInfo, propertyInfo, propertyInfo.Type)) continue; + CppAutoSerializeProperties.Add(propertyInfo); + + // Skip writing deprecated properties (read-only deserialization to allow reading old data) + if (propertyInfo.HasAttribute("Obsolete")) + continue; contents.Append(" {"); contents.Append(" const auto"); @@ -1456,7 +1461,6 @@ namespace Flax.Build.Bindings contents.Append($"stream.JKEY(\"{propertyInfo.Name}\"); Serialization::Serialize(stream, value, nullptr);"); contents.Append(" }"); contents.Append('}').AppendLine(); - CppAutoSerializeProperties.Add(propertyInfo); } } else if (structureInfo != null) @@ -1488,14 +1492,14 @@ namespace Flax.Build.Bindings foreach (var propertyInfo in CppAutoSerializeProperties) { - contents.Append(" {"); - contents.Append($" const auto e = SERIALIZE_FIND_MEMBER(stream, \"{propertyInfo.Name}\");"); - contents.Append(" if (e != stream.MemberEnd()) {"); - contents.Append($" auto p = {propertyInfo.Getter.Name}();"); - contents.Append(" Serialization::Deserialize(e->value, p, modifier);"); - contents.Append($" {propertyInfo.Setter.Name}(p);"); - contents.Append(" }"); - contents.Append('}').AppendLine(); + contents.AppendLine(" {"); + contents.AppendLine($" const auto e = SERIALIZE_FIND_MEMBER(stream, \"{propertyInfo.Name}\");"); + contents.AppendLine(" if (e != stream.MemberEnd()) {"); + contents.AppendLine($" auto p = {propertyInfo.Getter.Name}();"); + contents.AppendLine(" Serialization::Deserialize(e->value, p, modifier);"); + contents.AppendLine($" {propertyInfo.Setter.Name}(p);"); + contents.AppendLine(" }"); + contents.AppendLine(" }"); } contents.Append('}').AppendLine(); From 7656c6981e74c524bedf304f761190b22befd088 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 01:09:31 -0300 Subject: [PATCH 45/51] added is flipping variables --- Source/Engine/Platform/Base/WindowBase.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Source/Engine/Platform/Base/WindowBase.h b/Source/Engine/Platform/Base/WindowBase.h index 9782f40bb..2b10fd27b 100644 --- a/Source/Engine/Platform/Base/WindowBase.h +++ b/Source/Engine/Platform/Base/WindowBase.h @@ -287,6 +287,8 @@ protected: bool _isUsingMouseOffset; Rectangle _mouseOffsetScreenSize; bool _isTrackingMouse; + bool _isHorizontalFlippingMouse; + bool _isVerticalFlippingMouse; bool _isClippingCursor; explicit WindowBase(const CreateWindowSettings& settings); @@ -680,6 +682,22 @@ public: return _isTrackingMouse; } + /// + /// todo : add doc + /// + API_PROPERTY() bool IsHorizontalFlippingMouse() const + { + return _isHorizontalFlippingMouse; + } + + /// + /// todo : add doc + /// + API_PROPERTY() bool IsVerticalFlippingMouse() const + { + return _isVerticalFlippingMouse; + } + /// /// Ends the mouse tracking. /// From ae04253ba46a5cd2db761172925e5fdbed3caa04 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 01:11:33 -0300 Subject: [PATCH 46/51] added is flipping mouse on windows platform --- Source/Engine/Platform/Windows/WindowsWindow.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Engine/Platform/Windows/WindowsWindow.cpp b/Source/Engine/Platform/Windows/WindowsWindow.cpp index 0cd6aab95..62bce0014 100644 --- a/Source/Engine/Platform/Windows/WindowsWindow.cpp +++ b/Source/Engine/Platform/Windows/WindowsWindow.cpp @@ -824,14 +824,14 @@ LRESULT WindowsWindow::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) const Float2 mousePos(static_cast(WINDOWS_GET_X_LPARAM(lParam)), static_cast(WINDOWS_GET_Y_LPARAM(lParam))); Float2 mousePosition = ClientToScreen(mousePos); Float2 newMousePosition = mousePosition; - if (mousePosition.X <= desktopLocation.X + 2) - newMousePosition.X = desktopSize.X - 2; - else if (mousePosition.X >= desktopSize.X - 1) - newMousePosition.X = desktopLocation.X + 2; - if (mousePosition.Y <= desktopLocation.Y + 2) - newMousePosition.Y = desktopSize.Y - 2; - else if (mousePosition.Y >= desktopSize.Y - 1) - newMousePosition.Y = desktopLocation.Y + 2; + if (_isHorizontalFlippingMouse = mousePosition.X <= desktopLocation.X + 2) + newMousePosition.X = desktopSize.X - 3; + else if (_isHorizontalFlippingMouse = mousePosition.X >= desktopSize.X - 1) + newMousePosition.X = desktopLocation.X + 3; + if (_isVerticalFlippingMouse = mousePosition.Y <= desktopLocation.Y + 2) + newMousePosition.Y = desktopSize.Y - 3; + else if (_isVerticalFlippingMouse = mousePosition.Y >= desktopSize.Y - 1) + newMousePosition.Y = desktopLocation.Y + 3; if (!Float2::NearEqual(mousePosition, newMousePosition)) { _trackingMouseOffset -= newMousePosition - mousePosition; From f22a71509b8f8fc433bd98759ce312795bfc209d Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 01:12:38 -0300 Subject: [PATCH 47/51] fix value box sliding --- Source/Editor/GUI/Input/ValueBox.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index b818c56d5..0d1cbd356 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -259,7 +259,7 @@ namespace FlaxEditor.GUI.Input /// public override void OnMouseMove(Float2 location) { - if (_isSliding) + if (_isSliding && !RootWindow.Window.IsHorizontalFlippingMouse) { // Update sliding var slideLocation = location + Root.TrackingMouseOffset; From 0e45f16b1998965e58a8b6f795a7b24fe0fbbf03 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 01:14:47 -0300 Subject: [PATCH 48/51] update timeline edge to use the mouse flipping info --- .../Editor/GUI/Timeline/GUI/TimelineEdge.cs | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs b/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs index 2d93fb79b..0a620b86b 100644 --- a/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs +++ b/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs @@ -71,27 +71,10 @@ namespace FlaxEditor.GUI.Timeline.GUI /// public override void OnMouseMove(Float2 location) { - if (_isMoving) + if (_isMoving && !_timeline.RootWindow.Window.IsHorizontalFlippingMouse) { - Float2 currWndCenter = _timeline.RootWindow.Window.ClientBounds.Center; - Float2 currMonitorSize = Platform.GetMonitorBounds(currWndCenter).Size; var moveLocation = Root.MousePosition; - var diffFromLastMoveLocation = Mathf.Max(_lastMouseLocation.X, moveLocation.X) - Mathf.Min(_lastMouseLocation.X, moveLocation.X); - var movePorcentOfXMonitorSize = diffFromLastMoveLocation * 100f / currMonitorSize.X; - - if (movePorcentOfXMonitorSize >= 90f) - { - if (_lastMouseLocation.X > moveLocation.X) - { - _flipScreenMoveDelta += currMonitorSize.X; - } - else - { - _flipScreenMoveDelta -= currMonitorSize.X; - } - } - - var moveLocationDelta = moveLocation - _startMoveLocation + _flipScreenMoveDelta; + var moveLocationDelta = moveLocation - _startMoveLocation + _timeline.Root.TrackingMouseOffset.X; var moveDelta = (int)(moveLocationDelta.X / (Timeline.UnitsPerSecond * _timeline.Zoom) * _timeline.FramesPerSecond); var durationFrames = _timeline.DurationFrames; From 84009baeb00432a4e70a770adf5f2002cf9c22bf Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 09:10:35 -0300 Subject: [PATCH 49/51] change vars name and add code doc --- Source/Engine/Platform/Base/WindowBase.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Platform/Base/WindowBase.h b/Source/Engine/Platform/Base/WindowBase.h index 2b10fd27b..ebeeb6b45 100644 --- a/Source/Engine/Platform/Base/WindowBase.h +++ b/Source/Engine/Platform/Base/WindowBase.h @@ -683,17 +683,17 @@ public: } /// - /// todo : add doc + /// Gets the value indicating if the mouse flipped to the other screen edge horizontally /// - API_PROPERTY() bool IsHorizontalFlippingMouse() const + API_PROPERTY() bool IsMouseFlippingHorizontally() const { return _isHorizontalFlippingMouse; } /// - /// todo : add doc + /// Gets the value indicating if the mouse flipped to the other screen edge vertically /// - API_PROPERTY() bool IsVerticalFlippingMouse() const + API_PROPERTY() bool IsMouseFlippingVertically() const { return _isVerticalFlippingMouse; } From 2c12fffdf6f42d28a9e7ce0d61df70f4a9606833 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 09:14:05 -0300 Subject: [PATCH 50/51] reset value when start/stop mouse tracking --- Source/Engine/Platform/Windows/WindowsWindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Engine/Platform/Windows/WindowsWindow.cpp b/Source/Engine/Platform/Windows/WindowsWindow.cpp index 62bce0014..da7692eeb 100644 --- a/Source/Engine/Platform/Windows/WindowsWindow.cpp +++ b/Source/Engine/Platform/Windows/WindowsWindow.cpp @@ -544,6 +544,8 @@ void WindowsWindow::StartTrackingMouse(bool useMouseScreenOffset) _isTrackingMouse = true; _trackingMouseOffset = Float2::Zero; _isUsingMouseOffset = useMouseScreenOffset; + _isHorizontalFlippingMouse = false; + _isVerticalFlippingMouse = false; int32 x = 0, y = 0, width = 0, height = 0; GetScreenInfo(x, y, width, height); @@ -558,6 +560,8 @@ void WindowsWindow::EndTrackingMouse() if (_isTrackingMouse) { _isTrackingMouse = false; + _isHorizontalFlippingMouse = false; + _isVerticalFlippingMouse = false; ReleaseCapture(); } From 527ba719f44ad9d829a6e9ab24f5eef1fce03bf6 Mon Sep 17 00:00:00 2001 From: Cristhofer Marques Date: Thu, 13 Oct 2022 09:15:04 -0300 Subject: [PATCH 51/51] update to the new variable names --- Source/Editor/GUI/Input/ValueBox.cs | 2 +- Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index 0d1cbd356..50cdd529c 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -259,7 +259,7 @@ namespace FlaxEditor.GUI.Input /// public override void OnMouseMove(Float2 location) { - if (_isSliding && !RootWindow.Window.IsHorizontalFlippingMouse) + if (_isSliding && !RootWindow.Window.IsMouseFlippingHorizontally) { // Update sliding var slideLocation = location + Root.TrackingMouseOffset; diff --git a/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs b/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs index 0a620b86b..b74b47c46 100644 --- a/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs +++ b/Source/Editor/GUI/Timeline/GUI/TimelineEdge.cs @@ -15,8 +15,6 @@ namespace FlaxEditor.GUI.Timeline.GUI private Timeline _timeline; private bool _isMoving; private Float2 _startMoveLocation; - private Float2 _lastMouseLocation; - private float _flipScreenMoveDelta; private int _startMoveDuration; private bool _isStart; private bool _canEdit; @@ -71,15 +69,13 @@ namespace FlaxEditor.GUI.Timeline.GUI /// public override void OnMouseMove(Float2 location) { - if (_isMoving && !_timeline.RootWindow.Window.IsHorizontalFlippingMouse) + if (_isMoving && !_timeline.RootWindow.Window.IsMouseFlippingHorizontally) { var moveLocation = Root.MousePosition; var moveLocationDelta = moveLocation - _startMoveLocation + _timeline.Root.TrackingMouseOffset.X; var moveDelta = (int)(moveLocationDelta.X / (Timeline.UnitsPerSecond * _timeline.Zoom) * _timeline.FramesPerSecond); var durationFrames = _timeline.DurationFrames; - - if (_isStart) { // TODO: editing timeline start frame? @@ -94,9 +90,6 @@ namespace FlaxEditor.GUI.Timeline.GUI { _timeline.MarkAsEdited(); } - - _lastMouseLocation = moveLocation; - } else { @@ -148,7 +141,6 @@ namespace FlaxEditor.GUI.Timeline.GUI _timeline.DurationFrames = duration; } _isMoving = false; - _flipScreenMoveDelta = 0; _timeline.MediaBackground.HScrollBar.Value = _timeline.MediaBackground.HScrollBar.Maximum; EndMouseCapture();