You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-29 16:16:38 +00:00
Add function to get navigation map iteration id from NavigationServer
Adds function to get navigation map iteration id from NavigationServer.
This commit is contained in:
@@ -121,13 +121,13 @@ COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
|
||||
if (p_active) {
|
||||
if (!map_is_active(p_map)) {
|
||||
active_maps.push_back(map);
|
||||
active_maps_update_id.push_back(map->get_map_update_id());
|
||||
active_maps_iteration_id.push_back(map->get_iteration_id());
|
||||
}
|
||||
} else {
|
||||
int map_index = active_maps.find(map);
|
||||
ERR_FAIL_COND(map_index < 0);
|
||||
active_maps.remove_at(map_index);
|
||||
active_maps_update_id.remove_at(map_index);
|
||||
active_maps_iteration_id.remove_at(map_index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1165,7 +1165,7 @@ COMMAND_1(free, RID, p_object) {
|
||||
int map_index = active_maps.find(map);
|
||||
if (map_index >= 0) {
|
||||
active_maps.remove_at(map_index);
|
||||
active_maps_update_id.remove_at(map_index);
|
||||
active_maps_iteration_id.remove_at(map_index);
|
||||
}
|
||||
map_owner.free(p_object);
|
||||
|
||||
@@ -1258,6 +1258,13 @@ void GodotNavigationServer::map_force_update(RID p_map) {
|
||||
map->sync();
|
||||
}
|
||||
|
||||
uint32_t GodotNavigationServer::map_get_iteration_id(RID p_map) const {
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_NULL_V(map, 0);
|
||||
|
||||
return map->get_iteration_id();
|
||||
}
|
||||
|
||||
void GodotNavigationServer::sync() {
|
||||
#ifndef _3D_DISABLED
|
||||
if (navmesh_generator_3d) {
|
||||
@@ -1300,10 +1307,10 @@ void GodotNavigationServer::process(real_t p_delta_time) {
|
||||
_new_pm_edge_free_count += active_maps[i]->get_pm_edge_free_count();
|
||||
|
||||
// Emit a signal if a map changed.
|
||||
const uint32_t new_map_update_id = active_maps[i]->get_map_update_id();
|
||||
if (new_map_update_id != active_maps_update_id[i]) {
|
||||
const uint32_t new_map_iteration_id = active_maps[i]->get_iteration_id();
|
||||
if (new_map_iteration_id != active_maps_iteration_id[i]) {
|
||||
emit_signal(SNAME("map_changed"), active_maps[i]->get_self());
|
||||
active_maps_update_id[i] = new_map_update_id;
|
||||
active_maps_iteration_id[i] = new_map_iteration_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user