116class DebugDraw3D :
public Object,
public IScopeStorage<DebugDraw3DScopeConfig, DebugDraw3DScopeConfig::Data> {
121#ifndef DISABLE_DEBUG_RENDERING
122 friend DebugGeometryContainer;
123 friend _DD3D_WorldWatcher;
138 String root_settings_section;
139 const static char *s_use_icosphere;
140 const static char *s_use_icosphere_hd;
141 const static char *s_add_bevel_to_volumetric;
142 const static char *s_default_frustum_scale;
144 const static char *s_default_thickness;
145 const static char *s_default_center_brightness;
146 const static char *s_default_hd_spheres;
147 const static char *s_default_plane_size;
149 const static char *s_render_priority;
150 const static char *s_render_mode;
151 const static char *s_render_fog_disabled;
153 std::vector<SubViewport *> custom_editor_viewports;
156 Ref<DebugDraw3DScopeConfig> default_scoped_config;
158#ifndef DISABLE_DEBUG_RENDERING
159 ProfiledMutex(std::recursive_mutex, datalock,
"3D Geometry lock");
161 typedef std::pair<uint64_t, DebugDraw3DScopeConfig *> ScopedPairIdConfig;
163 std::unordered_map<uint64_t, std::vector<ScopedPairIdConfig> > scoped_configs;
165 std::unordered_map<uint64_t, std::shared_ptr<DebugDraw3DScopeConfig::Data> > cached_scoped_configs;
166 uint64_t created_scoped_configs = 0;
170 } scoped_stats_3d = {};
173 const std::shared_ptr<DebugDraw3DScopeConfig::Data> scoped_config_for_current_thread()
override;
177 std::vector<std::array<Ref<ArrayMesh>, 2> > shared_generated_meshes;
179 std::unordered_map<uint64_t, std::shared_ptr<DebugGeometryContainer>[2]> debug_containers;
180 struct viewportToWorldCache {
181 uint64_t world_id = 0;
182 std::shared_ptr<DebugGeometryContainer> dgcs[2];
184 std::unordered_map<const Viewport *, viewportToWorldCache> viewport_to_world_cache;
187 Ref<ShaderMaterial> mesh_shaders[(int)MeshMaterialType::MAX][(
int)MeshMaterialVariant::MAX];
190 void _register_scoped_config(uint64_t p_thread_id, uint64_t p_guard_id,
DebugDraw3DScopeConfig *p_cfg)
override;
191 void _unregister_scoped_config(uint64_t p_thread_id, uint64_t p_guard_id)
override;
192 void _clear_scoped_configs()
override;
194 std::array<Ref<ArrayMesh>, 2> *get_shared_meshes();
195 std::shared_ptr<DebugGeometryContainer> create_debug_container(
bool p_no_depth_test);
196 std::shared_ptr<DebugGeometryContainer> get_debug_container(
const DebugDraw3DScopeConfig::DebugContainerDependent &p_dgcd,
const bool p_generate_new_container);
197 void _register_viewport_world_deferred(uint64_t p_vp,
const uint64_t p_world_id);
198 Viewport *_get_root_world_viewport(Viewport *p_vp);
199 void _remove_debug_container(
const uint64_t &p_world_id);
201 _FORCE_INLINE_ Vector3 get_up_vector(
const Vector3 &p_dir);
202 void add_or_update_line_with_thickness(real_t p_exp_time, std::unique_ptr<Vector3[]> p_lines,
const size_t p_line_count,
const Color &p_col,
const std::function<
void(DelayedRendererLine *)> p_custom_upd =
nullptr);
203 Node *get_root_node();
205 void create_arrow(
const Vector3 &p_a,
const Vector3 &p_b,
const Color &p_color,
const real_t &p_arrow_size,
const bool &p_is_absolute_size,
const real_t &p_duration = 0);
211 void set_custom_editor_viewport(std::vector<SubViewport *> p_viewports);
212 std::vector<SubViewport *> get_custom_editor_viewports();
214 Ref<ShaderMaterial> get_material_variant(MeshMaterialType p_type, MeshMaterialVariant p_var);
216 void _load_materials();
217 inline bool _is_enabled_override()
const;
219 void process(
double p_delta);
220 void physics_process_start(
double p_delta);
221 void physics_process_end(
double p_delta);
223#pragma region Exposed Parameter Values
226 bool debug_enabled =
true;
228 Ref<DebugDraw3DConfig> config;
234 static void _bind_methods();
247#pragma region Configs
274#pragma region Exposed Parameters
276 void set_empty_color(
const Color &col){};
286 bool is_debug_enabled()
const;
290#pragma region Exposed Draw Methods
306#ifndef DISABLE_DEBUG_RENDERING
307#define FAKE_FUNC_IMPL
309#define FAKE_FUNC_IMPL \
325#pragma region Spheres
328 void draw_sphere_base(
const Transform3D &transform,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
339 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;
349 void draw_sphere_xf(const Transform3D &transform, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
353#pragma region Cylinders
364 void draw_cylinder(
const Transform3D &transform,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
377 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;
397 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;
413 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;
423 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;
432 void draw_aabb(const AABB &aabb, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
442 void draw_aabb_ab(const Vector3 &a, const Vector3 &b, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
464 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;
482 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;
487 void draw_lines_c(
const std::vector<Vector3> &lines,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
498 void draw_line(const Vector3 &a, const Vector3 &b, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
511 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;
522 void draw_lines(const PackedVector3Array &lines, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
535 void draw_line_path(const PackedVector3Array &path, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
548 void draw_arrowhead(
const Transform3D &transform,
const Color &color = Colors::empty_color,
const real_t &duration = 0) FAKE_FUNC_IMPL;
562 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;
575 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;
588 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;
607 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;
625 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;
635 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;
649 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;
660 void draw_position(const Transform3D &transform, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
674 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;
689 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;
702 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;
704#pragma region Camera Frustum
707 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;
717 void draw_camera_frustum(const class godot::Camera3D *camera, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;
726 void draw_camera_frustum_planes(const Array &camera_frustum, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL;