Properly checking distance for changing parents of already processed nodes.
This commit is contained in:
@@ -268,14 +268,12 @@ Variant MultilevelAStarEx::find_path(const Vector2i &from, const Vector2i &to, b
|
|||||||
node->open(_pass, current, current->distanceFromStart + distance, to2);
|
node->open(_pass, current, current->distanceFromStart + distance, to2);
|
||||||
open.push_back(node);
|
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->parent = current;
|
||||||
node->distanceFromStart = current->distanceFromStart + distance;
|
node->distanceFromStart = current->distanceFromStart + distance;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// find the closest cell
|
// find the closest cell
|
||||||
if (node->distanceToEndForClosest < closest->distanceToEndForClosest)
|
if (node->distanceToEndForClosest < closest->distanceToEndForClosest)
|
||||||
|
|||||||
Reference in New Issue
Block a user