diff --git a/Source/Editor/Viewport/PrefabWindowViewport.cs b/Source/Editor/Viewport/PrefabWindowViewport.cs index ceba98073..fb5e74d4d 100644 --- a/Source/Editor/Viewport/PrefabWindowViewport.cs +++ b/Source/Editor/Viewport/PrefabWindowViewport.cs @@ -627,8 +627,8 @@ namespace FlaxEditor.Viewport } // Debug draw all actors in prefab and collect actors - var viewFlags = Task.ViewFlags; - var collectActors = (viewFlags & ViewFlags.PhysicsDebug) != 0 || (viewFlags & ViewFlags.LightsDebug) != 0; + var view = Task.View; + var collectActors = (view.Flags & ViewFlags.PhysicsDebug) != 0 || view.Mode == ViewMode.PhysicsColliders || (view.Flags & ViewFlags.LightsDebug) != 0; _debugDrawActors.Clear(); foreach (var child in SceneGraphRoot.ChildNodes) { @@ -641,19 +641,17 @@ namespace FlaxEditor.Viewport } // Draw physics debug - if ((viewFlags & ViewFlags.PhysicsDebug) != 0) + if ((view.Flags & ViewFlags.PhysicsDebug) != 0 || view.Mode == ViewMode.PhysicsColliders) { foreach (var actor in _debugDrawActors) { if (actor is Collider c && c.IsActiveInHierarchy) - { DebugDraw.DrawColliderDebugPhysics(c, renderContext.View); - } } } // Draw lights debug - if ((viewFlags & ViewFlags.LightsDebug) != 0) + if ((view.Flags & ViewFlags.LightsDebug) != 0) { foreach (var actor in _debugDrawActors) { diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp index 2f20ae158..0e23040a4 100644 --- a/Source/Engine/Debug/DebugDraw.cpp +++ b/Source/Engine/Debug/DebugDraw.cpp @@ -788,7 +788,7 @@ void DebugDraw::Draw(RenderContext& renderContext, GPUTextureView* target, GPUTe Matrix vp; Matrix::Multiply(view.View, view.Projection, vp); Matrix::Transpose(vp, data.ViewProjection); - data.ClipPosZBias = -0.2f; // Reduce Z-fighting artifacts (eg. editor grid) + data.ClipPosZBias = view.IsPerspectiveProjection() ? -0.2f : 0.0f; // Reduce Z-fighting artifacts (eg. editor grid) data.EnableDepthTest = enableDepthTest; context->UpdateCB(cb, &data); context->BindCB(0, cb); @@ -953,11 +953,11 @@ void DebugDraw::DrawActorsTree(Actor* actor) } #if USE_EDITOR + void DebugDraw::DrawColliderDebugPhysics(Collider* collider, RenderView& view) { if (!collider) return; - collider->DrawPhysicsDebug(view); } @@ -965,10 +965,11 @@ 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()); diff --git a/Source/Engine/Debug/DebugDraw.h b/Source/Engine/Debug/DebugDraw.h index 13b556b1b..97788431d 100644 --- a/Source/Engine/Debug/DebugDraw.h +++ b/Source/Engine/Debug/DebugDraw.h @@ -75,6 +75,7 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw /// /// The actor to start drawing at. API_FUNCTION() static void DrawActorsTree(Actor* actor); + #if USE_EDITOR /// /// Draws the physics debug shapes for the given collider. Editor Only @@ -90,6 +91,7 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw /// The render view to draw in. API_FUNCTION() static void DrawLightDebug(Light* light, RenderView& view); #endif + /// /// Draws the lines axis from direction. ///