renamed currentNode
This commit is contained in:
parent
0f53ae579c
commit
2ca4207fd7
@ -20,17 +20,17 @@ public static partial class Pathfinder
|
||||
|
||||
while (toVisit.Count > 0)
|
||||
{
|
||||
OsmNode closestNodeToGoal = toVisit.Dequeue();
|
||||
OsmNode currentNode = toVisit.Dequeue();
|
||||
|
||||
foreach (OsmEdge edge in closestNodeToGoal.edges)
|
||||
foreach (OsmEdge edge in currentNode.edges)
|
||||
{
|
||||
OsmNode? neighbor = regionManager.GetNode(edge.neighborId, edge.neighborRegion);
|
||||
if (neighbor is not null)
|
||||
{
|
||||
double newPotentialLength = closestNodeToGoal.currentPathLength + Utils.DistanceBetween(closestNodeToGoal, neighbor);
|
||||
double newPotentialLength = currentNode.currentPathLength + Utils.DistanceBetween(currentNode, neighbor);
|
||||
if (newPotentialLength < neighbor.currentPathLength)
|
||||
{
|
||||
neighbor.previousPathNode = closestNodeToGoal;
|
||||
neighbor.previousPathNode = currentNode;
|
||||
neighbor.currentPathLength = newPotentialLength;
|
||||
neighbor.directDistanceToGoal = Utils.DistanceBetween(neighbor, goalNode);
|
||||
|
||||
|
@ -21,20 +21,20 @@ public static partial class Pathfinder
|
||||
|
||||
while (toVisit.Count > 0)
|
||||
{
|
||||
OsmNode closestNodeToGoal = toVisit.Dequeue();
|
||||
OsmNode currentNode = toVisit.Dequeue();
|
||||
|
||||
foreach (OsmEdge edge in closestNodeToGoal.edges.Where(
|
||||
edge => regionManager.TestValidConnectionForType(closestNodeToGoal, edge, vehicle)))
|
||||
foreach (OsmEdge edge in currentNode.edges.Where(
|
||||
edge => regionManager.TestValidConnectionForType(currentNode, edge, vehicle)))
|
||||
{
|
||||
OsmNode? neighbor = regionManager.GetNode(edge.neighborId, edge.neighborRegion);
|
||||
if (neighbor is not null)
|
||||
{
|
||||
double newPotentialWeight = closestNodeToGoal.currentPathWeight +
|
||||
EdgeWeight(closestNodeToGoal, edge, vehicle, regionManager);
|
||||
double newPotentialWeight = currentNode.currentPathWeight +
|
||||
EdgeWeight(currentNode, edge, vehicle, regionManager);
|
||||
if (newPotentialWeight < neighbor.currentPathWeight)
|
||||
{
|
||||
neighbor.previousPathNode = closestNodeToGoal;
|
||||
neighbor.currentPathLength = closestNodeToGoal.currentPathLength + Utils.DistanceBetween(closestNodeToGoal, neighbor);
|
||||
neighbor.previousPathNode = currentNode;
|
||||
neighbor.currentPathLength = currentNode.currentPathLength + Utils.DistanceBetween(currentNode, neighbor);
|
||||
neighbor.currentPathWeight = newPotentialWeight;
|
||||
neighbor.directDistanceToGoal = Utils.DistanceBetween(neighbor, goalNode);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user