Browse Source

load mesh data and structure meshes

server-collision
FatBoy-DOTC 12 months ago
parent
commit
86c8e985be
  1. 3
      src/engine/CollisionEngine/Mesh.java
  2. 1
      src/engine/devcmd/cmds/RegionCmd.java
  3. 12
      src/engine/gameManager/BuildingManager.java
  4. 5
      src/engine/net/client/handlers/MoveToPointHandler.java

3
src/engine/CollisionEngine/Mesh.java

@ -35,7 +35,8 @@ public class Mesh {
//check to see if character is under or over the mesh //check to see if character is under or over the mesh
if((charY + charHeight) < this.minY || charY > this.maxY) float head = charY + charHeight;
if(head < this.minY || charY > this.maxY)
return false; return false;
//check if any triangles intersect the movement path //check if any triangles intersect the movement path

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

@ -49,6 +49,7 @@ public class RegionCmd extends AbstractDevCmd {
} }
if(building != null){ if(building != null){
for (Mesh mesh : building.buildingMeshes){ for (Mesh mesh : building.buildingMeshes){
this.throwbackInfo(pc, "Mesh Rect: " + mesh.boundsRect);
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; return;

12
src/engine/gameManager/BuildingManager.java

@ -1017,12 +1017,13 @@ public enum BuildingManager {
Point2D.Float p4 = new Point2D.Float(bottomLeft.x, bottomLeft.z); Point2D.Float p4 = new Point2D.Float(bottomLeft.x, bottomLeft.z);
float rectWidth = topLeft.distance(topRight); float rectWidth = topLeft.distance(topRight);
float rectHeight = topLeft.distance(bottomLeft); float rectHeight = topLeft.distance(bottomLeft);
boundingBox.setRect(p1.x, p1.y, rectWidth, rectHeight); generatedMesh.boundsRect = new Rectangle2D.Float();
generatedMesh.boundsRect.setRect(p1.x, p1.y, rectWidth, rectHeight);
generatedMesh.BoundingLines.add(new Line2D.Float(p1, p2)); generatedMesh.BoundingLines.add(new Line2D.Float(p1, p2));
generatedMesh.BoundingLines.add(new Line2D.Float(p2, p3)); generatedMesh.BoundingLines.add(new Line2D.Float(p2, p3));
generatedMesh.BoundingLines.add(new Line2D.Float(p3, p4)); generatedMesh.BoundingLines.add(new Line2D.Float(p3, p4));
generatedMesh.BoundingLines.add(new Line2D.Float(p4, p1)); generatedMesh.BoundingLines.add(new Line2D.Float(p4, p1));
generatedMesh.boundsRect = boundingBox; //generatedMesh.boundsRect = boundingBox;
} else{ } else{
Logger.error("No Bounding Box Data For Mesh: " + mesh); Logger.error("No Bounding Box Data For Mesh: " + mesh);
} }
@ -1049,13 +1050,14 @@ public enum BuildingManager {
} }
building.buildingMeshes.add(generatedMesh); building.buildingMeshes.add(generatedMesh);
} }
Rectangle2D.Float buildingBound = new Rectangle2D.Float(); //Rectangle2D.Float buildingBound = new Rectangle2D.Float();
float xLoc = building.loc.x - building.getBounds().getHalfExtents().x; float xLoc = building.loc.x - building.getBounds().getHalfExtents().x;
float zLoc = building.loc.z - building.getBounds().getHalfExtents().y; float zLoc = building.loc.z - building.getBounds().getHalfExtents().y;
float width = building.getBounds().getHalfExtents().x * 2; float width = building.getBounds().getHalfExtents().x * 2;
float height = building.getBounds().getHalfExtents().y * 2; float height = building.getBounds().getHalfExtents().y * 2;
buildingBound.setRect(xLoc,zLoc,width,height); building.buildingRect = new Rectangle2D.Float();
building.buildingRect = buildingBound; building.buildingRect.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);

5
src/engine/net/client/handlers/MoveToPointHandler.java

@ -43,8 +43,7 @@ public class MoveToPointHandler extends AbstractClientMsgHandler {
Line2D travelLine = new Line2D.Float(); Line2D travelLine = new Line2D.Float();
Vector3fImmutable endLoc = new Vector3fImmutable(msg.getEndLat(),msg.getEndAlt(),msg.getEndLon()); Vector3fImmutable endLoc = new Vector3fImmutable(msg.getEndLat(),msg.getEndAlt(),msg.getEndLon());
travelLine.setLine(pc.loc.x,pc.loc.z,endLoc.x,endLoc.z); travelLine.setLine(pc.loc.x,pc.loc.z,endLoc.x,endLoc.z);
float movementDistance = 185 + pc.loc.distance(endLoc); HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(pc.loc, 1000, MBServerStatics.MASK_BUILDING);
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(pc.loc, movementDistance, MBServerStatics.MASK_BUILDING);
for(AbstractWorldObject awo : awoList){ for(AbstractWorldObject awo : awoList){
Building building = (Building)awo; Building building = (Building)awo;
if(CollisionManager.CollisionDetected(building, travelLine,pc.getCharacterHeight(),pc.loc.y)){ if(CollisionManager.CollisionDetected(building, travelLine,pc.getCharacterHeight(),pc.loc.y)){
@ -54,7 +53,7 @@ public class MoveToPointHandler extends AbstractClientMsgHandler {
return true; return true;
} }
} }
ChatManager.chatSystemInfo(pc, "No Collision Detected"); //ChatManager.chatSystemInfo(pc, "No Collision Detected");
MovementManager.movement(msg, pc); MovementManager.movement(msg, pc);
return true; return true;
} }

Loading…
Cancel
Save