From 12ee06e1280b7aa28887ee766ab4099a68809014 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 28 Oct 2023 00:22:27 -0500 Subject: [PATCH] region work --- .../mobileAI/utilities/MovementUtilities.java | 46 ++++--------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/src/engine/mobileAI/utilities/MovementUtilities.java b/src/engine/mobileAI/utilities/MovementUtilities.java index 94561854..4cf2efc7 100644 --- a/src/engine/mobileAI/utilities/MovementUtilities.java +++ b/src/engine/mobileAI/utilities/MovementUtilities.java @@ -32,7 +32,7 @@ import static engine.math.FastMath.sqrt; public class MovementUtilities { private static final int cellGap = 1; - private static final int stepHeight = 1; + private static final int stepHeight = 2; public static boolean inRangeOfBindLocation(Mob agent) { @@ -298,49 +298,18 @@ public class MovementUtilities { { count++; - Building building = BuildingManager.getBuildingAtLocation(point); - if(building != null){ - float halfX = building.getBounds().getHalfExtents().x; - float halfY = building.getBounds().getHalfExtents().y; - ArrayList corners = new ArrayList<>(); - corners.add(building.loc.add(new Vector3fImmutable(halfX,0,-halfY))); - corners.add(building.loc.add(new Vector3fImmutable(halfX,0,halfY))); - corners.add(building.loc.subtract(new Vector3fImmutable(halfX,0,halfY))); - corners.add(building.loc.add(new Vector3fImmutable(-halfX,0,halfY))); - Vector3fImmutable cheapCorner = Vector3fImmutable.ZERO; - for(Vector3fImmutable corn : corners){ - if(Bounds.collide(building.getBounds(),point,corn)) - continue; - if(getCost(corn,start,goal) < getCost(cheapCorner,start,goal)) - cheapCorner = corn; - } - if(!cheapCorner.equals(Vector3fImmutable.ZERO)) - if (path.contains(cheapCorner)) { - continue; - }else { - path.add(cheapCorner); - current = cheapCorner; - continue; - } - - - if (path.contains(point)) - continue; - } - if (path.contains(point)) continue; - Regions region = Regions.getRegionAtLocation(goal); - if(region != null) { - path.add(new Vector3fImmutable(region.center)); //only use center points when travelling through regions - continue; - } if (pointIsBlocked(point)) { obstructed = true; continue; } + Regions region = Regions.getRegionAtLocation(point); + if(region != null) + point = new Vector3fImmutable(point.x,region.lerpY(point),point.z); // adjust the Y value of the point to the region height it is in + if (getCost(cheapest, current, goal) > getCost(point, current, goal)) cheapest = point; @@ -371,6 +340,11 @@ public class MovementUtilities { if(building == null) return false;//no building at this location means nothing obstructing the walking path + Regions region = Regions.getRegionAtLocation(point); + if(region != null && Math.abs(region.lerpY(point) - point.y) < stepHeight) { + return false; + } + Zone currentZone = ZoneManager.findSmallestZone(point); if(currentZone == null) return false;