Skip to content

Commit

Permalink
added DebugDraw::clear_texts method
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Dec 2, 2023
1 parent 76a8479 commit 54410d0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
16 changes: 12 additions & 4 deletions src/2d/debug_draw_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void DebugDraw2D::_bind_methods() {
ClassDB::bind_method(D_METHOD(NAMEOF(begin_text_group), "group_title", "group_priority", "group_color", "show_title", "title_size", "text_size"), &DebugDraw2D::begin_text_group, 0, Colors::empty_color, true, -1, -1);
ClassDB::bind_method(D_METHOD(NAMEOF(end_text_group)), &DebugDraw2D::end_text_group);
ClassDB::bind_method(D_METHOD(NAMEOF(set_text), "key", "value", "priority", "color_of_value", "duration"), &DebugDraw2D::set_text, Variant(), 0, Colors::empty_color, -1.0);
ClassDB::bind_method(D_METHOD(NAMEOF(clear_texts)), &DebugDraw2D::clear_texts);

ClassDB::bind_method(D_METHOD(NAMEOF(create_graph), "title"), &DebugDraw2D::create_graph);
ClassDB::bind_method(D_METHOD(NAMEOF(create_fps_graph), "title"), &DebugDraw2D::create_fps_graph);
Expand Down Expand Up @@ -141,7 +142,8 @@ void DebugDraw2D::_finish_frame_and_update() {

// reset some values
_canvas_need_update = false;
grouped_text->end_text_group();
if (grouped_text)
grouped_text->end_text_group();
} else {
#ifdef TRACY_ENABLE
if (DebugDraw2D_frame_mark_2d_started) {
Expand Down Expand Up @@ -283,9 +285,10 @@ Ref<DebugDrawStats2D> DebugDraw2D::get_render_stats() {
void DebugDraw2D::clear_all() {
ZoneScoped;
#ifndef DISABLE_DEBUG_RENDERING
if (!grouped_text || !data_graphs) return;
grouped_text->clear_text();
data_graphs->clear_graphs();
if (grouped_text)
grouped_text->clear_groups();
if (data_graphs)
data_graphs->clear_graphs();
mark_canvas_dirty();
_finish_frame_and_update();
#else
Expand Down Expand Up @@ -334,6 +337,11 @@ void DebugDraw2D::set_text(String key, Variant value, int priority, Color color_
CALL_TO_2D(grouped_text, set_text, key, value, priority, color_of_value, duration);
}

void DebugDraw2D::clear_texts() {
ZoneScoped;
FORCE_CALL_TO_2D(grouped_text, clear_groups);
}

#pragma endregion // Text
#pragma region Graphs

Expand Down
3 changes: 3 additions & 0 deletions src/2d/debug_draw_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class DebugDraw2D : public Object {
/// duration: Expiration time
void set_text(String key, Variant value = Variant(), int priority = 0, Color color_of_value = Colors::empty_color, real_t duration = -1);

/// Clear all text
void clear_texts();

#pragma endregion // Text
#pragma region Graphs

Expand Down
2 changes: 1 addition & 1 deletion src/2d/grouped_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void GroupedText::init_group(DebugDraw2D *p_owner) {
item_for_title_of_groups->is_group_title = true;
}

void GroupedText::clear_text() {
void GroupedText::clear_groups() {
LOCK_GUARD(datalock);
_text_groups.clear();
}
Expand Down
2 changes: 1 addition & 1 deletion src/2d/grouped_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class GroupedText {

public:
void init_group(class DebugDraw2D *p_owner);
void clear_text();
void clear_groups();
void cleanup_text(const double &_delta);
void begin_text_group(const String &_group_title, const int &_group_priority, const Color &_group_color, const bool &_show_title, const int &_title_size, const int &_text_size);
void end_text_group();
Expand Down
3 changes: 3 additions & 0 deletions src/3d/geometry_generators.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ class GeometryGenerator {
const static std::array<Vector3, 8> CubeVertices;
const static std::array<int, 24> CubeIndices;
const static std::array<int, 36> CubeWithDiagonalsIndices;

const static std::array<Vector3, 6> ArrowheadVertices;
const static std::array<int, 18> ArrowheadIndices;
const static std::array<int, 18> ArrowheadIndicesSimplified;

const static std::array<Vector3, 4> CenteredSquareVertices;
const static std::array<int, 6> SquareIndices;

const static std::array<Vector3, 6> PositionVertices;
const static std::array<int, 6> PositionIndices;

Expand Down

0 comments on commit 54410d0

Please sign in to comment.