Repository for lakemenbane
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1000 B

package engine.CollisionEngine;
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){
for(Line2D side : BoundingLines)
if(side.intersectsLine(line))
return true;
return false;
}
public boolean MeshCollides(Line2D line, float charHeight){
//movement path does not intersect this mesh
if(!this.BoundsCollides(line))
return false;
//character moving is higher than the max Y of this mesh
if(charHeight > this.meshHeight)
return false;
for(Triangle tri : triangles)
if(tri.collides(line))
return true;
//characters movement path did not intersect this mesh
return false;
}
}