From 4af26a5516e345f0fb2324c206104551a155b0c7 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 11 Jul 2025 23:00:53 +0200 Subject: [PATCH] SImplify editor code for actors debug shapes drawing --- Source/Editor/Viewport/MainEditorGizmoViewport.cs | 9 +-------- Source/Editor/Viewport/PrefabWindowViewport.cs | 9 +-------- Source/Editor/ViewportDebugDrawData.cs | 12 ++++++++++++ Source/Editor/Windows/GameWindow.cs | 8 +------- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index 9e7983145..c14b6dfd8 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -374,14 +374,7 @@ namespace FlaxEditor.Viewport // Draw selected objects debug shapes and visuals if (DrawDebugDraw && (renderContext.View.Flags & ViewFlags.DebugDraw) == ViewFlags.DebugDraw) { - unsafe - { - fixed (IntPtr* actors = _debugDrawData.ActorsPtrs) - { - DebugDraw.DrawActors(new IntPtr(actors), _debugDrawData.ActorsCount, true); - } - } - + _debugDrawData.DrawActors(); DebugDraw.Draw(ref renderContext, target.View(), targetDepth.View(), true); } } diff --git a/Source/Editor/Viewport/PrefabWindowViewport.cs b/Source/Editor/Viewport/PrefabWindowViewport.cs index 2efe7c95f..8b508eedf 100644 --- a/Source/Editor/Viewport/PrefabWindowViewport.cs +++ b/Source/Editor/Viewport/PrefabWindowViewport.cs @@ -643,14 +643,7 @@ namespace FlaxEditor.Viewport if (selectedParents[i].IsActiveInHierarchy) selectedParents[i].OnDebugDraw(_debugDrawData); } - - unsafe - { - fixed (IntPtr* actors = _debugDrawData.ActorsPtrs) - { - DebugDraw.DrawActors(new IntPtr(actors), _debugDrawData.ActorsCount, false); - } - } + _debugDrawData.DrawActors(); // Debug draw all actors in prefab and collect actors var view = Task.View; diff --git a/Source/Editor/ViewportDebugDrawData.cs b/Source/Editor/ViewportDebugDrawData.cs index 7913e0287..7b5bee95c 100644 --- a/Source/Editor/ViewportDebugDrawData.cs +++ b/Source/Editor/ViewportDebugDrawData.cs @@ -88,6 +88,18 @@ namespace FlaxEditor } } + /// + /// Draws the collected actors via . + /// + /// True if draw all loaded scenes too, otherwise will draw only provided actors. + public unsafe void DrawActors(bool drawScenes = false) + { + fixed (IntPtr* actors = ActorsPtrs) + { + DebugDraw.DrawActors(new IntPtr(actors), _actors.Count, drawScenes); + } + } + /// /// Called when task calls event. /// diff --git a/Source/Editor/Windows/GameWindow.cs b/Source/Editor/Windows/GameWindow.cs index e05f0d2db..acb2deda3 100644 --- a/Source/Editor/Windows/GameWindow.cs +++ b/Source/Editor/Windows/GameWindow.cs @@ -510,13 +510,7 @@ namespace FlaxEditor.Windows selectedParents[i].OnDebugDraw(drawDebugData); } } - unsafe - { - fixed (IntPtr* actors = drawDebugData.ActorsPtrs) - { - DebugDraw.DrawActors(new IntPtr(actors), drawDebugData.ActorsCount, true); - } - } + drawDebugData.DrawActors(true); } DebugDraw.Draw(ref renderContext, task.OutputView);