load mesh data and structure meshes

This commit is contained in:
2024-01-15 19:32:49 -06:00
parent 6215e15e82
commit 5b9d1dd6eb
4 changed files with 18 additions and 2 deletions
@@ -5,9 +5,14 @@ import engine.objects.Building;
import java.awt.*;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
public class CollisionManager {
public static boolean CollisionDetected(Building building, Line2D travelLine, float charHeight, float charY){
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))
return true;
+4 -2
View File
@@ -49,11 +49,13 @@ public class RegionCmd extends AbstractDevCmd {
}
if(building != null){
for (Mesh mesh : building.buildingMeshes){
if(mesh.boundsRect.contains(pc.loc.x,pc.loc.z))
if(mesh.boundsRect.contains(pc.loc.x,pc.loc.z)) {
this.throwbackInfo(pc, "Inside A Mesh's Bounds");
return;
}
}
}
this.throwbackInfo(pc, "Outside All Mesh Bounds");
}
@Override
@@ -1046,6 +1046,13 @@ public enum BuildingManager {
}
building.buildingMeshes.add(generatedMesh);
}
Rectangle2D.Float buildingBound = new Rectangle2D.Float();
float xLoc = building.loc.x - building.getBounds().getHalfExtents().x;
float zLoc = building.loc.z - building.getBounds().getHalfExtents().y;
float width = building.getBounds().getHalfExtents().x * 2;
float height = building.getBounds().getHalfExtents().y * 2;
buildingBound.setRect(xLoc,zLoc,width,height);
building.buildingRect = buildingBound;
}
catch(Exception e){
Logger.info("Failed To Bake Building Mesh Data For Structure: " + building.meshUUID);
+2
View File
@@ -36,6 +36,7 @@ import engine.net.client.msg.UpdateObjectMsg;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.awt.geom.Rectangle2D;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
@@ -102,6 +103,7 @@ public class Building extends AbstractWorldObject {
private ArrayList<Building> children = null;
public ArrayList<Mesh> buildingMeshes;
public Rectangle2D.Float buildingRect;
/**
* ResultSet Constructor