Browse Source

load mesh data and structure meshes

server-collision
FatBoy-DOTC 10 months ago
parent
commit
5b9d1dd6eb
  1. 5
      src/engine/CollisionEngine/CollisionManager.java
  2. 6
      src/engine/devcmd/cmds/RegionCmd.java
  3. 7
      src/engine/gameManager/BuildingManager.java
  4. 2
      src/engine/objects/Building.java

5
src/engine/CollisionEngine/CollisionManager.java

@ -5,9 +5,14 @@ import engine.objects.Building;
import java.awt.*; import java.awt.*;
import java.awt.geom.Line2D; import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
public class CollisionManager { public class CollisionManager {
public static boolean CollisionDetected(Building building, Line2D travelLine, float charHeight, float charY){ 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) for (Mesh mesh : building.buildingMeshes)
if(mesh.MeshCollides(travelLine,charHeight,charY)) if(mesh.MeshCollides(travelLine,charHeight,charY))
return true; return true;

6
src/engine/devcmd/cmds/RegionCmd.java

@ -49,11 +49,13 @@ public class RegionCmd extends AbstractDevCmd {
} }
if(building != null){ if(building != null){
for (Mesh mesh : building.buildingMeshes){ 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"); this.throwbackInfo(pc, "Inside A Mesh's Bounds");
return;
}
} }
} }
this.throwbackInfo(pc, "Outside All Mesh Bounds");
} }
@Override @Override

7
src/engine/gameManager/BuildingManager.java

@ -1046,6 +1046,13 @@ public enum BuildingManager {
} }
building.buildingMeshes.add(generatedMesh); 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){ catch(Exception e){
Logger.info("Failed To Bake Building Mesh Data For Structure: " + building.meshUUID); Logger.info("Failed To Bake Building Mesh Data For Structure: " + building.meshUUID);

2
src/engine/objects/Building.java

@ -36,6 +36,7 @@ import engine.net.client.msg.UpdateObjectMsg;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.awt.geom.Rectangle2D;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -102,6 +103,7 @@ public class Building extends AbstractWorldObject {
private ArrayList<Building> children = null; private ArrayList<Building> children = null;
public ArrayList<Mesh> buildingMeshes; public ArrayList<Mesh> buildingMeshes;
public Rectangle2D.Float buildingRect;
/** /**
* ResultSet Constructor * ResultSet Constructor

Loading…
Cancel
Save