diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp index e4d53fcb5..1552da6be 100644 --- a/Source/Engine/Debug/DebugDraw.cpp +++ b/Source/Engine/Debug/DebugDraw.cpp @@ -938,6 +938,26 @@ void DebugDraw::DrawLine(const Vector3& start, const Vector3& end, const Color& } } +void DebugDraw::DrawLine(const Vector3& start, const Vector3& end, const Color& startColor, const Color& endColor, float duration, bool depthTest) +{ + const Float3 startF = start - Context->Origin, endF = end - Context->Origin; + auto& debugDrawData = depthTest ? Context->DebugDrawDepthTest : Context->DebugDrawDefault; + if (duration > 0) + { + // TODO: separate start/end colors for persistent lines + DebugLine l = { startF, endF, Color32(startColor), duration }; + debugDrawData.DefaultLines.Add(l); + } + else + { + Vertex l = { startF, Color32(startColor) }; + debugDrawData.OneFrameLines.Add(l); + l.Position = endF; + l.Color = Color32(endColor); + debugDrawData.OneFrameLines.Add(l); + } +} + void DebugDraw::DrawLines(const Span& lines, const Matrix& transform, const Color& color, float duration, bool depthTest) { if (lines.Length() == 0) diff --git a/Source/Engine/Debug/DebugDraw.h b/Source/Engine/Debug/DebugDraw.h index 8cc5452ed..090752781 100644 --- a/Source/Engine/Debug/DebugDraw.h +++ b/Source/Engine/Debug/DebugDraw.h @@ -79,6 +79,17 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw /// If set to true depth test will be performed, otherwise depth will be ignored. API_FUNCTION() static void DrawLine(const Vector3& start, const Vector3& end, const Color& color, float duration = 0.0f, bool depthTest = true); + /// + /// Draws the line. + /// + /// The start point. + /// The end point. + /// The color of the start point. + /// The color of the end point. + /// The duration (in seconds). Use 0 to draw it only once. + /// If set to true depth test will be performed, otherwise depth will be ignored. + API_FUNCTION() static void DrawLine(const Vector3& start, const Vector3& end, const Color& startColor, const Color& endColor, float duration = 0.0f, bool depthTest = true); + /// /// Draws the lines. Line positions are located one after another (e.g. l0.start, l0.end, l1.start, l1.end,...). ///