Merge branch 'Tryibion-prefab-physics-draw'
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "Engine/Render2D/FontAsset.h"
|
||||
#if USE_EDITOR
|
||||
#include "Editor/Editor.h"
|
||||
#include "Engine/Level/Actors/Light.h"
|
||||
#include "Engine/Physics/Colliders/Collider.h"
|
||||
#endif
|
||||
|
||||
// Debug draw service configuration
|
||||
@@ -950,6 +952,23 @@ void DebugDraw::DrawActorsTree(Actor* actor)
|
||||
actor->TreeExecute(function);
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
void DebugDraw::DrawColliderDebugPhysics(Collider* collider, RenderView& view)
|
||||
{
|
||||
if (!collider)
|
||||
return;
|
||||
|
||||
collider->DrawPhysicsDebug(view);
|
||||
}
|
||||
|
||||
void DebugDraw::DrawLightDebug(Light* light, RenderView& view)
|
||||
{
|
||||
if (!light)
|
||||
return;
|
||||
|
||||
light->DrawLightsDebug(view);
|
||||
}
|
||||
#endif
|
||||
void DebugDraw::DrawAxisFromDirection(const Vector3& origin, const Vector3& direction, float size, float duration, bool depthTest)
|
||||
{
|
||||
CHECK_DEBUG(direction.IsNormalized());
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "Engine/Core/Math/Color.h"
|
||||
#include "Engine/Core/Types/Span.h"
|
||||
|
||||
struct RenderView;
|
||||
class Collider;
|
||||
class Light;
|
||||
struct RenderContext;
|
||||
class GPUTextureView;
|
||||
class GPUContext;
|
||||
@@ -70,9 +73,23 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
|
||||
/// <summary>
|
||||
/// Draws the debug shapes for the given actor and the actor's children
|
||||
/// </summary>
|
||||
/// /// <param name="actor">The actor to start drawing at.</param>
|
||||
/// <param name="actor">The actor to start drawing at.</param>
|
||||
API_FUNCTION() static void DrawActorsTree(Actor* actor);
|
||||
#if USE_EDITOR
|
||||
/// <summary>
|
||||
/// Draws the physics debug shapes for the given collider. Editor Only
|
||||
/// </summary>
|
||||
/// <param name="collider">The collider to draw.</param>
|
||||
/// <param name="view">The render view to draw in.</param>
|
||||
API_FUNCTION() static void DrawColliderDebugPhysics(Collider* collider, RenderView& view);
|
||||
|
||||
/// <summary>
|
||||
/// Draws the light debug shapes for the given light. Editor Only
|
||||
/// </summary>
|
||||
/// <param name="light">The light debug to draw.</param>
|
||||
/// <param name="view">The render view to draw in.</param>
|
||||
API_FUNCTION() static void DrawLightDebug(Light* light, RenderView& view);
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Draws the lines axis from direction.
|
||||
/// </summary>
|
||||
|
||||
@@ -154,10 +154,6 @@ protected:
|
||||
/// </summary>
|
||||
void RemoveStaticActor();
|
||||
|
||||
#if USE_EDITOR
|
||||
virtual void DrawPhysicsDebug(RenderView& view);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void OnMaterialChanged();
|
||||
|
||||
@@ -169,6 +165,10 @@ public:
|
||||
void ClosestPoint(const Vector3& point, Vector3& result) const final;
|
||||
bool ContainsPoint(const Vector3& point) const final;
|
||||
|
||||
#if USE_EDITOR
|
||||
virtual void DrawPhysicsDebug(RenderView& view);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// [PhysicsColliderActor]
|
||||
void OnEnable() override;
|
||||
|
||||
Reference in New Issue
Block a user