From 92a212317d3ba121e71e14037b42237c1048532f Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Tue, 18 Mar 2025 22:25:51 +0100 Subject: [PATCH 01/14] show No parameters text when no parameters to be displayed in Preview tab --- Source/Editor/Windows/Assets/AnimationGraphWindow.cs | 4 ++++ Source/Editor/Windows/Assets/ParticleEmitterWindow.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Source/Editor/Windows/Assets/AnimationGraphWindow.cs b/Source/Editor/Windows/Assets/AnimationGraphWindow.cs index 1cf03f062..43faa59f9 100644 --- a/Source/Editor/Windows/Assets/AnimationGraphWindow.cs +++ b/Source/Editor/Windows/Assets/AnimationGraphWindow.cs @@ -149,6 +149,10 @@ namespace FlaxEditor.Windows.Assets (instance, parameter, tag) => ((AnimationGraphWindow)instance).PreviewActor.GetParameterValue(parameter.Identifier), (instance, value, parameter, tag) => ((AnimationGraphWindow)instance).PreviewActor.SetParameterValue(parameter.Identifier, value), Values); + + // Parameters will always have one element + if (parameters.Length < 2) + layout.Label("No parameters", TextAlignment.Center); } } } diff --git a/Source/Editor/Windows/Assets/ParticleEmitterWindow.cs b/Source/Editor/Windows/Assets/ParticleEmitterWindow.cs index c373b4cdc..39b4d6ac2 100644 --- a/Source/Editor/Windows/Assets/ParticleEmitterWindow.cs +++ b/Source/Editor/Windows/Assets/ParticleEmitterWindow.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; +using System.Linq; using FlaxEditor.Content; using FlaxEditor.CustomEditors; using FlaxEditor.Scripting; @@ -104,6 +105,9 @@ namespace FlaxEditor.Windows.Assets (instance, parameter, tag) => ((ParticleEmitterWindow)instance).Preview.PreviewActor.GetParameterValue(string.Empty, parameter.Name), (instance, value, parameter, tag) => ((ParticleEmitterWindow)instance).Preview.PreviewActor.SetParameterValue(string.Empty, parameter.Name, value), Values); + + if (!parameters.Any()) + layout.Label("No parameters", TextAlignment.Center); } } } From 04fa19fce7512448a5fe3f1a2717781fecf594ee Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 19 Mar 2025 16:55:05 +0100 Subject: [PATCH 02/14] Revert "Fix issue with re-loading scene and toolstip not updating." This reverts commit 3788021898389f64187c66dfeb1a7f1182e08f9f. --- Source/Editor/States/ChangingScenesState.cs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/Source/Editor/States/ChangingScenesState.cs b/Source/Editor/States/ChangingScenesState.cs index e1a95e6ab..17fa30ff7 100644 --- a/Source/Editor/States/ChangingScenesState.cs +++ b/Source/Editor/States/ChangingScenesState.cs @@ -164,21 +164,10 @@ namespace FlaxEditor.States { Assert.AreEqual(Guid.Empty, _lastSceneFromRequest, "Invalid state."); - // Bind events, only bind loading event and error if re-loading the same scene to avoid issues. - if (_scenesToUnload.Count == 1 && _scenesToLoad.Count == 1) - { - if (_scenesToLoad[0] == _scenesToUnload[0].ID) - { - Level.SceneLoaded += OnSceneEvent; - Level.SceneLoadError += OnSceneEvent; - } - } - else - { - Level.SceneLoaded += OnSceneEvent; - Level.SceneLoadError += OnSceneEvent; - Level.SceneUnloaded += OnSceneEvent; - } + // Bind events + Level.SceneLoaded += OnSceneEvent; + Level.SceneLoadError += OnSceneEvent; + Level.SceneUnloaded += OnSceneEvent; // Push scenes changing requests for (int i = 0; i < _scenesToUnload.Count; i++) From 2c8f2b6e92b1742a4b50c055459f90523c0ac008 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 19 Mar 2025 16:56:08 +0100 Subject: [PATCH 03/14] Fix potential crash --- Source/Editor/Viewport/MainEditorGizmoViewport.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index ab1b8b312..3f35b6c63 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -611,7 +611,7 @@ namespace FlaxEditor.Viewport // Don't allow rubber band selection when gizmo is controlling mouse, vertex painting mode, or cloth painting is enabled bool canStart = !(IsControllingMouse || IsRightMouseButtonDown || IsAltKeyDown) && - Gizmos.Active is TransformGizmo && !Gizmos.Active.IsControllingMouse; + Gizmos?.Active is TransformGizmo && !Gizmos.Active.IsControllingMouse; _rubberBandSelector.TryCreateRubberBand(canStart, _viewMousePos, ViewFrustum); } From a403e21cbc5343575bb1df8202b512e13b822e3f Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Wed, 19 Mar 2025 23:01:57 +0100 Subject: [PATCH 04/14] add search operator tooltip to scene tree search bar --- Source/Editor/Windows/SceneTreeWindow.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index 7b5e84c02..d865d384a 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -62,6 +62,7 @@ namespace FlaxEditor.Windows AnchorPreset = AnchorPresets.HorizontalStretchMiddle, Parent = headerPanel, Bounds = new Rectangle(4, 4, headerPanel.Width - 8, 18), + TooltipText = "Search the scene tree.\n\nYou can prefix your search with different search operators:\ns: -> Actor with script of type\na: -> Actor type\nc: -> Control type", }; _searchBox.TextChanged += OnSearchBoxTextChanged; From e9e96b21d3e6afdc8837d860881f5478313e1398 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Sun, 23 Mar 2025 14:48:02 +0100 Subject: [PATCH 05/14] put terrain info into own Properties panel group --- Source/Editor/CustomEditors/Dedicated/TerrainEditor.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/Editor/CustomEditors/Dedicated/TerrainEditor.cs b/Source/Editor/CustomEditors/Dedicated/TerrainEditor.cs index 8aaf5b7d6..05945efe7 100644 --- a/Source/Editor/CustomEditors/Dedicated/TerrainEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/TerrainEditor.cs @@ -2,6 +2,7 @@ using FlaxEditor.Utilities; using FlaxEngine; +using FlaxEngine.GUI; namespace FlaxEditor.CustomEditors.Dedicated { @@ -33,8 +34,12 @@ namespace FlaxEditor.CustomEditors.Dedicated totalSize.X / Units.Meters2Units * 0.001f, totalSize.Z / Units.Meters2Units * 0.001f ); - var label = layout.Label(text); + + var group = layout.Group("Info"); + var label = group.Label(text); label.Label.AutoHeight = true; + // Add a bit of padding to make it look nicer + label.Label.Margin = new Margin(3); } } } From 82bdc5d869320679be25bb70e603819e7450755c Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 24 Mar 2025 18:14:54 +0100 Subject: [PATCH 06/14] adjust sensitivity of some sliders in Model Tool --- Source/Engine/Tools/ModelTool/ModelTool.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Engine/Tools/ModelTool/ModelTool.h b/Source/Engine/Tools/ModelTool/ModelTool.h index bfd8092e7..77630fcc9 100644 --- a/Source/Engine/Tools/ModelTool/ModelTool.h +++ b/Source/Engine/Tools/ModelTool/ModelTool.h @@ -258,10 +258,10 @@ public: API_FIELD(Attributes="EditorOrder(1100), EditorDisplay(\"Level Of Detail\", \"Generate LODs\"), VisibleIf(nameof(ShowGeometry))") bool GenerateLODs = false; // The index of the LOD from the source model data to use as a reference for following LODs generation. - API_FIELD(Attributes="EditorOrder(1110), EditorDisplay(\"Level Of Detail\", \"Base LOD\"), VisibleIf(nameof(ShowGeometry)), Limit(0, 5)") + API_FIELD(Attributes="EditorOrder(1110), EditorDisplay(\"Level Of Detail\", \"Base LOD\"), VisibleIf(nameof(ShowGeometry)), Limit(0, 5, 0.065f)") int32 BaseLOD = 0; // The amount of LODs to include in the model (all remaining ones starting from Base LOD will be generated). - API_FIELD(Attributes="EditorOrder(1120), EditorDisplay(\"Level Of Detail\", \"LOD Count\"), VisibleIf(nameof(ShowGeometry)), Limit(1, 6)") + API_FIELD(Attributes="EditorOrder(1120), EditorDisplay(\"Level Of Detail\", \"LOD Count\"), VisibleIf(nameof(ShowGeometry)), Limit(1, 6, 0.065f)") int32 LODCount = 4; // The target amount of triangles for the generated LOD (based on the higher LOD). Normalized to range 0-1. For instance 0.4 cuts the triangle count to 40%. API_FIELD(Attributes="EditorOrder(1130), EditorDisplay(\"Level Of Detail\"), VisibleIf(nameof(ShowGeometry)), Limit(0, 1, 0.001f)") @@ -309,7 +309,7 @@ public: API_FIELD(Attributes="EditorOrder(2000), EditorDisplay(\"Splitting\"), VisibleIf(nameof(ShowSplitting))") bool SplitObjects = false; // The zero-based index for the mesh/animation clip to import. If the source file has more than one mesh/animation it can be used to pick a desired object. Default -1 imports all objects. - API_FIELD(Attributes="EditorOrder(2010), EditorDisplay(\"Splitting\"), VisibleIf(nameof(ShowSplitting))") + API_FIELD(Attributes="EditorOrder(2010), EditorDisplay(\"Splitting\"), VisibleIf(nameof(ShowSplitting)), Limit(int.MinValue, int.MaxValue, 0.065f)") int32 ObjectIndex = -1; public: // Other From bde4aec11313ddfef1399d62fd7a9fd49247bdb1 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 24 Mar 2025 19:12:16 +0100 Subject: [PATCH 07/14] make script compilation failed warning a bit nicer --- Source/Engine/Level/Level.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Level/Level.cpp b/Source/Engine/Level/Level.cpp index cb565f651..5d50c9339 100644 --- a/Source/Engine/Level/Level.cpp +++ b/Source/Engine/Level/Level.cpp @@ -884,9 +884,9 @@ bool Level::loadScene(rapidjson_flax::Value& data, int32 engineBuild, Scene** ou if (!CommandLine::Options.Headless.IsTrue()) { if (ScriptsBuilder::LastCompilationFailed()) - MessageBox::Show(TEXT("Scripts compilation failed. Cannot load scene without game script modules. Please fix the compilation issues. See logs for more info."), TEXT("Failed to compile scripts"), MessageBoxButtons::OK, MessageBoxIcon::Error); + MessageBox::Show(TEXT("Script compilation failed.\n\nCannot load scene without game script modules. Please fix any compilation issues.\n\nSee Output Log or logs for more info."), TEXT("Failed to compile scripts"), MessageBoxButtons::OK, MessageBoxIcon::Error); else - MessageBox::Show(TEXT("Failed to load scripts. Cannot load scene without game script modules. See logs for more info."), TEXT("Missing game modules"), MessageBoxButtons::OK, MessageBoxIcon::Error); + MessageBox::Show(TEXT("Failed to load scripts.\n\nCannot load scene without game script modules.\n\nSee logs for more info."), TEXT("Missing game modules"), MessageBoxButtons::OK, MessageBoxIcon::Error); } #endif return true; From 0938dd3f5dfc1e8508afd0658ce85c1241a80e2d Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Tue, 25 Mar 2025 00:34:28 +0100 Subject: [PATCH 08/14] hide Remove option in collections editor if collection can not be resized --- Source/Editor/CustomEditors/Editors/CollectionEditor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/CustomEditors/Editors/CollectionEditor.cs b/Source/Editor/CustomEditors/Editors/CollectionEditor.cs index f76bd4d89..1a4bcab4d 100644 --- a/Source/Editor/CustomEditors/Editors/CollectionEditor.cs +++ b/Source/Editor/CustomEditors/Editors/CollectionEditor.cs @@ -81,7 +81,7 @@ namespace FlaxEditor.CustomEditors.Editors b.Enabled = Index + 1 < Editor.Count && !Editor._readOnly; b = menu.AddButton("Remove", OnRemoveClicked); - b.Enabled = !Editor._readOnly; + b.Enabled = !Editor._readOnly && Editor._canResize; } /// From bd74d9202e74d888236b5efd02151d4184e4ef60 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Tue, 25 Mar 2025 10:33:47 +0100 Subject: [PATCH 09/14] update and fix the emitter template descriptions --- .../Content/Create/ParticleEmitterCreateEntry.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Editor/Content/Create/ParticleEmitterCreateEntry.cs b/Source/Editor/Content/Create/ParticleEmitterCreateEntry.cs index 8aefc58b2..a88d74c18 100644 --- a/Source/Editor/Content/Create/ParticleEmitterCreateEntry.cs +++ b/Source/Editor/Content/Create/ParticleEmitterCreateEntry.cs @@ -18,32 +18,32 @@ namespace FlaxEditor.Content.Create public enum Templates { /// - /// The empty asset. + /// An empty emitter. /// Empty, /// - /// The simple particle system that uses constant emission rate. + /// An emitter that emits particles at a constant emission rate. /// ConstantBurst, /// - /// The simple periodic burst particle system. + /// An emitter that produces simple, periodic bursts of particles. /// PeriodicBurst, /// - /// The layers and tags settings. + /// An emitter that uses a blended spritesheet to produce a smooth, thick cloud of smoke. /// Smoke, /// - /// The GPU sparks with depth-buffer collisions. + /// A GPU emitter that produces sparks that can collide, thanks to depth-buffer based collisions. /// Sparks, /// - /// The ribbon spiral particles. + /// An emitter that produces a spiral shaped ribbon. /// RibbonSpiral, } From 38c3d88a8a0cc7c66d288da0168501c66d53eeab Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 25 Mar 2025 17:12:14 +0100 Subject: [PATCH 10/14] Fix crash on incorrect MultiBlend2D triangles memory #3302 --- Source/Engine/Animations/Graph/AnimGraph.Base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Engine/Animations/Graph/AnimGraph.Base.cpp b/Source/Engine/Animations/Graph/AnimGraph.Base.cpp index 204026724..4d7ae9363 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.Base.cpp +++ b/Source/Engine/Animations/Graph/AnimGraph.Base.cpp @@ -224,7 +224,7 @@ bool AnimGraphBase::onNodeLoaded(Node* n) // Store triangles vertices indices (map the back to the anim node slots) n->Data.MultiBlend2D.TrianglesCount = triangles.Count(); - n->Data.MultiBlend2D.Triangles = (ANIM_GRAPH_MULTI_BLEND_INDEX*)Allocator::Allocate(triangles.Count() * 3 - sizeof(ANIM_GRAPH_MULTI_BLEND_INDEX)); + n->Data.MultiBlend2D.Triangles = (ANIM_GRAPH_MULTI_BLEND_INDEX*)Allocator::Allocate(triangles.Count() * 3 * sizeof(ANIM_GRAPH_MULTI_BLEND_INDEX)); for (int32 i = 0, t = 0; i < triangles.Count(); i++) { n->Data.MultiBlend2D.Triangles[t++] = vertexToAnim[triangles[i].Indices[0]]; From df6cf13b988d6cba19a96a999b82015d9fc1659c Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 26 Mar 2025 15:57:58 +0100 Subject: [PATCH 11/14] Fix rubber band selection with large worlds #3305 --- .../Gizmo/ViewportRubberBandSelector.cs | 30 ++++++++++++------- .../Viewport/MainEditorGizmoViewport.cs | 2 +- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Source/Editor/Gizmo/ViewportRubberBandSelector.cs b/Source/Editor/Gizmo/ViewportRubberBandSelector.cs index 36b1884ad..164868fc7 100644 --- a/Source/Editor/Gizmo/ViewportRubberBandSelector.cs +++ b/Source/Editor/Gizmo/ViewportRubberBandSelector.cs @@ -74,8 +74,7 @@ public sealed class ViewportRubberBandSelector /// /// Whether the creation can start. /// The current mouse position. - /// The view frustum. - public void TryCreateRubberBand(bool canStart, Float2 mousePosition, BoundingFrustum viewFrustum) + public void TryCreateRubberBand(bool canStart, Float2 mousePosition) { if (_isRubberBandSpanning && !canStart) { @@ -101,32 +100,43 @@ public sealed class ViewportRubberBandSelector _isMosueCaptured = true; _owner.Viewport.StartMouseCapture(); } - UpdateRubberBand(ref viewFrustum); + UpdateRubberBand(); } } } private struct ViewportProjection { - private Viewport _viewport; private Matrix _viewProjection; + private BoundingFrustum _frustum; + private Viewport _viewport; + private Vector3 _origin; public void Init(EditorViewport editorViewport) { // Inline EditorViewport.ProjectPoint to save on calculation for large set of points _viewport = new Viewport(0, 0, editorViewport.Width, editorViewport.Height); - var frustum = editorViewport.ViewFrustum; - _viewProjection = frustum.Matrix; + _frustum = editorViewport.ViewFrustum; + _viewProjection = _frustum.Matrix; + _origin = editorViewport.Task.View.Origin; } - public void ProjectPoint(ref Vector3 worldSpaceLocation, out Float2 viewportSpaceLocation) + public void ProjectPoint(Vector3 worldSpaceLocation, out Float2 viewportSpaceLocation) { + worldSpaceLocation -= _origin; _viewport.Project(ref worldSpaceLocation, ref _viewProjection, out var projected); viewportSpaceLocation = new Float2((float)projected.X, (float)projected.Y); } + + public ContainmentType FrustumCull(ref BoundingBox bounds) + { + bounds.Minimum -= _origin; + bounds.Maximum -= _origin; + return _frustum.Contains(ref bounds); + } } - private void UpdateRubberBand(ref BoundingFrustum viewFrustum) + private void UpdateRubberBand() { Profiler.BeginEvent("UpdateRubberBand"); @@ -169,7 +179,7 @@ public sealed class ViewportRubberBandSelector // Skip actor if outside of view frustum var actorBox = a.EditorBox; - if (viewFrustum.Contains(actorBox) == ContainmentType.Disjoint) + if (projection.FrustumCull(ref actorBox) == ContainmentType.Disjoint) continue; // Get valid selection points @@ -220,7 +230,7 @@ public sealed class ViewportRubberBandSelector bool containsAllPoints = points.Length != 0; for (int i = 0; i < points.Length; i++) { - projection.ProjectPoint(ref points[i], out var loc); + projection.ProjectPoint(points[i], out var loc); if (!adjustedRect.Contains(loc)) { containsAllPoints = false; diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index 3f35b6c63..ad6836f1b 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -612,7 +612,7 @@ namespace FlaxEditor.Viewport // Don't allow rubber band selection when gizmo is controlling mouse, vertex painting mode, or cloth painting is enabled bool canStart = !(IsControllingMouse || IsRightMouseButtonDown || IsAltKeyDown) && Gizmos?.Active is TransformGizmo && !Gizmos.Active.IsControllingMouse; - _rubberBandSelector.TryCreateRubberBand(canStart, _viewMousePos, ViewFrustum); + _rubberBandSelector.TryCreateRubberBand(canStart, _viewMousePos); } /// From a0497a8f603b956940648ab954058a85b204cd93 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 26 Mar 2025 17:15:01 +0100 Subject: [PATCH 12/14] Fix opening game project when engine Large Worlds config gets changed --- Flax.flaxproj | 2 +- Source/Editor/Editor.cpp | 40 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Flax.flaxproj b/Flax.flaxproj index 15b925c0d..77d285c31 100644 --- a/Flax.flaxproj +++ b/Flax.flaxproj @@ -4,7 +4,7 @@ "Major": 1, "Minor": 9, "Revision": 0, - "Build": 6606 + "Build": 6607 }, "Company": "Flax", "Copyright": "Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.", diff --git a/Source/Editor/Editor.cpp b/Source/Editor/Editor.cpp index 3d77445b9..824721592 100644 --- a/Source/Editor/Editor.cpp +++ b/Source/Editor/Editor.cpp @@ -50,30 +50,31 @@ bool Editor::CheckProjectUpgrade() const auto versionFilePath = Globals::ProjectCacheFolder / TEXT("version"); // Load version cache file - int32 lastMajor = FLAXENGINE_VERSION_MAJOR; - int32 lastMinor = FLAXENGINE_VERSION_MINOR; - int32 lastBuild = FLAXENGINE_VERSION_BUILD; + struct VersionCache + { + int32 Major = FLAXENGINE_VERSION_MAJOR; + int32 Minor = FLAXENGINE_VERSION_MINOR; + int32 Build = FLAXENGINE_VERSION_BUILD; + int32 RealSize = sizeof(Real); // Rebuild when changing between Large Worlds + }; + VersionCache lastVersion; if (FileSystem::FileExists(versionFilePath)) { auto file = FileReadStream::Open(versionFilePath); if (file) { - file->ReadInt32(&lastMajor); - file->ReadInt32(&lastMinor); - file->ReadInt32(&lastBuild); + file->ReadBytes(&lastVersion, sizeof(lastVersion)); // Invalidate results if data has issues - if (file->HasError() || lastMajor < 0 || lastMinor < 0 || lastMajor > 100 || lastMinor > 1000) + if (file->HasError() || lastVersion.Major < 0 || lastVersion.Minor < 0 || lastVersion.Major > 100 || lastVersion.Minor > 1000) { - lastMajor = FLAXENGINE_VERSION_MAJOR; - lastMinor = FLAXENGINE_VERSION_MINOR; - lastBuild = FLAXENGINE_VERSION_BUILD; + lastVersion = VersionCache(); LOG(Warning, "Invalid version cache data"); } else { - LOG(Info, "Last project open version: {0}.{1}.{2}", lastMajor, lastMinor, lastBuild); - LastProjectOpenedEngineBuild = lastBuild; + LOG(Info, "Last project open version: {0}.{1}.{2}", lastVersion.Major, lastVersion.Minor, lastVersion.Build); + LastProjectOpenedEngineBuild = lastVersion.Build; } Delete(file); @@ -260,13 +261,13 @@ bool Editor::CheckProjectUpgrade() LOG(Warning, "Project layout upgraded!"); } // Check if last version was the same - else if (lastMajor == FLAXENGINE_VERSION_MAJOR && lastMinor == FLAXENGINE_VERSION_MINOR) + else if (lastVersion.Major == FLAXENGINE_VERSION_MAJOR && lastVersion.Minor == FLAXENGINE_VERSION_MINOR) { // Do nothing IsOldProjectOpened = false; } // Check if last version was older - else if (lastMajor < FLAXENGINE_VERSION_MAJOR || (lastMajor == FLAXENGINE_VERSION_MAJOR && lastMinor < FLAXENGINE_VERSION_MINOR)) + else if (lastVersion.Major < FLAXENGINE_VERSION_MAJOR || (lastVersion.Major == FLAXENGINE_VERSION_MAJOR && lastVersion.Minor < FLAXENGINE_VERSION_MINOR)) { LOG(Warning, "The project was opened with the older editor version last time"); const auto result = MessageBox::Show(TEXT("The project was opened with the older editor version last time. Loading it may modify existing data so older editor version won't open it. Do you want to perform a backup before or cancel operation?"), TEXT("Project upgrade"), MessageBoxButtons::YesNoCancel, MessageBoxIcon::Question); @@ -289,7 +290,7 @@ bool Editor::CheckProjectUpgrade() } } // Check if last version was newer - else if (lastMajor > FLAXENGINE_VERSION_MAJOR || (lastMajor == FLAXENGINE_VERSION_MAJOR && lastMinor > FLAXENGINE_VERSION_MINOR)) + else if (lastVersion.Major > FLAXENGINE_VERSION_MAJOR || (lastVersion.Major == FLAXENGINE_VERSION_MAJOR && lastVersion.Minor > FLAXENGINE_VERSION_MINOR)) { LOG(Warning, "The project was opened with the newer editor version last time"); const auto result = MessageBox::Show(TEXT("The project was opened with the newer editor version last time. Loading it may fail and corrupt existing data. Do you want to perform a backup before or cancel operation?"), TEXT("Project upgrade"), MessageBoxButtons::YesNoCancel, MessageBoxIcon::Warning); @@ -313,7 +314,7 @@ bool Editor::CheckProjectUpgrade() } // When changing between major/minor version clear some caches to prevent possible issues - if (lastMajor != FLAXENGINE_VERSION_MAJOR || lastMinor != FLAXENGINE_VERSION_MINOR) + if (lastVersion.Major != FLAXENGINE_VERSION_MAJOR || lastVersion.Minor != FLAXENGINE_VERSION_MINOR || lastVersion.RealSize != sizeof(Real)) { LOG(Info, "Cleaning cache files from different engine version"); FileSystem::DeleteDirectory(Globals::ProjectFolder / TEXT("Cache/Cooker")); @@ -322,7 +323,7 @@ bool Editor::CheckProjectUpgrade() // Upgrade old 0.7 projects // [Deprecated: 01.11.2020, expires 01.11.2021] - if (lastMajor == 0 && lastMinor == 7 && lastBuild <= 6197) + if (lastVersion.Major == 0 && lastVersion.Minor == 7 && lastVersion.Build <= 6197) { Array files; FileSystem::DirectoryGetFiles(files, Globals::ProjectSourceFolder, TEXT("*.Gen.cs")); @@ -335,9 +336,8 @@ bool Editor::CheckProjectUpgrade() auto file = FileWriteStream::Open(versionFilePath); if (file) { - file->WriteInt32(FLAXENGINE_VERSION_MAJOR); - file->WriteInt32(FLAXENGINE_VERSION_MINOR); - file->WriteInt32(FLAXENGINE_VERSION_BUILD); + lastVersion = VersionCache(); + file->WriteBytes(&lastVersion, sizeof(lastVersion)); Delete(file); } else From 6a4078c589f1737d3885d4d6f71c51cec83a20ff Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 26 Mar 2025 17:26:01 +0100 Subject: [PATCH 13/14] Fix displaying double vectors in Visject constant fields #3314 --- Source/Editor/Surface/Elements/FloatValue.cs | 54 ++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Source/Editor/Surface/Elements/FloatValue.cs b/Source/Editor/Surface/Elements/FloatValue.cs index 71ee26df9..3dfd53758 100644 --- a/Source/Editor/Surface/Elements/FloatValue.cs +++ b/Source/Editor/Surface/Elements/FloatValue.cs @@ -114,6 +114,18 @@ namespace FlaxEditor.Surface.Elements { result = (arch.BoxID == 0 ? asFloat4.X : arch.BoxID == 1 ? asFloat4.Y : arch.BoxID == 2 ? asFloat4.Z : asFloat4.W); } + else if (value is Double2 asDouble2) + { + result = (float)(arch.BoxID == 0 ? asDouble2.X : asDouble2.Y); + } + else if (value is Double3 asDouble3) + { + result = (float)(arch.BoxID == 0 ? asDouble3.X : arch.BoxID == 1 ? asDouble3.Y : asDouble3.Z); + } + else if (value is Double4 asDouble4) + { + result = (float)(arch.BoxID == 0 ? asDouble4.X : arch.BoxID == 1 ? asDouble4.Y : arch.BoxID == 2 ? asDouble4.Z : asDouble4.W); + } else { result = 0; @@ -207,6 +219,36 @@ namespace FlaxEditor.Surface.Elements asFloat4.W = toSet; value = asFloat4; } + else if (value is Double2 asDouble2) + { + if (arch.BoxID == 0) + asDouble2.X = toSet; + else + asDouble2.Y = toSet; + value = asDouble2; + } + else if (value is Double3 asDouble3) + { + if (arch.BoxID == 0) + asDouble3.X = toSet; + else if (arch.BoxID == 1) + asDouble3.Y = toSet; + else + asDouble3.Z = toSet; + value = asDouble3; + } + else if (value is Double4 asDouble4) + { + if (arch.BoxID == 0) + asDouble4.X = toSet; + else if (arch.BoxID == 1) + asDouble4.Y = toSet; + else if (arch.BoxID == 2) + asDouble4.Z = toSet; + else + asDouble4.W = toSet; + value = asDouble4; + } else { value = 0; @@ -264,6 +306,18 @@ namespace FlaxEditor.Surface.Elements { value = new Float4(toSet); } + else if (value is Double2) + { + value = new Double2(toSet); + } + else if (value is Double3) + { + value = new Double3(toSet); + } + else if (value is Double4) + { + value = new Double4(toSet); + } else { value = 0; From faa3f628139ba4127c891d301a3dd20b4f0873c4 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 26 Mar 2025 18:20:09 +0100 Subject: [PATCH 14/14] Fix crash when using different values in various math nodes in Visject #3315 --- Source/Engine/Visject/VisjectGraph.cpp | 29 ++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/Source/Engine/Visject/VisjectGraph.cpp b/Source/Engine/Visject/VisjectGraph.cpp index 7e02f0aa5..dcb6edbfd 100644 --- a/Source/Engine/Visject/VisjectGraph.cpp +++ b/Source/Engine/Visject/VisjectGraph.cpp @@ -230,7 +230,8 @@ void VisjectExecutor::ProcessGroupMath(Box* box, Node* node, Value& value) case VariantType::Double4: value = Double3(v1.AsDouble4()).Length(); break; - default: CRASH; + default: + value = 0.0f; break; } break; @@ -265,7 +266,8 @@ void VisjectExecutor::ProcessGroupMath(Box* box, Node* node, Value& value) case VariantType::Double4: value = Double4(Double3::Normalize(Double3(v1.AsDouble3())), 0.0f); break; - default: CRASH; + default: + value = 0.0f; break; } break; @@ -290,13 +292,25 @@ void VisjectExecutor::ProcessGroupMath(Box* box, Node* node, Value& value) case VariantType::Double3: value = Double3::Cross(v1.AsDouble3(), v2.AsDouble3()); break; - default: CRASH; + default: + value = 0.0f; break; } break; case 19: switch (v1.Type.Type) { + case VariantType::Bool: + case VariantType::Int16: + case VariantType::Uint16: + case VariantType::Int: + case VariantType::Uint: + case VariantType::Int64: + case VariantType::Uint64: + case VariantType::Float: + case VariantType::Double: + value = Math::Abs((float)v1 - (float)v2); + break; case VariantType::Float2: value = Float2::Distance(v1.AsFloat2(), v2.AsFloat2()); break; @@ -316,7 +330,8 @@ void VisjectExecutor::ProcessGroupMath(Box* box, Node* node, Value& value) case VariantType::Double4: value = Double3::Distance((Double3)v1, (Double3)v2); break; - default: CRASH; + default: + value = 0.0f; break; } break; @@ -342,7 +357,8 @@ void VisjectExecutor::ProcessGroupMath(Box* box, Node* node, Value& value) case VariantType::Double4: value = Double3::Dot((Double3)v1, (Double3)v2); break; - default: CRASH; + default: + value = 0.0f; break; } break; @@ -386,7 +402,8 @@ void VisjectExecutor::ProcessGroupMath(Box* box, Node* node, Value& value) case VariantType::Float4: value = Float4(v1.AsFloat4() - 2.0f * v2.AsFloat4() * Float3::Dot((Float3)v1, (Float3)v2)); break; - default: CRASH; + default: + value = 0.0f; break; } break;