Skip to content

Commit

Permalink
Merge pull request #83814 from smix8/navagent_properties
Browse files Browse the repository at this point in the history
Fix missing NavigationAgent property updates in constructor
  • Loading branch information
akien-mga committed Dec 4, 2023
2 parents 4bd5ffd + 9640179 commit 1389d8a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
12 changes: 7 additions & 5 deletions scene/2d/navigation_agent_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,13 @@ NavigationAgent2D::NavigationAgent2D() {
NavigationServer2D::get_singleton()->agent_set_time_horizon_obstacles(agent, time_horizon_obstacles);
NavigationServer2D::get_singleton()->agent_set_radius(agent, radius);
NavigationServer2D::get_singleton()->agent_set_max_speed(agent, max_speed);
NavigationServer2D::get_singleton()->agent_set_avoidance_layers(agent, avoidance_layers);
NavigationServer2D::get_singleton()->agent_set_avoidance_mask(agent, avoidance_mask);
NavigationServer2D::get_singleton()->agent_set_avoidance_priority(agent, avoidance_priority);
NavigationServer2D::get_singleton()->agent_set_avoidance_enabled(agent, avoidance_enabled);
if (avoidance_enabled) {
NavigationServer2D::get_singleton()->agent_set_avoidance_callback(agent, callable_mp(this, &NavigationAgent2D::_avoidance_done));
}

// Preallocate query and result objects to improve performance.
navigation_query = Ref<NavigationPathQueryParameters2D>();
Expand All @@ -302,11 +309,6 @@ NavigationAgent2D::NavigationAgent2D() {
navigation_result = Ref<NavigationPathQueryResult2D>();
navigation_result.instantiate();

set_avoidance_layers(avoidance_layers);
set_avoidance_mask(avoidance_mask);
set_avoidance_priority(avoidance_priority);
set_avoidance_enabled(avoidance_enabled);

#ifdef DEBUG_ENABLED
NavigationServer2D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationAgent2D::_navigation_debug_changed));
#endif // DEBUG_ENABLED
Expand Down
14 changes: 8 additions & 6 deletions scene/3d/navigation_agent_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,14 @@ NavigationAgent3D::NavigationAgent3D() {
NavigationServer3D::get_singleton()->agent_set_radius(agent, radius);
NavigationServer3D::get_singleton()->agent_set_height(agent, height);
NavigationServer3D::get_singleton()->agent_set_max_speed(agent, max_speed);
NavigationServer3D::get_singleton()->agent_set_avoidance_layers(agent, avoidance_layers);
NavigationServer3D::get_singleton()->agent_set_avoidance_mask(agent, avoidance_mask);
NavigationServer3D::get_singleton()->agent_set_avoidance_priority(agent, avoidance_priority);
NavigationServer3D::get_singleton()->agent_set_use_3d_avoidance(agent, use_3d_avoidance);
NavigationServer3D::get_singleton()->agent_set_avoidance_enabled(agent, avoidance_enabled);
if (avoidance_enabled) {
NavigationServer3D::get_singleton()->agent_set_avoidance_callback(agent, callable_mp(this, &NavigationAgent3D::_avoidance_done));
}

// Preallocate query and result objects to improve performance.
navigation_query = Ref<NavigationPathQueryParameters3D>();
Expand All @@ -335,12 +343,6 @@ NavigationAgent3D::NavigationAgent3D() {
navigation_result = Ref<NavigationPathQueryResult3D>();
navigation_result.instantiate();

set_avoidance_layers(avoidance_layers);
set_avoidance_mask(avoidance_mask);
set_avoidance_priority(avoidance_priority);
set_use_3d_avoidance(use_3d_avoidance);
set_avoidance_enabled(avoidance_enabled);

#ifdef DEBUG_ENABLED
NavigationServer3D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationAgent3D::_navigation_debug_changed));
#endif // DEBUG_ENABLED
Expand Down

0 comments on commit 1389d8a

Please sign in to comment.