74class DebugDraw3D :
public Object,
public IScopeStorage<DebugDraw3DScopeConfig> {
79#ifndef DISABLE_DEBUG_RENDERING
80 friend DebugGeometryContainer;
101 String root_settings_section;
102 const static char *s_use_icosphere;
103 const static char *s_use_icosphere_hd;
104 const static char *s_add_bevel_to_volumetric;
105 const static char *s_default_thickness;
106 const static char *s_default_center_brightness;
107 const static char *s_default_hd_spheres;
108 const static char *s_default_plane_size;
110 std::vector<SubViewport *> custom_editor_viewports;
113 Ref<DebugDraw3DStats> stats_3d;
114 Ref<DebugDraw3DScopeConfig> default_scoped_config;
116#ifndef DISABLE_DEBUG_RENDERING
117 ProfiledMutex(std::recursive_mutex, datalock,
"3D Geometry lock");
119 typedef std::pair<uint64_t, DebugDraw3DScopeConfig *> ScopedPairIdConfig;
121 std::unordered_map<uint64_t, std::vector<ScopedPairIdConfig> > scoped_configs;
123 std::unordered_map<uint64_t, DebugDraw3DScopeConfig *> cached_scoped_configs;
124 uint64_t create_scoped_configs = 0;
130 std::unique_ptr<DebugGeometryContainer> dgc;
132 Vector3 previous_camera_position;
133 double previous_camera_far_plane = 0;
136 Ref<ShaderMaterial> shader_wireframe_mat;
137 Ref<Shader> shader_wireframe_code;
139 Ref<ShaderMaterial> shader_billboard_mat;
140 Ref<Shader> shader_billboard_code;
142 Ref<ShaderMaterial> shader_plane_mat;
143 Ref<Shader> shader_plane_code;
145 Ref<ShaderMaterial> shader_extendable_mat;
146 Ref<Shader> shader_extendable_code;
149 void _register_scoped_config(uint64_t thread_id, uint64_t guard_id,
DebugDraw3DScopeConfig *cfg)
override;
150 void _unregister_scoped_config(uint64_t thread_id, uint64_t guard_id)
override;
151 void _clear_scoped_configs()
override;
158 _FORCE_INLINE_ Vector3 get_up_vector(
const Vector3 &dir);
159 void add_or_update_line_with_thickness(real_t _exp_time, std::unique_ptr<Vector3[]> _lines,
const size_t _line_count,
const Color &_col,
const std::function<
void(DelayedRendererLine *)> _custom_upd =
nullptr);
160 Node *get_root_node();
162 void create_arrow(
const Vector3 &a,
const Vector3 &b,
const Color &color,
const real_t &arrow_size,
const bool &is_absolute_size,
const real_t &duration = 0);
168 void set_custom_editor_viewport(std::vector<SubViewport *> _viewports);
169 std::vector<SubViewport *> get_custom_editor_viewports();
171 Ref<ShaderMaterial> get_wireframe_material();
172 Ref<ShaderMaterial> get_billboard_material();
173 Ref<ShaderMaterial> get_plane_material();
174 Ref<ShaderMaterial> get_extendable_material();
176 void _load_materials();
177 void _set_base_world_node(Node *world_base);
178 inline bool _is_enabled_override()
const;
180 void process(
double delta);
181 void physics_process_start(
double delta);
182 void physics_process_end(
double delta);
184#pragma region Exposed Parameter Values
187 bool debug_enabled =
true;
189 Viewport *custom_viewport =
nullptr;
191 Ref<DebugDraw3DConfig> config;
197 static void _bind_methods();
210#pragma region Configs
237#pragma region Exposed Parameters
239 void set_empty_color(
const Color &_col){};
249 bool is_debug_enabled()
const;
255 Viewport *get_custom_viewport()
const;
259#pragma region Exposed Draw Methods
268#ifndef DISABLE_DEBUG_RENDERING
269#define FAKE_FUNC_IMPL
271#define FAKE_FUNC_IMPL \
287#pragma region Spheres
290 void draw_sphere_base(
const Transform3D &transform,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
301 void draw_sphere(const Vector3 &position, const real_t &radius = 0.5f, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
311 void draw_sphere_xf(const Transform3D &transform, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
315#pragma region Cylinders
326 void draw_cylinder(
const Transform3D &transform,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
339 void draw_cylinder_ab(const Vector3 &a, const Vector3 &b, const real_t &radius = 0.5f, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
359 void draw_box(
const Vector3 &position,
const Quaternion &rotation,
const Vector3 &size,
const Color &color = Colors::empty_color,
const bool &is_box_centered =
false,
const real_t &duration = 0) FAKE_FUNC_IMPL;
375 void draw_box_ab(const Vector3 &a, const Vector3 &b, const Vector3 &up, const Color &color = Colors::empty_color, const
bool &is_ab_diagonal = true, const real_t &duration = 0) FAKE_FUNC_IMPL;
385 void draw_box_xf(const Transform3D &transform, const Color &color = Colors::empty_color, const
bool &is_box_centered = true, const real_t &duration = 0) FAKE_FUNC_IMPL;
394 void draw_aabb(const AABB &aabb, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
404 void draw_aabb_ab(const Vector3 &a, const Vector3 &b, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
426 void draw_line_hit(
const Vector3 &start,
const Vector3 &end,
const Vector3 &hit,
const bool &is_hit,
const real_t &hit_size = 0.25f,
const Color &hit_color = Colors::empty_color,
const Color &after_hit_color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
444 void draw_line_hit_offset(const Vector3 &start, const Vector3 &end, const
bool &is_hit, const real_t &unit_offset_of_hit = 0.5f, const real_t &hit_size = 0.25f, const Color &hit_color = Colors::empty_color, const Color &after_hit_color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
449 void draw_lines_c(
const std::vector<Vector3> &lines,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
460 void draw_line(const Vector3 &a, const Vector3 &b, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
473 void draw_ray(const Vector3 &origin, const Vector3 &direction, const real_t &length, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
484 void draw_lines(const PackedVector3Array &lines, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
497 void draw_line_path(const PackedVector3Array &path, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
510 void draw_arrowhead(
const Transform3D &transform,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
524 void draw_arrow(const Vector3 &a, const Vector3 &b, const Color &color = Colors::empty_color, const real_t &arrow_size = 0.5f, const
bool &is_absolute_size = false, const real_t &duration = 0) FAKE_FUNC_IMPL;
537 void draw_arrow_ray(const Vector3 &origin, const Vector3 &direction, const real_t &length, const Color &color = Colors::empty_color, const real_t &arrow_size = 0.5f, const
bool &is_absolute_size = false, const real_t &duration = 0) FAKE_FUNC_IMPL;
550 void draw_arrow_path(const PackedVector3Array &path, const Color &color = Colors::empty_color, const real_t &arrow_size = 0.75f, const
bool &is_absolute_size = true, const real_t &duration = 0) FAKE_FUNC_IMPL;
569 void draw_point_path(
const PackedVector3Array &path,
const PointType type = PointType::POINT_TYPE_SQUARE,
const real_t &size = 0.25f,
const Color &points_color = Colors::empty_color,
const Color &lines_color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
587 void draw_points(
const PackedVector3Array &points,
const PointType type = PointType::POINT_TYPE_SQUARE,
const real_t &size = 0.25f,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
597 void draw_square(const Vector3 &position, const real_t &size = 0.2f, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
611 void draw_plane(const Plane &plane, const Color &color = Colors::empty_color, const Vector3 &anchor_point = Vector3(INFINITY, INFINITY, INFINITY), const real_t &duration = 0) FAKE_FUNC_IMPL;
622 void draw_position(const Transform3D &transform, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
636 void draw_gizmo(const Transform3D &transform, const Color &color = Colors::empty_color, const
bool &is_centered = false, const real_t &duration = 0) FAKE_FUNC_IMPL;
651 void draw_grid(const Vector3 &origin, const Vector3 &x_size, const Vector3 &y_size, const Vector2i &subdivision, const Color &color = Colors::empty_color, const
bool &is_centered = true, const real_t &duration = 0) FAKE_FUNC_IMPL;
664 void draw_grid_xf(const Transform3D &transform, const Vector2i &p_subdivision, const Color &color = Colors::empty_color, const
bool &is_centered = true, const real_t &duration = 0) FAKE_FUNC_IMPL;
666#pragma region Camera Frustum
669 void draw_camera_frustum_planes_c(
const std::array<Plane, 6> &planes,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
679 void draw_camera_frustum(const class godot::Camera3D *camera, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
688 void draw_camera_frustum_planes(const Array &camera_frustum, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;