load mesh data and structure meshes

This commit is contained in:
2024-01-15 20:07:21 -06:00
parent a52f0941b7
commit 94e16bdf3d
2 changed files with 9 additions and 1 deletions
+8 -1
View File
@@ -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 {
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 {
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;
@@ -996,6 +996,7 @@ public enum BuildingManager {
return; //no data for this mesh
Mesh generatedMesh = new Mesh();
generatedMesh.parentBuilding = building;
generatedMesh.maxY = building.loc.y + mesh_heights.get(mesh).x;
generatedMesh.minY = building.loc.y + mesh_heights.get(mesh).y;
ArrayList<ArrayList<Vector3f>> triPoints = mesh_triangle_points.get(mesh);