summaryrefslogtreecommitdiffstats
path: root/modules/navigation
diff options
context:
space:
mode:
authorSpartan322 <Megacake1234@gmail.com>2024-11-11 09:07:04 -0500
committerSpartan322 <Megacake1234@gmail.com>2024-11-11 09:08:01 -0500
commit62fbec9f6f0722a1f9825c17f073742932082228 (patch)
treea10abf56ba93705731da1aaf338f2cf21403c6ad /modules/navigation
parente7894c2c4efdd51049a21af4892005381fe57cd6 (diff)
parent0f5f3bc9546b46b2029fc8896dc859697f1eab97 (diff)
downloadredot-engine-62fbec9f6f0722a1f9825c17f073742932082228.tar.gz
Merge commit godotengine/godot@0f5f3bc9546b46b2029fc8896dc859697f1eab97
Diffstat (limited to 'modules/navigation')
-rw-r--r--modules/navigation/3d/nav_mesh_queries_3d.cpp2
-rw-r--r--modules/navigation/nav_map.cpp9
-rw-r--r--modules/navigation/nav_map.h8
-rw-r--r--modules/navigation/nav_utils.h2
4 files changed, 12 insertions, 9 deletions
diff --git a/modules/navigation/3d/nav_mesh_queries_3d.cpp b/modules/navigation/3d/nav_mesh_queries_3d.cpp
index ba87e534c2..cc675f0976 100644
--- a/modules/navigation/3d/nav_mesh_queries_3d.cpp
+++ b/modules/navigation/3d/nav_mesh_queries_3d.cpp
@@ -236,7 +236,7 @@ Vector<Vector3> NavMeshQueries3D::polygons_get_path(const LocalVector<gd::Polygo
// Takes the current least_cost_poly neighbors (iterating over its edges) and compute the traveled_distance.
for (const gd::Edge &edge : navigation_polys[least_cost_id].poly->edges) {
// Iterate over connections in this edge, then compute the new optimized travel distance assigned to this polygon.
- for (int connection_index = 0; connection_index < edge.connections.size(); connection_index++) {
+ for (uint32_t connection_index = 0; connection_index < edge.connections.size(); connection_index++) {
const gd::Edge::Connection &connection = edge.connections[connection_index];
// Only consider the connection to another polygon if this polygon is in a region with compatible layers.
diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp
index e4c41925a9..38bb70568f 100644
--- a/modules/navigation/nav_map.cpp
+++ b/modules/navigation/nav_map.cpp
@@ -428,13 +428,8 @@ void NavMap::sync() {
_new_pm_polygon_count = polygon_count;
- struct ConnectionPair {
- gd::Edge::Connection connections[2];
- int size = 0;
- };
-
// Group all edges per key.
- HashMap<gd::EdgeKey, ConnectionPair, gd::EdgeKey> connection_pairs_map;
+ connection_pairs_map.clear();
connection_pairs_map.reserve(polygons.size());
int free_edges_count = 0; // How many ConnectionPairs have only one Connection.
@@ -471,7 +466,7 @@ void NavMap::sync() {
}
}
- LocalVector<gd::Edge::Connection> free_edges;
+ free_edges.clear();
free_edges.reserve(free_edges_count);
for (const KeyValue<gd::EdgeKey, ConnectionPair> &pair_it : connection_pairs_map) {
diff --git a/modules/navigation/nav_map.h b/modules/navigation/nav_map.h
index 3ddbeee592..2594ace8fc 100644
--- a/modules/navigation/nav_map.h
+++ b/modules/navigation/nav_map.h
@@ -130,6 +130,14 @@ class NavMap : public NavRid {
HashMap<NavRegion *, LocalVector<gd::Edge::Connection>> region_external_connections;
+ struct ConnectionPair {
+ gd::Edge::Connection connections[2];
+ int size = 0;
+ };
+
+ HashMap<gd::EdgeKey, ConnectionPair, gd::EdgeKey> connection_pairs_map;
+ LocalVector<gd::Edge::Connection> free_edges;
+
public:
NavMap();
~NavMap();
diff --git a/modules/navigation/nav_utils.h b/modules/navigation/nav_utils.h
index 5132a9bcec..525c786ec5 100644
--- a/modules/navigation/nav_utils.h
+++ b/modules/navigation/nav_utils.h
@@ -96,7 +96,7 @@ struct Edge {
};
/// Connections from this edge to other polygons.
- Vector<Connection> connections;
+ LocalVector<Connection> connections;
};
struct Polygon {