diff --git a/src/engine/devcmd/cmds/RegionCmd.java b/src/engine/devcmd/cmds/RegionCmd.java index 786c493a..81a561c6 100644 --- a/src/engine/devcmd/cmds/RegionCmd.java +++ b/src/engine/devcmd/cmds/RegionCmd.java @@ -19,6 +19,7 @@ import engine.objects.*; import java.awt.*; import java.awt.geom.Area; +import java.awt.geom.Path2D; import java.lang.reflect.Field; public class RegionCmd extends AbstractDevCmd { @@ -64,9 +65,9 @@ public class RegionCmd extends AbstractDevCmd { //} if( building != null){ boolean pointBlocked = false; - for(Area area : building.meshes){ + for(Path2D.Float area : building.meshes){ Vector3fImmutable pos = ((AbstractCharacter)target).loc; - if(area.contains(new Point((int) pos.x, (int) pos.z))){ + if(area.contains(pos.x, pos.z)){ pointBlocked = true; } } diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index e82ca047..b9ea7f9f 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -984,16 +984,17 @@ public enum BuildingManager { return; } - if(building.meshUUID == 24000){ - int i = 0; - } for (ArrayList meshEntry : convexHullList) { - Polygon poly = new Polygon(); + Path2D.Float meshBound = new Path2D.Float(); + Vector3fImmutable start = Vector3fImmutable.rotateAroundPoint(new Vector3fImmutable(meshEntry.get(0).x,building.loc.y,meshEntry.get(0).y),building.loc,building.getRot().getRotation()); + meshBound.moveTo(start.x,start.z); for (Vector2f vect : meshEntry) { - Vector3fImmutable rotationPoint = Vector3fImmutable.rotateAroundPoint(new Vector3fImmutable(vect.x + building.loc.x, 0, vect.y + building.loc.z), building.loc, building.getRot().getRotation()); - poly.addPoint((int) rotationPoint.x, (int) rotationPoint.z); + Vector3fImmutable pos = Vector3fImmutable.rotateAroundPoint(new Vector3fImmutable(vect.x,building.loc.y,vect.y),building.loc,building.getRot().getRotation()); + meshBound.lineTo(pos.x,pos.z); } - building.meshes.add(new Area(poly)); + meshBound.lineTo(start.x,start.z); + meshBound.closePath(); + building.meshes.add(meshBound); } } } diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index ccb901b7..8e1a6a25 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -35,6 +35,7 @@ import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.awt.geom.Area; +import java.awt.geom.Path2D; import java.sql.ResultSet; import java.sql.SQLException; import java.time.LocalDateTime; @@ -100,7 +101,7 @@ public class Building extends AbstractWorldObject { private ConcurrentHashMap condemned; private ArrayList children = null; - public ArrayList meshes; + public ArrayList meshes; /** * ResultSet Constructor