diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-04-26 11:51:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 11:51:02 +0200 |
commit | c45202a89b8762a4fa805c6038c42e3aaa1f8ce0 (patch) | |
tree | f59f9c9e8b8a3860ae9e26d0b25d716b6497648d /modules/navigation | |
parent | 525ee68087581c84528d03aa7ea6b2f33b55cbb9 (diff) | |
parent | 732102cbc599e486c4bb8cba33d2b4fe48ca4734 (diff) |
Merge pull request #60359 from adamscott/nav-map-thread-work-pool
Diffstat (limited to 'modules/navigation')
-rw-r--r-- | modules/navigation/nav_map.cpp | 11 | ||||
-rw-r--r-- | modules/navigation/nav_map.h | 7 |
2 files changed, 15 insertions, 3 deletions
diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp index a6df6bb72c..182de45e7c 100644 --- a/modules/navigation/nav_map.cpp +++ b/modules/navigation/nav_map.cpp @@ -30,7 +30,6 @@ #include "nav_map.h" -#include "core/os/threaded_array_processor.h" #include "nav_region.h" #include "rvo_agent.h" @@ -674,7 +673,7 @@ void NavMap::compute_single_step(uint32_t index, RvoAgent **agent) { void NavMap::step(real_t p_deltatime) { deltatime = p_deltatime; if (controlled_agents.size() > 0) { - thread_process_array( + step_work_pool.do_work( controlled_agents.size(), this, &NavMap::compute_single_step, @@ -719,3 +718,11 @@ void NavMap::clip_path(const std::vector<gd::NavigationPoly> &p_navigation_polys } } } + +NavMap::NavMap() { + step_work_pool.init(); +} + +NavMap::~NavMap() { + step_work_pool.finish(); +} diff --git a/modules/navigation/nav_map.h b/modules/navigation/nav_map.h index f46297a7ce..5232e42bed 100644 --- a/modules/navigation/nav_map.h +++ b/modules/navigation/nav_map.h @@ -35,6 +35,7 @@ #include "core/math/math_defs.h" #include "core/templates/map.h" +#include "core/templates/thread_work_pool.h" #include "nav_utils.h" #include <KdTree.h> @@ -80,8 +81,12 @@ class NavMap : public NavRid { /// Change the id each time the map is updated. uint32_t map_update_id = 0; + /// Pooled threads for computing steps + ThreadWorkPool step_work_pool; + public: - NavMap() {} + NavMap(); + ~NavMap(); void set_up(Vector3 p_up); Vector3 get_up() const { |