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) { void NavigationMesh::_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];
} }
_change_notify(); _change_notify();
} }
@ -313,16 +313,14 @@ Array NavigationMesh::_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;
} }
void NavigationMesh::add_polygon(const Vector<int> &p_polygon) { void NavigationMesh::add_polygon(const Vector<int> &p_polygon) {
Polygon polygon; polygons.push_back(p_polygon);
polygon.indices = p_polygon;
polygons.push_back(polygon);
_change_notify(); _change_notify();
} }
int NavigationMesh::get_polygon_count() const { int NavigationMesh::get_polygon_count() const {
@ -330,7 +328,7 @@ int NavigationMesh::get_polygon_count() const {
} }
Vector<int> NavigationMesh::get_polygon(int p_idx) { Vector<int> NavigationMesh::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 NavigationMesh::clear_polygons() { void NavigationMesh::clear_polygons() {
polygons.clear(); polygons.clear();

View File

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