From 307c67d9768354de6a217810eb050cbc19c76e36 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 28 Jun 2024 23:05:38 +0700 Subject: [PATCH] Relaxed path finder "reached" check --- .../ru/dbotthepony/kstarbound/world/entities/PathFinder.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PathFinder.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PathFinder.kt index 2d384d1f..fc0cd89c 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PathFinder.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PathFinder.kt @@ -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