diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 4e42d534..65008fd6 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -29,6 +29,7 @@ import engine.objects.*; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; +import java.awt.geom.AffineTransform; import java.awt.geom.Path2D; import java.time.LocalDateTime; import java.time.ZoneId; @@ -965,7 +966,7 @@ public enum BuildingManager { } public static void bakeNavMesh(Building building) { - building.meshes = new ArrayList<>(); + if (building.parentZone == null) { Logger.error("Attempt to bake navmesh with no parent: " + building.getObjectUUID()); return; @@ -982,10 +983,6 @@ public enum BuildingManager { return; } - for (Path2D.Float meshEntry : convexHullList) { - building.meshes.add(meshEntry); - building.parentZone.navObstacles.add(meshEntry); - } //add navNodes to parent zone list float X = building.getBounds().getHalfExtents().x; float Y = building.getBounds().getHalfExtents().y; @@ -1043,4 +1040,16 @@ public enum BuildingManager { outPath.closePath(); return outPath; } + + public static void loadColliders(Building building){ + building.meshes = new ArrayList<>(); + for(Path2D.Float path : _hull_data.get(building.meshUUID)){ + Path2D.Float translatedPath = new Path2D.Float(path); + AffineTransform offset = AffineTransform.getTranslateInstance(building.loc.x , building.loc.y); + translatedPath.transform(offset); + AffineTransform rotate = AffineTransform.getRotateInstance(Math.toRadians(building.getRot().y), building.loc.x, building.loc.z); + translatedPath.transform(rotate); + building.meshes.add(translatedPath); + } + } } diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 8e1a6a25..b6cd0a7c 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -1008,6 +1008,7 @@ public class Building extends AbstractWorldObject { if (this.upgradeDateTime != null) BuildingManager.submitUpgradeJob(this); + BuildingManager.loadColliders(this); // load building colliders BuildingManager.bakeNavMesh(this); // update the navmesh of the parent zone }