Add physics and lights debug drawing in prefabs when enabled.

This commit is contained in:
Chandler Cox
2024-08-06 17:06:23 -05:00
parent 0b03a5da0d
commit 3140865780
4 changed files with 69 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ using FlaxEditor.Viewport.Previews;
using FlaxEditor.Windows.Assets;
using FlaxEngine;
using FlaxEngine.GUI;
using Utils = FlaxEditor.Utilities.Utils;
namespace FlaxEditor.Viewport
{
@@ -624,12 +625,37 @@ namespace FlaxEditor.Viewport
}
}
// Debug draw all actors in prefab
// Debug draw all actors in prefab and collect actors
List<Actor> pActors = new List<Actor>();
foreach (var child in SceneGraphRoot.ChildNodes)
{
if (child is not ActorNode actorNode)
continue;
DebugDraw.DrawActorsTree(actorNode.Actor);
var actor = actorNode.Actor;
Utils.GetActorsTree(pActors, actor);
DebugDraw.DrawActorsTree(actor);
}
// Draw physics debug
if ((Task.ViewFlags & ViewFlags.PhysicsDebug) != 0)
{
foreach (var actor in pActors)
{
if (actor is Collider c && c.IsActiveInHierarchy)
{
DebugDraw.DrawColliderDebugPhysics(c, renderContext.View);
}
}
}
// Draw lights debug
if ((Task.ViewFlags & ViewFlags.LightsDebug) != 0)
{
foreach (var actor in pActors)
{
if (actor is Light l && l.IsActiveInHierarchy)
DebugDraw.DrawLightDebug(l, renderContext.View);
}
}
}
}