summaryrefslogtreecommitdiff
path: root/core/math/a_star.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-02-18 11:27:04 +0100
committerGitHub <noreply@github.com>2020-02-18 11:27:04 +0100
commitef5891091bceef2800b4fae4cd85af219e791467 (patch)
tree8d58cca8cae2c34d408450cfb5ceb198543147b7 /core/math/a_star.cpp
parentc7faf2e16b684f3dd0246dbdb662b1826dd24571 (diff)
parent3205a92ad872f918c8322cdcd1434c231a1fd251 (diff)
Merge pull request #36311 from reduz/poolvector-deprecation
Convert all references and instances of PoolVector to Vector
Diffstat (limited to 'core/math/a_star.cpp')
-rw-r--r--core/math/a_star.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 73f190a330..b26903e45a 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -235,13 +235,13 @@ Array AStar::get_points() {
return point_list;
}
-PoolVector<int> AStar::get_point_connections(int p_id) {
+Vector<int> AStar::get_point_connections(int p_id) {
Point *p;
bool p_exists = points.lookup(p_id, p);
- ERR_FAIL_COND_V(!p_exists, PoolVector<int>());
+ ERR_FAIL_COND_V(!p_exists, Vector<int>());
- PoolVector<int> point_list;
+ Vector<int> point_list;
for (OAHashMap<int, Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) {
point_list.push_back((*it.key));
@@ -431,18 +431,18 @@ float AStar::_compute_cost(int p_from_id, int p_to_id) {
return from_point->pos.distance_to(to_point->pos);
}
-PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
+Vector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
Point *a;
bool from_exists = points.lookup(p_from_id, a);
- ERR_FAIL_COND_V(!from_exists, PoolVector<Vector3>());
+ ERR_FAIL_COND_V(!from_exists, Vector<Vector3>());
Point *b;
bool to_exists = points.lookup(p_to_id, b);
- ERR_FAIL_COND_V(!to_exists, PoolVector<Vector3>());
+ ERR_FAIL_COND_V(!to_exists, Vector<Vector3>());
if (a == b) {
- PoolVector<Vector3> ret;
+ Vector<Vector3> ret;
ret.push_back(a->pos);
return ret;
}
@@ -451,7 +451,7 @@ PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
Point *end_point = b;
bool found_route = _solve(begin_point, end_point);
- if (!found_route) return PoolVector<Vector3>();
+ if (!found_route) return Vector<Vector3>();
Point *p = end_point;
int pc = 1; // Begin point
@@ -460,11 +460,11 @@ PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
p = p->prev_point;
}
- PoolVector<Vector3> path;
+ Vector<Vector3> path;
path.resize(pc);
{
- PoolVector<Vector3>::Write w = path.write();
+ Vector3 *w = path.ptrw();
Point *p2 = end_point;
int idx = pc - 1;
@@ -479,18 +479,18 @@ PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
return path;
}
-PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
+Vector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
Point *a;
bool from_exists = points.lookup(p_from_id, a);
- ERR_FAIL_COND_V(!from_exists, PoolVector<int>());
+ ERR_FAIL_COND_V(!from_exists, Vector<int>());
Point *b;
bool to_exists = points.lookup(p_to_id, b);
- ERR_FAIL_COND_V(!to_exists, PoolVector<int>());
+ ERR_FAIL_COND_V(!to_exists, Vector<int>());
if (a == b) {
- PoolVector<int> ret;
+ Vector<int> ret;
ret.push_back(a->id);
return ret;
}
@@ -499,7 +499,7 @@ PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
Point *end_point = b;
bool found_route = _solve(begin_point, end_point);
- if (!found_route) return PoolVector<int>();
+ if (!found_route) return Vector<int>();
Point *p = end_point;
int pc = 1; // Begin point
@@ -508,11 +508,11 @@ PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
p = p->prev_point;
}
- PoolVector<int> path;
+ Vector<int> path;
path.resize(pc);
{
- PoolVector<int>::Write w = path.write();
+ int *w = path.ptrw();
p = end_point;
int idx = pc - 1;
@@ -624,7 +624,7 @@ bool AStar2D::has_point(int p_id) const {
return astar.has_point(p_id);
}
-PoolVector<int> AStar2D::get_point_connections(int p_id) {
+Vector<int> AStar2D::get_point_connections(int p_id) {
return astar.get_point_connections(p_id);
}
@@ -677,15 +677,15 @@ Vector2 AStar2D::get_closest_position_in_segment(const Vector2 &p_point) const {
return Vector2(p.x, p.y);
}
-PoolVector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) {
+Vector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) {
- PoolVector3Array pv = astar.get_point_path(p_from_id, p_to_id);
+ PackedVector3Array pv = astar.get_point_path(p_from_id, p_to_id);
int size = pv.size();
- PoolVector2Array path;
+ PackedVector2Array path;
path.resize(size);
{
- PoolVector<Vector3>::Read r = pv.read();
- PoolVector<Vector2>::Write w = path.write();
+ const Vector3 *r = pv.ptr();
+ Vector2 *w = path.ptrw();
for (int i = 0; i < size; i++) {
Vector3 p = r[i];
w[i] = Vector2(p.x, p.y);
@@ -694,7 +694,7 @@ PoolVector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) {
return path;
}
-PoolVector<int> AStar2D::get_id_path(int p_from_id, int p_to_id) {
+Vector<int> AStar2D::get_id_path(int p_from_id, int p_to_id) {
return astar.get_id_path(p_from_id, p_to_id);
}