|
|
|
@ -1,5 +1,7 @@
@@ -1,5 +1,7 @@
|
|
|
|
|
package engine.CollisionEngine; |
|
|
|
|
|
|
|
|
|
import engine.objects.Building; |
|
|
|
|
|
|
|
|
|
import java.awt.geom.Line2D; |
|
|
|
|
|
|
|
|
|
import java.awt.geom.Rectangle2D; |
|
|
|
@ -11,6 +13,7 @@ public class Mesh {
@@ -11,6 +13,7 @@ public class Mesh {
|
|
|
|
|
public Rectangle2D boundsRect; |
|
|
|
|
public float maxY; |
|
|
|
|
public float minY; |
|
|
|
|
public Building parentBuilding; |
|
|
|
|
|
|
|
|
|
public boolean BoundsCollides(Line2D line){ |
|
|
|
|
for(Line2D side : BoundingLines) |
|
|
|
@ -23,7 +26,11 @@ public class Mesh {
@@ -23,7 +26,11 @@ public class Mesh {
|
|
|
|
|
public boolean MeshCollides(Line2D line, float charHeight, float charY){ |
|
|
|
|
|
|
|
|
|
//check if movement path intersects this mesh
|
|
|
|
|
if(!this.BoundsCollides(line) && !boundsRect.contains(line.getP1()) && !boundsRect.contains(line.getP2())) |
|
|
|
|
if(boundsRect == null){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!line.intersects(boundsRect) && !boundsRect.contains(line.getP1()) && !boundsRect.contains(line.getP2())) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|