diff options
author | smix8 <52464204+smix8@users.noreply.github.com> | 2024-06-21 10:49:46 +0200 |
---|---|---|
committer | smix8 <52464204+smix8@users.noreply.github.com> | 2024-06-21 12:58:03 +0200 |
commit | eba3acadaca8527554a0cf30ba86a9939e1d7758 (patch) | |
tree | f1781ec343bbf061966472648239fa1038e63213 /modules/navigation/2d/nav_mesh_generator_2d.cpp | |
parent | 04a530f91fc83b41112007dbd2ce02e9528df682 (diff) | |
download | redot-engine-eba3acadaca8527554a0cf30ba86a9939e1d7758.tar.gz |
Fix thread-use causing navigation polygon data corruption
Fixes navigation polygon data corruption caused by thread-use that changed vertices or polygons while the navigation polygon was processed, e.g. by server region sync, navmesh baking or user thread updates.
Diffstat (limited to 'modules/navigation/2d/nav_mesh_generator_2d.cpp')
-rw-r--r-- | modules/navigation/2d/nav_mesh_generator_2d.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/modules/navigation/2d/nav_mesh_generator_2d.cpp b/modules/navigation/2d/nav_mesh_generator_2d.cpp index aa4c797723..8c2fb42463 100644 --- a/modules/navigation/2d/nav_mesh_generator_2d.cpp +++ b/modules/navigation/2d/nav_mesh_generator_2d.cpp @@ -1010,8 +1010,7 @@ void NavMeshGenerator2D::generator_bake_from_source_geometry_data(Ref<Navigation } if (new_baked_outlines.size() == 0) { - p_navigation_mesh->set_vertices(Vector<Vector2>()); - p_navigation_mesh->clear_polygons(); + p_navigation_mesh->clear(); return; } @@ -1045,8 +1044,7 @@ void NavMeshGenerator2D::generator_bake_from_source_geometry_data(Ref<Navigation TPPLPartition tpart; if (tpart.ConvexPartition_HM(&tppl_in_polygon, &tppl_out_polygon) == 0) { //failed! ERR_PRINT("NavigationPolygon Convex partition failed. Unable to create a valid NavigationMesh from defined polygon outline paths."); - p_navigation_mesh->set_vertices(Vector<Vector2>()); - p_navigation_mesh->clear_polygons(); + p_navigation_mesh->clear(); return; } @@ -1071,11 +1069,7 @@ void NavMeshGenerator2D::generator_bake_from_source_geometry_data(Ref<Navigation new_polygons.push_back(new_polygon); } - p_navigation_mesh->set_vertices(new_vertices); - p_navigation_mesh->clear_polygons(); - for (int i = 0; i < new_polygons.size(); i++) { - p_navigation_mesh->add_polygon(new_polygons[i]); - } + p_navigation_mesh->set_data(new_vertices, new_polygons); } #endif // CLIPPER2_ENABLED |