mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 07:27:15 +01:00
cleanup
This commit is contained in:
parent
bb11cd7b59
commit
b0d1a9e3bb
1 changed files with 9 additions and 14 deletions
|
@ -18,8 +18,6 @@ import javax.annotation.Nullable;
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import com.simibubi.create.content.trains.graph.DiscoveredPath;
|
import com.simibubi.create.content.trains.graph.DiscoveredPath;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.mutable.MutableDouble;
|
import org.apache.commons.lang3.mutable.MutableDouble;
|
||||||
import org.apache.commons.lang3.mutable.MutableObject;
|
import org.apache.commons.lang3.mutable.MutableObject;
|
||||||
|
|
||||||
|
@ -445,7 +443,7 @@ public class Navigation {
|
||||||
TrackGraph graph = train.graph;
|
TrackGraph graph = train.graph;
|
||||||
if (graph == null)
|
if (graph == null)
|
||||||
return null;
|
return null;
|
||||||
long startTime = System.nanoTime();
|
|
||||||
Couple<DiscoveredPath> results = Couple.create(null, null);
|
Couple<DiscoveredPath> results = Couple.create(null, null);
|
||||||
for (boolean forward : Iterate.trueAndFalse) {
|
for (boolean forward : Iterate.trueAndFalse) {
|
||||||
|
|
||||||
|
@ -500,9 +498,6 @@ public class Navigation {
|
||||||
boolean canDriveForward = train.hasForwardConductor() || train.runtime.paused;
|
boolean canDriveForward = train.hasForwardConductor() || train.runtime.paused;
|
||||||
boolean canDriveBackward = train.doubleEnded && train.hasBackwardConductor() || train.runtime.paused;
|
boolean canDriveBackward = train.doubleEnded && train.hasBackwardConductor() || train.runtime.paused;
|
||||||
|
|
||||||
long endTime = System.nanoTime();
|
|
||||||
long duration = (endTime - startTime);
|
|
||||||
|
|
||||||
if (backEmpty || !canDriveBackward)
|
if (backEmpty || !canDriveBackward)
|
||||||
return canDriveForward ? front : null;
|
return canDriveForward ? front : null;
|
||||||
if (frontEmpty || !canDriveForward)
|
if (frontEmpty || !canDriveForward)
|
||||||
|
@ -688,15 +683,15 @@ public class Navigation {
|
||||||
TrackNode newNode = target.getKey();
|
TrackNode newNode = target.getKey();
|
||||||
TrackEdge newEdge = target.getValue();
|
TrackEdge newEdge = target.getValue();
|
||||||
double newDistance = newEdge.getLength() + distance;
|
double newDistance = newEdge.getLength() + distance;
|
||||||
double straightDist = destination == null ? 0 : newNode.getLocation().getLocation().distanceTo(destination.edgeLocation.getSecond().getLocation());
|
double remainingDist = destination == null ? 0 : newNode.getLocation().getLocation().distanceTo(destination.edgeLocation.getSecond().getLocation());
|
||||||
int newPenalty = penalty;
|
|
||||||
reachedVia.putIfAbsent(newEdge, Pair.of(validTargets.size() > 1, Couple.create(node1, node2)));
|
reachedVia.putIfAbsent(newEdge, Pair.of(validTargets.size() > 1, Couple.create(node1, node2)));
|
||||||
if (destination != null && straightDist == 0.0 && stationTest.test(newDistance, newDistance + newPenalty, reachedVia,
|
if (destination != null && remainingDist == 0.0 && stationTest.test(newDistance, newDistance + penalty, reachedVia,
|
||||||
Pair.of(Couple.create(node2, newNode), newEdge), destination)){
|
Pair.of(Couple.create(node2, newNode), newEdge), destination)){
|
||||||
LogUtils.getLogger().info("Node term: " + total);
|
LogUtils.getLogger().info("Node term: " + total);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
frontier.add(new FrontierEntry(newDistance, newPenalty, straightDist, node2, newNode, newEdge));
|
frontier.add(new FrontierEntry(newDistance, penalty, remainingDist, node2, newNode, newEdge));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -705,15 +700,15 @@ public class Navigation {
|
||||||
|
|
||||||
double distance;
|
double distance;
|
||||||
int penalty;
|
int penalty;
|
||||||
double straight;
|
double remaining;
|
||||||
TrackNode node1;
|
TrackNode node1;
|
||||||
TrackNode node2;
|
TrackNode node2;
|
||||||
TrackEdge edge;
|
TrackEdge edge;
|
||||||
|
|
||||||
public FrontierEntry(double distance, int penalty, double straight, TrackNode node1, TrackNode node2, TrackEdge edge) {
|
public FrontierEntry(double distance, int penalty, double remaining, TrackNode node1, TrackNode node2, TrackEdge edge) {
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
this.penalty = penalty;
|
this.penalty = penalty;
|
||||||
this.straight = straight;
|
this.remaining = remaining;
|
||||||
this.node1 = node1;
|
this.node1 = node1;
|
||||||
this.node2 = node2;
|
this.node2 = node2;
|
||||||
this.edge = edge;
|
this.edge = edge;
|
||||||
|
@ -721,7 +716,7 @@ public class Navigation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(FrontierEntry o) {
|
public int compareTo(FrontierEntry o) {
|
||||||
return Double.compare(distance + penalty + straight, o.distance + o.penalty + o.straight);
|
return Double.compare(distance + penalty + remaining, o.distance + o.penalty + o.remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue