Removed the Polygon struct from NavigationPolygon.

This commit is contained in:
Relintai 2023-06-05 12:48:57 +02:00
parent 0bfa40bb09
commit 712eb8eb8a
2 changed files with 7 additions and 12 deletions

View File

@ -97,9 +97,7 @@ PoolVector<Vector2> NavigationPolygon::get_vertices() const {
} }
void NavigationPolygon::add_polygon(const Vector<int> &p_polygon) { void NavigationPolygon::add_polygon(const Vector<int> &p_polygon) {
Polygon polygon; polygons.push_back(p_polygon);
polygon.indices = p_polygon;
polygons.push_back(polygon);
{ {
MutexLock lock(navmesh_generation); MutexLock lock(navmesh_generation);
navmesh.unref(); navmesh.unref();
@ -117,7 +115,7 @@ int NavigationPolygon::get_polygon_count() const {
Vector<int> NavigationPolygon::get_polygon(int p_idx) { Vector<int> NavigationPolygon::get_polygon(int p_idx) {
ERR_FAIL_INDEX_V(p_idx, polygons.size(), Vector<int>()); ERR_FAIL_INDEX_V(p_idx, polygons.size(), Vector<int>());
return polygons[p_idx].indices; return polygons[p_idx];
} }
void NavigationPolygon::clear_polygons() { void NavigationPolygon::clear_polygons() {
@ -270,7 +268,7 @@ void NavigationPolygon::make_polygons_from_outlines() {
for (List<TriangulatorPoly>::Element *I = out_poly.front(); I; I = I->next()) { for (List<TriangulatorPoly>::Element *I = out_poly.front(); I; I = I->next()) {
TriangulatorPoly &tp = I->get(); TriangulatorPoly &tp = I->get();
struct Polygon p; Vector<int> p;
for (int64_t i = 0; i < tp.GetNumPoints(); i++) { for (int64_t i = 0; i < tp.GetNumPoints(); i++) {
RBMap<Vector2, int>::Element *E = points.find(tp[i]); RBMap<Vector2, int>::Element *E = points.find(tp[i]);
@ -278,7 +276,7 @@ void NavigationPolygon::make_polygons_from_outlines() {
E = points.insert(tp[i], vertices.size()); E = points.insert(tp[i], vertices.size());
vertices.push_back(tp[i]); vertices.push_back(tp[i]);
} }
p.indices.push_back(E->get()); p.push_back(E->get());
} }
polygons.push_back(p); polygons.push_back(p);
@ -301,7 +299,7 @@ void NavigationPolygon::_set_polygons(const Array &p_array) {
} }
polygons.resize(p_array.size()); polygons.resize(p_array.size());
for (int i = 0; i < p_array.size(); i++) { for (int i = 0; i < p_array.size(); i++) {
polygons.write[i].indices = p_array[i]; polygons.write[i] = p_array[i];
} }
} }
@ -309,7 +307,7 @@ Array NavigationPolygon::_get_polygons() const {
Array ret; Array ret;
ret.resize(polygons.size()); ret.resize(polygons.size());
for (int i = 0; i < ret.size(); i++) { for (int i = 0; i < ret.size(); i++) {
ret[i] = polygons[i].indices; ret[i] = polygons[i];
} }
return ret; return ret;

View File

@ -79,10 +79,7 @@ protected:
private: private:
PoolVector<Vector2> vertices; PoolVector<Vector2> vertices;
struct Polygon { Vector<Vector<int>> polygons;
Vector<int> indices;
};
Vector<Polygon> polygons;
Vector<PoolVector<Vector2>> outlines; Vector<PoolVector<Vector2>> outlines;
mutable Rect2 item_rect; mutable Rect2 item_rect;