From dc9931661b861d92b701cf14fa9bf66410d29eff Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 20 Dec 2024 01:30:21 +0100 Subject: [PATCH] Improvement: Graph Navigation performance boost (#3083) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt index 957d1e837820..b814f0a40af2 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt @@ -103,7 +103,6 @@ object IslandGraphs { private var pathfindClosestNode: GraphNode? = null var closestNode: GraphNode? = null - private var secondClosestNode: GraphNode? = null private var currentTarget: LorenzVec? = null private var currentTargetNode: GraphNode? = null @@ -251,13 +250,11 @@ object IslandGraphs { } val graph = currentIslandGraph ?: return - val sortedNodes = graph.sortedBy { it.position.distanceSqToPlayer() } - val newClosest = sortedNodes.first() + val newClosest = graph.minBy { it.position.distanceSqToPlayer() } if (pathfindClosestNode == newClosest) return val newPath = !onCurrentPath() closestNode = newClosest - secondClosestNode = sortedNodes.getOrNull(1) onNewNode() if (newClosest == prevClosest) return if (newPath) { @@ -277,9 +274,6 @@ object IslandGraphs { val newNodes = path.drop(index) val newGraph = Graph(newNodes) fastestPath = skipIfCloser(newGraph) - newNodes.getOrNull(1)?.let { - secondClosestNode = it - } setFastestPath(newGraph to newGraph.totalLenght(), setPath = false) return true }