mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-21 20:18:14 +07:00
Changed rounding behavior of positions
Changed rounding behavior of position from casting down to Math.round This has helped smooth pathing and prevent some on-the-fly pathing bugs
This commit is contained in:
parent
e9b2d6f2fb
commit
0016dda7da
@ -272,6 +272,10 @@ public class Map implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
static int round(float i) {
|
||||
return MathUtils.round(i);
|
||||
}
|
||||
|
||||
// TODO: maybe replace with R-tree? // https://en.wikipedia.org/wiki/R-tree
|
||||
Array<Zone> zones = new Array<>();
|
||||
IntMap<DT1s> dt1s;
|
||||
|
@ -14,6 +14,7 @@ import com.badlogic.gdx.ai.pfa.indexed.IndexedGraph;
|
||||
import com.badlogic.gdx.ai.utils.Collision;
|
||||
import com.badlogic.gdx.ai.utils.Ray;
|
||||
import com.badlogic.gdx.ai.utils.RaycastCollisionDetector;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@ -67,8 +68,12 @@ public class MapGraph implements IndexedGraph<MapGraph.Point2> {
|
||||
public boolean searchNodePath(PathFinder<Point2> pathFinder, Vector3 src, Vector3 dst, GraphPath<Point2> path) {
|
||||
path.clear();
|
||||
if (dst == null) return false;
|
||||
Map.Zone zone = map.getZone((int) dst.x, (int) dst.y);
|
||||
if (zone != null && zone.flags((int) dst.x, (int) dst.y) != 0) {
|
||||
//Map.Zone zone = map.getZone((int) dst.x, (int) dst.y);
|
||||
//if (zone != null && zone.flags((int) dst.x, (int) dst.y) != 0) {
|
||||
int x = Map.round(dst.x);
|
||||
int y = Map.round(dst.y);
|
||||
Map.Zone zone = map.getZone(x, y);
|
||||
if (zone != null && zone.flags(x, y) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -158,7 +163,8 @@ public class MapGraph implements IndexedGraph<MapGraph.Point2> {
|
||||
}
|
||||
|
||||
Point2(Vector3 src) {
|
||||
this((int) src.x, (int) src.y);
|
||||
//this((int) src.x, (int) src.y);
|
||||
this(Map.round(src.x), Map.round(src.y));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -167,7 +173,8 @@ public class MapGraph implements IndexedGraph<MapGraph.Point2> {
|
||||
}
|
||||
|
||||
static int hash(Vector3 src) {
|
||||
return hash((int) src.x, (int) src.y);
|
||||
//return hash((int) src.x, (int) src.y);
|
||||
return hash(Map.round(src.x), Map.round(src.y));
|
||||
}
|
||||
|
||||
static int hash(int x, int y) {
|
||||
|
@ -263,8 +263,8 @@ public class MapRenderer {
|
||||
Vector3 pos = src.position();
|
||||
if (pos.epsilonEquals(currentPos) && !force) return;
|
||||
currentPos.set(pos);
|
||||
this.x = (int) pos.x;
|
||||
this.y = (int) pos.y;
|
||||
this.x = Map.round(pos.x);//(int) pos.x;
|
||||
this.y = Map.round(pos.y);//(int) pos.y;
|
||||
spx = (x * Tile.SUBTILE_WIDTH50) - (y * Tile.SUBTILE_WIDTH50);
|
||||
spy = -(x * Tile.SUBTILE_HEIGHT50) - (y * Tile.SUBTILE_HEIGHT50);
|
||||
float spxf = (pos.x * Tile.SUBTILE_WIDTH50) - (pos.y * Tile.SUBTILE_WIDTH50);
|
||||
|
Loading…
Reference in New Issue
Block a user