Browse Source

debug dev command for collision

server-collision
FatBoy-DOTC 10 months ago
parent
commit
f8cbeb4cc6
  1. 2
      src/engine/collision/Mesh.java
  2. 13
      src/engine/devcmd/cmds/RegionCmd.java
  3. 3
      src/engine/gameManager/BuildingManager.java

2
src/engine/collision/Mesh.java

@ -2,11 +2,13 @@ package engine.collision; @@ -2,11 +2,13 @@ package engine.collision;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
public class Mesh {
public ArrayList<Triangle> triangles;
public ArrayList<Line2D> BoundingLines;
public Rectangle2D boundsRect;
public float meshHeight;
public boolean BoundsCollides(Line2D line){

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

@ -10,10 +10,12 @@ @@ -10,10 +10,12 @@
package engine.devcmd.cmds;
import engine.Enum;
import engine.collision.Mesh;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.BuildingManager;
import engine.objects.*;
import java.awt.geom.Point2D;
import java.lang.reflect.Field;
public class RegionCmd extends AbstractDevCmd {
@ -37,7 +39,6 @@ public class RegionCmd extends AbstractDevCmd { @@ -37,7 +39,6 @@ public class RegionCmd extends AbstractDevCmd {
Regions region = ((AbstractCharacter)target).region;
if (region == null) {
this.throwbackInfo(pc, "No Region Found.");
return;
}
if(region != null) {
@ -48,7 +49,15 @@ public class RegionCmd extends AbstractDevCmd { @@ -48,7 +49,15 @@ public class RegionCmd extends AbstractDevCmd {
output += "is Outside: " + region.isOutside();
this.throwbackInfo(pc, output);
}
if(building != null){
for(Mesh mesh : building.buildingMeshes){
if(mesh.boundsRect.contains(new Point2D.Float(((AbstractCharacter) target).loc.x,((AbstractCharacter) target).loc.z))){
this.throwbackInfo(pc, "Inside Mesh Bounds");
return;
}
}
this.throwbackInfo(pc, "Outside Mesh Bounds");
}
}
@Override

3
src/engine/gameManager/BuildingManager.java

@ -1031,6 +1031,9 @@ public enum BuildingManager { @@ -1031,6 +1031,9 @@ 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);
}
}

Loading…
Cancel
Save