From c326722a65a2a566276d0cc3ad1cb7fcdcdb9762 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 4 Sep 2023 18:03:12 +0200 Subject: [PATCH] Backported from godot4: Allow negative NavigationAgent2D path debug line_width for thin lines Allows the line_width for NavigationAgent2D path debug to go negativ for thin line rendering. - smix8 https://github.com/godotengine/godot/commit/f6a10c0565e32e0170bcce71635d8bad16077d1d --- doc/classes/NavigationAgent2D.xml | 2 +- scene/2d/navigation_agent_2d.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/classes/NavigationAgent2D.xml b/doc/classes/NavigationAgent2D.xml index c4cb3baa7..f5ed2093d 100644 --- a/doc/classes/NavigationAgent2D.xml +++ b/doc/classes/NavigationAgent2D.xml @@ -168,7 +168,7 @@ If [member debug_use_custom] is [code]true[/code] uses this color for this agent instead of global color. - + If [member debug_use_custom] is [code]true[/code] uses this line width for rendering paths for this agent instead of global line width. diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index 78edb2893..f6029ef68 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -165,8 +165,8 @@ void NavigationAgent2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_enabled"), "set_debug_enabled", "get_debug_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_use_custom"), "set_debug_use_custom", "get_debug_use_custom"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_path_custom_color"), "set_debug_path_custom_color", "get_debug_path_custom_color"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "debug_path_custom_point_size", PROPERTY_HINT_RANGE, "1,50,1,suffix:px"), "set_debug_path_custom_point_size", "get_debug_path_custom_point_size"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "debug_path_custom_line_width", PROPERTY_HINT_RANGE, "1,50,1,suffix:px"), "set_debug_path_custom_line_width", "get_debug_path_custom_line_width"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "debug_path_custom_point_size", PROPERTY_HINT_RANGE, "0,50,0.01,or_greater,suffix:px"), "set_debug_path_custom_point_size", "get_debug_path_custom_point_size"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "debug_path_custom_line_width", PROPERTY_HINT_RANGE, "-1,50,0.01,or_greater,suffix:px"), "set_debug_path_custom_line_width", "get_debug_path_custom_line_width"); ADD_SIGNAL(MethodInfo("path_changed")); ADD_SIGNAL(MethodInfo("target_reached")); @@ -337,7 +337,7 @@ NavigationAgent2D::NavigationAgent2D() { debug_enabled = false; debug_path_dirty = true; debug_path_custom_point_size = 4.0; - debug_path_custom_line_width = 1.0; + debug_path_custom_line_width = -1.0; debug_use_custom = false; debug_path_custom_color = Color(1.0, 1.0, 1.0, 1.0); @@ -887,7 +887,7 @@ Color NavigationAgent2D::get_debug_path_custom_color() const { } void NavigationAgent2D::set_debug_path_custom_point_size(float p_point_size) { - debug_path_custom_point_size = MAX(0.1, p_point_size); + debug_path_custom_point_size = MAX(0.0, p_point_size); debug_path_dirty = true; } @@ -949,6 +949,10 @@ void NavigationAgent2D::_update_debug_path() { RenderingServer::get_singleton()->canvas_item_add_polyline(debug_path_instance, navigation_path, debug_path_colors, debug_path_custom_line_width, false); + if (debug_path_custom_point_size <= 0.0) { + return; + } + float point_size = Navigation2DServer::get_singleton()->get_debug_navigation_agent_path_point_size(); float half_point_size = point_size * 0.5;