From 9dd05964d587b35db84497ed9cfda0dd1d012fe4 Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Sun, 14 Jul 2024 21:53:14 +0200 Subject: [PATCH] Fix NavigationPolygon not updating consistently on rebakes Fixes that NavigationPolygon did not update in all cases because the internal NavigationMesh was not always unref and freed which blocked creating a new mesh later if nothing else freed it. --- scene/resources/2d/navigation_polygon.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scene/resources/2d/navigation_polygon.cpp b/scene/resources/2d/navigation_polygon.cpp index a845809bf2f..4a290db86b5 100644 --- a/scene/resources/2d/navigation_polygon.cpp +++ b/scene/resources/2d/navigation_polygon.cpp @@ -193,6 +193,10 @@ void NavigationPolygon::set_data(const Vector &p_vertices, const Vector for (int i = 0; i < p_polygons.size(); i++) { polygons.write[i].indices = p_polygons[i]; } + { + MutexLock lock(navigation_mesh_generation); + navigation_mesh.unref(); + } } void NavigationPolygon::get_data(Vector &r_vertices, Vector> &r_polygons) {