From 8dc6a0627c8108c50836c184874e27dd86f31832 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 17 Jan 2024 22:03:35 -0600 Subject: [PATCH] load mesh data and structure meshes --- src/engine/CollisionEngine/Mesh.java | 7 ++++--- src/engine/gameManager/BuildingManager.java | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/engine/CollisionEngine/Mesh.java b/src/engine/CollisionEngine/Mesh.java index fbfb1bd5..1f11b3b8 100644 --- a/src/engine/CollisionEngine/Mesh.java +++ b/src/engine/CollisionEngine/Mesh.java @@ -23,6 +23,9 @@ public class Mesh { public int parent_prop_id; public int parent_structure_id; public int parentUUID; + + public float rectWidth; + public float rectHeight; public Rectangle2D.Float mesh_bounds; public void AdoptTriangles(float rotation){ @@ -56,8 +59,6 @@ public class Mesh { public void MakeBounds(){ this.mesh_bounds = new Rectangle2D.Float(); - float width = this.mesh_ref_point.subtract(this.mesh_location).x * 2; - float height = this.mesh_ref_point.subtract(this.mesh_location).z * 2; - this.mesh_bounds.setRect(this.mesh_ref_point.x,this.mesh_ref_point.z,width, height); + this.mesh_bounds.setRect(this.mesh_ref_point.x,this.mesh_ref_point.z,this.rectWidth, this.rectHeight); } } diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index b11ed33e..ab7911f6 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -996,10 +996,12 @@ public enum BuildingManager { int degrees = (int)Math.toDegrees(building.getBounds().getQuaternion().angleY); Mesh generatedMesh = new Mesh(); - - generatedMesh.mesh_end_point = Vector3f.rotateAroundPoint(new Vector3f(building.loc.x,building.loc.y,building.loc.z).add(meshData.loc.add(meshData.endPoint)),new Vector3f(building.loc.x,building.loc.y,building.loc.z),degrees); - generatedMesh.mesh_ref_point = Vector3f.rotateAroundPoint(new Vector3f(building.loc.x,building.loc.y,building.loc.z).add(meshData.loc.add(meshData.refPoint)),new Vector3f(building.loc.x,building.loc.y,building.loc.z),degrees); - generatedMesh.mesh_location = Vector3f.rotateAroundPoint(new Vector3f(building.loc.x,building.loc.y,building.loc.z).add(meshData.loc),new Vector3f(building.loc.x,building.loc.y,building.loc.z),degrees); + Vector3f buildingLoc = new Vector3f(building.loc.x,building.loc.y,building.loc.z); + generatedMesh.mesh_location = Vector3f.rotateAroundPoint(buildingLoc.add(meshData.loc),buildingLoc,degrees); + generatedMesh.mesh_end_point = Vector3f.rotateAroundPoint(generatedMesh.mesh_location.add(meshData.endPoint),buildingLoc,degrees); + generatedMesh.mesh_ref_point = Vector3f.rotateAroundPoint(generatedMesh.mesh_location.add(meshData.refPoint),buildingLoc,degrees); + generatedMesh.rectWidth = meshData.refPoint.x * 2; + generatedMesh.rectHeight = meshData.refPoint.z * 2; generatedMesh.mesh_max_y = building.loc.y + meshData.maxY; generatedMesh.mesh_min_y = building.loc.y + meshData.minY; generatedMesh.mesh_scale = meshData.scale;