Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-threaded NavMesh baking to NavigationServer #79972

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

smix8
Copy link
Contributor

@smix8 smix8 commented Jul 27, 2023

Adds multi-threaded NavMesh baking to NavigationServer.

Requires #79643 to be merged first.

  • Adds threaded / async navigation mesh baking to the NavigationServer3D using WorkerThreadPool.
  • Adds NavigationServer3D.bake_from_source_geometry_data_async() to the API.
  • Removes the stutter plagued bake Thread from NavigationRegion3D, it now calls the NavigationServer instead.

The threaded navmesh baking is auto-disabled inside the Editor (as it was before) due to random crashes when switching Editor Scenes or Gizmos.

I first did not want to poll the WorkerThreadPool like that to finish tasks and instead use deferred calls to make the thread functions exit themself in a "fire & forget" way. While this worked well it was very unresponsive as deferred calls had to wait for the next message queue flush and missed important navigation map sync points for the current server iteration. It also had problems with unexpected shutdowns so I reverted that to a classic server sync.

Copy link
Member

@RandomShaper RandomShaper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides a few little things I've pointed out, I cant't really say anything beyond the threading part looks good.

modules/navigation/nav_mesh_generator_3d.cpp Outdated Show resolved Hide resolved
modules/navigation/nav_mesh_generator_3d.cpp Outdated Show resolved Hide resolved
modules/navigation/nav_mesh_generator_3d.cpp Outdated Show resolved Hide resolved
modules/navigation/godot_navigation_server.cpp Outdated Show resolved Hide resolved
modules/navigation/nav_mesh_generator_3d.cpp Outdated Show resolved Hide resolved
@smix8 smix8 force-pushed the navgenerator_multithreading_4.x branch 3 times, most recently from 25bb8ab to 8869c41 Compare July 28, 2023 18:54
Adds multi-threaded NavMesh baking to NavigationServer.
@smix8 smix8 force-pushed the navgenerator_multithreading_4.x branch from 8869c41 to 8686e84 Compare August 7, 2023 15:17
@akien-mga akien-mga merged commit 37d213b into godotengine:master Aug 17, 2023
@akien-mga
Copy link
Member

Thanks!

@smix8 smix8 deleted the navgenerator_multithreading_4.x branch August 17, 2023 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants