diff options
author | Malcolm Nixon <Malcolm.nixon@gmail.com> | 2023-10-14 23:17:57 -0400 |
---|---|---|
committer | Malcolm Nixon <Malcolm.nixon@gmail.com> | 2023-10-14 23:17:57 -0400 |
commit | 0646b230e495df272b504d5cfe43dc886a776418 (patch) | |
tree | c12caf9d366862470b55046229792502814a2aed /scene/2d/navigation_region_2d.cpp | |
parent | a574c0296b38d5f786f249b12e6251e562c528cc (diff) | |
download | redot-engine-0646b230e495df272b504d5cfe43dc886a776418.tar.gz |
Fix enabling NavigationRegion3D saved disabled
This PR fixes issue #83364 by always registering the region when it enters the tree, and instead using region_set_enabled to control whether its enabled. The same logical changes have been applied to NavigationRegion2D.
Diffstat (limited to 'scene/2d/navigation_region_2d.cpp')
-rw-r--r-- | scene/2d/navigation_region_2d.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp index 706b26bd05..78733f04e4 100644 --- a/scene/2d/navigation_region_2d.cpp +++ b/scene/2d/navigation_region_2d.cpp @@ -497,20 +497,18 @@ void NavigationRegion2D::_region_enter_navigation_map() { return; } - if (enabled) { - if (map_override.is_valid()) { - NavigationServer2D::get_singleton()->region_set_map(region, map_override); - for (uint32_t i = 0; i < constrain_avoidance_obstacles.size(); i++) { - if (constrain_avoidance_obstacles[i].is_valid()) { - NavigationServer2D::get_singleton()->obstacle_set_map(constrain_avoidance_obstacles[i], map_override); - } + if (map_override.is_valid()) { + NavigationServer2D::get_singleton()->region_set_map(region, map_override); + for (uint32_t i = 0; i < constrain_avoidance_obstacles.size(); i++) { + if (constrain_avoidance_obstacles[i].is_valid()) { + NavigationServer2D::get_singleton()->obstacle_set_map(constrain_avoidance_obstacles[i], map_override); } - } else { - NavigationServer2D::get_singleton()->region_set_map(region, get_world_2d()->get_navigation_map()); - for (uint32_t i = 0; i < constrain_avoidance_obstacles.size(); i++) { - if (constrain_avoidance_obstacles[i].is_valid()) { - NavigationServer2D::get_singleton()->obstacle_set_map(constrain_avoidance_obstacles[i], get_world_2d()->get_navigation_map()); - } + } + } else { + NavigationServer2D::get_singleton()->region_set_map(region, get_world_2d()->get_navigation_map()); + for (uint32_t i = 0; i < constrain_avoidance_obstacles.size(); i++) { + if (constrain_avoidance_obstacles[i].is_valid()) { + NavigationServer2D::get_singleton()->obstacle_set_map(constrain_avoidance_obstacles[i], get_world_2d()->get_navigation_map()); } } } @@ -523,6 +521,8 @@ void NavigationRegion2D::_region_enter_navigation_map() { } } + NavigationServer2D::get_singleton()->region_set_enabled(region, enabled); + queue_redraw(); } |