From 868db7c84890c15e8be07663432c913ebb301ca8 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Sat, 15 Jul 2023 13:52:10 -0500 Subject: [PATCH 1/4] Add functionality to combine similar logs into a log with a count. --- Source/Editor/Windows/DebugLogWindow.cs | 34 ++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Windows/DebugLogWindow.cs b/Source/Editor/Windows/DebugLogWindow.cs index b02f63f87..81dcaae92 100644 --- a/Source/Editor/Windows/DebugLogWindow.cs +++ b/Source/Editor/Windows/DebugLogWindow.cs @@ -80,6 +80,7 @@ namespace FlaxEditor.Windows public LogGroup Group; public LogEntryDescription Desc; public SpriteHandle Icon; + public int LogCount = 1; public LogEntry(DebugLogWindow window, ref LogEntryDescription desc) : base(0, 0, 120, DefaultHeight) @@ -137,7 +138,12 @@ namespace FlaxEditor.Windows // Title var textRect = new Rectangle(38, 2, clientRect.Width - 40, clientRect.Height - 10); Render2D.PushClip(ref clientRect); - Render2D.DrawText(style.FontMedium, Desc.Title, textRect, style.Foreground); + string countText = string.Empty; + if (LogCount > 1) + { + countText = $" ({LogCount})"; + } + Render2D.DrawText(style.FontMedium, Desc.Title + countText, textRect, style.Foreground); Render2D.PopClip(); } @@ -289,6 +295,7 @@ namespace FlaxEditor.Windows private readonly List _pendingEntries = new List(32); private readonly ToolStripButton _clearOnPlayButton; + private readonly ToolStripButton _collapseLogsButton; private readonly ToolStripButton _pauseOnErrorButton; private readonly ToolStripButton[] _groupButtons = new ToolStripButton[3]; @@ -316,6 +323,7 @@ namespace FlaxEditor.Windows }; toolstrip.AddButton("Clear", Clear).LinkTooltip("Clears all log entries"); _clearOnPlayButton = (ToolStripButton)toolstrip.AddButton("Clear on Play").SetAutoCheck(true).SetChecked(true).LinkTooltip("Clears all log entries on enter playmode"); + _collapseLogsButton = (ToolStripButton)toolstrip.AddButton("Collapse").SetAutoCheck(true).SetChecked(true).LinkTooltip("Collapses similar logs."); _pauseOnErrorButton = (ToolStripButton)toolstrip.AddButton("Pause on Error").SetAutoCheck(true).LinkTooltip("Performs auto pause on error"); toolstrip.AddSeparator(); _groupButtons[0] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Error32, () => UpdateLogTypeVisibility(LogGroup.Error, _groupButtons[0].Checked)).SetAutoCheck(true).SetChecked(true).LinkTooltip("Shows/hides error messages"); @@ -612,6 +620,30 @@ namespace FlaxEditor.Windows var top = _entriesPanel.Children.Count != 0 ? _entriesPanel.Children[_entriesPanel.Children.Count - 1].Bottom + spacing : margin.Top; for (int i = 0; i < _pendingEntries.Count; i++) { + if (_collapseLogsButton.Checked) + { + bool logExists = false; + foreach (var child in _entriesPanel.Children) + { + if (child is LogEntry entry) + { + var pendingEntry = _pendingEntries[i]; + if (string.Equals(entry.Desc.Title, pendingEntry.Desc.Title) && + string.Equals(entry.Desc.LocationFile, pendingEntry.Desc.LocationFile) && + entry.Desc.Level == pendingEntry.Desc.Level && + string.Equals(entry.Desc.Description, pendingEntry.Desc.Description) && + entry.Desc.LocationLine == pendingEntry.Desc.LocationLine) + { + entry.LogCount += 1; + newEntry = entry; + logExists = true; + break; + } + } + } + if (logExists) + continue; + } newEntry = _pendingEntries[i]; newEntry.Visible = _groupButtons[(int)newEntry.Group].Checked; anyVisible |= newEntry.Visible; From be079b9b67f7c5c9b63ba8189ca4ccc8ce2e2ca4 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Tue, 18 Jul 2023 09:51:21 -0500 Subject: [PATCH 2/4] Improvements to debug log count. --- Source/Editor/Windows/DebugLogWindow.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Source/Editor/Windows/DebugLogWindow.cs b/Source/Editor/Windows/DebugLogWindow.cs index 81dcaae92..49b03ede1 100644 --- a/Source/Editor/Windows/DebugLogWindow.cs +++ b/Source/Editor/Windows/DebugLogWindow.cs @@ -138,12 +138,14 @@ namespace FlaxEditor.Windows // Title var textRect = new Rectangle(38, 2, clientRect.Width - 40, clientRect.Height - 10); Render2D.PushClip(ref clientRect); - string countText = string.Empty; - if (LogCount > 1) + if (LogCount == 1) { - countText = $" ({LogCount})"; + Render2D.DrawText(style.FontMedium, Desc.Title, textRect, style.Foreground); + } + else if (LogCount > 1) + { + Render2D.DrawText(style.FontMedium, $"{Desc.Title} ({LogCount})", textRect, style.Foreground); } - Render2D.DrawText(style.FontMedium, Desc.Title + countText, textRect, style.Foreground); Render2D.PopClip(); } @@ -628,10 +630,10 @@ namespace FlaxEditor.Windows if (child is LogEntry entry) { var pendingEntry = _pendingEntries[i]; - if (string.Equals(entry.Desc.Title, pendingEntry.Desc.Title) && - string.Equals(entry.Desc.LocationFile, pendingEntry.Desc.LocationFile) && + if (string.Equals(entry.Desc.Title, pendingEntry.Desc.Title, StringComparison.Ordinal) && + string.Equals(entry.Desc.LocationFile, pendingEntry.Desc.LocationFile, StringComparison.Ordinal) && entry.Desc.Level == pendingEntry.Desc.Level && - string.Equals(entry.Desc.Description, pendingEntry.Desc.Description) && + string.Equals(entry.Desc.Description, pendingEntry.Desc.Description, StringComparison.Ordinal) && entry.Desc.LocationLine == pendingEntry.Desc.LocationLine) { entry.LogCount += 1; From 872509df2a099b0cea4c1cd7c6d3f5827adbf6b2 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 18 Jul 2023 18:13:19 +0200 Subject: [PATCH 3/4] Fix incorrect `Transform Position To Screen UV` in particles graph in CPU code path --- .../Particles/Graph/CPU/ParticleEmitterGraph.CPU.Particles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.Particles.cpp b/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.Particles.cpp index 649d01d85..9ef996869 100644 --- a/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.Particles.cpp +++ b/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.Particles.cpp @@ -189,7 +189,7 @@ void ParticleEmitterGraphCPUExecutor::ProcessGroupTools(Box* box, Node* node, Va const Matrix viewProjection = context.ViewTask ? context.ViewTask->View.PrevViewProjection : Matrix::Identity; const Float3 position = (Float3)TryGetValue(node->GetBox(0), Value::Zero); Float4 projPos; - Float3::Transform(position, viewProjection); + Float3::Transform(position, viewProjection, projPos); projPos /= projPos.W; value = Float2(projPos.X * 0.5f + 0.5f, projPos.Y * 0.5f + 0.5f); break; From b2b10ce7da7f3ac47e8f5688bb2693e1a3d7a8c4 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 18 Jul 2023 18:20:11 +0200 Subject: [PATCH 4/4] Fix various core types to be trivially constructible as properly POD-type --- Source/Editor/Tools/Foliage/FoliageTools.cpp | 1 - Source/Engine/Core/Math/BoundingBox.h | 4 +--- Source/Engine/Core/Math/BoundingFrustum.h | 4 +--- Source/Engine/Core/Math/BoundingSphere.h | 4 +--- Source/Engine/Core/Math/Color.h | 4 +--- Source/Engine/Core/Math/Color32.h | 4 +--- Source/Engine/Core/Math/Half.h | 12 +++--------- Source/Engine/Core/Math/Matrix.h | 4 +--- Source/Engine/Core/Math/Matrix3x3.h | 4 +--- Source/Engine/Core/Math/Plane.h | 4 +--- Source/Engine/Core/Math/Quaternion.h | 4 +--- Source/Engine/Core/Math/Ray.h | 4 +--- Source/Engine/Core/Math/Rectangle.h | 4 +--- Source/Engine/Core/Math/Transform.h | 4 +--- Source/Engine/Core/Math/Triangle.h | 4 +--- Source/Engine/Core/Math/Vector2.h | 4 +--- Source/Engine/Core/Math/Vector3.h | 4 +--- Source/Engine/Core/Math/Vector4.h | 4 +--- Source/Engine/Core/Math/Viewport.h | 4 +--- 19 files changed, 20 insertions(+), 61 deletions(-) diff --git a/Source/Editor/Tools/Foliage/FoliageTools.cpp b/Source/Editor/Tools/Foliage/FoliageTools.cpp index b24bcdf00..7d0de7d41 100644 --- a/Source/Editor/Tools/Foliage/FoliageTools.cpp +++ b/Source/Editor/Tools/Foliage/FoliageTools.cpp @@ -292,7 +292,6 @@ void FoliageTools::Paint(Foliage* foliage, Span foliageTypesIndices, cons { PROFILE_CPU_NAMED("Place Instances"); - Matrix matrix; FoliageInstance instance; Quaternion tmp; Matrix world; diff --git a/Source/Engine/Core/Math/BoundingBox.h b/Source/Engine/Core/Math/BoundingBox.h index 0ee4fc1a9..d06ef0b3f 100644 --- a/Source/Engine/Core/Math/BoundingBox.h +++ b/Source/Engine/Core/Math/BoundingBox.h @@ -38,9 +38,7 @@ public: /// /// Empty constructor. /// - BoundingBox() - { - } + BoundingBox() = default; /// /// Initializes a new instance of the struct. diff --git a/Source/Engine/Core/Math/BoundingFrustum.h b/Source/Engine/Core/Math/BoundingFrustum.h index 287d33c2f..1502b6302 100644 --- a/Source/Engine/Core/Math/BoundingFrustum.h +++ b/Source/Engine/Core/Math/BoundingFrustum.h @@ -34,9 +34,7 @@ public: /// /// Empty constructor. /// - BoundingFrustum() - { - } + BoundingFrustum() = default; /// /// Initializes a new instance of the struct. diff --git a/Source/Engine/Core/Math/BoundingSphere.h b/Source/Engine/Core/Math/BoundingSphere.h index 08f5df7f1..da303e8d5 100644 --- a/Source/Engine/Core/Math/BoundingSphere.h +++ b/Source/Engine/Core/Math/BoundingSphere.h @@ -34,9 +34,7 @@ public: /// /// Empty constructor. /// - BoundingSphere() - { - } + BoundingSphere() = default; /// /// Initializes a new instance of the struct. diff --git a/Source/Engine/Core/Math/Color.h b/Source/Engine/Core/Math/Color.h index 997ed9c17..af93fc0f2 100644 --- a/Source/Engine/Core/Math/Color.h +++ b/Source/Engine/Core/Math/Color.h @@ -50,9 +50,7 @@ public: /// /// Empty constructor. /// - Color() - { - } + Color() = default; /// /// Initializes a new instance of the struct. diff --git a/Source/Engine/Core/Math/Color32.h b/Source/Engine/Core/Math/Color32.h index 36da3d41d..6c2b9648d 100644 --- a/Source/Engine/Core/Math/Color32.h +++ b/Source/Engine/Core/Math/Color32.h @@ -53,9 +53,7 @@ public: /// /// Empty constructor. /// - Color32() - { - } + Color32() = default; /// /// Constructs a new Color32 with given r, g, b, a components. diff --git a/Source/Engine/Core/Math/Half.h b/Source/Engine/Core/Math/Half.h index 06b03895d..346b5d6b3 100644 --- a/Source/Engine/Core/Math/Half.h +++ b/Source/Engine/Core/Math/Half.h @@ -121,9 +121,7 @@ public: /// /// Default constructor /// - Half2() - { - } + Half2() = default; /// /// Init @@ -185,9 +183,7 @@ public: Half Z; public: - Half3() - { - } + Half3() = default; Half3(Half x, Half y, Half z) : X(x) @@ -242,9 +238,7 @@ public: Half W; public: - Half4() - { - } + Half4() = default; Half4(Half x, Half y, Half z, Half w) : X(x) diff --git a/Source/Engine/Core/Math/Matrix.h b/Source/Engine/Core/Math/Matrix.h index 7d6d57bac..aed2ead8d 100644 --- a/Source/Engine/Core/Math/Matrix.h +++ b/Source/Engine/Core/Math/Matrix.h @@ -83,9 +83,7 @@ public: /// /// Empty constructor. /// - Matrix() - { - } + Matrix() = default; /// /// Initializes a new instance of the struct. diff --git a/Source/Engine/Core/Math/Matrix3x3.h b/Source/Engine/Core/Math/Matrix3x3.h index 1e29be85a..344f68455 100644 --- a/Source/Engine/Core/Math/Matrix3x3.h +++ b/Source/Engine/Core/Math/Matrix3x3.h @@ -63,9 +63,7 @@ public: /// /// Empty constructor. /// - Matrix3x3() - { - } + Matrix3x3() = default; /// /// Initializes a new instance of the struct. diff --git a/Source/Engine/Core/Math/Plane.h b/Source/Engine/Core/Math/Plane.h index 57a2be344..8c3d4129b 100644 --- a/Source/Engine/Core/Math/Plane.h +++ b/Source/Engine/Core/Math/Plane.h @@ -30,9 +30,7 @@ public: /// /// Empty constructor. /// - Plane() - { - } + Plane() = default; /// /// Init diff --git a/Source/Engine/Core/Math/Quaternion.h b/Source/Engine/Core/Math/Quaternion.h index 5b164f979..e6425f7ab 100644 --- a/Source/Engine/Core/Math/Quaternion.h +++ b/Source/Engine/Core/Math/Quaternion.h @@ -67,9 +67,7 @@ public: /// /// Empty constructor. /// - Quaternion() - { - } + Quaternion() = default; /// /// Init diff --git a/Source/Engine/Core/Math/Ray.h b/Source/Engine/Core/Math/Ray.h index c8486f39e..f2f9081e5 100644 --- a/Source/Engine/Core/Math/Ray.h +++ b/Source/Engine/Core/Math/Ray.h @@ -35,9 +35,7 @@ public: /// /// Empty constructor. /// - Ray() - { - } + Ray() = default; /// /// Initializes a new instance of the struct. diff --git a/Source/Engine/Core/Math/Rectangle.h b/Source/Engine/Core/Math/Rectangle.h index c59905fd6..bf282b6e3 100644 --- a/Source/Engine/Core/Math/Rectangle.h +++ b/Source/Engine/Core/Math/Rectangle.h @@ -31,9 +31,7 @@ public: /// /// Empty constructor. /// - Rectangle() - { - } + Rectangle() = default; // Init // @param x Rectangle location X coordinate diff --git a/Source/Engine/Core/Math/Transform.h b/Source/Engine/Core/Math/Transform.h index ef644f08a..1079b4c23 100644 --- a/Source/Engine/Core/Math/Transform.h +++ b/Source/Engine/Core/Math/Transform.h @@ -40,9 +40,7 @@ public: /// /// Empty constructor. /// - Transform() - { - } + Transform() = default; /// /// Initializes a new instance of the struct. diff --git a/Source/Engine/Core/Math/Triangle.h b/Source/Engine/Core/Math/Triangle.h index a92919cfc..63f0e34ec 100644 --- a/Source/Engine/Core/Math/Triangle.h +++ b/Source/Engine/Core/Math/Triangle.h @@ -30,9 +30,7 @@ public: /// /// Empty constructor. /// - Triangle() - { - } + Triangle() = default; /// /// Initializes a new instance of the struct. diff --git a/Source/Engine/Core/Math/Vector2.h b/Source/Engine/Core/Math/Vector2.h index 87ced1de6..83deb009a 100644 --- a/Source/Engine/Core/Math/Vector2.h +++ b/Source/Engine/Core/Math/Vector2.h @@ -60,9 +60,7 @@ public: /// /// Empty constructor. /// - Vector2Base() - { - } + Vector2Base() = default; FORCE_INLINE Vector2Base(T xy) : X(xy) diff --git a/Source/Engine/Core/Math/Vector3.h b/Source/Engine/Core/Math/Vector3.h index 33be7f2d6..cad5250b7 100644 --- a/Source/Engine/Core/Math/Vector3.h +++ b/Source/Engine/Core/Math/Vector3.h @@ -89,9 +89,7 @@ public: /// /// Empty constructor. /// - Vector3Base() - { - } + Vector3Base() = default; FORCE_INLINE Vector3Base(T xyz) : X(xyz) diff --git a/Source/Engine/Core/Math/Vector4.h b/Source/Engine/Core/Math/Vector4.h index 213f05815..5c7b24c4a 100644 --- a/Source/Engine/Core/Math/Vector4.h +++ b/Source/Engine/Core/Math/Vector4.h @@ -76,9 +76,7 @@ public: /// /// Empty constructor. /// - Vector4Base() - { - } + Vector4Base() = default; FORCE_INLINE Vector4Base(T xyzw) : X(xyzw) diff --git a/Source/Engine/Core/Math/Viewport.h b/Source/Engine/Core/Math/Viewport.h index bb4ec8f8b..d478eb7cc 100644 --- a/Source/Engine/Core/Math/Viewport.h +++ b/Source/Engine/Core/Math/Viewport.h @@ -52,9 +52,7 @@ public: /// /// Empty constructor. /// - Viewport() - { - } + Viewport() = default; // Init // @param x The x coordinate of the upper-left corner of the viewport in pixels