From 5a57677013d1e3e2587ef2a0b59fa1cd7fe00193 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 13 Jan 2024 21:34:36 -0600 Subject: [PATCH] Triangle check --- src/engine/gameManager/BuildingManager.java | 70 ++++++++++----------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 5823c96c..7b23e1d7 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -985,44 +985,44 @@ public enum BuildingManager { building.buildingTriangles = new ArrayList<>(); float rotation = building.getRot().getRotation(); Vector3f buildingLoc = new Vector3f(building.loc.x, building.loc.y, building.loc.z); - if (!prop_meshes.containsKey(building.meshUUID)) + if (!mesh_triangle_points.containsKey(building.meshUUID)) return; //no data for this prop ID - ArrayList meshes = prop_meshes.get(building.meshUUID); - for (int mesh : meshes) { + //ArrayList meshes = prop_meshes.get(building.meshUUID); + //for (int mesh : meshes) { - if (!mesh_heights.containsKey(mesh) || !mesh_triangle_points.containsKey(mesh)) - return; //no data for this mesh + //if (!mesh_heights.containsKey(mesh) || !mesh_triangle_points.containsKey(mesh)) + //return; //no data for this mesh - Mesh generatedMesh = new Mesh(); - 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); + //Mesh generatedMesh = new Mesh(); + //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(building.meshUUID); - if (mesh_bounding_boxes.containsKey(mesh)) { - Rectangle2D boundingBox = mesh_bounding_boxes.get(mesh); + //if (mesh_bounding_boxes.containsKey(mesh)) { + //Rectangle2D boundingBox = mesh_bounding_boxes.get(mesh); //Bounds buildingBounds = building.getBounds(); - float halfX = (float) boundingBox.getWidth() * 0.5f; - float halfZ = (float)boundingBox.getHeight() * 0.5f; - Vector3f bottomRight = new Vector3f(building.loc.x + halfX,building.loc.y,building.loc.z + halfZ); - Vector3f topLeft = new Vector3f(building.loc.x - halfX,building.loc.y,building.loc.z - halfZ); - Vector3f topRight = new Vector3f(building.loc.x + halfX,building.loc.y,building.loc.z - halfZ); - Vector3f bottomLeft = new Vector3f(building.loc.x - halfX,building.loc.y,building.loc.z + halfZ); - - generatedMesh.BoundingLines = new ArrayList<>(); - Point2D.Float p1 = new Point2D.Float(topLeft.x, topLeft.z); - Point2D.Float p2 = new Point2D.Float(topRight.x, topRight.z); - Point2D.Float p3 = new Point2D.Float(bottomRight.x, bottomRight.z); - Point2D.Float p4 = new Point2D.Float(bottomLeft.x, bottomLeft.z); - float rectWidth = topLeft.distance(topRight); - float rectHeight = topLeft.distance(bottomLeft); - boundingBox.setRect(p1.x,p1.y,rectWidth, rectHeight); - generatedMesh.BoundingLines.add(new Line2D.Float(p1, p2)); - generatedMesh.BoundingLines.add(new Line2D.Float(p2, p3)); - generatedMesh.BoundingLines.add(new Line2D.Float(p3, p4)); - generatedMesh.BoundingLines.add(new Line2D.Float(p4, p1)); - generatedMesh.boundsRect = boundingBox; - } - generatedMesh.triangles = new ArrayList<>(); + //float halfX = (float) boundingBox.getWidth() * 0.5f; + //float halfZ = (float)boundingBox.getHeight() * 0.5f; + //Vector3f bottomRight = new Vector3f(building.loc.x + halfX,building.loc.y,building.loc.z + halfZ); + //Vector3f topLeft = new Vector3f(building.loc.x - halfX,building.loc.y,building.loc.z - halfZ); + //Vector3f topRight = new Vector3f(building.loc.x + halfX,building.loc.y,building.loc.z - halfZ); + //Vector3f bottomLeft = new Vector3f(building.loc.x - halfX,building.loc.y,building.loc.z + halfZ); + + //generatedMesh.BoundingLines = new ArrayList<>(); + //Point2D.Float p1 = new Point2D.Float(topLeft.x, topLeft.z); + //Point2D.Float p2 = new Point2D.Float(topRight.x, topRight.z); + //Point2D.Float p3 = new Point2D.Float(bottomRight.x, bottomRight.z); + //Point2D.Float p4 = new Point2D.Float(bottomLeft.x, bottomLeft.z); + //float rectWidth = topLeft.distance(topRight); + //float rectHeight = topLeft.distance(bottomLeft); + //boundingBox.setRect(p1.x,p1.y,rectWidth, rectHeight); + //generatedMesh.BoundingLines.add(new Line2D.Float(p1, p2)); + //generatedMesh.BoundingLines.add(new Line2D.Float(p2, p3)); + //generatedMesh.BoundingLines.add(new Line2D.Float(p3, p4)); + //generatedMesh.BoundingLines.add(new Line2D.Float(p4, p1)); + //generatedMesh.boundsRect = boundingBox; + //} + //generatedMesh.triangles = new ArrayList<>(); for (ArrayList pointList : triPoints) { ArrayList rotatedPoints = new ArrayList<>(); @@ -1043,8 +1043,8 @@ public enum BuildingManager { //generatedMesh.triangles.add(tri); building.buildingTriangles.add(tri); } - //building.buildingTriangles.add(generatedMesh); - } + //building.buildingMeshes.add(generatedMesh); + //} } catch(Exception e){ Logger.info("Failed To Bake Building Mesh Data For Structure: " + building.meshUUID);