Skip to content

Commit

Permalink
WIP 5
Browse files Browse the repository at this point in the history
removed graphs
removed C# API generator
  • Loading branch information
DmitriySalnikov committed Jan 9, 2025
1 parent c541481 commit cad2dca
Show file tree
Hide file tree
Showing 23 changed files with 21 additions and 2,717 deletions.
12 changes: 0 additions & 12 deletions src/2d/config_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ void DebugDraw2DConfig::_bind_methods() {
BIND_ENUM_CONSTANT(POSITION_LEFT_BOTTOM);
BIND_ENUM_CONSTANT(POSITION_RIGHT_BOTTOM);

REG_PROP(graphs_base_offset, Variant::VECTOR2I);
REG_PROP(text_block_position, Variant::INT);
REG_PROP(text_block_offset, Variant::VECTOR2I);
REG_PROP(text_padding, Variant::VECTOR2I);
Expand Down Expand Up @@ -40,7 +39,6 @@ DebugDraw2DConfig::DebugDraw2DConfig() {
if (IS_EDITOR_HINT()) {
text_block_position = BlockPosition::POSITION_LEFT_BOTTOM;
text_block_offset = Vector2(24, 24);
graphs_base_offset = Vector2(12, 72);
}
}

Expand All @@ -49,16 +47,6 @@ void DebugDraw2DConfig::mark_canvas_dirty() {
mark_dirty_func();
}

void DebugDraw2DConfig::set_graphs_base_offset(const Vector2i &_offset) {
if (graphs_base_offset != _offset)
mark_canvas_dirty();
graphs_base_offset = _offset;
}

Vector2i DebugDraw2DConfig::get_graphs_base_offset() const {
return graphs_base_offset;
}

void DebugDraw2DConfig::set_text_block_position(BlockPosition _position) {
if (text_block_position != (BlockPosition)_position)
mark_canvas_dirty();
Expand Down
9 changes: 0 additions & 9 deletions src/2d/config_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ class DebugDraw2DConfig : public RefCounted {
/// @private
void mark_canvas_dirty();

// Graphs
Vector2i graphs_base_offset = Vector2i(8, 8);

// TEXT
BlockPosition text_block_position = BlockPosition::POSITION_LEFT_TOP;
Vector2i text_block_offset = Vector2i(8, 8);
Expand Down Expand Up @@ -67,12 +64,6 @@ class DebugDraw2DConfig : public RefCounted {
/// @private
void unregister_config();

/**
* Base offset for all graphs
*/
void set_graphs_base_offset(const Vector2i &_offset);
Vector2i get_graphs_base_offset() const;

/**
* Position of the text block
*/
Expand Down
60 changes: 1 addition & 59 deletions src/2d/debug_draw_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "config_2d.h"
#include "debug_draw_manager.h"
#include "graphs.h"
#include "grouped_text.h"
#include "stats_2d.h"
#include "utils/utils.h"
Expand Down Expand Up @@ -39,14 +38,6 @@ void DebugDraw2D::_bind_methods() {
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);
ClassDB::bind_method(D_METHOD(NAMEOF(graph_update_data), "title", "data"), &DebugDraw2D::graph_update_data);
ClassDB::bind_method(D_METHOD(NAMEOF(remove_graph), "title"), &DebugDraw2D::remove_graph);
ClassDB::bind_method(D_METHOD(NAMEOF(clear_graphs)), &DebugDraw2D::clear_graphs);
ClassDB::bind_method(D_METHOD(NAMEOF(get_graph), "title"), &DebugDraw2D::get_graph);
ClassDB::bind_method(D_METHOD(NAMEOF(get_graph_names)), &DebugDraw2D::get_graph_names);

#pragma endregion // Draw Functions

ClassDB::bind_method(D_METHOD(NAMEOF(get_render_stats)), &DebugDraw2D::get_render_stats);
Expand All @@ -68,7 +59,6 @@ void DebugDraw2D::init(DebugDrawManager *root) {
#ifndef DISABLE_DEBUG_RENDERING
grouped_text = std::make_unique<GroupedText>();
grouped_text->init_group(this);
data_graphs = std::make_unique<DataGraphManager>(this);
#endif
}

Expand All @@ -77,7 +67,6 @@ DebugDraw2D::~DebugDraw2D() {
UNASSIGN_SINGLETON(DebugDraw2D);

#ifndef DISABLE_DEBUG_RENDERING
data_graphs.reset();
grouped_text.reset();

Control *default_control = Object::cast_to<Control>(ObjectDB::get_instance(default_control_id));
Expand Down Expand Up @@ -128,9 +117,6 @@ void DebugDraw2D::process_end(double delta) {
// Clean texts
grouped_text->cleanup_text(delta);

// FPS Graph
data_graphs->auto_update_graphs(delta);

// Update overlay
_finish_frame_and_update();
#endif
Expand Down Expand Up @@ -185,8 +171,6 @@ void DebugDraw2D::_finish_frame_and_update() {
void DebugDraw2D::_clear_all_internal() {
if (grouped_text)
grouped_text->clear_groups();
if (data_graphs)
data_graphs->clear_graphs();
mark_canvas_dirty();
_finish_frame_and_update();

Expand Down Expand Up @@ -232,7 +216,6 @@ void DebugDraw2D::_on_canvas_item_draw(Control *ci) {
Vector2 vp_size = ci->has_meta("UseParentSize") ? Object::cast_to<Control>(ci->get_parent())->get_rect().size : ci->get_rect().size;

grouped_text->draw(ci, _font, vp_size);
data_graphs->draw(ci, _font, vp_size, ci->get_process_delta_time());
#endif

#ifdef TRACY_ENABLE
Expand Down Expand Up @@ -332,10 +315,7 @@ Ref<DebugDraw2DStats> DebugDraw2D::get_render_stats() {
#ifndef DISABLE_DEBUG_RENDERING
stats_2d->setup(
grouped_text->get_text_group_count(),
grouped_text->get_text_line_total_count(),

data_graphs->get_graphs_enabled(),
data_graphs->get_graphs_total());
grouped_text->get_text_line_total_count());
#endif

return stats_2d;
Expand Down Expand Up @@ -395,44 +375,6 @@ void DebugDraw2D::clear_texts() {
}

#pragma endregion // Text
#pragma region Graphs

Ref<DebugDraw2DGraph> DebugDraw2D::create_graph(const StringName &title) {
ZoneScoped;
CALL_TO_2D_RET(data_graphs, create_graph, Ref<DebugDraw2DGraph>(), title);
}

Ref<DebugDraw2DGraph> DebugDraw2D::create_fps_graph(const StringName &title) {
ZoneScoped;
CALL_TO_2D_RET(data_graphs, create_fps_graph, Ref<DebugDraw2DGraph>(), title);
}

void DebugDraw2D::graph_update_data(const StringName &title, real_t data) {
ZoneScoped;
CALL_TO_2D(data_graphs, graph_update_data, title, data);
}

void DebugDraw2D::remove_graph(const StringName &title) {
ZoneScoped;
FORCE_CALL_TO_2D(data_graphs, remove_graph, title);
}

void DebugDraw2D::clear_graphs() {
ZoneScoped;
FORCE_CALL_TO_2D(data_graphs, clear_graphs);
}

Ref<DebugDraw2DGraph> DebugDraw2D::get_graph(const StringName &title) {
ZoneScoped;
FORCE_CALL_TO_2D_RET(data_graphs, get_graph, Ref<DebugDraw2DGraph>(), title);
}

PackedStringArray DebugDraw2D::get_graph_names() {
ZoneScoped;
FORCE_CALL_TO_2D_RET(data_graphs, get_graph_names, PackedStringArray());
}

#pragma endregion // Graphs
#pragma endregion // 2D

#pragma endregion // Draw Functions
Expand Down
52 changes: 1 addition & 51 deletions src/2d/debug_draw_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ GODOT_WARNING_DISABLE()
GODOT_WARNING_RESTORE()
using namespace godot;

class DataGraphManager;
class DebugDrawManager;
class DebugDraw2DConfig;
class DebugDraw2DGraph;
class DebugDraw2DStats;
class GroupedText;

/**
* @brief
* Singleton class for calling debugging 2D methods.
*
* Currently, this class supports drawing an overlay with text and graphs.
* Currently, this class supports drawing an overlay with text.
*/
class DebugDraw2D : public Object {
GDCLASS(DebugDraw2D, Object)
Expand All @@ -46,7 +44,6 @@ class DebugDraw2D : public Object {

#ifndef DISABLE_DEBUG_RENDERING
std::unique_ptr<GroupedText> grouped_text;
std::unique_ptr<DataGraphManager> data_graphs;
#endif

#ifndef DISABLE_DEBUG_RENDERING
Expand Down Expand Up @@ -179,52 +176,5 @@ class DebugDraw2D : public Object {
*/
void clear_texts();
#pragma endregion // Text
#pragma region Graphs

/**
* Create a new graph for the custom data.
*
* Use DebugDraw2D.graph_update_data to update the values.
*
* @param title Title of the graph
*/
Ref<DebugDraw2DGraph> create_graph(const StringName &title);

/**
* Create a new graph with FPS that will be automatically updated.
* @param title Title of the graph
*/
Ref<DebugDraw2DGraph> create_fps_graph(const StringName &title);

/**
* Update custom graph data
* @param title Title of the graph
* @param data New data
*/
void graph_update_data(const StringName &title, real_t data);

/**
* Delete a graph by its title
* @param title Title of the graph
*/
void remove_graph(const StringName &title);

/**
* Remove all graphs
*/
void clear_graphs();

/**
* Get the configuration for a graph.
* @param title Title of the graph
*/
Ref<DebugDraw2DGraph> get_graph(const StringName &title);

/**
* Get a list of titles of all existing graphs.
*/
PackedStringArray get_graph_names();

#pragma endregion // Graphs
#pragma endregion // Exposed Draw Functions
};
Loading

0 comments on commit cad2dca

Please sign in to comment.