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