feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -32,7 +32,6 @@
|
|||
#include "a_star.compat.inc"
|
||||
|
||||
#include "core/math/geometry_3d.h"
|
||||
#include "core/object/script_language.h"
|
||||
|
||||
int64_t AStar3D::get_available_point_id() const {
|
||||
if (points.has(last_free_id)) {
|
||||
|
|
@ -40,7 +39,7 @@ int64_t AStar3D::get_available_point_id() const {
|
|||
while (points.has(cur_new_id)) {
|
||||
cur_new_id++;
|
||||
}
|
||||
const_cast<int64_t &>(last_free_id) = cur_new_id;
|
||||
last_free_id = cur_new_id;
|
||||
}
|
||||
|
||||
return last_free_id;
|
||||
|
|
@ -319,11 +318,11 @@ Vector3 AStar3D::get_closest_position_in_segment(const Vector3 &p_point) const {
|
|||
return closest_point;
|
||||
}
|
||||
|
||||
bool AStar3D::_solve(Point *begin_point, Point *end_point) {
|
||||
bool AStar3D::_solve(Point *begin_point, Point *end_point, bool p_allow_partial_path) {
|
||||
last_closest_point = nullptr;
|
||||
pass++;
|
||||
|
||||
if (!end_point->enabled) {
|
||||
if (!end_point->enabled && !p_allow_partial_path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -391,9 +390,9 @@ bool AStar3D::_solve(Point *begin_point, Point *end_point) {
|
|||
return found_route;
|
||||
}
|
||||
|
||||
real_t AStar3D::_estimate_cost(int64_t p_from_id, int64_t p_to_id) {
|
||||
real_t AStar3D::_estimate_cost(int64_t p_from_id, int64_t p_end_id) {
|
||||
real_t scost;
|
||||
if (GDVIRTUAL_CALL(_estimate_cost, p_from_id, p_to_id, scost)) {
|
||||
if (GDVIRTUAL_CALL(_estimate_cost, p_from_id, p_end_id, scost)) {
|
||||
return scost;
|
||||
}
|
||||
|
||||
|
|
@ -401,11 +400,11 @@ real_t AStar3D::_estimate_cost(int64_t p_from_id, int64_t p_to_id) {
|
|||
bool from_exists = points.lookup(p_from_id, from_point);
|
||||
ERR_FAIL_COND_V_MSG(!from_exists, 0, vformat("Can't estimate cost. Point with id: %d doesn't exist.", p_from_id));
|
||||
|
||||
Point *to_point = nullptr;
|
||||
bool to_exists = points.lookup(p_to_id, to_point);
|
||||
ERR_FAIL_COND_V_MSG(!to_exists, 0, vformat("Can't estimate cost. Point with id: %d doesn't exist.", p_to_id));
|
||||
Point *end_point = nullptr;
|
||||
bool end_exists = points.lookup(p_end_id, end_point);
|
||||
ERR_FAIL_COND_V_MSG(!end_exists, 0, vformat("Can't estimate cost. Point with id: %d doesn't exist.", p_end_id));
|
||||
|
||||
return from_point->pos.distance_to(to_point->pos);
|
||||
return from_point->pos.distance_to(end_point->pos);
|
||||
}
|
||||
|
||||
real_t AStar3D::_compute_cost(int64_t p_from_id, int64_t p_to_id) {
|
||||
|
|
@ -443,7 +442,7 @@ Vector<Vector3> AStar3D::get_point_path(int64_t p_from_id, int64_t p_to_id, bool
|
|||
Point *begin_point = a;
|
||||
Point *end_point = b;
|
||||
|
||||
bool found_route = _solve(begin_point, end_point);
|
||||
bool found_route = _solve(begin_point, end_point, p_allow_partial_path);
|
||||
if (!found_route) {
|
||||
if (!p_allow_partial_path || last_closest_point == nullptr) {
|
||||
return Vector<Vector3>();
|
||||
|
|
@ -497,7 +496,7 @@ Vector<int64_t> AStar3D::get_id_path(int64_t p_from_id, int64_t p_to_id, bool p_
|
|||
Point *begin_point = a;
|
||||
Point *end_point = b;
|
||||
|
||||
bool found_route = _solve(begin_point, end_point);
|
||||
bool found_route = _solve(begin_point, end_point, p_allow_partial_path);
|
||||
if (!found_route) {
|
||||
if (!p_allow_partial_path || last_closest_point == nullptr) {
|
||||
return Vector<int64_t>();
|
||||
|
|
@ -579,7 +578,7 @@ void AStar3D::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_point_path", "from_id", "to_id", "allow_partial_path"), &AStar3D::get_point_path, DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("get_id_path", "from_id", "to_id", "allow_partial_path"), &AStar3D::get_id_path, DEFVAL(false));
|
||||
|
||||
GDVIRTUAL_BIND(_estimate_cost, "from_id", "to_id")
|
||||
GDVIRTUAL_BIND(_estimate_cost, "from_id", "end_id")
|
||||
GDVIRTUAL_BIND(_compute_cost, "from_id", "to_id")
|
||||
}
|
||||
|
||||
|
|
@ -675,9 +674,9 @@ Vector2 AStar2D::get_closest_position_in_segment(const Vector2 &p_point) const {
|
|||
return Vector2(p.x, p.y);
|
||||
}
|
||||
|
||||
real_t AStar2D::_estimate_cost(int64_t p_from_id, int64_t p_to_id) {
|
||||
real_t AStar2D::_estimate_cost(int64_t p_from_id, int64_t p_end_id) {
|
||||
real_t scost;
|
||||
if (GDVIRTUAL_CALL(_estimate_cost, p_from_id, p_to_id, scost)) {
|
||||
if (GDVIRTUAL_CALL(_estimate_cost, p_from_id, p_end_id, scost)) {
|
||||
return scost;
|
||||
}
|
||||
|
||||
|
|
@ -685,11 +684,11 @@ real_t AStar2D::_estimate_cost(int64_t p_from_id, int64_t p_to_id) {
|
|||
bool from_exists = astar.points.lookup(p_from_id, from_point);
|
||||
ERR_FAIL_COND_V_MSG(!from_exists, 0, vformat("Can't estimate cost. Point with id: %d doesn't exist.", p_from_id));
|
||||
|
||||
AStar3D::Point *to_point = nullptr;
|
||||
bool to_exists = astar.points.lookup(p_to_id, to_point);
|
||||
ERR_FAIL_COND_V_MSG(!to_exists, 0, vformat("Can't estimate cost. Point with id: %d doesn't exist.", p_to_id));
|
||||
AStar3D::Point *end_point = nullptr;
|
||||
bool to_exists = astar.points.lookup(p_end_id, end_point);
|
||||
ERR_FAIL_COND_V_MSG(!to_exists, 0, vformat("Can't estimate cost. Point with id: %d doesn't exist.", p_end_id));
|
||||
|
||||
return from_point->pos.distance_to(to_point->pos);
|
||||
return from_point->pos.distance_to(end_point->pos);
|
||||
}
|
||||
|
||||
real_t AStar2D::_compute_cost(int64_t p_from_id, int64_t p_to_id) {
|
||||
|
|
@ -726,7 +725,7 @@ Vector<Vector2> AStar2D::get_point_path(int64_t p_from_id, int64_t p_to_id, bool
|
|||
AStar3D::Point *begin_point = a;
|
||||
AStar3D::Point *end_point = b;
|
||||
|
||||
bool found_route = _solve(begin_point, end_point);
|
||||
bool found_route = _solve(begin_point, end_point, p_allow_partial_path);
|
||||
if (!found_route) {
|
||||
if (!p_allow_partial_path || astar.last_closest_point == nullptr) {
|
||||
return Vector<Vector2>();
|
||||
|
|
@ -780,7 +779,7 @@ Vector<int64_t> AStar2D::get_id_path(int64_t p_from_id, int64_t p_to_id, bool p_
|
|||
AStar3D::Point *begin_point = a;
|
||||
AStar3D::Point *end_point = b;
|
||||
|
||||
bool found_route = _solve(begin_point, end_point);
|
||||
bool found_route = _solve(begin_point, end_point, p_allow_partial_path);
|
||||
if (!found_route) {
|
||||
if (!p_allow_partial_path || astar.last_closest_point == nullptr) {
|
||||
return Vector<int64_t>();
|
||||
|
|
@ -816,11 +815,11 @@ Vector<int64_t> AStar2D::get_id_path(int64_t p_from_id, int64_t p_to_id, bool p_
|
|||
return path;
|
||||
}
|
||||
|
||||
bool AStar2D::_solve(AStar3D::Point *begin_point, AStar3D::Point *end_point) {
|
||||
bool AStar2D::_solve(AStar3D::Point *begin_point, AStar3D::Point *end_point, bool p_allow_partial_path) {
|
||||
astar.last_closest_point = nullptr;
|
||||
astar.pass++;
|
||||
|
||||
if (!end_point->enabled) {
|
||||
if (!end_point->enabled && !p_allow_partial_path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -918,6 +917,6 @@ void AStar2D::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_point_path", "from_id", "to_id", "allow_partial_path"), &AStar2D::get_point_path, DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("get_id_path", "from_id", "to_id", "allow_partial_path"), &AStar2D::get_id_path, DEFVAL(false));
|
||||
|
||||
GDVIRTUAL_BIND(_estimate_cost, "from_id", "to_id")
|
||||
GDVIRTUAL_BIND(_estimate_cost, "from_id", "end_id")
|
||||
GDVIRTUAL_BIND(_compute_cost, "from_id", "to_id")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue