From 831cb5b1193da95ea7ac131b4cf07cf8c0b28d2b Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Tue, 16 May 2017 14:46:13 +0300 Subject: [PATCH] Fix weigth scale of A* being applied to the whole path and estimation Attempt to fix #8584 (cherry picked from commit bd91730347b33fd88d3944dc63fed06655f0b736) --- core/math/a_star.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 44e796044c8..7a79da1cee4 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -193,8 +193,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) { Point *n = begin_point->neighbours[i]; n->prev_point = begin_point; - n->distance = _compute_cost(n->id, begin_point->id); - n->distance *= n->weight_scale; + n->distance = _compute_cost(begin_point->id, n->id) * n->weight_scale; n->last_pass = pass; open_list.add(&n->list); @@ -238,8 +237,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) { Point *e = p->neighbours[i]; - float distance = _compute_cost(p->id, e->id) + p->distance; - distance *= e->weight_scale; + float distance = _compute_cost(p->id, e->id) * e->weight_scale + p->distance; if (e->last_pass == pass) { //oh this was visited already, can we win the cost?