Skip to content

Commit 7ccb5d4

Browse files
committed
Fix refining of path start
1 parent fc26de3 commit 7ccb5d4

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

common/src/main/kotlin/com/lambda/module/modules/movement/Pathfinder.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import com.lambda.util.player.MovementUtils.buildMovementInput
5151
import com.lambda.util.player.MovementUtils.mergeFrom
5252
import com.lambda.util.world.FastVector
5353
import com.lambda.util.world.WorldUtils.hasSupport
54+
import com.lambda.util.world.WorldUtils.isPathClear
5455
import com.lambda.util.world.fastVectorOf
5556
import com.lambda.util.world.toBlockPos
5657
import com.lambda.util.world.toFastVec
@@ -120,7 +121,8 @@ object Pathfinder : Module(
120121
currentStart = playerPos.toFastVec()
121122
needsUpdate = true
122123
}
123-
updateTargetNode()
124+
if (pathing.moveAlongPath) updateTargetNode()
125+
// info("${isPathClear(playerPos, targetPos)}")
124126
}
125127

126128
// listen<WorldEvent.BlockUpdate.Client> {
@@ -231,7 +233,6 @@ object Pathfinder : Module(
231233
}
232234
info("A* (Length: ${long.length().string} Nodes: ${long.size} T: $aStar ms) and \u03b8* (Length: ${short.length().string} Nodes: ${short.size} T: $thetaStar ms)")
233235
// println("Long: $long | Short: $short")
234-
short.moves.removeFirstOrNull()
235236
coarsePath = long
236237
refinedPath = short
237238
}
@@ -252,7 +253,6 @@ object Pathfinder : Module(
252253
}
253254
info("Lazy D* Lite (Length: ${long.length().string} Nodes: ${long.size} Graph Size: ${graph.size} T: $dStar ms) and \u03b8* (Length: ${short.length().string} Nodes: ${short.size} T: $thetaStar ms)")
254255
// println("Long: $long | Short: $short")
255-
short.moves.removeFirstOrNull()
256256
coarsePath = long
257257
refinedPath = short
258258
}

common/src/main/kotlin/com/lambda/pathing/Pathing.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ object Pathing {
7373
}
7474

7575
fun SafeContext.thetaStarClearance(path: Path, config: PathingConfig): Path {
76-
if (path.moves.isEmpty()) return Path()
76+
if (path.moves.isEmpty()) return path
7777

7878
val cleanedPath = Path()
7979
var currentIndex = 0
@@ -84,22 +84,18 @@ object Pathing {
8484
cleanedPath.append(startMove)
8585

8686
// Attempt to skip over as many nodes as possible
87-
// by checking if they share the same Y and have a clear path
8887
var nextIndex = currentIndex + 1
8988
while (nextIndex < path.moves.size) {
9089
val candidateMove = path.moves[nextIndex]
90+
val startPos = startMove.pos.toBlockPos()
91+
val candidatePos = candidateMove.pos.toBlockPos()
9192

9293
// Only try to skip if both moves are on the same Y level
93-
if (startMove.pos.y != candidateMove.pos.y) break
94+
if (startPos.y != candidatePos.y) break
9495

9596
// Verify there's a clear path from the start move to the candidate
96-
if (
97-
isPathClear(
98-
startMove.pos.toBlockPos(),
99-
candidateMove.pos.toBlockPos(),
100-
config.clearancePrecision
101-
)
102-
) nextIndex++ else break
97+
val isClear = isPathClear(startPos, candidatePos, config.clearancePrecision)
98+
if (isClear) nextIndex++ else break
10399
}
104100

105101
// Move to the last node that was confirmed reachable

common/src/main/kotlin/com/lambda/pathing/dstar/LazyGraph.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ class LazyGraph(
112112
}
113113
}
114114
dirtyNodes.take(maxElements).forEach { node ->
115-
renderer.buildOutline(
116-
Box.of(node.toCenterVec3d(), 0.3, 0.3, 0.3),
117-
Color.RED
118-
)
115+
renderer.buildOutline(Box.of(node.toCenterVec3d(), 0.2, 0.2, 0.2), Color.RED)
119116
}
120117
}
121118

0 commit comments

Comments
 (0)