From 7c28efb47c28baf5d90717144630567fd18ef0fa Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 5 Jan 2024 19:06:56 -0600 Subject: [PATCH] offset cleanup --- src/engine/gameManager/BuildingManager.java | 11 ++++----- .../client/handlers/MoveToPointHandler.java | 24 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 23f40de5..ddcf6580 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -1004,11 +1004,11 @@ public enum BuildingManager { float minX = building.loc.x + (float) boundingBox.getMinX(); float maxY = building.loc.z + (float) boundingBox.getMaxY(); float minY = building.loc.z + (float) boundingBox.getMinY(); - boundingBox.setRect(buildingLoc.x + boundingBox.getCenterX(),buildingLoc.z + boundingBox.getCenterY(),boundingBox.getMaxX(), boundingBox.getMaxY()); Point2D.Float p1 = new Point2D.Float(minX, maxY); Point2D.Float p2 = new Point2D.Float(maxX, maxY); Point2D.Float p3 = new Point2D.Float(maxX, minY); Point2D.Float p4 = new Point2D.Float(minX, minY); + boundingBox.setRect(p1.x,p1.y,Math.abs(maxX - minX), Math.abs(maxY - minY)); generatedMesh.BoundingLines.add(new Line2D.Float(p1, p2)); generatedMesh.BoundingLines.add(new Line2D.Float(p2, p3)); generatedMesh.BoundingLines.add(new Line2D.Float(p3, p4)); @@ -1019,8 +1019,10 @@ public enum BuildingManager { for (ArrayList pointList : triPoints) { ArrayList rotatedPoints = new ArrayList<>(); - for (Vector3f point : pointList) - rotatedPoints.add(Vector3f.rotateAroundPoint(buildingLoc, buildingLoc.add(point), rotation)); + for (Vector3f point : pointList) { + Vector3f calculatedOffsetPoint = buildingLoc.add(point); + rotatedPoints.add(Vector3f.rotateAroundPoint(buildingLoc, calculatedOffsetPoint, rotation)); + } Point2D.Float p1 = new Point2D.Float(rotatedPoints.get(0).x, rotatedPoints.get(0).z); Point2D.Float p2 = new Point2D.Float(rotatedPoints.get(1).x, rotatedPoints.get(1).z); @@ -1033,9 +1035,6 @@ public enum BuildingManager { tri.sides.add(new Line2D.Float(p3, p1)); generatedMesh.triangles.add(tri); } - if (BuildingManager.mesh_bounding_boxes.containsKey(mesh)) { - generatedMesh.boundsRect = BuildingManager.mesh_bounding_boxes.get(mesh); - } building.buildingMeshes.add(generatedMesh); } } diff --git a/src/engine/net/client/handlers/MoveToPointHandler.java b/src/engine/net/client/handlers/MoveToPointHandler.java index 932bbe0b..bae389a1 100644 --- a/src/engine/net/client/handlers/MoveToPointHandler.java +++ b/src/engine/net/client/handlers/MoveToPointHandler.java @@ -49,29 +49,29 @@ public class MoveToPointHandler extends AbstractClientMsgHandler { Vector3fImmutable endLoc = new Vector3fImmutable(msg.getEndLat(),msg.getEndAlt(),msg.getEndLon()); travelLine.setLine(pc.loc.x,pc.loc.z,endLoc.x,endLoc.z); float movementDistance = 185 + pc.loc.distance(endLoc); + boolean collided = false; HashSet awoList = WorldGrid.getObjectsInRangePartial(pc.loc, movementDistance, MBServerStatics.MASK_BUILDING); for(AbstractWorldObject awo : awoList){ Building building = (Building)awo; Rectangle.Float boundsRect = new Rectangle.Float(); - boundsRect.setRect(building.loc.x + building.getBounds().getHalfExtents().x, building.loc.z + building.getBounds().getHalfExtents().y, building.getBounds().getHalfExtents().x * 2,building.getBounds().getHalfExtents().y * 2); - //if(travelLine.intersects(boundsRect)){ + float rectCenterX = building.loc.x + building.getBounds().getHalfExtents().x; + float rectCenterZ = building.loc.z + building.getBounds().getHalfExtents().y; + boundsRect.setRect(rectCenterX, rectCenterZ, building.getBounds().getHalfExtents().x * 2,building.getBounds().getHalfExtents().y * 2); + if(travelLine.intersects(boundsRect)){ //collided with building for(Mesh mesh : building.buildingMeshes) { - float height = pc.getCharacterHeight(); - if (height < mesh.meshHeight) { - for (Triangle tri : mesh.triangles) { - if (tri.collides(travelLine)) { + if (mesh.MeshCollides(travelLine,pc.getCharacterHeight())) + for (Triangle tri : mesh.triangles) + if (tri.collides(travelLine)){ ChatManager.chatSystemInfo(pc, "Collision Detected"); + MovementManager.movement(msg, pc); return true; } - } - } + } - //} + } } - ChatManager.chatSystemInfo(pc, "No Collision Detected"); - - + ChatManager.chatSystemInfo(pc, "No Collision Detected"); MovementManager.movement(msg, pc); return true; }