From 6b51ab66d83b7c85e16189eba280a00ab5ff9536 Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Tue, 17 May 2022 20:08:39 +0200 Subject: Make Navigation Agents and Obstacles respect parent process mode Temporarily removes agent from navigation map when parent node cannot process due to SceneTree pause and process_mode property. Normal process_mode does not work as other agents would still avoid the paused agents because they were still active on the navigation map and the rvo world. Also fixes potential crash when region_get_map or agent_get_map is called while no map is set. --- modules/navigation/godot_navigation_server.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp index 42aad77979..cc9d05da47 100644 --- a/modules/navigation/godot_navigation_server.cpp +++ b/modules/navigation/godot_navigation_server.cpp @@ -256,13 +256,19 @@ Array GodotNavigationServer::map_get_agents(RID p_map) const { RID GodotNavigationServer::region_get_map(RID p_region) const { NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_COND_V(region == nullptr, RID()); - return region->get_map()->get_self(); + if (region->get_map()) { + return region->get_map()->get_self(); + } + return RID(); } RID GodotNavigationServer::agent_get_map(RID p_agent) const { RvoAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_COND_V(agent == nullptr, RID()); - return agent->get_map()->get_self(); + if (agent->get_map()) { + return agent->get_map()->get_self(); + } + return RID(); } RID GodotNavigationServer::region_create() const { -- cgit v1.2.3