| 379 | } |
| 380 | |
| 381 | void NavMap2D::sync() { |
| 382 | // Performance Monitor. |
| 383 | performance_data.pm_region_count = regions.size(); |
| 384 | performance_data.pm_agent_count = agents.size(); |
| 385 | performance_data.pm_link_count = links.size(); |
| 386 | performance_data.pm_obstacle_count = obstacles.size(); |
| 387 | |
| 388 | _sync_async_tasks(); |
| 389 | |
| 390 | _sync_dirty_map_update_requests(); |
| 391 | |
| 392 | if (iteration_dirty && !iteration_building && !iteration_ready) { |
| 393 | _build_iteration(); |
| 394 | } |
| 395 | if (use_async_iterations && iteration_build_thread_task_id != WorkerThreadPool::INVALID_TASK_ID) { |
| 396 | if (WorkerThreadPool::get_singleton()->is_task_completed(iteration_build_thread_task_id)) { |
| 397 | WorkerThreadPool::get_singleton()->wait_for_task_completion(iteration_build_thread_task_id); |
| 398 | |
| 399 | iteration_build_thread_task_id = WorkerThreadPool::INVALID_TASK_ID; |
| 400 | iteration_building = false; |
| 401 | iteration_ready = true; |
| 402 | } |
| 403 | } |
| 404 | if (iteration_ready) { |
| 405 | _sync_iteration(); |
| 406 | |
| 407 | NavigationServer2D::get_singleton()->emit_signal(SNAME("map_changed"), get_self()); |
| 408 | } |
| 409 | |
| 410 | map_settings_dirty = false; |
| 411 | |
| 412 | _sync_avoidance(); |
| 413 | |
| 414 | performance_data.pm_polygon_count = 0; |
| 415 | performance_data.pm_edge_count = 0; |
| 416 | performance_data.pm_edge_merge_count = 0; |
| 417 | |
| 418 | for (NavRegion2D *region : regions) { |
| 419 | performance_data.pm_polygon_count += region->get_pm_polygon_count(); |
| 420 | performance_data.pm_edge_count += region->get_pm_edge_count(); |
| 421 | performance_data.pm_edge_merge_count += region->get_pm_edge_merge_count(); |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | void NavMap2D::_sync_avoidance() { |
| 426 | _sync_dirty_avoidance_update_requests(); |