From 94e16bdf3d6d0caa7b2c8c955814836d930d173b Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 15 Jan 2024 20:07:21 -0600 Subject: [PATCH] load mesh data and structure meshes --- src/engine/CollisionEngine/Mesh.java | 9 ++++++++- src/engine/gameManager/BuildingManager.java | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/engine/CollisionEngine/Mesh.java b/src/engine/CollisionEngine/Mesh.java index 17d5ec08..5f7e68b0 100644 --- a/src/engine/CollisionEngine/Mesh.java +++ b/src/engine/CollisionEngine/Mesh.java @@ -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; diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 4f0bdbf6..2cad325d 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -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> triPoints = mesh_triangle_points.get(mesh);