Skip to content

Commit

Permalink
Merge pull request #79465 from smix8/navregion_bake_deferred_4.x
Browse files Browse the repository at this point in the history
Make NavigationRegion3D baking NavMesh on the main thread not finish deferred
  • Loading branch information
YuriSizov committed Jul 18, 2023
2 parents f8f06d3 + bb5f160 commit 182b94c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scene/3d/navigation_region_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,19 @@ void _bake_navigation_mesh(void *p_user_data) {
Ref<NavigationMeshSourceGeometryData3D> source_geometry_data = args->source_geometry_data;

NavigationServer3D::get_singleton()->bake_from_source_geometry_data(nav_mesh, source_geometry_data);
args->nav_region->call_deferred(SNAME("_bake_finished"), nav_mesh);
if (!Thread::is_main_thread()) {
args->nav_region->call_deferred(SNAME("_bake_finished"), nav_mesh);
} else {
args->nav_region->_bake_finished(nav_mesh);
}
memdelete(args);
} else {
ERR_PRINT("Can't bake the navigation mesh if the `NavigationMesh` resource doesn't exist");
args->nav_region->call_deferred(SNAME("_bake_finished"), Ref<NavigationMesh>());
if (!Thread::is_main_thread()) {
args->nav_region->call_deferred(SNAME("_bake_finished"), Ref<NavigationMesh>());
} else {
args->nav_region->_bake_finished(Ref<NavigationMesh>());
}
memdelete(args);
}
}
Expand Down

0 comments on commit 182b94c

Please sign in to comment.