From 488958ce44b2d7cff21b7edaa9ddbb0e3dd7d3da Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 18 Jul 2023 10:16:11 +0200 Subject: [PATCH] Fix `DrawSceneDepth` to properly draw scene objects when custom actors list is empty #1253 --- Source/Editor/Gizmo/SelectionOutline.cs | 2 ++ Source/Engine/Renderer/Renderer.cs | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Source/Editor/Gizmo/SelectionOutline.cs b/Source/Editor/Gizmo/SelectionOutline.cs index ccc4bdd27..1374c7247 100644 --- a/Source/Editor/Gizmo/SelectionOutline.cs +++ b/Source/Editor/Gizmo/SelectionOutline.cs @@ -178,6 +178,8 @@ namespace FlaxEditor.Gizmo if (selection[i] is ActorNode actorNode && actorNode.Actor != null) CollectActors(actorNode.Actor); } + if (_actors.Count == 0) + return; // Render selected objects depth Renderer.DrawSceneDepth(context, task, customDepth, _actors); diff --git a/Source/Engine/Renderer/Renderer.cs b/Source/Engine/Renderer/Renderer.cs index bfb81a84c..71dca424b 100644 --- a/Source/Engine/Renderer/Renderer.cs +++ b/Source/Engine/Renderer/Renderer.cs @@ -17,10 +17,13 @@ namespace FlaxEngine [Unmanaged] public static void DrawSceneDepth(GPUContext context, SceneRenderTask task, GPUTexture output, List customActors) { - if (customActors.Count == 0) - return; - var temp = CollectionsMarshal.AsSpan(customActors).ToArray(); // FIXME - var tempCount = temp.Length; + Actor[] temp = null; + int tempCount = 0; + if (customActors != null && customActors.Count != 0) + { + temp = CollectionsMarshal.AsSpan(customActors).ToArray(); // FIXME + tempCount = temp.Length; + } Internal_DrawSceneDepth(FlaxEngine.Object.GetUnmanagedPtr(context), FlaxEngine.Object.GetUnmanagedPtr(task), FlaxEngine.Object.GetUnmanagedPtr(output), temp, ref tempCount); } @@ -32,7 +35,14 @@ namespace FlaxEngine [Unmanaged] public static void DrawActors(ref RenderContext renderContext, List customActors) { - DrawActors(ref renderContext, Utils.ExtractArrayFromList(customActors)); + Actor[] temp = null; + int tempCount = 0; + if (customActors != null && customActors.Count != 0) + { + temp = CollectionsMarshal.AsSpan(customActors).ToArray(); // FIXME + tempCount = temp.Length; + } + Internal_DrawActors(ref renderContext, temp, ref tempCount); } } }