Relaxed path finder "reached" check

This commit is contained in:
DBotThePony 2024-06-28 23:05:38 +07:00
parent d9b25c960d
commit 307c67d976
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -135,8 +135,8 @@ class PathFinder(val world: World<*, *>, val start: Vector2d, val goal: Vector2d
// through.
val bottom = standingBox.mins.y
val x = (pos.x / NODE_GRANULARITY).roundToInt() * NODE_GRANULARITY
val y = ((pos.y + bottom) / NODE_GRANULARITY).roundToInt() * NODE_GRANULARITY - bottom
val x = (pos.x / NODE_GRANULARITY + 0.5).toInt() * NODE_GRANULARITY
val y = ((pos.y + bottom) / NODE_GRANULARITY + 0.5).toInt() * NODE_GRANULARITY - bottom
return Vector2d(x, y)
}
@ -671,7 +671,7 @@ class PathFinder(val world: World<*, *>, val start: Vector2d, val goal: Vector2d
if (closest > node)
closest = node
if (node.position.distance(goal) <= NODE_GRANULARITY && (!parameters.mustEndOnGround || onGround(node.position) && node.velocity == null)) {
if (node.position.distance(goal) <= NODE_GRANULARITY * 2.0 && (!parameters.mustEndOnGround || onGround(node.position) && node.velocity == null)) {
closest = node
result = KOptional(closest.reconstructPath())
return true