Debug Draw 3D (and 2D) 1.4.5
Draw 3D debug graphics and 2D overlays with this add-on.
Loading...
Searching...
No Matches
debug_draw_manager.h
1#pragma once
2
3#include "utils/compiler.h"
4
5GODOT_WARNING_DISABLE()
6#include <godot_cpp/classes/canvas_layer.hpp>
7GODOT_WARNING_RESTORE()
8using namespace godot;
9
10class DebugDraw2D;
11class DebugDraw3D;
13
14#ifndef DISABLE_DEBUG_RENDERING
16class _DD3D_PhysicsWatcher : public Node {
17 GDCLASS(_DD3D_PhysicsWatcher, Node)
18protected:
19 DebugDrawManager *root_node;
20 static void _bind_methods(){};
21
22public:
23 void init(DebugDrawManager *p_root);
24
25 virtual void _process(double p_delta) override;
26 virtual void _physics_process(double p_delta) override;
27};
28#endif
29
54class DebugDrawManager : public CanvasLayer {
55 GDCLASS(DebugDrawManager, CanvasLayer)
56protected:
58 static void _bind_methods();
59
60private:
61#ifndef DISABLE_DEBUG_RENDERING
62 friend _DD3D_PhysicsWatcher;
63#endif
64
65 static DebugDrawManager *singleton;
66
67 String root_settings_section;
68 const static char *s_initial_state;
69 const static char *s_manager_aliases;
70 const static char *s_dd2d_aliases;
71 const static char *s_dd3d_aliases;
72
73 double log_flush_time = 0;
74 bool debug_enabled = true;
75 bool is_closing = false;
76 bool is_current_scene_is_null = true;
77
78 DebugDraw2D *debug_draw_2d_singleton = nullptr;
79 DebugDraw3D *debug_draw_3d_singleton = nullptr;
80
81 TypedArray<StringName> manager_aliases;
82 TypedArray<StringName> dd2d_aliases;
83 TypedArray<StringName> dd3d_aliases;
84
85 Node *_get_current_scene();
86 void _connect_scene_changed();
87 void _on_scene_changed(bool p_is_scene_null);
88
89 void _integrate_into_engine();
90
91 void _register_singleton_aliases(const TypedArray<StringName> &p_names, Object *p_instance);
92 void _unregister_singleton_aliases(const TypedArray<StringName> &p_names);
93
94#ifdef TOOLS_ENABLED
95 void _try_to_update_cs_bindings();
96#endif
97
98 // TEST C# API GENERATOR
99#ifdef DEV_ENABLED
100public:
101 enum DevTestEnum : int {
102 FIRST_VALUE = 0,
103 SECOND_VALUE = 1,
104 };
105
106private:
107 static Object *default_arg_obj;
108
109 // Test regular arguments
110 void api_test1(Variant, Object *, bool, int, float, String, StringName, NodePath){};
111 void api_test2(Color, Vector2, Vector2i, Vector3, Vector3i, Vector4, Vector4i, Rect2, Rect2i){};
112 void api_test3(Transform2D, Transform3D, Plane, Quaternion, AABB, Basis, Projection){};
113 void api_test4(RID, Callable, Signal, Dictionary, Array){};
114 void api_test5(PackedByteArray, PackedInt32Array, PackedInt64Array, PackedFloat32Array, PackedFloat64Array, PackedStringArray, PackedVector2Array, PackedVector3Array, PackedColorArray){};
115 // Test with default arguments
116 Variant api_test6(Object *, Variant, Variant, bool, int, DevTestEnum, float, String, StringName, NodePath) { return "test var"; };
117 Color api_test7(Color, Vector2, Vector2i, Vector3, Vector3i, Vector4, Vector4i, Rect2, Rect2i) { return Color(4, 3, 2, 1); };
118 DevTestEnum api_test8(Transform2D, Transform3D, Plane, Quaternion, AABB, Basis, Projection) { return (DevTestEnum)1; };
119 Object *api_test9(RID, Callable, Signal, Dictionary, Array) { return this; };
120 void api_test10(PackedByteArray, PackedInt32Array, PackedInt64Array, PackedFloat32Array, PackedFloat64Array, PackedStringArray, PackedVector2Array, PackedVector3Array, PackedColorArray){};
121
122public:
123#endif
124
125public:
127 static const char *s_extension_unloading;
128
131
136 return singleton;
137 };
138
139#pragma region Exposed Methods
143 void clear_all();
147 void set_debug_enabled(bool value);
151 bool is_debug_enabled() const;
152#pragma endregion // Exposed Methods
153
155 void init();
157 void deinit();
158
160 void _process_start(double p_delta);
162 virtual void _process(double p_delta) override;
164 void _physics_process_start(double p_delta);
166 virtual void _physics_process(double p_delta) override;
167};
168
169#ifdef DEV_ENABLED
170VARIANT_ENUM_CAST(DebugDrawManager::DevTestEnum);
171#endif
Singleton class for calling debugging 2D methods.
Definition debug_draw_2d.h:27
Singleton class for calling debugging 3D methods.
Definition debug_draw_3d.h:116
The main singleton class that handles DebugDraw2D and DebugDraw3D.
Definition debug_draw_manager.h:54
bool is_debug_enabled() const
void set_debug_enabled(bool value)
static DebugDrawManager * get_singleton()
Definition debug_draw_manager.h:135