From 6db8d89ab772fe37a819c22199f77409b394d32e Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 2 Sep 2023 13:05:19 +0200 Subject: [PATCH] Backported from godot4: Add navigation map synchronization warnings. - smix8 https://github.com/godotengine/godot/commit/fef7b4efdc5653866a5fba3d2d6a515138c11a99 --- modules/navigation/nav_map.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp index 4af88054c..5bd9b314b 100644 --- a/modules/navigation/nav_map.cpp +++ b/modules/navigation/nav_map.cpp @@ -122,6 +122,8 @@ gd::PointKey NavMap::get_point_key(const Vector3 &p_pos) const { } Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p_optimize, uint32_t p_navigation_layers, Vector *r_path_types, Array *r_path_rids, Vector *r_path_owners) const { + ERR_FAIL_COND_V_MSG(map_update_id == 0, Vector(), "NavigationServer map query failed because it was made before first map synchronization."); + // Clear metadata outputs. if (r_path_types) { r_path_types->clear(); @@ -502,6 +504,8 @@ Vector NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p } Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const { + ERR_FAIL_COND_V_MSG(map_update_id == 0, Vector3(), "NavigationServer map query failed because it was made before first map synchronization."); + bool use_collision = p_use_collision; Vector3 closest_point; real_t closest_point_d = FLT_MAX; @@ -551,16 +555,22 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector } Vector3 NavMap::get_closest_point(const Vector3 &p_point) const { + ERR_FAIL_COND_V_MSG(map_update_id == 0, Vector3(), "NavigationServer map query failed because it was made before first map synchronization."); + gd::ClosestPointQueryResult cp = get_closest_point_info(p_point); return cp.point; } Vector3 NavMap::get_closest_point_normal(const Vector3 &p_point) const { + ERR_FAIL_COND_V_MSG(map_update_id == 0, Vector3(), "NavigationServer map query failed because it was made before first map synchronization."); + gd::ClosestPointQueryResult cp = get_closest_point_info(p_point); return cp.normal; } RID NavMap::get_closest_point_owner(const Vector3 &p_point) const { + ERR_FAIL_COND_V_MSG(map_update_id == 0, RID(), "NavigationServer map query failed because it was made before first map synchronization."); + gd::ClosestPointQueryResult cp = get_closest_point_info(p_point); return cp.owner; }