From 89f9c0471fd57bad7347e628cdb4d95a8c63f9b9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 21 Nov 2023 08:48:17 -0500 Subject: [PATCH] Update to hull loading --- src/engine/db/handlers/dbBuildingHandler.java | 48 +++++-------------- src/engine/gameManager/BuildingManager.java | 2 - src/engine/server/world/WorldServer.java | 3 -- 3 files changed, 12 insertions(+), 41 deletions(-) diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index b3a5cf3e..3b3bf8c7 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -549,29 +549,6 @@ public class dbBuildingHandler extends dbHandlerBase { return false; } - public void LOAD_SUBMESH_LOOKUP() { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_render_submesh`")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - - int structureID = rs.getInt("propID"); - int renderID = rs.getInt("meshID"); - - if (!BuildingManager._prop_subMeshes.containsKey(structureID)) - BuildingManager._prop_subMeshes.put(structureID, new ArrayList<>()); - - BuildingManager._prop_subMeshes.get(structureID).add(renderID); - } - - } catch (SQLException e) { - Logger.error(e); - } - } - public void LOAD_CONVEX_HULLS() { int recordsRead = 0; @@ -586,40 +563,39 @@ public class dbBuildingHandler extends dbHandlerBase { recordsRead++; int meshID = rs.getInt("meshID"); - String[] vertStrings = rs.getString("convexHull").split(";"); - ArrayList vertArrayList = new ArrayList<>(); + String[] hullString = rs.getString("vertices").split(";"); // Filter things that couldn't be wrapped - if (vertStrings.length < 3) { + if (hullString.length < 3) { Logger.error("Mesh : " + meshID + " has less than 3 vertices."); continue; } - ArrayList vectors = new ArrayList<>(); + ArrayList convexHull = new ArrayList<>(); ArrayList floats = new ArrayList<>(); - for(String read : vertStrings){ + for (String read : hullString) { floats.add(Float.parseFloat(read)); - if(floats.size() == 2) { - vectors.add(new Vector2f(floats.get(0), floats.get(1))); + if (floats.size() == 2) { + convexHull.add(new Vector2f(floats.get(0), floats.get(1))); floats.clear(); } } - ArrayList> meshList; + ArrayList> hullList; if (BuildingManager._hull_data.get(meshID) == null) { - meshList = new ArrayList<>(); - meshList.add(vectors); - BuildingManager._hull_data.put(meshID, meshList); + hullList = new ArrayList<>(); + hullList.add(convexHull); + BuildingManager._hull_data.put(meshID, hullList); } else { - meshList = BuildingManager._hull_data.get(meshID); - meshList.add(vectors); + hullList = BuildingManager._hull_data.get(meshID); + hullList.add(convexHull); } } diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index b00613db..180bd17c 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -40,8 +40,6 @@ import java.util.concurrent.ThreadLocalRandom; public enum BuildingManager { BUILDINGMANAGER; - - public static HashMap> _prop_subMeshes = new HashMap<>(); public static HashMap>> _hull_data = new HashMap<>(); public static HashMap> _stuckLocations = new HashMap<>(); public static HashMap> _slotLocations = new HashMap<>(); diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index ad50c5a5..b270a8a0 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -403,9 +403,6 @@ public class WorldServer { Logger.info("Loading building slot/stuck location data."); BuildingLocation.loadBuildingLocations(); - Logger.info("Loading sub-mesh lookup."); - DbManager.BuildingQueries.LOAD_SUBMESH_LOOKUP(); - Logger.info("Loading mesh hulls."); DbManager.BuildingQueries.LOAD_CONVEX_HULLS();