data load fixes
This commit is contained in:
@@ -920,7 +920,7 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
public void LOAD_MESH_BOUNDING_BOXES() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_mesh_triangles`")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_mesh_bounding_boxes`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
BuildingManager.mesh_bounding_boxes = new HashMap<>();
|
||||
|
||||
@@ -1004,7 +1004,7 @@ 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);
|
||||
@@ -1013,13 +1013,14 @@ public enum BuildingManager {
|
||||
generatedMesh.BoundingLines.add(new Line2D.Float(p2, p3));
|
||||
generatedMesh.BoundingLines.add(new Line2D.Float(p3, p4));
|
||||
generatedMesh.BoundingLines.add(new Line2D.Float(p4, p1));
|
||||
generatedMesh.boundsRect = boundingBox;
|
||||
}
|
||||
generatedMesh.triangles = new ArrayList<>();
|
||||
for (ArrayList<Vector3f> pointList : triPoints) {
|
||||
|
||||
ArrayList<Vector3f> rotatedPoints = new ArrayList<>();
|
||||
for (Vector3f point : pointList)
|
||||
rotatedPoints.add(Vector3f.rotateAroundPoint(buildingLoc, point, rotation));
|
||||
rotatedPoints.add(Vector3f.rotateAroundPoint(buildingLoc, buildingLoc.add(point), 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);
|
||||
|
||||
@@ -28,6 +28,8 @@ import engine.server.MBServerStatics;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Line2D;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class MoveToPointHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public MoveToPointHandler() {
|
||||
@@ -46,24 +48,28 @@ 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);
|
||||
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(pc.loc, pc.loc.distance(endLoc), MBServerStatics.MASK_BUILDING)){
|
||||
float movementDistance = 185 + pc.loc.distance(endLoc);
|
||||
HashSet<AbstractWorldObject> 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.getBounds().getHalfExtents().x, building.getBounds().getHalfExtents().y, building.getBounds().getHalfExtents().x * 2,building.getBounds().getHalfExtents().y * 2);
|
||||
if(travelLine.intersects(boundsRect)){
|
||||
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)){
|
||||
//collided with building
|
||||
for(Mesh mesh : building.buildingMeshes)
|
||||
if(mesh.MeshCollides(travelLine,pc.getCharacterHeight())){
|
||||
for(Triangle tri : mesh.triangles){
|
||||
if(tri.collides(travelLine)){
|
||||
for(Mesh mesh : building.buildingMeshes) {
|
||||
float height = pc.getCharacterHeight();
|
||||
if (height < mesh.meshHeight) {
|
||||
for (Triangle tri : mesh.triangles) {
|
||||
if (tri.collides(travelLine)) {
|
||||
ChatManager.chatSystemInfo(pc, "Collision Detected");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
ChatManager.chatSystemInfo(pc, "No Collision Detected");
|
||||
|
||||
|
||||
MovementManager.movement(msg, pc);
|
||||
|
||||
Reference in New Issue
Block a user