1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-19 14:31:59 +00:00

Merge pull request #60366 from adamscott/nav-map-thread-work-pool-3x

Use ThreadWorkPool instead of thread_process_array in NavMap [3.x]
This commit is contained in:
Rémi Verschelde
2022-04-26 18:45:53 +02:00
committed by GitHub
5 changed files with 252 additions and 2 deletions

View File

@@ -30,7 +30,6 @@
#include "nav_map.h"
#include "core/os/threaded_array_processor.h"
#include "nav_region.h"
#include "rvo_agent.h"
#include <algorithm>
@@ -52,6 +51,10 @@ NavMap::NavMap() :
deltatime(0.0),
map_update_id(0) {}
NavMap::~NavMap() {
step_work_pool.finish();
}
void NavMap::set_up(Vector3 p_up) {
up = p_up;
regenerate_polygons = true;
@@ -702,7 +705,10 @@ 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(
if (step_work_pool.get_thread_count() == 0) {
step_work_pool.init();
}
step_work_pool.do_work(
controlled_agents.size(),
this,
&NavMap::compute_single_step,