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