From 3205a92ad872f918c8322cdcd1434c231a1fd251 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 17 Feb 2020 18:06:54 -0300 Subject: PoolVector is gone, replaced by Vector Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector`. --- core/math/a_star.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'core/math/a_star.cpp') 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 AStar::get_point_connections(int p_id) { +Vector AStar::get_point_connections(int p_id) { Point *p; bool p_exists = points.lookup(p_id, p); - ERR_FAIL_COND_V(!p_exists, PoolVector()); + ERR_FAIL_COND_V(!p_exists, Vector()); - PoolVector point_list; + Vector point_list; for (OAHashMap::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 AStar::get_point_path(int p_from_id, int p_to_id) { +Vector 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()); + ERR_FAIL_COND_V(!from_exists, Vector()); Point *b; bool to_exists = points.lookup(p_to_id, b); - ERR_FAIL_COND_V(!to_exists, PoolVector()); + ERR_FAIL_COND_V(!to_exists, Vector()); if (a == b) { - PoolVector ret; + Vector ret; ret.push_back(a->pos); return ret; } @@ -451,7 +451,7 @@ PoolVector 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(); + if (!found_route) return Vector(); Point *p = end_point; int pc = 1; // Begin point @@ -460,11 +460,11 @@ PoolVector AStar::get_point_path(int p_from_id, int p_to_id) { p = p->prev_point; } - PoolVector path; + Vector path; path.resize(pc); { - PoolVector::Write w = path.write(); + Vector3 *w = path.ptrw(); Point *p2 = end_point; int idx = pc - 1; @@ -479,18 +479,18 @@ PoolVector AStar::get_point_path(int p_from_id, int p_to_id) { return path; } -PoolVector AStar::get_id_path(int p_from_id, int p_to_id) { +Vector 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()); + ERR_FAIL_COND_V(!from_exists, Vector()); Point *b; bool to_exists = points.lookup(p_to_id, b); - ERR_FAIL_COND_V(!to_exists, PoolVector()); + ERR_FAIL_COND_V(!to_exists, Vector()); if (a == b) { - PoolVector ret; + Vector ret; ret.push_back(a->id); return ret; } @@ -499,7 +499,7 @@ PoolVector 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(); + if (!found_route) return Vector(); Point *p = end_point; int pc = 1; // Begin point @@ -508,11 +508,11 @@ PoolVector AStar::get_id_path(int p_from_id, int p_to_id) { p = p->prev_point; } - PoolVector path; + Vector path; path.resize(pc); { - PoolVector::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 AStar2D::get_point_connections(int p_id) { +Vector 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 AStar2D::get_point_path(int p_from_id, int p_to_id) { +Vector 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::Read r = pv.read(); - PoolVector::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 AStar2D::get_point_path(int p_from_id, int p_to_id) { return path; } -PoolVector AStar2D::get_id_path(int p_from_id, int p_to_id) { +Vector AStar2D::get_id_path(int p_from_id, int p_to_id) { return astar.get_id_path(p_from_id, p_to_id); } -- cgit v1.2.3