Merge pull request #8850 from tagcup/astar_overestimate

Avoid overestimating the cost in AStar heuristics.
This commit is contained in:
Rémi Verschelde 2017-05-22 15:15:25 +02:00 committed by GitHub
commit 6dfab3c7e9
2 changed files with 2 additions and 1 deletions

View file

@ -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) {

View file

@ -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>