diff options
author | smix8 <52464204+smix8@users.noreply.github.com> | 2023-04-01 01:49:43 +0200 |
---|---|---|
committer | smix8 <52464204+smix8@users.noreply.github.com> | 2023-05-11 18:46:34 +0200 |
commit | f986b52b3cc107374d4e74774c8695a0f1282e11 (patch) | |
tree | 4f7382431f7b58e133528f02ea1d139851cc588e /scene/3d/navigation_region_3d.cpp | |
parent | fd4a06c51555904104b18494d0224f450d74fe2a (diff) | |
download | redot-engine-f986b52b3cc107374d4e74774c8695a0f1282e11.tar.gz |
Make navigation mesh edge connections optional
Makes navigation mesh edge connections optional.
Diffstat (limited to 'scene/3d/navigation_region_3d.cpp')
-rw-r--r-- | scene/3d/navigation_region_3d.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp index b775ef94cb..165d44436c 100644 --- a/scene/3d/navigation_region_3d.cpp +++ b/scene/3d/navigation_region_3d.cpp @@ -81,6 +81,20 @@ bool NavigationRegion3D::is_enabled() const { return enabled; } +void NavigationRegion3D::set_use_edge_connections(bool p_enabled) { + if (use_edge_connections == p_enabled) { + return; + } + + use_edge_connections = p_enabled; + + NavigationServer3D::get_singleton()->region_set_use_edge_connections(region, use_edge_connections); +} + +bool NavigationRegion3D::get_use_edge_connections() const { + return use_edge_connections; +} + void NavigationRegion3D::set_navigation_layers(uint32_t p_navigation_layers) { if (navigation_layers == p_navigation_layers) { return; @@ -307,6 +321,9 @@ void NavigationRegion3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationRegion3D::set_enabled); ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationRegion3D::is_enabled); + ClassDB::bind_method(D_METHOD("set_use_edge_connections", "enabled"), &NavigationRegion3D::set_use_edge_connections); + ClassDB::bind_method(D_METHOD("get_use_edge_connections"), &NavigationRegion3D::get_use_edge_connections); + ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationRegion3D::set_navigation_layers); ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationRegion3D::get_navigation_layers); @@ -326,6 +343,7 @@ void NavigationRegion3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navigation_mesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"), "set_navigation_mesh", "get_navigation_mesh"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_edge_connections"), "set_use_edge_connections", "get_use_edge_connections"); ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "enter_cost"), "set_enter_cost", "get_enter_cost"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "travel_cost"), "set_travel_cost", "get_travel_cost"); @@ -602,6 +620,13 @@ void NavigationRegion3D::_update_debug_edge_connections_mesh() { return; } + if (!use_edge_connections || !NavigationServer3D::get_singleton()->map_get_use_edge_connections(get_world_3d()->get_navigation_map())) { + if (debug_edge_connections_instance.is_valid()) { + RS::get_singleton()->instance_set_visible(debug_edge_connections_instance, false); + } + return; + } + if (!navigation_mesh.is_valid()) { if (debug_edge_connections_instance.is_valid()) { RS::get_singleton()->instance_set_visible(debug_edge_connections_instance, false); |