Backported from godot4: Fix navigation debug not toggleable in scripts

Fixes that navigation debug was not toggleable in script while even the docs mentioned it.
- smix8
aecad7bb25
This commit is contained in:
Relintai 2023-06-09 09:01:01 +02:00
parent d434a1c4e5
commit 9c95fade84
6 changed files with 40 additions and 19 deletions

View File

@ -127,6 +127,12 @@
Destroys the given RID.
</description>
</method>
<method name="get_debug_enabled" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] when the NavigationServer has debug enabled.
</description>
</method>
<method name="get_maps" qualifiers="const">
<return type="Array" />
<description>

View File

@ -127,6 +127,13 @@
Destroys the given RID.
</description>
</method>
<method name="set_debug_enabled">
<return type="void" />
<param index="0" name="enabled" type="bool" />
<description>
If [code]true[/code] enables debug mode on the NavigationServer.
</description>
</method>
<method name="get_maps" qualifiers="const">
<return type="Array" />
<description>

View File

@ -108,6 +108,9 @@ void Navigation2DServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("free_rid", "rid"), &Navigation2DServer::free);
ClassDB::bind_method(D_METHOD("set_debug_enabled", "enabled"), &Navigation2DServer::set_debug_enabled);
ClassDB::bind_method(D_METHOD("get_debug_enabled"), &Navigation2DServer::get_debug_enabled);
ADD_SIGNAL(MethodInfo("map_changed", PropertyInfo(Variant::RID, "map")));
}
@ -131,7 +134,6 @@ Navigation2DServer::~Navigation2DServer() {
singleton = nullptr;
}
#ifdef DEBUG_ENABLED
void Navigation2DServer::set_debug_enabled(bool p_enabled) {
NavigationServer::get_singleton_mut()->set_debug_enabled(p_enabled);
}
@ -139,6 +141,8 @@ bool Navigation2DServer::get_debug_enabled() const {
return NavigationServer::get_singleton()->get_debug_enabled();
}
#ifdef DEBUG_ENABLED
void Navigation2DServer::set_debug_navigation_link_connection_color(const Color &p_color) {
NavigationServer::get_singleton_mut()->set_debug_navigation_link_connection_color(p_color);
}

View File

@ -238,10 +238,10 @@ public:
Navigation2DServer();
virtual ~Navigation2DServer();
#ifdef DEBUG_ENABLED
void set_debug_enabled(bool p_enabled);
bool get_debug_enabled() const;
#ifdef DEBUG_ENABLED
void set_debug_navigation_link_connection_color(const Color &p_color);
Color get_debug_navigation_link_connection_color() const;

View File

@ -130,6 +130,9 @@ void NavigationServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_active", "active"), &NavigationServer::set_active);
ClassDB::bind_method(D_METHOD("process", "delta_time"), &NavigationServer::process);
ClassDB::bind_method(D_METHOD("set_debug_enabled", "enabled"), &NavigationServer::set_debug_enabled);
ClassDB::bind_method(D_METHOD("get_debug_enabled"), &NavigationServer::get_debug_enabled);
ADD_SIGNAL(MethodInfo("map_changed", PropertyInfo(Variant::RID, "map")));
#ifdef DEBUG_ENABLED
@ -181,6 +184,22 @@ NavigationServer::~NavigationServer() {
singleton = nullptr;
}
void NavigationServer::set_debug_enabled(bool p_enabled) {
if (_debug_enabled != p_enabled) {
_debug_dirty = true;
}
_debug_enabled = p_enabled;
if (_debug_dirty) {
call_deferred("_emit_navigation_debug_changed_signal");
}
}
bool NavigationServer::get_debug_enabled() const {
return _debug_enabled;
}
#ifdef DEBUG_ENABLED
void NavigationServer::_emit_navigation_debug_changed_signal() {
if (_debug_dirty) {
@ -481,21 +500,6 @@ bool NavigationServer::get_debug_navigation_enable_link_connections_xray() const
return _debug_navigation_enable_link_connections_xray;
}
void NavigationServer::set_debug_enabled(bool p_enabled) {
if (_debug_enabled != p_enabled) {
_debug_dirty = true;
}
_debug_enabled = p_enabled;
if (_debug_dirty) {
call_deferred("_emit_navigation_debug_changed_signal");
}
}
bool NavigationServer::get_debug_enabled() const {
return _debug_enabled;
}
#endif // DEBUG_ENABLED
void NavigationServer::query_path(const Ref<NavigationPathQueryParameters3D> &p_query_parameters, Ref<NavigationPathQueryResult3D> p_query_result) const {

View File

@ -263,11 +263,11 @@ public:
NavigationServer();
virtual ~NavigationServer();
#ifdef DEBUG_ENABLED
void set_debug_enabled(bool p_enabled);
bool get_debug_enabled() const;
#ifdef DEBUG_ENABLED
void set_debug_navigation_edge_connection_color(const Color &p_color);
Color get_debug_navigation_edge_connection_color() const;