From 301bf41fab41e6ce5bea2ccd14b8d9d877965496 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Wed, 25 Sep 2024 17:38:29 +0300 Subject: [PATCH 01/19] Fix ARM64 compiler support detection with MSVC v140 toolset --- .../Platforms/Windows/WindowsPlatformBase.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatformBase.cs b/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatformBase.cs index ae6819859..215bb32e8 100644 --- a/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatformBase.cs +++ b/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatformBase.cs @@ -433,7 +433,12 @@ namespace Flax.Build.Platforms { case WindowsPlatformToolset.v140: { - if (hostArchitecture != TargetArchitecture.x86) + if (architecture == TargetArchitecture.ARM64) + { + Log.Verbose(string.Format("Unsupported {0} architecture for v140 toolset", hostArchitecture.ToString())); + return null; + } + else if (hostArchitecture == TargetArchitecture.x64) { string nativeCompilerPath = Path.Combine(vcToolChainDir, "bin", "amd64", "cl.exe"); if (File.Exists(nativeCompilerPath)) @@ -446,12 +451,17 @@ namespace Flax.Build.Platforms Log.Verbose(string.Format("No {0} host compiler toolchain found in {1} or {2}", hostArchitecture.ToString(), nativeCompilerPath, crossCompilerPath)); return null; } - else + else if (hostArchitecture == TargetArchitecture.x86) { string compilerPath = Path.Combine(vcToolChainDir, "bin", "cl.exe"); if (File.Exists(compilerPath)) return Path.GetDirectoryName(compilerPath); - Log.Verbose(string.Format("No {0} host compiler toolchain found in {1}", hostArchitecture.ToString())); + Log.Verbose(string.Format("No {0} host compiler toolchain found in {1}", hostArchitecture.ToString(), compilerPath)); + return null; + } + else + { + Log.Verbose(string.Format("Unsupported {0} host compiler for v140 toolset", hostArchitecture.ToString())); return null; } } From d580667b9738c77d5764e28e36a330d87f6535e4 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Wed, 25 Sep 2024 17:40:54 +0300 Subject: [PATCH 02/19] Prevent generating configurations for unsupported external projects --- Source/Tools/Flax.Build/Build/Builder.Projects.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Tools/Flax.Build/Build/Builder.Projects.cs b/Source/Tools/Flax.Build/Build/Builder.Projects.cs index 917cc9325..d0ab1dd8a 100644 --- a/Source/Tools/Flax.Build/Build/Builder.Projects.cs +++ b/Source/Tools/Flax.Build/Build/Builder.Projects.cs @@ -50,6 +50,9 @@ namespace Flax.Build var platform = Platform.BuildPlatform; var architecture = TargetArchitecture.AnyCPU; var architectureName = "AnyCPU"; + + if (!platform.CanBuildArchitecture(architecture)) + continue; var toolchain = platform.TryGetToolchain(architecture); var configuration = TargetConfiguration.Debug; From 19817e4ad61d2828c8da05b253df536caa210b3c Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 25 Sep 2024 20:26:28 +0200 Subject: [PATCH 03/19] Fix crash on find references in visject surface after grid snap has been added --- Source/Editor/Surface/SurfaceControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Surface/SurfaceControl.cs b/Source/Editor/Surface/SurfaceControl.cs index 29d7c1768..5b39c6dae 100644 --- a/Source/Editor/Surface/SurfaceControl.cs +++ b/Source/Editor/Surface/SurfaceControl.cs @@ -132,7 +132,7 @@ namespace FlaxEditor.Surface public virtual void OnSurfaceLoaded(SurfaceNodeActions action) { // Snap bounds (with ceil) when using grid snapping - if (Surface.GridSnappingEnabled) + if (Surface != null && Surface.GridSnappingEnabled) { var bounds = Bounds; bounds.Location = Surface.SnapToGrid(bounds.Location, false); From b70e65acb4bdbc2814593cc4f23bde26f0f6c9f1 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 25 Sep 2024 20:33:10 +0200 Subject: [PATCH 04/19] Fix error when adding new audio track to scene anim via drag & drop --- Source/Editor/GUI/Timeline/SceneAnimationTimeline.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Editor/GUI/Timeline/SceneAnimationTimeline.cs b/Source/Editor/GUI/Timeline/SceneAnimationTimeline.cs index 10c4474fa..ceac9931b 100644 --- a/Source/Editor/GUI/Timeline/SceneAnimationTimeline.cs +++ b/Source/Editor/GUI/Timeline/SceneAnimationTimeline.cs @@ -197,7 +197,7 @@ namespace FlaxEditor.GUI.Timeline continue; var track = (NestedSceneAnimationTrack)timeline.NewTrack(NestedSceneAnimationTrack.GetArchetype()); track.Asset = sceneAnimation; - track.TrackMedia.Duration = sceneAnimation.Duration; + track.TrackMedia.DurationFrames = (int)(sceneAnimation.Duration * timeline.FramesPerSecond); track.Rename(assetItem.ShortName); timeline.AddTrack(track); } @@ -208,7 +208,7 @@ namespace FlaxEditor.GUI.Timeline continue; var track = (AudioTrack)timeline.NewTrack(AudioTrack.GetArchetype()); track.Asset = audioClip; - track.TrackMedia.Duration = audioClip.Length; + track.TrackMedia.DurationFrames = (int)(audioClip.Length * timeline.FramesPerSecond); track.Rename(assetItem.ShortName); timeline.AddTrack(track); } From 6e91e26dfe8fe38da9c0c49de0054b76f0d1d418 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 27 Sep 2024 11:24:33 -0500 Subject: [PATCH 05/19] Fix issue with scroll bars not showing in item search panel when clear search button is clicked. --- Source/Editor/GUI/ItemsListContextMenu.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Editor/GUI/ItemsListContextMenu.cs b/Source/Editor/GUI/ItemsListContextMenu.cs index 4a1793982..23f493c65 100644 --- a/Source/Editor/GUI/ItemsListContextMenu.cs +++ b/Source/Editor/GUI/ItemsListContextMenu.cs @@ -223,7 +223,7 @@ namespace FlaxEditor.GUI } } - private readonly TextBox _searchBox; + private readonly SearchBox _searchBox; private readonly Panel _scrollPanel; private List _categoryPanels; private bool _waitingForInput; @@ -260,6 +260,7 @@ namespace FlaxEditor.GUI Width = Width - 3, }; _searchBox.TextChanged += OnSearchFilterChanged; + _searchBox.ClearSearchButton.Clicked += () => PerformLayout(); // Panel with scrollbar _scrollPanel = new Panel(ScrollBars.Vertical) From 8080c21760e1f4aeba36efbaddd0436d49ec263a Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 27 Sep 2024 11:31:59 -0500 Subject: [PATCH 06/19] Fix `HasBorder` and `BorderThickness` for RichTextBox --- Source/Engine/UI/GUI/Common/RichTextBoxBase.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs index 985ee193b..df5582cc3 100644 --- a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs @@ -233,7 +233,8 @@ namespace FlaxEngine.GUI if (IsMouseOver || IsNavFocused) backColor = BackgroundSelectedColor; Render2D.FillRectangle(rect, backColor); - Render2D.DrawRectangle(rect, IsFocused ? BorderSelectedColor : BorderColor); + if (HasBorder) + Render2D.DrawRectangle(rect, IsFocused ? BorderSelectedColor : BorderColor, BorderThickness); // Apply view offset and clip mask if (ClipText) From 6b2380c5fab5504057522e43cc77e4520c728361 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Sat, 28 Sep 2024 15:20:44 -0500 Subject: [PATCH 07/19] Add audio debug sphere for video player if spatial audio is used. --- Source/Engine/Video/VideoPlayer.cpp | 12 ++++++++++++ Source/Engine/Video/VideoPlayer.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/Source/Engine/Video/VideoPlayer.cpp b/Source/Engine/Video/VideoPlayer.cpp index 5bdcad7bf..80c0ed8ce 100644 --- a/Source/Engine/Video/VideoPlayer.cpp +++ b/Source/Engine/Video/VideoPlayer.cpp @@ -152,6 +152,18 @@ int32 VideoPlayer::GetFramesCount() const return _player.FramesCount; } +#if USE_EDITOR +#include "Engine/Debug/DebugDraw.h" + +void VideoPlayer::OnDebugDrawSelected() +{ + // Draw influence range + if (_isSpatial) + DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(_transform.Translation, _minDistance), Color::CornflowerBlue, 0, true); + Actor::OnDebugDrawSelected(); +} +#endif + bool VideoPlayer::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) { return false; diff --git a/Source/Engine/Video/VideoPlayer.h b/Source/Engine/Video/VideoPlayer.h index 87f75327b..02e751ac9 100644 --- a/Source/Engine/Video/VideoPlayer.h +++ b/Source/Engine/Video/VideoPlayer.h @@ -221,6 +221,8 @@ public: const Vector3 size(50); return BoundingBox(_transform.Translation - size, _transform.Translation + size); } + + void OnDebugDrawSelected() override; #endif bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override; From 60155146804921cef8cbf0e8d782d42a861aa1d6 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Sun, 29 Sep 2024 12:38:55 +0800 Subject: [PATCH 08/19] Fixed NetworkLagDriver having wrong ChannelType and Length --- .../Networking/Drivers/NetworkLagDriver.cpp | 21 ++++++++++++------- .../Networking/Drivers/NetworkLagDriver.h | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Source/Engine/Networking/Drivers/NetworkLagDriver.cpp b/Source/Engine/Networking/Drivers/NetworkLagDriver.cpp index 35d1ac5d4..81c02c6f4 100644 --- a/Source/Engine/Networking/Drivers/NetworkLagDriver.cpp +++ b/Source/Engine/Networking/Drivers/NetworkLagDriver.cpp @@ -132,9 +132,10 @@ void NetworkLagDriver::SendMessage(const NetworkChannelType channelType, const N auto& msg = _messages.AddOne(); msg.Lag = (double)Lag; + msg.ChannelType = channelType; msg.Type = 0; - msg.Message = message; msg.MessageData.Set(message.Buffer, message.Length); + msg.MessageLength = message.Length; } void NetworkLagDriver::SendMessage(NetworkChannelType channelType, const NetworkMessage& message, NetworkConnection target) @@ -147,10 +148,11 @@ void NetworkLagDriver::SendMessage(NetworkChannelType channelType, const Network auto& msg = _messages.AddOne(); msg.Lag = (double)Lag; + msg.ChannelType = channelType; msg.Type = 1; - msg.Message = message; msg.Target = target; msg.MessageData.Set(message.Buffer, message.Length); + msg.MessageLength = message.Length; } void NetworkLagDriver::SendMessage(const NetworkChannelType channelType, const NetworkMessage& message, const Array& targets) @@ -163,10 +165,11 @@ void NetworkLagDriver::SendMessage(const NetworkChannelType channelType, const N auto& msg = _messages.AddOne(); msg.Lag = (double)Lag; + msg.ChannelType = channelType; msg.Type = 2; - msg.Message = message; msg.Targets = targets; msg.MessageData.Set(message.Buffer, message.Length); + msg.MessageLength = message.Length; } NetworkDriverStats NetworkLagDriver::GetStats() @@ -197,19 +200,21 @@ void NetworkLagDriver::OnUpdate() if (msg.Lag > 0.0) continue; - // Fix message to point to the current buffer - msg.Message.Buffer = msg.MessageData.Get(); + // Use this helper message as a container to send the stored data and length to the ENet driver + NetworkMessage message; + message.Buffer = msg.MessageData.Get(); + message.Length = msg.MessageLength; switch (msg.Type) { case 0: - _driver->SendMessage(msg.ChannelType, msg.Message); + _driver->SendMessage(msg.ChannelType, message); break; case 1: - _driver->SendMessage(msg.ChannelType, msg.Message, msg.Target); + _driver->SendMessage(msg.ChannelType, message, msg.Target); break; case 2: - _driver->SendMessage(msg.ChannelType, msg.Message, msg.Targets); + _driver->SendMessage(msg.ChannelType, message, msg.Targets); break; } _messages.RemoveAt(i); diff --git a/Source/Engine/Networking/Drivers/NetworkLagDriver.h b/Source/Engine/Networking/Drivers/NetworkLagDriver.h index 1fd1a455a..36a89fcbb 100644 --- a/Source/Engine/Networking/Drivers/NetworkLagDriver.h +++ b/Source/Engine/Networking/Drivers/NetworkLagDriver.h @@ -22,10 +22,10 @@ private: double Lag; int32 Type; NetworkChannelType ChannelType; - NetworkMessage Message; NetworkConnection Target; Array Targets; Array MessageData; // TODO: use message buffers cache (of size config.MessageSize) to reduce dynamic memory allocations + uint32 MessageLength; }; struct LagEvent From 5f19538455d3afe74b8976a1ff8ba1a3c37d0553 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 29 Sep 2024 22:03:46 +0200 Subject: [PATCH 09/19] Add `UpdateFlags` to `ISceneRenderingListener::UpdateActor` for more contextual control overdirtying actors state in renderer data Fixes issue of static shadow maps not refreshing when changing static flags of the model. --- Source/Engine/Foliage/Foliage.cpp | 6 +++--- Source/Engine/Level/Actors/AnimatedModel.cpp | 2 +- Source/Engine/Level/Actors/Decal.cpp | 2 +- Source/Engine/Level/Actors/EnvironmentProbe.cpp | 4 ++-- Source/Engine/Level/Actors/ModelInstanceActor.cpp | 14 ++++++++++---- Source/Engine/Level/Actors/ModelInstanceActor.h | 1 + Source/Engine/Level/Actors/PointLight.cpp | 4 ++-- Source/Engine/Level/Actors/SkyLight.cpp | 2 +- Source/Engine/Level/Actors/SpotLight.cpp | 2 +- Source/Engine/Level/Actors/StaticModel.cpp | 2 +- Source/Engine/Level/Scene/SceneRendering.cpp | 10 ++++++---- Source/Engine/Level/Scene/SceneRendering.h | 14 ++++++++++++-- Source/Engine/Particles/ParticleEffect.cpp | 2 +- .../Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp | 2 +- .../Renderer/GlobalSignDistanceFieldPass.cpp | 2 +- Source/Engine/Renderer/ShadowsPass.cpp | 6 +++++- Source/Engine/Terrain/Terrain.cpp | 4 ++-- Source/Engine/UI/SpriteRender.cpp | 2 +- Source/Engine/UI/TextRender.cpp | 2 +- 19 files changed, 53 insertions(+), 30 deletions(-) diff --git a/Source/Engine/Foliage/Foliage.cpp b/Source/Engine/Foliage/Foliage.cpp index 09a5b9108..8c0b337ae 100644 --- a/Source/Engine/Foliage/Foliage.cpp +++ b/Source/Engine/Foliage/Foliage.cpp @@ -775,7 +775,7 @@ void Foliage::OnFoliageTypeModelLoaded(int32 index) } BoundingSphere::FromBox(_box, _sphere); if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds); } { PROFILE_CPU_NAMED("Create Clusters"); @@ -912,7 +912,7 @@ void Foliage::RebuildClusters() _box = totalBounds; BoundingSphere::FromBox(_box, _sphere); if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds); } // Insert all instances to the clusters @@ -1441,7 +1441,7 @@ void Foliage::Deserialize(DeserializeStream& stream, ISerializeModifier* modifie void Foliage::OnLayerChanged() { if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Layer); } void Foliage::OnEnable() diff --git a/Source/Engine/Level/Actors/AnimatedModel.cpp b/Source/Engine/Level/Actors/AnimatedModel.cpp index a13085651..b09b76394 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.cpp +++ b/Source/Engine/Level/Actors/AnimatedModel.cpp @@ -758,7 +758,7 @@ void AnimatedModel::UpdateBounds() } BoundingSphere::FromBox(_box, _sphere); if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds); } void AnimatedModel::UpdateSockets() diff --git a/Source/Engine/Level/Actors/Decal.cpp b/Source/Engine/Level/Actors/Decal.cpp index dbec91b57..2e42fb6a9 100644 --- a/Source/Engine/Level/Actors/Decal.cpp +++ b/Source/Engine/Level/Actors/Decal.cpp @@ -64,7 +64,7 @@ BoundingBox Decal::GetEditorBox() const void Decal::OnLayerChanged() { if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Layer); } void Decal::Draw(RenderContext& renderContext) diff --git a/Source/Engine/Level/Actors/EnvironmentProbe.cpp b/Source/Engine/Level/Actors/EnvironmentProbe.cpp index ada74d410..8d7155dee 100644 --- a/Source/Engine/Level/Actors/EnvironmentProbe.cpp +++ b/Source/Engine/Level/Actors/EnvironmentProbe.cpp @@ -166,7 +166,7 @@ void EnvironmentProbe::UpdateBounds() _sphere = BoundingSphere(GetPosition(), GetScaledRadius()); BoundingBox::FromSphere(_sphere, _box); if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds); } void EnvironmentProbe::Draw(RenderContext& renderContext) @@ -220,7 +220,7 @@ void EnvironmentProbe::OnDebugDrawSelected() void EnvironmentProbe::OnLayerChanged() { if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Layer); } void EnvironmentProbe::Serialize(SerializeStream& stream, const void* otherObj) diff --git a/Source/Engine/Level/Actors/ModelInstanceActor.cpp b/Source/Engine/Level/Actors/ModelInstanceActor.cpp index 054e07b15..6021daadc 100644 --- a/Source/Engine/Level/Actors/ModelInstanceActor.cpp +++ b/Source/Engine/Level/Actors/ModelInstanceActor.cpp @@ -20,7 +20,7 @@ void ModelInstanceActor::SetEntries(const Array& value) Entries[i] = value[i]; } if (anyChanged && _sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Visual); } void ModelInstanceActor::SetMaterial(int32 entryIndex, MaterialBase* material) @@ -33,7 +33,7 @@ void ModelInstanceActor::SetMaterial(int32 entryIndex, MaterialBase* material) return; Entries[entryIndex].Material = material; if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Visual); } MaterialInstance* ModelInstanceActor::CreateAndSetVirtualMaterialInstance(int32 entryIndex) @@ -44,7 +44,7 @@ MaterialInstance* ModelInstanceActor::CreateAndSetVirtualMaterialInstance(int32 MaterialInstance* result = material->CreateVirtualInstance(); Entries[entryIndex].Material = result; if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Visual); return result; } @@ -55,7 +55,13 @@ void ModelInstanceActor::WaitForModelLoad() void ModelInstanceActor::OnLayerChanged() { if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Layer); +} + +void ModelInstanceActor::OnStaticFlagsChanged() +{ + if (_sceneRenderingKey != -1) + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::StaticFlags); } void ModelInstanceActor::OnTransformChanged() diff --git a/Source/Engine/Level/Actors/ModelInstanceActor.h b/Source/Engine/Level/Actors/ModelInstanceActor.h index c7cf2001b..f3c6cd5e1 100644 --- a/Source/Engine/Level/Actors/ModelInstanceActor.h +++ b/Source/Engine/Level/Actors/ModelInstanceActor.h @@ -142,6 +142,7 @@ protected: public: // [Actor] void OnLayerChanged() override; + void OnStaticFlagsChanged() override; void OnTransformChanged() override; protected: diff --git a/Source/Engine/Level/Actors/PointLight.cpp b/Source/Engine/Level/Actors/PointLight.cpp index fbe3fd9e6..6d26df2d9 100644 --- a/Source/Engine/Level/Actors/PointLight.cpp +++ b/Source/Engine/Level/Actors/PointLight.cpp @@ -67,7 +67,7 @@ void PointLight::UpdateBounds() BoundingBox::FromSphere(_sphere, _box); if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds); } void PointLight::OnTransformChanged() @@ -163,7 +163,7 @@ void PointLight::DrawLightsDebug(RenderView& view) void PointLight::OnLayerChanged() { if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Layer); } void PointLight::Serialize(SerializeStream& stream, const void* otherObj) diff --git a/Source/Engine/Level/Actors/SkyLight.cpp b/Source/Engine/Level/Actors/SkyLight.cpp index 19152a557..88f083a4c 100644 --- a/Source/Engine/Level/Actors/SkyLight.cpp +++ b/Source/Engine/Level/Actors/SkyLight.cpp @@ -101,7 +101,7 @@ void SkyLight::UpdateBounds() _sphere = BoundingSphere(GetPosition(), GetScaledRadius()); BoundingBox::FromSphere(_sphere, _box); if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds); } void SkyLight::Draw(RenderContext& renderContext) diff --git a/Source/Engine/Level/Actors/SpotLight.cpp b/Source/Engine/Level/Actors/SpotLight.cpp index 9494c14fa..54846e156 100644 --- a/Source/Engine/Level/Actors/SpotLight.cpp +++ b/Source/Engine/Level/Actors/SpotLight.cpp @@ -115,7 +115,7 @@ void SpotLight::UpdateBounds() BoundingBox::FromSphere(_sphere, _box); if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds); } void SpotLight::OnTransformChanged() diff --git a/Source/Engine/Level/Actors/StaticModel.cpp b/Source/Engine/Level/Actors/StaticModel.cpp index 81f30df0c..3840ab5ce 100644 --- a/Source/Engine/Level/Actors/StaticModel.cpp +++ b/Source/Engine/Level/Actors/StaticModel.cpp @@ -283,7 +283,7 @@ void StaticModel::UpdateBounds() } BoundingSphere::FromBox(_box, _sphere); if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds); } void StaticModel::FlushVertexColors() diff --git a/Source/Engine/Level/Scene/SceneRendering.cpp b/Source/Engine/Level/Scene/SceneRendering.cpp index 69d8edf4c..3dbbd113f 100644 --- a/Source/Engine/Level/Scene/SceneRendering.cpp +++ b/Source/Engine/Level/Scene/SceneRendering.cpp @@ -162,7 +162,7 @@ void SceneRendering::AddActor(Actor* a, int32& key) listener->OnSceneRenderingAddActor(a); } -void SceneRendering::UpdateActor(Actor* a, int32& key) +void SceneRendering::UpdateActor(Actor* a, int32& key, ISceneRenderingListener::UpdateFlags flags) { const int32 category = a->_drawCategory; ScopeLock lock(Locker); @@ -173,9 +173,11 @@ void SceneRendering::UpdateActor(Actor* a, int32& key) if (e.Actor == a) { for (auto* listener : _listeners) - listener->OnSceneRenderingUpdateActor(a, e.Bounds); - e.LayerMask = a->GetLayerMask(); - e.Bounds = a->GetSphere(); + listener->OnSceneRenderingUpdateActor(a, e.Bounds, flags); + if (flags & ISceneRenderingListener::Layer) + e.LayerMask = a->GetLayerMask(); + if (flags & ISceneRenderingListener::Bounds) + e.Bounds = a->GetSphere(); } } diff --git a/Source/Engine/Level/Scene/SceneRendering.h b/Source/Engine/Level/Scene/SceneRendering.h index 45c8d51cd..88716d9e8 100644 --- a/Source/Engine/Level/Scene/SceneRendering.h +++ b/Source/Engine/Level/Scene/SceneRendering.h @@ -48,12 +48,22 @@ private: public: ~ISceneRenderingListener(); + // Actor properties that were modified. + enum UpdateFlags + { + Visual = 1, + Bounds = 2, + Layer = 4, + StaticFlags = 8, + Auto = Visual | Bounds | Layer, + }; + // Starts listening to the scene rendering events. void ListenSceneRendering(SceneRendering* scene); // Events called by Scene Rendering virtual void OnSceneRenderingAddActor(Actor* a) = 0; - virtual void OnSceneRenderingUpdateActor(Actor* a, const BoundingSphere& prevBounds) = 0; + virtual void OnSceneRenderingUpdateActor(Actor* a, const BoundingSphere& prevBounds, UpdateFlags flags = Auto) = 0; virtual void OnSceneRenderingRemoveActor(Actor* a) = 0; virtual void OnSceneRenderingClear(SceneRendering* scene) = 0; }; @@ -125,7 +135,7 @@ public: public: void AddActor(Actor* a, int32& key); - void UpdateActor(Actor* a, int32& key); + void UpdateActor(Actor* a, int32& key, ISceneRenderingListener::UpdateFlags flags = ISceneRenderingListener::Auto); void RemoveActor(Actor* a, int32& key); FORCE_INLINE void AddPostFxProvider(IPostFxSettingsProvider* obj) diff --git a/Source/Engine/Particles/ParticleEffect.cpp b/Source/Engine/Particles/ParticleEffect.cpp index 92f5b94a0..f06a9b945 100644 --- a/Source/Engine/Particles/ParticleEffect.cpp +++ b/Source/Engine/Particles/ParticleEffect.cpp @@ -589,7 +589,7 @@ void ParticleEffect::OnDebugDrawSelected() void ParticleEffect::OnLayerChanged() { if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Layer); } void ParticleEffect::Serialize(SerializeStream& stream, const void* otherObj) diff --git a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp index c4a39820b..be5992bde 100644 --- a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp +++ b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp @@ -499,7 +499,7 @@ public: { } - void OnSceneRenderingUpdateActor(Actor* a, const BoundingSphere& prevBounds) override + void OnSceneRenderingUpdateActor(Actor* a, const BoundingSphere& prevBounds, UpdateFlags flags) override { // Dirty static objects to redraw when changed (eg. material modification) if (a->HasStaticFlag(StaticFlags::Lightmap)) diff --git a/Source/Engine/Renderer/GlobalSignDistanceFieldPass.cpp b/Source/Engine/Renderer/GlobalSignDistanceFieldPass.cpp index 173604069..017146f8b 100644 --- a/Source/Engine/Renderer/GlobalSignDistanceFieldPass.cpp +++ b/Source/Engine/Renderer/GlobalSignDistanceFieldPass.cpp @@ -399,7 +399,7 @@ public: } } - void OnSceneRenderingUpdateActor(Actor* a, const BoundingSphere& prevBounds) override + void OnSceneRenderingUpdateActor(Actor* a, const BoundingSphere& prevBounds, UpdateFlags flags) override { if (GLOBAL_SDF_ACTOR_IS_STATIC(a) && ObjectTypes.Contains(a->GetTypeHandle())) { diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp index a8cf19542..b30005b51 100644 --- a/Source/Engine/Renderer/ShadowsPass.cpp +++ b/Source/Engine/Renderer/ShadowsPass.cpp @@ -392,7 +392,7 @@ public: DirtyStaticBounds(a->GetSphere()); } - void OnSceneRenderingUpdateActor(Actor* a, const BoundingSphere& prevBounds) override + void OnSceneRenderingUpdateActor(Actor* a, const BoundingSphere& prevBounds, UpdateFlags flags) override { // Dirty static objects to redraw when changed (eg. material modification) if (a->HasStaticFlag(StaticFlags::Shadow)) @@ -400,6 +400,10 @@ public: DirtyStaticBounds(prevBounds); DirtyStaticBounds(a->GetSphere()); } + else if (flags & StaticFlags) + { + DirtyStaticBounds(a->GetSphere()); + } } void OnSceneRenderingRemoveActor(Actor* a) override diff --git a/Source/Engine/Terrain/Terrain.cpp b/Source/Engine/Terrain/Terrain.cpp index 10c137d33..204a78359 100644 --- a/Source/Engine/Terrain/Terrain.cpp +++ b/Source/Engine/Terrain/Terrain.cpp @@ -52,7 +52,7 @@ void Terrain::UpdateBounds() } BoundingSphere::FromBox(_box, _sphere); if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds); } void Terrain::CacheNeighbors() @@ -905,7 +905,7 @@ void Terrain::OnLayerChanged() UpdateLayerBits(); if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Layer); } void Terrain::OnActiveInTreeChanged() diff --git a/Source/Engine/UI/SpriteRender.cpp b/Source/Engine/UI/SpriteRender.cpp index 4f28551b7..f0ddaaf60 100644 --- a/Source/Engine/UI/SpriteRender.cpp +++ b/Source/Engine/UI/SpriteRender.cpp @@ -186,7 +186,7 @@ void SpriteRender::Deserialize(DeserializeStream& stream, ISerializeModifier* mo void SpriteRender::OnLayerChanged() { if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Layer); } void SpriteRender::OnEndPlay() diff --git a/Source/Engine/UI/TextRender.cpp b/Source/Engine/UI/TextRender.cpp index 5a18d915c..05c6cdf73 100644 --- a/Source/Engine/UI/TextRender.cpp +++ b/Source/Engine/UI/TextRender.cpp @@ -415,7 +415,7 @@ void TextRender::OnDebugDrawSelected() void TextRender::OnLayerChanged() { if (_sceneRenderingKey != -1) - GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); + GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Layer); } bool TextRender::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) From 5f7075d2f7559e60605a6f4e11095ba198e71e01 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 29 Sep 2024 22:08:31 +0200 Subject: [PATCH 10/19] Add `NetworkReplicationNode::SetObject` to customize object replication settings at runtime --- .../Engine/Networking/NetworkReplicationHierarchy.cpp | 11 +++++++++++ .../Engine/Networking/NetworkReplicationHierarchy.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/Source/Engine/Networking/NetworkReplicationHierarchy.cpp b/Source/Engine/Networking/NetworkReplicationHierarchy.cpp index 224ee9f31..b6772fc48 100644 --- a/Source/Engine/Networking/NetworkReplicationHierarchy.cpp +++ b/Source/Engine/Networking/NetworkReplicationHierarchy.cpp @@ -74,6 +74,17 @@ bool NetworkReplicationNode::GetObject(ScriptingObject* obj, NetworkReplicationH return false; } +bool NetworkReplicationNode::SetObject(const NetworkReplicationHierarchyObject& value) +{ + const int32 index = Objects.Find(value.Object); + if (index != -1) + { + Objects[index] = value; + return true; + } + return false; +} + bool NetworkReplicationNode::DirtyObject(ScriptingObject* obj) { const int32 index = Objects.Find(obj); diff --git a/Source/Engine/Networking/NetworkReplicationHierarchy.h b/Source/Engine/Networking/NetworkReplicationHierarchy.h index 78f9cad1f..a3196d67f 100644 --- a/Source/Engine/Networking/NetworkReplicationHierarchy.h +++ b/Source/Engine/Networking/NetworkReplicationHierarchy.h @@ -208,6 +208,13 @@ API_CLASS(Abstract, Namespace = "FlaxEngine.Networking") class FLAXENGINE_API Ne /// True on successful retrieval, otherwise false. API_FUNCTION() virtual bool GetObject(ScriptingObject* obj, NetworkReplicationHierarchyObject& result); + /// + /// Sets object properties in the hierarchy. Can be used to modify replication settings at runtime. + /// + /// The object data to update. + /// True on successful update, otherwise false (eg, if specific object has not been added to this node). + API_FUNCTION() virtual bool SetObject(const NetworkReplicationHierarchyObject& value); + /// /// Force replicates the object during the next update. Resets any internal tracking state to force the synchronization. /// From dd5b66386ac571513371d92c46e87864222b7253 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 29 Sep 2024 22:25:44 +0200 Subject: [PATCH 11/19] Fix compilation regression from 5f7075d2f7559e60605a6f4e11095ba198e71e01 --- Source/Engine/Networking/NetworkReplicationHierarchy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Engine/Networking/NetworkReplicationHierarchy.cpp b/Source/Engine/Networking/NetworkReplicationHierarchy.cpp index b6772fc48..b41923442 100644 --- a/Source/Engine/Networking/NetworkReplicationHierarchy.cpp +++ b/Source/Engine/Networking/NetworkReplicationHierarchy.cpp @@ -76,7 +76,7 @@ bool NetworkReplicationNode::GetObject(ScriptingObject* obj, NetworkReplicationH bool NetworkReplicationNode::SetObject(const NetworkReplicationHierarchyObject& value) { - const int32 index = Objects.Find(value.Object); + const int32 index = Objects.Find(value.Object.Get()); if (index != -1) { Objects[index] = value; From c063afc5bc876f5740cb5cc00754787825b1ceae Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 30 Sep 2024 14:52:05 +0200 Subject: [PATCH 12/19] Fix GetObject/SetObject usage in network replication hierarchy --- .../Networking/NetworkReplicationHierarchy.cpp | 12 +++++++++--- .../Engine/Networking/NetworkReplicationHierarchy.h | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Networking/NetworkReplicationHierarchy.cpp b/Source/Engine/Networking/NetworkReplicationHierarchy.cpp index b41923442..765bb57b9 100644 --- a/Source/Engine/Networking/NetworkReplicationHierarchy.cpp +++ b/Source/Engine/Networking/NetworkReplicationHierarchy.cpp @@ -223,11 +223,17 @@ bool NetworkReplicationGridNode::GetObject(ScriptingObject* obj, NetworkReplicat { return false; } - if (_children[coord].Node->GetObject(obj, result)) + return _children[coord].Node->GetObject(obj, result); +} + +bool NetworkReplicationGridNode::SetObject(const NetworkReplicationHierarchyObject& value) +{ + Int3 coord; + if (!_objectToCell.TryGet(value.Object.Get(), coord)) { - return true; + return false; } - return false; + return _children[coord].Node->SetObject(value); } bool NetworkReplicationGridNode::DirtyObject(ScriptingObject* obj) diff --git a/Source/Engine/Networking/NetworkReplicationHierarchy.h b/Source/Engine/Networking/NetworkReplicationHierarchy.h index a3196d67f..b58602254 100644 --- a/Source/Engine/Networking/NetworkReplicationHierarchy.h +++ b/Source/Engine/Networking/NetworkReplicationHierarchy.h @@ -206,7 +206,7 @@ API_CLASS(Abstract, Namespace = "FlaxEngine.Networking") class FLAXENGINE_API Ne /// The object to get. /// The hierarchy object to retrieve. /// True on successful retrieval, otherwise false. - API_FUNCTION() virtual bool GetObject(ScriptingObject* obj, NetworkReplicationHierarchyObject& result); + API_FUNCTION() virtual bool GetObject(ScriptingObject* obj, API_PARAM(Out) NetworkReplicationHierarchyObject& result); /// /// Sets object properties in the hierarchy. Can be used to modify replication settings at runtime. @@ -264,6 +264,7 @@ public: void AddObject(NetworkReplicationHierarchyObject obj) override; bool RemoveObject(ScriptingObject* obj) override; bool GetObject(ScriptingObject* obj, NetworkReplicationHierarchyObject& result) override; + bool SetObject(const NetworkReplicationHierarchyObject& value) override; bool DirtyObject(ScriptingObject* obj) override; void Update(NetworkReplicationHierarchyUpdateResult* result) override; }; From bfa09e165a0b5318229f82a4de78a6a95852ae87 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 30 Sep 2024 23:15:16 +0200 Subject: [PATCH 13/19] Fix `BehaviorTreeMoveToNode` when goal location changes every frame by less than tolerance --- Source/Engine/AI/BehaviorTreeNodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Engine/AI/BehaviorTreeNodes.cpp b/Source/Engine/AI/BehaviorTreeNodes.cpp index 2833cf624..cf4b4d65a 100644 --- a/Source/Engine/AI/BehaviorTreeNodes.cpp +++ b/Source/Engine/AI/BehaviorTreeNodes.cpp @@ -444,7 +444,6 @@ BehaviorUpdateResult BehaviorTreeMoveToNode::Update(const BehaviorUpdateContext& else goalLocation = TargetLocation.Get(context.Knowledge); repath |= Vector3::Distance(goalLocation, state->GoalLocation) > TargetGoalUpdateTolerance; - state->GoalLocation = goalLocation; } if (repath) @@ -490,6 +489,7 @@ BehaviorUpdateResult BehaviorTreeMoveToNode::Update(const BehaviorUpdateContext& state->HasPath = true; state->TargetPathIndex = 1; state->Result = BehaviorUpdateResult::Running; + state->GoalLocation = goalLocation; // TODO: add path debugging in Editor (eg. via BT window) From d1d14daa1ea676b849f658e962a34703eb4b5b2c Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 1 Oct 2024 10:16:30 +0200 Subject: [PATCH 14/19] Improve timeline tracks renaming to use shared utility with proper incrementing --- Source/Editor/GUI/Timeline/Timeline.cs | 11 ++--------- Source/Editor/GUI/Timeline/Track.cs | 8 +++----- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Source/Editor/GUI/Timeline/Timeline.cs b/Source/Editor/GUI/Timeline/Timeline.cs index 81fe950b9..556c4dcdb 100644 --- a/Source/Editor/GUI/Timeline/Timeline.cs +++ b/Source/Editor/GUI/Timeline/Timeline.cs @@ -1288,10 +1288,7 @@ namespace FlaxEditor.GUI.Timeline public virtual void AddTrack(Track track, bool withUndo = true) { // Ensure name is unique - int idx = 1; - var name = track.Name; - while (!IsTrackNameValid(track.Name)) - track.Name = string.Format("{0} {1}", name, idx++); + track.Name = GetValidTrackName(track.Name); // Add it to the timeline _tracks.Add(track); @@ -1843,11 +1840,7 @@ namespace FlaxEditor.GUI.Timeline /// The track name. public string GetValidTrackName(string name) { - string newName = name; - int count = 0; - while (!IsTrackNameValid(newName)) - newName = string.Format("{0} {1}", name, count++); - return newName; + return Utilities.Utils.IncrementNameNumber(name, IsTrackNameValid); } /// diff --git a/Source/Editor/GUI/Timeline/Track.cs b/Source/Editor/GUI/Timeline/Track.cs index 929b213e4..ec2dd63d8 100644 --- a/Source/Editor/GUI/Timeline/Track.cs +++ b/Source/Editor/GUI/Timeline/Track.cs @@ -854,11 +854,9 @@ namespace FlaxEditor.GUI.Timeline /// The base name. public void Rename(string name) { - string newName = name; - int count = 0; - while (_timeline != null && !_timeline.IsTrackNameValid(newName)) - newName = string.Format("{0} {1}", name, count++); - OnRename(newName); + if (_timeline != null) + name = _timeline.GetValidTrackName(name); + OnRename(name); } /// From e9ac02d4160ece124b81a7f64271e7a0edbffd92 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 1 Oct 2024 11:06:13 +0200 Subject: [PATCH 15/19] Refactor toolstrip buttons tooltips to properly format empty input bindings --- Source/Editor/GUI/ToolStripButton.cs | 15 +++++++++++++ Source/Editor/Modules/UIModule.cs | 22 +++++++++---------- Source/Editor/Surface/SurfaceUtils.cs | 8 +++---- .../Editor/Windows/Assets/AnimationWindow.cs | 6 ++--- .../Windows/Assets/GameplayGlobalsWindow.cs | 6 ++--- .../Editor/Windows/Assets/JsonAssetWindow.cs | 6 ++--- .../Assets/LocalizedStringTableWindow.cs | 6 ++--- .../Windows/Assets/MaterialInstanceWindow.cs | 6 ++--- .../Editor/Windows/Assets/ModelBaseWindow.cs | 4 +++- .../Windows/Assets/ParticleSystemWindow.cs | 6 ++--- Source/Editor/Windows/Assets/PrefabWindow.cs | 12 +++++----- .../Windows/Assets/SceneAnimationWindow.cs | 6 ++--- .../Windows/Assets/SkeletonMaskWindow.cs | 4 +++- .../Windows/Assets/SpriteAtlasWindow.cs | 4 +++- Source/Editor/Windows/Assets/TextureWindow.cs | 16 ++++++++------ .../Windows/Assets/VisualScriptWindow.cs | 8 +++---- .../Windows/VisualScriptDebuggerWindow.cs | 2 +- 17 files changed, 80 insertions(+), 57 deletions(-) diff --git a/Source/Editor/GUI/ToolStripButton.cs b/Source/Editor/GUI/ToolStripButton.cs index a90a19321..c6cb5fa4a 100644 --- a/Source/Editor/GUI/ToolStripButton.cs +++ b/Source/Editor/GUI/ToolStripButton.cs @@ -107,6 +107,21 @@ namespace FlaxEditor.GUI return this; } + /// + /// Links the tooltip with input binding info. + /// + /// The text. + /// The input key binding. + /// This tooltip. + public ToolStripButton LinkTooltip(string text, ref Options.InputBinding inputBinding) + { + var input = inputBinding.ToString(); + if (input.Length != 0) + text = $"{text} ({input})"; + LinkTooltip(text); + return this; + } + /// public override void Draw() { diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index 4282d5305..6a197c62f 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -707,18 +707,18 @@ namespace FlaxEditor.Modules Parent = mainWindow, }; - _toolStripSaveAll = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Save64, Editor.SaveAll).LinkTooltip($"Save all ({inputOptions.Save})"); + _toolStripSaveAll = ToolStrip.AddButton(Editor.Icons.Save64, Editor.SaveAll).LinkTooltip("Save all", ref inputOptions.Save); ToolStrip.AddSeparator(); - _toolStripUndo = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Undo64, Editor.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})"); - _toolStripRedo = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Redo64, Editor.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})"); + _toolStripUndo = ToolStrip.AddButton(Editor.Icons.Undo64, Editor.PerformUndo).LinkTooltip("Undo", ref inputOptions.Undo); + _toolStripRedo = ToolStrip.AddButton(Editor.Icons.Redo64, Editor.PerformRedo).LinkTooltip("Redo", ref inputOptions.Redo); ToolStrip.AddSeparator(); - _toolStripTranslate = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Translate32, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Translate).LinkTooltip($"Change Gizmo tool mode to Translate ({inputOptions.TranslateMode})"); - _toolStripRotate = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Rotate32, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Rotate).LinkTooltip($"Change Gizmo tool mode to Rotate ({inputOptions.RotateMode})"); - _toolStripScale = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Scale32, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Scale).LinkTooltip($"Change Gizmo tool mode to Scale ({inputOptions.ScaleMode})"); + _toolStripTranslate = ToolStrip.AddButton(Editor.Icons.Translate32, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Translate).LinkTooltip("Change Gizmo tool mode to Translate", ref inputOptions.TranslateMode); + _toolStripRotate = ToolStrip.AddButton(Editor.Icons.Rotate32, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Rotate).LinkTooltip("Change Gizmo tool mode to Rotate", ref inputOptions.RotateMode); + _toolStripScale = ToolStrip.AddButton(Editor.Icons.Scale32, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Scale).LinkTooltip("Change Gizmo tool mode to Scale", ref inputOptions.ScaleMode); ToolStrip.AddSeparator(); // Play - _toolStripPlay = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Play64, Editor.Simulation.DelegatePlayOrStopPlayInEditor).LinkTooltip($"Play In Editor ({inputOptions.Play})"); + _toolStripPlay = ToolStrip.AddButton(Editor.Icons.Play64, Editor.Simulation.DelegatePlayOrStopPlayInEditor).LinkTooltip("Play In Editor", ref inputOptions.Play); _toolStripPlay.ContextMenu = new ContextMenu(); var playSubMenu = _toolStripPlay.ContextMenu.AddChildMenu("Play button action"); var playActionGroup = new ContextMenuSingleSelectGroup(); @@ -739,16 +739,16 @@ namespace FlaxEditor.Modules windowModesGroup.SelectedChanged = SetGameWindowMode; Editor.Options.OptionsChanged += options => { windowModesGroup.Selected = options.Interface.DefaultGameWindowMode; }; - _toolStripPause = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Pause64, Editor.Simulation.RequestResumeOrPause).LinkTooltip($"Pause/Resume game ({inputOptions.Pause})"); - _toolStripStep = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Skip64, Editor.Simulation.RequestPlayOneFrame).LinkTooltip($"Step one frame in game ({inputOptions.StepFrame})"); + _toolStripPause = ToolStrip.AddButton(Editor.Icons.Pause64, Editor.Simulation.RequestResumeOrPause).LinkTooltip("Pause/Resume game", ref inputOptions.Pause); + _toolStripStep = ToolStrip.AddButton(Editor.Icons.Skip64, Editor.Simulation.RequestPlayOneFrame).LinkTooltip("Step one frame in game", ref inputOptions.StepFrame); ToolStrip.AddSeparator(); // Build scenes - _toolStripBuildScenes = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Build64, Editor.BuildScenesOrCancel).LinkTooltip($"Build scenes data - CSG, navmesh, static lighting, env probes - configurable via Build Actions in editor options ({inputOptions.BuildScenesData})"); + _toolStripBuildScenes = ToolStrip.AddButton(Editor.Icons.Build64, Editor.BuildScenesOrCancel).LinkTooltip("Build scenes data - CSG, navmesh, static lighting, env probes - configurable via Build Actions in editor options", ref inputOptions.BuildScenesData); // Cook and run - _toolStripCook = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.ShipIt64, Editor.Windows.GameCookerWin.BuildAndRun).LinkTooltip($"Cook & Run - build game for the current platform and run it locally ({inputOptions.CookAndRun})"); + _toolStripCook = ToolStrip.AddButton(Editor.Icons.ShipIt64, Editor.Windows.GameCookerWin.BuildAndRun).LinkTooltip("Cook & Run - build game for the current platform and run it locally", ref inputOptions.CookAndRun); _toolStripCook.ContextMenu = new ContextMenu(); _toolStripCook.ContextMenu.AddButton("Run cooked game", Editor.Windows.GameCookerWin.RunCooked); _toolStripCook.ContextMenu.AddSeparator(); diff --git a/Source/Editor/Surface/SurfaceUtils.cs b/Source/Editor/Surface/SurfaceUtils.cs index f19adbff5..990b3ea8a 100644 --- a/Source/Editor/Surface/SurfaceUtils.cs +++ b/Source/Editor/Surface/SurfaceUtils.cs @@ -572,12 +572,12 @@ namespace FlaxEditor.Surface var undo = surface.Undo; // Toolstrip - saveButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Save64, window.Save).LinkTooltip("Save"); + saveButton = toolStrip.AddButton(editor.Icons.Save64, window.Save).LinkTooltip("Save", ref inputOptions.Save); toolStrip.AddSeparator(); - undoButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Undo64, undo.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})"); - redoButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Redo64, undo.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})"); + undoButton = toolStrip.AddButton(editor.Icons.Undo64, undo.PerformUndo).LinkTooltip("Undo", ref inputOptions.Undo); + redoButton = toolStrip.AddButton(editor.Icons.Redo64, undo.PerformRedo).LinkTooltip("Redo", ref inputOptions.Redo); toolStrip.AddSeparator(); - toolStrip.AddButton(editor.Icons.Search64, editor.ContentFinding.ShowSearch).LinkTooltip($"Open content search tool ({inputOptions.Search})"); + toolStrip.AddButton(editor.Icons.Search64, editor.ContentFinding.ShowSearch).LinkTooltip("Open content search tool", ref inputOptions.Search); toolStrip.AddButton(editor.Icons.CenterView64, surface.ShowWholeGraph).LinkTooltip("Show whole graph"); var gridSnapButton = toolStrip.AddButton(editor.Icons.Grid32, surface.ToggleGridSnapping); gridSnapButton.LinkTooltip("Toggle grid snapping for nodes."); diff --git a/Source/Editor/Windows/Assets/AnimationWindow.cs b/Source/Editor/Windows/Assets/AnimationWindow.cs index 45627eaf2..d0e6a3fe9 100644 --- a/Source/Editor/Windows/Assets/AnimationWindow.cs +++ b/Source/Editor/Windows/Assets/AnimationWindow.cs @@ -281,10 +281,10 @@ namespace FlaxEditor.Windows.Assets _propertiesPresenter.Select(_properties); // Toolstrip - _saveButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save"); + _saveButton = _toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save", ref inputOptions.Save); _toolstrip.AddSeparator(); - _undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})"); - _redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})"); + _undoButton = _toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip("Undo", ref inputOptions.Undo); + _redoButton = _toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip("Redo", ref inputOptions.Redo); _toolstrip.AddSeparator(); _toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/animation/animation/index.html")).LinkTooltip("See documentation to learn more"); diff --git a/Source/Editor/Windows/Assets/GameplayGlobalsWindow.cs b/Source/Editor/Windows/Assets/GameplayGlobalsWindow.cs index 477be532c..3dda281a6 100644 --- a/Source/Editor/Windows/Assets/GameplayGlobalsWindow.cs +++ b/Source/Editor/Windows/Assets/GameplayGlobalsWindow.cs @@ -422,10 +422,10 @@ namespace FlaxEditor.Windows.Assets _proxy = new PropertiesProxy(); _propertiesEditor.Select(_proxy); - _saveButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip($"Save asset ({inputOptions.Save})"); + _saveButton = _toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save", ref inputOptions.Save); _toolstrip.AddSeparator(); - _undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})"); - _redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})"); + _undoButton = _toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip("Undo", ref inputOptions.Undo); + _redoButton = _toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip("Redo", ref inputOptions.Redo); _toolstrip.AddSeparator(); _resetButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Rotate32, Reset).LinkTooltip("Resets the variables values to the default values"); diff --git a/Source/Editor/Windows/Assets/JsonAssetWindow.cs b/Source/Editor/Windows/Assets/JsonAssetWindow.cs index c1ce59f75..dc1e1e71f 100644 --- a/Source/Editor/Windows/Assets/JsonAssetWindow.cs +++ b/Source/Editor/Windows/Assets/JsonAssetWindow.cs @@ -95,10 +95,10 @@ namespace FlaxEditor.Windows.Assets _undo.ActionDone += OnUndoRedo; // Toolstrip - _saveButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save"); + _saveButton = _toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save", ref inputOptions.Save); _toolstrip.AddSeparator(); - _undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})"); - _redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})"); + _undoButton = _toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip("Undo", ref inputOptions.Undo); + _redoButton = _toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip("Redo", ref inputOptions.Redo); // Panel var panel = new Panel(ScrollBars.Vertical) diff --git a/Source/Editor/Windows/Assets/LocalizedStringTableWindow.cs b/Source/Editor/Windows/Assets/LocalizedStringTableWindow.cs index 45752f734..09ab43b39 100644 --- a/Source/Editor/Windows/Assets/LocalizedStringTableWindow.cs +++ b/Source/Editor/Windows/Assets/LocalizedStringTableWindow.cs @@ -135,10 +135,10 @@ namespace FlaxEditor.Windows.Assets _undo.ActionDone += OnUndoRedo; // Toolstrip - _saveButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save"); + _saveButton = _toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save", ref inputOptions.Save); _toolstrip.AddSeparator(); - _undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})"); - _redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})"); + _undoButton = _toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip("Undo", ref inputOptions.Undo); + _redoButton = _toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip("Redo", ref inputOptions.Redo); _toolstrip.AddSeparator(); _toolstrip.AddButton(Editor.Icons.Up64, OnExport).LinkTooltip("Export localization table entries for translation to .pot file"); diff --git a/Source/Editor/Windows/Assets/MaterialInstanceWindow.cs b/Source/Editor/Windows/Assets/MaterialInstanceWindow.cs index 63471a446..d025c9d6d 100644 --- a/Source/Editor/Windows/Assets/MaterialInstanceWindow.cs +++ b/Source/Editor/Windows/Assets/MaterialInstanceWindow.cs @@ -387,10 +387,10 @@ namespace FlaxEditor.Windows.Assets _undo.ActionDone += OnAction; // Toolstrip - _saveButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save"); + _saveButton = _toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save", ref inputOptions.Save); _toolstrip.AddSeparator(); - _undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})"); - _redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})"); + _undoButton = _toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip("Undo", ref inputOptions.Undo); + _redoButton = _toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip("Redo", ref inputOptions.Redo); _toolstrip.AddSeparator(); _toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/graphics/materials/instanced-materials/index.html")).LinkTooltip("See documentation to learn more"); diff --git a/Source/Editor/Windows/Assets/ModelBaseWindow.cs b/Source/Editor/Windows/Assets/ModelBaseWindow.cs index dc9b04ee7..ee355c9de 100644 --- a/Source/Editor/Windows/Assets/ModelBaseWindow.cs +++ b/Source/Editor/Windows/Assets/ModelBaseWindow.cs @@ -105,8 +105,10 @@ namespace FlaxEditor.Windows.Assets protected ModelBaseWindow(Editor editor, AssetItem item) : base(editor, item) { + var inputOptions = Editor.Options.Options.Input; + // Toolstrip - _saveButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save"); + _saveButton = _toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save", ref inputOptions.Save); // Split Panel _split = new SplitPanel(Orientation.Horizontal, ScrollBars.None, ScrollBars.None) diff --git a/Source/Editor/Windows/Assets/ParticleSystemWindow.cs b/Source/Editor/Windows/Assets/ParticleSystemWindow.cs index 39ce93918..2708f8c87 100644 --- a/Source/Editor/Windows/Assets/ParticleSystemWindow.cs +++ b/Source/Editor/Windows/Assets/ParticleSystemWindow.cs @@ -359,10 +359,10 @@ namespace FlaxEditor.Windows.Assets propertiesEditor.Select(new GeneralProxy(this)); // Toolstrip - _saveButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save"); + _saveButton = _toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save", ref inputOptions.Save); _toolstrip.AddSeparator(); - _undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})"); - _redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})"); + _undoButton = _toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip("Undo", ref inputOptions.Undo); + _redoButton = _toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip("Redo", ref inputOptions.Redo); _toolstrip.AddSeparator(); _toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/particles/index.html")).LinkTooltip("See documentation to learn more"); diff --git a/Source/Editor/Windows/Assets/PrefabWindow.cs b/Source/Editor/Windows/Assets/PrefabWindow.cs index 8aa1fbbad..7ee8ecff0 100644 --- a/Source/Editor/Windows/Assets/PrefabWindow.cs +++ b/Source/Editor/Windows/Assets/PrefabWindow.cs @@ -181,14 +181,14 @@ namespace FlaxEditor.Windows.Assets _propertiesEditor.Modified += MarkAsEdited; // Toolstrip - _saveButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save"); + _saveButton = _toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save", ref inputOptions.Save); _toolstrip.AddSeparator(); - _toolStripUndo = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})"); - _toolStripRedo = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})"); + _toolStripUndo = _toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip("Undo", ref inputOptions.Undo); + _toolStripRedo = _toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip("Redo", ref inputOptions.Redo); _toolstrip.AddSeparator(); - _toolStripTranslate = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Translate32, () => _viewport.TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Translate).LinkTooltip($"Change Gizmo tool mode to Translate ({inputOptions.TranslateMode})"); - _toolStripRotate = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Rotate32, () => _viewport.TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Rotate).LinkTooltip($"Change Gizmo tool mode to Rotate ({inputOptions.RotateMode})"); - _toolStripScale = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Scale32, () => _viewport.TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Scale).LinkTooltip($"Change Gizmo tool mode to Scale ({inputOptions.ScaleMode})"); + _toolStripTranslate = _toolstrip.AddButton(Editor.Icons.Translate32, () => _viewport.TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Translate).LinkTooltip("Change Gizmo tool mode to Translate", ref inputOptions.TranslateMode); + _toolStripRotate = _toolstrip.AddButton(Editor.Icons.Rotate32, () => _viewport.TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Rotate).LinkTooltip("Change Gizmo tool mode to Rotate", ref inputOptions.RotateMode); + _toolStripScale = _toolstrip.AddButton(Editor.Icons.Scale32, () => _viewport.TransformGizmo.ActiveMode = TransformGizmoBase.Mode.Scale).LinkTooltip("Change Gizmo tool mode to Scale", ref inputOptions.ScaleMode); _toolstrip.AddSeparator(); _toolStripLiveReload = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Refresh64, () => LiveReload = !LiveReload).SetChecked(true).SetAutoCheck(true).LinkTooltip("Live changes preview (applies prefab changes on modification by auto)"); diff --git a/Source/Editor/Windows/Assets/SceneAnimationWindow.cs b/Source/Editor/Windows/Assets/SceneAnimationWindow.cs index 878eb3b00..9b0875752 100644 --- a/Source/Editor/Windows/Assets/SceneAnimationWindow.cs +++ b/Source/Editor/Windows/Assets/SceneAnimationWindow.cs @@ -652,10 +652,10 @@ namespace FlaxEditor.Windows.Assets _timeline.SetNoTracksText("Loading..."); // Toolstrip - _saveButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save"); + _saveButton = _toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save", ref inputOptions.Save); _toolstrip.AddSeparator(); - _undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})"); - _redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})"); + _undoButton = _toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip("Undo", ref inputOptions.Undo); + _redoButton = _toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip("Redo", ref inputOptions.Redo); _toolstrip.AddSeparator(); _previewButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Refresh64, OnPreviewButtonClicked).SetAutoCheck(true).LinkTooltip("If checked, enables live-preview of the animation on a scene while editing"); _renderButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Build64, OnRenderButtonClicked).LinkTooltip("Open the scene animation rendering utility..."); diff --git a/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs b/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs index 0b9cf2b5c..ff2446439 100644 --- a/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs +++ b/Source/Editor/Windows/Assets/SkeletonMaskWindow.cs @@ -195,8 +195,10 @@ namespace FlaxEditor.Windows.Assets public SkeletonMaskWindow(Editor editor, AssetItem item) : base(editor, item) { + var inputOptions = Editor.Options.Options.Input; + // Toolstrip - _saveButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save asset to the file"); + _saveButton = _toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save", ref inputOptions.Save); _toolstrip.AddSeparator(); _toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/animation/skeleton-mask.html")).LinkTooltip("See documentation to learn more"); diff --git a/Source/Editor/Windows/Assets/SpriteAtlasWindow.cs b/Source/Editor/Windows/Assets/SpriteAtlasWindow.cs index 9d32e5077..9601555d2 100644 --- a/Source/Editor/Windows/Assets/SpriteAtlasWindow.cs +++ b/Source/Editor/Windows/Assets/SpriteAtlasWindow.cs @@ -273,6 +273,8 @@ namespace FlaxEditor.Windows.Assets public SpriteAtlasWindow(Editor editor, AssetItem item) : base(editor, item) { + var inputOptions = Editor.Options.Options.Input; + // Split Panel _split = new SplitPanel(Orientation.Horizontal, ScrollBars.None, ScrollBars.Vertical) { @@ -296,7 +298,7 @@ namespace FlaxEditor.Windows.Assets _propertiesEditor.Modified += MarkAsEdited; // Toolstrip - _saveButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save"); + _saveButton = _toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save", ref inputOptions.Save); _toolstrip.AddButton(editor.Icons.Import64, () => Editor.ContentImporting.Reimport((BinaryAssetItem)Item)).LinkTooltip("Reimport"); _toolstrip.AddSeparator(); _toolstrip.AddButton(editor.Icons.AddFile64, () => diff --git a/Source/Editor/Windows/Assets/TextureWindow.cs b/Source/Editor/Windows/Assets/TextureWindow.cs index 9d4b94024..68f138978 100644 --- a/Source/Editor/Windows/Assets/TextureWindow.cs +++ b/Source/Editor/Windows/Assets/TextureWindow.cs @@ -27,7 +27,7 @@ namespace FlaxEditor.Windows.Assets public class PropertiesProxyBase { internal TextureWindow _window; - + /// /// Gathers parameters from the specified texture. /// @@ -37,7 +37,7 @@ namespace FlaxEditor.Windows.Assets // Link _window = window; } - + /// /// Clears temporary data. /// @@ -83,7 +83,7 @@ namespace FlaxEditor.Windows.Assets } } } - + /// /// The texture import properties proxy object. /// @@ -129,7 +129,7 @@ namespace FlaxEditor.Windows.Assets public void DiscardChanges() { } - + private sealed class ProxyEditor : GenericEditor { public override void Initialize(LayoutElementsContainer layout) @@ -151,7 +151,7 @@ namespace FlaxEditor.Windows.Assets /// The presenter to use in the tab. /// public CustomEditorPresenter Presenter; - + /// /// The proxy to use in the tab. /// @@ -214,6 +214,8 @@ namespace FlaxEditor.Windows.Assets public TextureWindow(Editor editor, AssetItem item) : base(editor, item) { + var inputOptions = Editor.Options.Options.Input; + // Split Panel _split = new SplitPanel(Orientation.Horizontal, ScrollBars.None, ScrollBars.Vertical) { @@ -228,7 +230,7 @@ namespace FlaxEditor.Windows.Assets { Parent = _split.Panel1 }; - + // Properties tabs _tabs = new() { @@ -244,7 +246,7 @@ namespace FlaxEditor.Windows.Assets _tabs.AddTab(new ImportTab(this)); // Toolstrip - _saveButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save"); + _saveButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save", ref inputOptions.Save); _toolstrip.AddButton(Editor.Icons.Import64, () => Editor.ContentImporting.Reimport((BinaryAssetItem)Item)).LinkTooltip("Reimport"); _toolstrip.AddSeparator(); _toolstrip.AddButton(Editor.Icons.CenterView64, _preview.CenterView).LinkTooltip("Center view"); diff --git a/Source/Editor/Windows/Assets/VisualScriptWindow.cs b/Source/Editor/Windows/Assets/VisualScriptWindow.cs index b424ecffc..f41936dd0 100644 --- a/Source/Editor/Windows/Assets/VisualScriptWindow.cs +++ b/Source/Editor/Windows/Assets/VisualScriptWindow.cs @@ -603,11 +603,11 @@ namespace FlaxEditor.Windows.Assets _debugToolstripControls = new[] { _toolstrip.AddSeparator(), - _toolstrip.AddButton(editor.Icons.Play64, OnDebuggerContinue).LinkTooltip($"Continue ({inputOptions.DebuggerContinue})"), + _toolstrip.AddButton(editor.Icons.Play64, OnDebuggerContinue).LinkTooltip("Continue", ref inputOptions.DebuggerContinue), _toolstrip.AddButton(editor.Icons.Search64, OnDebuggerNavigateToCurrentNode).LinkTooltip("Navigate to the current stack trace node"), - _toolstrip.AddButton(editor.Icons.Right64, OnDebuggerStepOver).LinkTooltip($"Step Over ({inputOptions.DebuggerStepOver})"), - _toolstrip.AddButton(editor.Icons.Down64, OnDebuggerStepInto).LinkTooltip($"Step Into ({inputOptions.DebuggerStepInto})"), - _toolstrip.AddButton(editor.Icons.Up64, OnDebuggerStepOut).LinkTooltip($"Step Out ({inputOptions.DebuggerStepOut})"), + _toolstrip.AddButton(editor.Icons.Right64, OnDebuggerStepOver).LinkTooltip("Step Over", ref inputOptions.DebuggerStepOver), + _toolstrip.AddButton(editor.Icons.Down64, OnDebuggerStepInto).LinkTooltip("Step Into", ref inputOptions.DebuggerStepInto), + _toolstrip.AddButton(editor.Icons.Up64, OnDebuggerStepOut).LinkTooltip("Step Out", ref inputOptions.DebuggerStepOut), _toolstrip.AddButton(editor.Icons.Stop64, OnDebuggerStop).LinkTooltip("Stop debugging"), }; foreach (var control in _debugToolstripControls) diff --git a/Source/Editor/Windows/VisualScriptDebuggerWindow.cs b/Source/Editor/Windows/VisualScriptDebuggerWindow.cs index 00acd7ba1..6104d41bb 100644 --- a/Source/Editor/Windows/VisualScriptDebuggerWindow.cs +++ b/Source/Editor/Windows/VisualScriptDebuggerWindow.cs @@ -409,7 +409,7 @@ namespace FlaxEditor.Windows _debugToolstripControls = new[] { toolstrip.AddSeparator(), - toolstrip.AddButton(editor.Icons.Play64, OnDebuggerContinue).LinkTooltip($"Continue ({inputOptions.DebuggerContinue})"), + toolstrip.AddButton(editor.Icons.Play64, OnDebuggerContinue).LinkTooltip("Continue", ref inputOptions.DebuggerContinue), toolstrip.AddButton(editor.Icons.Search64, OnDebuggerNavigateToCurrentNode).LinkTooltip("Navigate to the current stack trace node"), toolstrip.AddButton(editor.Icons.Stop64, OnDebuggerStop).LinkTooltip("Stop debugging"), }; From 0b492180dfe2a5877b13c481b551287eb9073e57 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 1 Oct 2024 12:29:29 +0200 Subject: [PATCH 16/19] Fix Content Finder input action binding in Output Log --- Source/Editor/Windows/OutputLogWindow.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Source/Editor/Windows/OutputLogWindow.cs b/Source/Editor/Windows/OutputLogWindow.cs index 5d37ce865..f8c4ea9b5 100644 --- a/Source/Editor/Windows/OutputLogWindow.cs +++ b/Source/Editor/Windows/OutputLogWindow.cs @@ -65,11 +65,6 @@ namespace FlaxEditor.Windows /// public OutputLogWindow Window; - /// - /// The input actions collection to processed during user input. - /// - public InputActionsContainer InputActions = new InputActionsContainer(); - /// /// The default text style. /// @@ -88,7 +83,7 @@ namespace FlaxEditor.Windows /// public override bool OnKeyDown(KeyboardKeys key) { - if (InputActions.Process(Editor.Instance, this, key)) + if (Window.InputActions.Process(Editor.Instance, this, key)) return true; return base.OnKeyDown(key); } @@ -214,9 +209,8 @@ namespace FlaxEditor.Windows // Setup editor options Editor.Options.OptionsChanged += OnEditorOptionsChanged; OnEditorOptionsChanged(Editor.Options.Options); - - _output.InputActions.Add(options => options.Search, () => _searchBox.Focus()); - InputActions.Add(options => options.Search, () => _searchBox.Focus()); + + InputActions.Add(options => options.Search, _searchBox.Focus); GameCooker.Event += OnGameCookerEvent; ScriptsBuilder.CompilationFailed += OnScriptsCompilationFailed; From b00cab638897d13af59cc63eabf077dfeb874531 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 1 Oct 2024 14:38:32 +0200 Subject: [PATCH 17/19] Fix using old CPU particle assets --- .../Particles/Graph/CPU/ParticleEmitterGraph.CPU.Particles.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.Particles.cpp b/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.Particles.cpp index e517ab9b9..a2c8ba03c 100644 --- a/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.Particles.cpp +++ b/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.Particles.cpp @@ -16,6 +16,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupParameters(Box* box, Node* nod switch (node->TypeID) { // Get + case 1: case 2: { int32 paramIndex; From c597c38705efe2fe0fa2860539d23f6dee34951b Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 1 Oct 2024 15:07:32 +0200 Subject: [PATCH 18/19] Fix volumetric fog particles after objects instancing refactor --- Content/Shaders/VolumetricFog.flax | 4 +-- .../Graphics/Materials/MaterialShader.cpp | 1 + Source/Engine/Renderer/VolumetricFogPass.cpp | 27 ++++++++++--------- Source/Engine/Renderer/VolumetricFogPass.h | 2 +- Source/Shaders/VolumetricFog.shader | 2 +- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Content/Shaders/VolumetricFog.flax b/Content/Shaders/VolumetricFog.flax index 3613c79b6..6612a2c6a 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:9ccc821da8613409f4c829f14958534f87c142edc6ac0f0d73d8a9e6e3fc6efc -size 13299 +oid sha256:ebbfff2b1ca68e630dff99b58b00de77f3e19e32fae3ad04dc7fae6ae95117ef +size 13293 diff --git a/Source/Engine/Graphics/Materials/MaterialShader.cpp b/Source/Engine/Graphics/Materials/MaterialShader.cpp index 63faaf300..ef119245d 100644 --- a/Source/Engine/Graphics/Materials/MaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/MaterialShader.cpp @@ -87,6 +87,7 @@ void IMaterial::BindParameters::BindViewData() void IMaterial::BindParameters::BindDrawData() { // Write draw call to the object buffer + ASSERT(DrawCall); auto& objectBuffer = RenderContext.List->TempObjectBuffer; objectBuffer.Clear(); ShaderObjectData objData; diff --git a/Source/Engine/Renderer/VolumetricFogPass.cpp b/Source/Engine/Renderer/VolumetricFogPass.cpp index 2b9a4b441..d9a77bc37 100644 --- a/Source/Engine/Renderer/VolumetricFogPass.cpp +++ b/Source/Engine/Renderer/VolumetricFogPass.cpp @@ -60,9 +60,10 @@ bool VolumetricFogPass::setupResources() REPORT_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); return true; } - if (shader->GetCB(1)->GetSize() != sizeof(PerLight)) + // CB1 is used for per-draw info (ObjectIndex) + if (shader->GetCB(2)->GetSize() != sizeof(PerLight)) { - REPORT_INVALID_SHADER_PASS_CB_SIZE(shader, 1, PerLight); + REPORT_INVALID_SHADER_PASS_CB_SIZE(shader, 2, PerLight); return true; } @@ -254,7 +255,7 @@ GPUTextureView* VolumetricFogPass::GetLocalShadowedLightScattering(RenderContext } template -void VolumetricFogPass::RenderRadialLight(RenderContext& renderContext, GPUContext* context, RenderView& view, VolumetricFogOptions& options, T& light, PerLight& perLight, GPUConstantBuffer* cb1) +void VolumetricFogPass::RenderRadialLight(RenderContext& renderContext, GPUContext* context, RenderView& view, VolumetricFogOptions& options, T& light, PerLight& perLight, GPUConstantBuffer* cb2) { const Float3 center = light.Position; const float radius = light.Radius; @@ -281,8 +282,8 @@ void VolumetricFogPass::RenderRadialLight(RenderContext& renderContext, GPUConte light.SetShaderData(perLight.LocalLight, withShadow); // Upload data - context->UpdateCB(cb1, &perLight); - context->BindCB(1, cb1); + context->UpdateCB(cb2, &perLight); + context->BindCB(2, cb2); // Ensure to have valid buffers created if (_vbCircleRasterize == nullptr || _ibCircleRasterize == nullptr) @@ -414,6 +415,8 @@ void VolumetricFogPass::Render(RenderContext& renderContext) customData.VolumetricFogMaxDistance = cache.Data.VolumetricFogMaxDistance; bindParams.CustomData = &customData; bindParams.BindViewData(); + bindParams.DrawCall = &renderContext.List->VolumetricFogParticles.First(); + bindParams.BindDrawData(); for (auto& drawCall : renderContext.List->VolumetricFogParticles) { @@ -439,7 +442,7 @@ void VolumetricFogPass::Render(RenderContext& renderContext) // Setup volumetric shader data PerLight perLight; - auto cb1 = _shader->GetShader()->GetCB(1); + auto cb2 = _shader->GetShader()->GetCB(2); perLight.SliceToDepth.X = cache.Data.GridSize.Z; perLight.SliceToDepth.Y = cache.Data.VolumetricFogMaxDistance; perLight.MinZ = volumeZBoundsMin; @@ -447,8 +450,8 @@ void VolumetricFogPass::Render(RenderContext& renderContext) Matrix::Transpose(renderContext.View.Projection, perLight.ViewToVolumeClip); // Upload data - context->UpdateCB(cb1, &perLight); - context->BindCB(1, cb1); + context->UpdateCB(cb2, &perLight); + context->BindCB(2, cb2); // Call rendering to the volume const int32 instanceCount = volumeZBoundsMax - volumeZBoundsMin; @@ -495,7 +498,7 @@ void VolumetricFogPass::Render(RenderContext& renderContext) PerLight perLight; perLight.SliceToDepth.X = cache.Data.GridSize.Z; perLight.SliceToDepth.Y = cache.Data.VolumetricFogMaxDistance; - auto cb1 = _shader->GetShader()->GetCB(1); + auto cb2 = _shader->GetShader()->GetCB(2); // Bind the output context->SetRenderTarget(localShadowedLightScattering); @@ -505,12 +508,12 @@ void VolumetricFogPass::Render(RenderContext& renderContext) context->BindSR(0, shadowMap); context->BindSR(1, shadowsBuffer); for (int32 i = 0; i < pointLights.Count(); i++) - RenderRadialLight(renderContext, context, view, options, renderContext.List->PointLights[pointLights[i]], perLight, cb1); + RenderRadialLight(renderContext, context, view, options, renderContext.List->PointLights[pointLights[i]], perLight, cb2); for (int32 i = 0; i < spotLights.Count(); i++) - RenderRadialLight(renderContext, context, view, options, renderContext.List->SpotLights[spotLights[i]], perLight, cb1); + RenderRadialLight(renderContext, context, view, options, renderContext.List->SpotLights[spotLights[i]], perLight, cb2); // Cleanup - context->UnBindCB(1); + context->UnBindCB(2); context->ResetRenderTarget(); context->FlushState(); } diff --git a/Source/Engine/Renderer/VolumetricFogPass.h b/Source/Engine/Renderer/VolumetricFogPass.h index 0489bb88a..156f485f8 100644 --- a/Source/Engine/Renderer/VolumetricFogPass.h +++ b/Source/Engine/Renderer/VolumetricFogPass.h @@ -157,7 +157,7 @@ private: GPUTextureView* GetLocalShadowedLightScattering(RenderContext& renderContext, GPUContext* context, VolumetricFogOptions& options) const; void InitCircleBuffer(); template - void RenderRadialLight(RenderContext& renderContext, GPUContext* context, RenderView& view, VolumetricFogOptions& options, T& light, PerLight& perLight, GPUConstantBuffer* cb1); + void RenderRadialLight(RenderContext& renderContext, GPUContext* context, RenderView& view, VolumetricFogOptions& options, T& light, PerLight& perLight, GPUConstantBuffer* cb2); #if COMPILE_WITH_DEV_ENV void OnShaderReloading(Asset* obj) { diff --git a/Source/Shaders/VolumetricFog.shader b/Source/Shaders/VolumetricFog.shader index 0032149b2..d04a2eb92 100644 --- a/Source/Shaders/VolumetricFog.shader +++ b/Source/Shaders/VolumetricFog.shader @@ -60,7 +60,7 @@ SkyLightData SkyLight; DDGIData DDGI; META_CB_END -META_CB_BEGIN(1, PerLight) +META_CB_BEGIN(2, PerLight) float2 SliceToDepth; int MinZ; float LocalLightScatteringIntensity; From 7f7549d2f78d1a9336f2f31d5dcf1fc6e89f7422 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 1 Oct 2024 23:07:47 +0200 Subject: [PATCH 19/19] Add `Foliage.RemoveAllInstances` to clear all instances of foliage #2957 --- Source/Engine/Foliage/Foliage.cpp | 6 ++++++ Source/Engine/Foliage/Foliage.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/Source/Engine/Foliage/Foliage.cpp b/Source/Engine/Foliage/Foliage.cpp index 8c0b337ae..427e2260b 100644 --- a/Source/Engine/Foliage/Foliage.cpp +++ b/Source/Engine/Foliage/Foliage.cpp @@ -986,6 +986,12 @@ void Foliage::UpdateCullDistance() #endif } +void Foliage::RemoveAllInstances() +{ + Instances.Clear(); + RebuildClusters(); +} + static float GlobalDensityScale = 1.0f; float Foliage::GetGlobalDensityScale() diff --git a/Source/Engine/Foliage/Foliage.h b/Source/Engine/Foliage/Foliage.h index d10a75a7e..c062279a8 100644 --- a/Source/Engine/Foliage/Foliage.h +++ b/Source/Engine/Foliage/Foliage.h @@ -134,6 +134,11 @@ public: /// API_FUNCTION() void UpdateCullDistance(); + /// + /// Clears all foliage instances. Preserves the foliage types and other properties. + /// + API_FUNCTION() void RemoveAllInstances(); + public: /// /// Gets the global density scale for all foliage instances. The default value is 1. Use values from range 0-1. Lower values decrease amount of foliage instances in-game. Use it to tweak game performance for slower devices.