diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-01-31 15:24:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-31 15:24:56 +0100 |
commit | 5525cd85c60455b0bb9716bbef0ad2ad8111d752 (patch) | |
tree | 52ff0e2d3e01dd2655feff1cf88f07e10d84aad1 /scene/3d | |
parent | 02eb11450b4151b02db861b5029783e52e16c603 (diff) | |
parent | 99fe462452be44efa618e83ad9bbecd722ae6ecd (diff) |
Merge pull request #45315 from RandomShaper/modernize_thread
Modernize Thread
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/navigation_region_3d.cpp | 7 | ||||
-rw-r--r-- | scene/3d/navigation_region_3d.h | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp index b7b1415091..e8cfa05a4b 100644 --- a/scene/3d/navigation_region_3d.cpp +++ b/scene/3d/navigation_region_3d.cpp @@ -170,18 +170,17 @@ void _bake_navigation_mesh(void *p_user_data) { } void NavigationRegion3D::bake_navigation_mesh() { - ERR_FAIL_COND(bake_thread != nullptr); + ERR_FAIL_COND(bake_thread.is_started()); BakeThreadsArgs *args = memnew(BakeThreadsArgs); args->nav_region = this; - bake_thread = Thread::create(_bake_navigation_mesh, args); - ERR_FAIL_COND(bake_thread == nullptr); + bake_thread.start(_bake_navigation_mesh, args); } void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_nav_mesh) { set_navigation_mesh(p_nav_mesh); - bake_thread = nullptr; + bake_thread.wait_to_finish(); emit_signal("bake_finished"); } diff --git a/scene/3d/navigation_region_3d.h b/scene/3d/navigation_region_3d.h index a5b8c2cd5e..e966523b64 100644 --- a/scene/3d/navigation_region_3d.h +++ b/scene/3d/navigation_region_3d.h @@ -46,7 +46,7 @@ class NavigationRegion3D : public Node3D { Navigation3D *navigation = nullptr; Node *debug_view = nullptr; - Thread *bake_thread = nullptr; + Thread bake_thread; protected: void _notification(int p_what); |