Skip to content

Commit

Permalink
Improvement: Graph Navigation performance boost (#3083)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
hannibal002 and hannibal002 authored Dec 20, 2024
1 parent 5761c02 commit dc99316
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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
}
Expand Down

0 comments on commit dc99316

Please sign in to comment.