Removed the Polygon struct from NavigationMesh.

This commit is contained in:
Relintai 2023-06-05 19:07:04 +02:00
parent 3c9d9bdad4
commit c72a079c49
2 changed files with 5 additions and 10 deletions

View File

@ -304,7 +304,7 @@ PoolVector<Vector3> NavigationMesh::get_vertices() const {
void NavigationMesh::_set_polygons(const Array &p_array) {
polygons.resize(p_array.size());
for (int i = 0; i < p_array.size(); i++) {
polygons.write[i].indices = p_array[i];
polygons.write[i] = p_array[i];
}
_change_notify();
}
@ -313,16 +313,14 @@ Array NavigationMesh::_get_polygons() const {
Array ret;
ret.resize(polygons.size());
for (int i = 0; i < ret.size(); i++) {
ret[i] = polygons[i].indices;
ret[i] = polygons[i];
}
return ret;
}
void NavigationMesh::add_polygon(const Vector<int> &p_polygon) {
Polygon polygon;
polygon.indices = p_polygon;
polygons.push_back(polygon);
polygons.push_back(p_polygon);
_change_notify();
}
int NavigationMesh::get_polygon_count() const {
@ -330,7 +328,7 @@ int NavigationMesh::get_polygon_count() const {
}
Vector<int> NavigationMesh::get_polygon(int p_idx) {
ERR_FAIL_INDEX_V(p_idx, polygons.size(), Vector<int>());
return polygons[p_idx].indices;
return polygons[p_idx];
}
void NavigationMesh::clear_polygons() {
polygons.clear();

View File

@ -41,10 +41,7 @@ class NavigationMesh : public Resource {
friend class NavigationMeshGenerator;
PoolVector<Vector3> vertices;
struct Polygon {
Vector<int> indices;
};
Vector<Polygon> polygons;
Vector<Vector<int>> polygons;
Ref<ArrayMesh> debug_mesh;
protected: