aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/pathfinding
diff options
context:
space:
mode:
authorsyeyoung <cyoung06@naver.com>2021-09-18 16:46:07 +0900
committersyeyoung <cyoung06@naver.com>2021-09-18 16:46:07 +0900
commit07f74480447495e6cd42237e4740fb082cb4b821 (patch)
tree0b1f61eac4e424f5adf924b94f67dfe71d57ba98 /src/main/java/kr/syeyoung/dungeonsguide/pathfinding
parent44eef4302880c031465aae4d712f57ca366e2b44 (diff)
downloadSkyblock-Dungeons-Guide-07f74480447495e6cd42237e4740fb082cb4b821.tar.gz
Skyblock-Dungeons-Guide-07f74480447495e6cd42237e4740fb082cb4b821.tar.bz2
Skyblock-Dungeons-Guide-07f74480447495e6cd42237e4740fb082cb4b821.zip
Waypoints!
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/pathfinding')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java
index 42595d2f..b824c731 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java
@@ -103,9 +103,14 @@ public class JPSPathfinder {
long arr[];
- public boolean pathfind(Vec3 from, Vec3 to) {
+ public boolean pathfind(Vec3 from, Vec3 to, float within, long timeout) {
route.clear(); nodeMap.clearMap();
+ {
+ from = new Vec3(((int)(from.xCoord * 2)) / 2.0, ((int)(from.yCoord * 2)) / 2.0, ((int)(from.zCoord* 2)) / 2.0);
+ to = new Vec3(((int)(to.xCoord * 2)) / 2.0, ((int)(to.yCoord * 2)) / 2.0, ((int)(to.zCoord* 2)) / 2.0);
+ }
+
this.start = from; this.destination = to;
tx = (int)(to.xCoord * 2);
ty = (int)(to.yCoord * 2);
@@ -113,14 +118,14 @@ public class JPSPathfinder {
arr = new long[lenx *leny * lenz * 2 / 8];
- destinationBB = AxisAlignedBB.fromBounds((to.xCoord - 0.6)* 2, (to.yCoord - 0.6) * 2, (to.zCoord - 0.6) * 2, (to.xCoord + 0.6) * 2, (to.yCoord + 0.6)* 2, (to.zCoord + 0.6) *2);
+ destinationBB = AxisAlignedBB.fromBounds((to.xCoord - within)* 2, (to.yCoord - within) * 2, (to.zCoord - within) * 2, (to.xCoord + within) * 2, (to.yCoord + within)* 2, (to.zCoord + within) *2);
open.clear();
Node start;
open.add(start = openNode((int)from.xCoord* 2 + 1, (int)from.yCoord* 2 + 1, (int)from.zCoord * 2 + 1));
start.g = 0; start.f = 0; start.h = (float) from.squareDistanceTo(to);
Node end = null; float minDist = Float.MAX_VALUE;
- long forceEnd = System.currentTimeMillis() + 5000;
+ long forceEnd = System.currentTimeMillis() + timeout;
while(!open.isEmpty()) {
if (forceEnd < System.currentTimeMillis()) break;
Node n = open.poll();