summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-05-22 15:15:25 +0200
committerGitHub <noreply@github.com>2017-05-22 15:15:25 +0200
commit6dfab3c7e92992293c536248d2244c12da8aef38 (patch)
tree3c4f454bb0446b709b67f2c205292d2cc4ad041c
parenta9fc9a464209c26271f653c311b384cc788778cc (diff)
parente4eb093c62044cdce05ada0e0a42011c7e6628cf (diff)
Merge pull request #8850 from tagcup/astar_overestimate
Avoid overestimating the cost in AStar heuristics.
-rw-r--r--core/math/a_star.cpp2
-rw-r--r--doc/base/classes.xml1
2 files changed, 2 insertions, 1 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 7e061359fc..fa84144271 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -43,6 +43,7 @@ int AStar::get_available_point_id() const {
void AStar::add_point(int p_id, const Vector3 &p_pos, real_t p_weight_scale) {
ERR_FAIL_COND(p_id < 0);
+ ERR_FAIL_COND(p_weight_scale < 1);
if (!points.has(p_id)) {
Point *pt = memnew(Point);
pt->id = p_id;
@@ -221,7 +222,6 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
real_t cost = p->distance;
cost += _estimate_cost(p->id, end_point->id);
- cost *= p->weight_scale;
if (cost < least_cost) {
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index a04890d4fd..da614e14d3 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -1991,6 +1991,7 @@
<argument index="1" name="pos" type="Vector3">
</argument>
<argument index="2" name="weight_scale" type="float" default="1">
+ Weight scale has to be 1 or larger.
</argument>
<description>
</description>