|
|
@ -31,7 +31,6 @@ public class Mesh { |
|
|
|
|
|
|
|
|
|
|
|
public void update(){ |
|
|
|
public void update(){ |
|
|
|
this.BakeTriangles(); |
|
|
|
this.BakeTriangles(); |
|
|
|
this.BakeBoundsRect(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
public Vector3f getLocation(){ |
|
|
|
public Vector3f getLocation(){ |
|
|
|
Building parentBuilding = BuildingManager.getBuilding(this.parentUUID); |
|
|
|
Building parentBuilding = BuildingManager.getBuilding(this.parentUUID); |
|
|
@ -78,21 +77,11 @@ public class Mesh { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void BakeBoundsRect(){ |
|
|
|
public Boolean collides(Line2D line){ |
|
|
|
ArrayList<Rectangle2D> rects = new ArrayList<>(); |
|
|
|
for(Triangle tri : this.triangles) |
|
|
|
for(Triangle tri : this.triangles){ |
|
|
|
if(tri.collides(line)) |
|
|
|
Path2D.Float path = new Path2D.Float(); |
|
|
|
return true; |
|
|
|
path.lineTo(tri.point1.x,tri.point1.y); |
|
|
|
|
|
|
|
path.lineTo(tri.point2.x,tri.point2.y); |
|
|
|
return false; |
|
|
|
path.lineTo(tri.point3.x,tri.point3.y); |
|
|
|
|
|
|
|
path.closePath(); |
|
|
|
|
|
|
|
rects.add(path.getBounds()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Rectangle2D.Float boundsRect = new Rectangle2D.Float(); |
|
|
|
|
|
|
|
boundsRect.setRect(rects.get(0)); |
|
|
|
|
|
|
|
for(Rectangle2D rectangle : rects){ |
|
|
|
|
|
|
|
boundsRect.add(rectangle); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.mesh_bounds = (Rectangle2D.Float)boundsRect.clone(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|