1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Fix avoidance calculation on NO_THREADS build

This commit is contained in:
smix8
2022-10-03 11:51:17 +02:00
parent cbde08d452
commit f15cb16b14
5 changed files with 14 additions and 0 deletions

View File

@@ -690,6 +690,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) {
#ifndef NO_THREADS
if (step_work_pool.get_thread_count() == 0) {
step_work_pool.init();
}
@@ -698,6 +699,12 @@ void NavMap::step(real_t p_deltatime) {
this,
&NavMap::compute_single_step,
controlled_agents.ptr());
#else
for (int i(0); i < static_cast<int>(controlled_agents.size()); i++) {
controlled_agents[i]->get_agent()->computeNeighbors(&rvo);
controlled_agents[i]->get_agent()->computeNewVelocity(deltatime);
}
#endif // NO_THREADS
}
}
@@ -743,5 +750,7 @@ NavMap::NavMap() {
}
NavMap::~NavMap() {
#ifndef NO_THREADS
step_work_pool.finish();
#endif // !NO_THREADS
}