From e3f889a63ba9beafc714cc3bebc48b1b9bb31fa0 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 2 Sep 2023 13:07:00 +0200 Subject: [PATCH] Backported from godot4: Improve navigation map synchronisation error msgs Improves navigation map synchronisation error msgs related to mismatch of cell sizes. - smix8 https://github.com/godotengine/godot/commit/7f2417135f75b1bb48d570db41e2127c9585238a --- modules/navigation/nav_map.cpp | 2 +- modules/navigation/nav_region.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp index 5bd9b314b..270a5621a 100644 --- a/modules/navigation/nav_map.cpp +++ b/modules/navigation/nav_map.cpp @@ -787,7 +787,7 @@ void NavMap::sync() { connections[ek].push_back(new_connection); // The edge is already connected with another edge, skip. - ERR_PRINT_ONCE("Attempted to merge a navigation mesh triangle edge with another already-merged edge. This happens when the current `cell_size` is different from the one used to generate the navigation mesh. This will cause navigation problem."); + ERR_PRINT_ONCE("Navigation map synchronization error. Attempted to merge a navigation mesh polygon edge with another already-merged edge. This is usually caused by crossing edges, overlapping polygons, or a mismatch of the NavigationMesh / NavigationPolygon baked 'cell_size' and navigation map 'cell_size'."); } } } diff --git a/modules/navigation/nav_region.cpp b/modules/navigation/nav_region.cpp index 407f59a17..13cc357ea 100644 --- a/modules/navigation/nav_region.cpp +++ b/modules/navigation/nav_region.cpp @@ -108,6 +108,10 @@ void NavRegion::update_polygons() { return; } + if (!Math::is_equal_approx(double(map->get_cell_size()), double(mesh->get_cell_size()))) { + ERR_PRINT_ONCE("Navigation map synchronization error. Attempted to update a navigation region with a navigation mesh that uses a different `cell_size` than the `cell_size` set on the navigation map."); + } + PoolVector vertices = mesh->get_vertices(); int len = vertices.size(); if (len == 0) {