Fix DrawSceneDepth to properly draw scene objects when custom actors list is empty

#1253
This commit is contained in:
Wojtek Figat
2023-07-18 10:16:11 +02:00
parent a535c701e5
commit 488958ce44
2 changed files with 17 additions and 5 deletions

View File

@@ -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);

View File

@@ -17,10 +17,13 @@ namespace FlaxEngine
[Unmanaged]
public static void DrawSceneDepth(GPUContext context, SceneRenderTask task, GPUTexture output, List<Actor> 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<Actor> 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);
}
}
}