mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Merge pull request #105257 from smix8/navbuilder_linkpolys
Remove no longer needed link polygons from NavMapBuilder
This commit is contained in:
commit
2bf96fe18c
6 changed files with 18 additions and 27 deletions
|
|
@ -269,16 +269,13 @@ void NavMapBuilder3D::_build_step_navlink_connections(NavMapIterationBuild3D &r_
|
|||
|
||||
real_t link_connection_radius = r_build.link_connection_radius;
|
||||
|
||||
LocalVector<Polygon> &link_polygons = map_iteration->link_polygons;
|
||||
LocalVector<NavLinkIteration3D> &links = map_iteration->link_iterations;
|
||||
int polygon_count = r_build.polygon_count;
|
||||
|
||||
real_t link_connection_radius_sqr = link_connection_radius * link_connection_radius;
|
||||
uint32_t link_poly_idx = 0;
|
||||
link_polygons.resize(links.size());
|
||||
|
||||
// Search for polygons within range of a nav link.
|
||||
for (const NavLinkIteration3D &link : links) {
|
||||
for (NavLinkIteration3D &link : links) {
|
||||
if (!link.get_enabled()) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -335,7 +332,9 @@ void NavMapBuilder3D::_build_step_navlink_connections(NavMapIterationBuild3D &r_
|
|||
|
||||
// If we have both a start and end point, then create a synthetic polygon to route through.
|
||||
if (closest_start_polygon && closest_end_polygon) {
|
||||
Polygon &new_polygon = link_polygons[link_poly_idx++];
|
||||
link.navmesh_polygons.clear();
|
||||
link.navmesh_polygons.resize(1);
|
||||
Polygon &new_polygon = link.navmesh_polygons[0];
|
||||
new_polygon.id = polygon_count++;
|
||||
new_polygon.owner = &link;
|
||||
|
||||
|
|
@ -384,22 +383,21 @@ void NavMapBuilder3D::_build_step_navlink_connections(NavMapIterationBuild3D &r_
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
r_build.polygon_count = polygon_count;
|
||||
}
|
||||
|
||||
void NavMapBuilder3D::_build_update_map_iteration(NavMapIterationBuild3D &r_build) {
|
||||
NavMapIteration3D *map_iteration = r_build.map_iteration;
|
||||
|
||||
LocalVector<Polygon> &link_polygons = map_iteration->link_polygons;
|
||||
|
||||
map_iteration->navmesh_polygon_count = r_build.polygon_count;
|
||||
map_iteration->link_polygon_count = link_polygons.size();
|
||||
|
||||
map_iteration->path_query_slots_mutex.lock();
|
||||
for (NavMeshQueries3D::PathQuerySlot &p_path_query_slot : map_iteration->path_query_slots) {
|
||||
p_path_query_slot.traversable_polys.clear();
|
||||
p_path_query_slot.traversable_polys.reserve(map_iteration->navmesh_polygon_count * 0.25);
|
||||
p_path_query_slot.path_corridor.clear();
|
||||
p_path_query_slot.path_corridor.resize(map_iteration->navmesh_polygon_count + map_iteration->link_polygon_count);
|
||||
p_path_query_slot.path_corridor.resize(map_iteration->navmesh_polygon_count);
|
||||
}
|
||||
map_iteration->path_query_slots_mutex.unlock();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ struct NavMapIterationBuild3D {
|
|||
NavMapIteration3D *map_iteration = nullptr;
|
||||
|
||||
int navmesh_polygon_count = 0;
|
||||
int link_polygon_count = 0;
|
||||
|
||||
void reset() {
|
||||
performance_data.reset();
|
||||
|
|
@ -68,7 +67,6 @@ struct NavMapIterationBuild3D {
|
|||
free_edge_count = 0;
|
||||
|
||||
navmesh_polygon_count = 0;
|
||||
link_polygon_count = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -77,13 +75,11 @@ struct NavMapIteration3D {
|
|||
RWLock rwlock;
|
||||
|
||||
Vector3 map_up;
|
||||
LocalVector<Nav3D::Polygon> link_polygons;
|
||||
|
||||
LocalVector<NavRegionIteration3D> region_iterations;
|
||||
LocalVector<NavLinkIteration3D> link_iterations;
|
||||
|
||||
int navmesh_polygon_count = 0;
|
||||
int link_polygon_count = 0;
|
||||
|
||||
// The edge connections that the map builds on top with the edge connection margin.
|
||||
HashMap<uint32_t, LocalVector<Nav3D::Edge::Connection>> external_region_connections;
|
||||
|
|
|
|||
|
|
@ -177,4 +177,6 @@ void NavLink3D::get_iteration_update(NavLinkIteration3D &r_iteration) {
|
|||
r_iteration.start_position = get_start_position();
|
||||
r_iteration.end_position = get_end_position();
|
||||
r_iteration.bidirectional = is_bidirectional();
|
||||
|
||||
r_iteration.navmesh_polygons.clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue