Properly checking distance for changing parents of already processed nodes.
This commit is contained in:
@@ -268,13 +268,11 @@ Variant MultilevelAStarEx::find_path(const Vector2i &from, const Vector2i &to, b
|
||||
node->open(_pass, current, current->distanceFromStart + distance, to2);
|
||||
open.push_back(node);
|
||||
}
|
||||
else if (node->state(_pass) == Node::OPEN)
|
||||
// TODO: check if this should only be performed on open nodes or all nodes
|
||||
else if (current->distanceFromStart + distance < node->distanceFromStart)
|
||||
{
|
||||
if (current->distanceFromStart < node->parent->distanceFromStart)
|
||||
{
|
||||
node->parent = current;
|
||||
node->distanceFromStart = current->distanceFromStart + distance;
|
||||
}
|
||||
node->parent = current;
|
||||
node->distanceFromStart = current->distanceFromStart + distance;
|
||||
}
|
||||
|
||||
// find the closest cell
|
||||
|
||||
Reference in New Issue
Block a user