diff --git a/src/engine/CollisionEngine/CollisionManager.java b/src/engine/CollisionEngine/CollisionManager.java index 22701825..0867d6fb 100644 --- a/src/engine/CollisionEngine/CollisionManager.java +++ b/src/engine/CollisionEngine/CollisionManager.java @@ -10,8 +10,9 @@ import java.awt.geom.Rectangle2D; public class CollisionManager { public static boolean CollisionDetected(Building building, Line2D travelLine, float charHeight, float charY){ - if(building.buildingRect != null && !travelLine.intersects(building.buildingRect) && !building.buildingRect.contains(travelLine.getP1()) && !building.buildingRect.contains(travelLine.getP2())) - return false; + if(building.buildingRect != null) + if(!travelLine.intersects(building.buildingRect) && !building.buildingRect.contains(travelLine.getP1()) && !building.buildingRect.contains(travelLine.getP2())) + return false; for (Mesh mesh : building.buildingMeshes) if(mesh.MeshCollides(travelLine,charHeight,charY)) diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 313c21ce..cdb18b90 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -9,6 +9,7 @@ package engine.devcmd.cmds; +import engine.CollisionEngine.Mesh; import engine.Enum; import engine.Enum.BuildingGroup; import engine.Enum.GameObjectType; @@ -244,7 +245,11 @@ public class InfoCmd extends AbstractDevCmd { for (Regions regions : targetBuilding.getBounds().getRegions()) { //TODO ADD REGION INFO } - output += "Mesh Count: " + targetBuilding.buildingMeshes.size(); + output += "-------Mesh Data-------" + newline; + output += "Mesh Count: " + targetBuilding.buildingMeshes.size() + newline; + for(Mesh mesh : targetBuilding.buildingMeshes){ + output += "Mesh Rect: " + mesh.boundsRect + newline; + } break; case PlayerCharacter: output += newline; diff --git a/src/engine/devcmd/cmds/RegionCmd.java b/src/engine/devcmd/cmds/RegionCmd.java index 0749b145..53ae6880 100644 --- a/src/engine/devcmd/cmds/RegionCmd.java +++ b/src/engine/devcmd/cmds/RegionCmd.java @@ -48,10 +48,12 @@ public class RegionCmd extends AbstractDevCmd { this.throwbackInfo(pc, output); } if(building != null){ + this.throwbackInfo(pc, "Building Rect: " + building.buildingRect); for (Mesh mesh : building.buildingMeshes){ - this.throwbackInfo(pc, "Mesh Rect: " + mesh.boundsRect); + //this.throwbackInfo(pc, "Mesh Rect: " + mesh.boundsRect); if(mesh.boundsRect.contains(pc.loc.x,pc.loc.z)) { this.throwbackInfo(pc, "Inside A Mesh's Bounds"); + this.throwbackInfo(pc, "Rect: " + mesh.boundsRect); return; } } diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 6598a3b4..d1a47882 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -986,7 +986,9 @@ public enum BuildingManager { int i = 0; // stop point for testing } building.buildingMeshes = new ArrayList<>(); - float rotation = building.getRot().getRotation(); + //float rotation = building.getRot().getRotation(); + double radian = building.getBounds().getQuaternion().angleY; + int degrees = (int) Math.toDegrees(radian); Vector3f buildingLoc = new Vector3f(building.loc.x, building.loc.y, building.loc.z); if(prop_meshes.containsKey(building.meshUUID) == false) return;//no meshes to load for this prop @@ -1039,7 +1041,7 @@ public enum BuildingManager { ArrayList rotatedPoints = new ArrayList<>(); for (Vector3f point : pointList) { Vector3f calculatedOffsetPoint = buildingLoc.add(point); - rotatedPoints.add(Vector3f.rotateAroundPoint(buildingLoc, calculatedOffsetPoint, rotation)); + rotatedPoints.add(Vector3f.rotateAroundPoint(buildingLoc, calculatedOffsetPoint, radian)); } Point2D.Float p1 = new Point2D.Float(rotatedPoints.get(0).x, rotatedPoints.get(0).z); diff --git a/src/engine/net/client/handlers/MoveToPointHandler.java b/src/engine/net/client/handlers/MoveToPointHandler.java index c94aeb76..a1a03dd0 100644 --- a/src/engine/net/client/handlers/MoveToPointHandler.java +++ b/src/engine/net/client/handlers/MoveToPointHandler.java @@ -11,6 +11,7 @@ package engine.net.client.handlers; import engine.InterestManagement.WorldGrid; import engine.exception.MsgSendException; +import engine.gameManager.BuildingManager; import engine.gameManager.ChatManager; import engine.CollisionEngine.CollisionManager; import engine.gameManager.MovementManager; @@ -43,16 +44,27 @@ public class MoveToPointHandler extends AbstractClientMsgHandler { Line2D travelLine = new Line2D.Float(); Vector3fImmutable endLoc = new Vector3fImmutable(msg.getEndLat(),msg.getEndAlt(),msg.getEndLon()); travelLine.setLine(pc.loc.x,pc.loc.z,endLoc.x,endLoc.z); - HashSet awoList = WorldGrid.getObjectsInRangePartial(pc.loc, 1000, MBServerStatics.MASK_BUILDING); - for(AbstractWorldObject awo : awoList){ - Building building = (Building)awo; - if(CollisionManager.CollisionDetected(building, travelLine,pc.getCharacterHeight(),pc.loc.y)){ - ChatManager.chatSystemInfo(pc, "Collision Detected"); + if(BuildingManager.getBuildingAtLocation(pc.loc) != null){ + Building current = BuildingManager.getBuildingAtLocation(pc.loc); + if (CollisionManager.CollisionDetected(current, travelLine, pc.getCharacterHeight(), pc.loc.y)) { + ChatManager.chatSystemInfo(pc, "Collision Detected With : " + current.getName() + " Rect: " + current.buildingRect); //msg.setEndCoord(); MovementManager.movement(msg, pc); return true; } } + HashSet awoList = WorldGrid.getObjectsInRangePartial(pc.loc, 1000, MBServerStatics.MASK_BUILDING); + for(AbstractWorldObject awo : awoList){ + Building building = (Building)awo; + if(travelLine.intersects(building.buildingRect) || building.buildingRect.contains(travelLine.getP1()) || building.buildingRect.contains(travelLine.getP2())) { + if (CollisionManager.CollisionDetected(building, travelLine, pc.getCharacterHeight(), pc.loc.y)) { + ChatManager.chatSystemInfo(pc, "Collision Detected With : " + building.getName() + " Rect: " + building.buildingRect); + //msg.setEndCoord(); + MovementManager.movement(msg, pc); + return true; + } + } + } //ChatManager.chatSystemInfo(pc, "No Collision Detected"); MovementManager.movement(msg, pc); return true;