From 283ee2af6fb39601dcd8a13cad63e294ebedd8ce Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Tue, 15 Oct 2024 18:55:03 +0200 Subject: [PATCH] add debug draw clear method --- Source/Engine/Debug/DebugDraw.cpp | 4 ++++ Source/Engine/Debug/DebugDraw.h | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp index 2ae7756da..dccfcc206 100644 --- a/Source/Engine/Debug/DebugDraw.cpp +++ b/Source/Engine/Debug/DebugDraw.cpp @@ -2145,4 +2145,8 @@ void DebugDraw::DrawText(const StringView& text, const Transform& transform, con t.TimeLeft = duration; } +void DebugDraw::Clear(void* context) +{ + DebugDraw::UpdateContext(nullptr, MAX_float); +} #endif diff --git a/Source/Engine/Debug/DebugDraw.h b/Source/Engine/Debug/DebugDraw.h index 9c58aa727..bb5cf2e50 100644 --- a/Source/Engine/Debug/DebugDraw.h +++ b/Source/Engine/Debug/DebugDraw.h @@ -689,6 +689,12 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw /// The font size. /// The duration (in seconds). Use 0 to draw it only once. API_FUNCTION() static void DrawText(const StringView& text, const Transform& transform, const Color& color = Color::White, int32 size = 32, float duration = 0.0f); + + /// + /// Clear all debug draw displayed on sceen. + /// + /// + API_FUNCTION() static void Clear(void* context = nullptr); }; #define DEBUG_DRAW_AXIS_FROM_DIRECTION(origin, direction, size, duration, depthTest) DebugDraw::DrawAxisFromDirection(origin, direction, size, duration, depthTest); @@ -721,6 +727,7 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw #define DEBUG_DRAW_WIRE_ARC(position, orientation, radius, angle, color, duration, depthTest) DebugDraw::DrawWireArc(position, orientation, radius, angle, color, duration, depthTest) #define DEBUG_DRAW_WIRE_ARROW(position, orientation, scale, capScale, color, duration, depthTest) DebugDraw::DrawWireArrow(position, orientation, scale, capScale, color, duration, depthTest) #define DEBUG_DRAW_TEXT(text, position, color, size, duration) DebugDraw::DrawText(text, position, color, size, duration) +#define DEBUG_DRAW_CLEAR(context) DebugDraw::Clear(context) #else @@ -753,5 +760,6 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw #define DEBUG_DRAW_WIRE_ARC(position, orientation, radius, angle, color, duration, depthTest) #define DEBUG_DRAW_WIRE_ARROW(position, orientation, scale, capScale, color, duration, depthTest) #define DEBUG_DRAW_TEXT(text, position, color, size, duration) +#define DEBUG_DRAW_CLEAR(context) #endif