74class DebugDraw3D :
public Object,
public IScopeStorage<DebugDraw3DScopeConfig, DebugDraw3DScopeConfig::Data> {
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;
120 typedef std::shared_ptr<DebugDraw3DScopeConfig::Data> DebugDraw3DScopeConfig_Data;
122 std::unordered_map<uint64_t, std::vector<ScopedPairIdConfig> > scoped_configs;
124 std::unordered_map<uint64_t, DebugDraw3DScopeConfig_Data> cached_scoped_configs;
125 uint64_t create_scoped_configs = 0;
128 const DebugDraw3DScopeConfig_Data scoped_config_for_current_thread()
override;
131 std::unique_ptr<DebugGeometryContainer> dgc;
133 Vector3 previous_camera_position;
134 double previous_camera_far_plane = 0;
137 Ref<ShaderMaterial> shader_wireframe_mat;
138 Ref<Shader> shader_wireframe_code;
140 Ref<ShaderMaterial> shader_billboard_mat;
141 Ref<Shader> shader_billboard_code;
143 Ref<ShaderMaterial> shader_plane_mat;
144 Ref<Shader> shader_plane_code;
146 Ref<ShaderMaterial> shader_extendable_mat;
147 Ref<Shader> shader_extendable_code;
150 void _register_scoped_config(uint64_t thread_id, uint64_t guard_id,
DebugDraw3DScopeConfig *cfg)
override;
151 void _unregister_scoped_config(uint64_t thread_id, uint64_t guard_id)
override;
152 void _clear_scoped_configs()
override;
155 Color _scoped_config_to_custom(
const DebugDraw3DScopeConfig_Data &cfg);
156 InstanceType _scoped_config_type_convert(ConvertableInstanceType type,
const DebugDraw3DScopeConfig_Data &cfg);
157 GeometryType _scoped_config_get_geometry_type(
const DebugDraw3DScopeConfig_Data &cfg);
159 _FORCE_INLINE_ Vector3 get_up_vector(
const Vector3 &dir);
160 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);
161 Node *get_root_node();
163 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);
169 void set_custom_editor_viewport(std::vector<SubViewport *> _viewports);
170 std::vector<SubViewport *> get_custom_editor_viewports();
172 Ref<ShaderMaterial> get_wireframe_material();
173 Ref<ShaderMaterial> get_billboard_material();
174 Ref<ShaderMaterial> get_plane_material();
175 Ref<ShaderMaterial> get_extendable_material();
177 void _load_materials();
178 void _set_base_world_node(Node *world_base);
179 inline bool _is_enabled_override()
const;
181 void process(
double delta);
182 void physics_process_start(
double delta);
183 void physics_process_end(
double delta);
185#pragma region Exposed Parameter Values
188 bool debug_enabled =
true;
190 Viewport *custom_viewport =
nullptr;
192 Ref<DebugDraw3DConfig> config;
198 static void _bind_methods();
211#pragma region Configs
238#pragma region Exposed Parameters
240 void set_empty_color(
const Color &_col){};
250 bool is_debug_enabled()
const;
256 Viewport *get_custom_viewport()
const;
260#pragma region Exposed Draw Methods
269#ifndef DISABLE_DEBUG_RENDERING
270#define FAKE_FUNC_IMPL
272#define FAKE_FUNC_IMPL \
288#pragma region Spheres
291 void draw_sphere_base(
const Transform3D &transform,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
302 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;
312 void draw_sphere_xf(const Transform3D &transform, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
316#pragma region Cylinders
327 void draw_cylinder(
const Transform3D &transform,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
340 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;
360 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;
376 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;
386 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;
395 void draw_aabb(const AABB &aabb, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
405 void draw_aabb_ab(const Vector3 &a, const Vector3 &b, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
427 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;
445 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;
450 void draw_lines_c(
const std::vector<Vector3> &lines,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
461 void draw_line(const Vector3 &a, const Vector3 &b, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
474 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;
485 void draw_lines(const PackedVector3Array &lines, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
498 void draw_line_path(const PackedVector3Array &path, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
511 void draw_arrowhead(
const Transform3D &transform,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
525 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;
538 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;
551 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;
570 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;
588 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;
598 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;
612 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;
623 void draw_position(const Transform3D &transform, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
637 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;
652 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;
665 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;
667#pragma region Camera Frustum
670 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;
680 void draw_camera_frustum(const class godot::Camera3D *camera, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
689 void draw_camera_frustum_planes(const Array &camera_frustum, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;