Added currentPathLength to OsmNode

This commit is contained in:
2023-02-08 19:09:46 +01:00
parent 55b9e87b7e
commit d3680565fc
2 changed files with 7 additions and 4 deletions

View File

@ -28,6 +28,7 @@ public class Pathfinder
List<OsmNode> toVisit = new() { startNode };
OsmNode closestNodeToGoal = toVisit.First();
closestNodeToGoal.currentPathWeight = 0;
closestNodeToGoal.currentPathLength = 0;
bool stop = false;
while (toVisit.Count > 0 && !stop)
@ -57,6 +58,7 @@ public class Pathfinder
{
neighbor.previousPathNode = closestNodeToGoal;
neighbor.currentPathWeight = newPotentialWeight;
neighbor.currentPathLength = closestNodeToGoal.currentPathLength + Utils.DistanceBetween(closestNodeToGoal, neighbor);
if (neighbor.Equals(goalNode))
stop = true;