Browse Source

Update to hull loading

convex-data
MagicBot 12 months ago
parent
commit
89f9c0471f
  1. 48
      src/engine/db/handlers/dbBuildingHandler.java
  2. 2
      src/engine/gameManager/BuildingManager.java
  3. 3
      src/engine/server/world/WorldServer.java

48
src/engine/db/handlers/dbBuildingHandler.java

@ -549,29 +549,6 @@ public class dbBuildingHandler extends dbHandlerBase {
return false; 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() { public void LOAD_CONVEX_HULLS() {
int recordsRead = 0; int recordsRead = 0;
@ -586,40 +563,39 @@ public class dbBuildingHandler extends dbHandlerBase {
recordsRead++; recordsRead++;
int meshID = rs.getInt("meshID"); int meshID = rs.getInt("meshID");
String[] vertStrings = rs.getString("convexHull").split(";"); String[] hullString = rs.getString("vertices").split(";");
ArrayList<Vector2f> vertArrayList = new ArrayList<>();
// Filter things that couldn't be wrapped // Filter things that couldn't be wrapped
if (vertStrings.length < 3) { if (hullString.length < 3) {
Logger.error("Mesh : " + meshID + " has less than 3 vertices."); Logger.error("Mesh : " + meshID + " has less than 3 vertices.");
continue; continue;
} }
ArrayList<Vector2f> vectors = new ArrayList<>(); ArrayList<Vector2f> convexHull = new ArrayList<>();
ArrayList<Float> floats = new ArrayList<>(); ArrayList<Float> floats = new ArrayList<>();
for(String read : vertStrings){ for (String read : hullString) {
floats.add(Float.parseFloat(read)); floats.add(Float.parseFloat(read));
if(floats.size() == 2) { if (floats.size() == 2) {
vectors.add(new Vector2f(floats.get(0), floats.get(1))); convexHull.add(new Vector2f(floats.get(0), floats.get(1)));
floats.clear(); floats.clear();
} }
} }
ArrayList<ArrayList<Vector2f>> meshList; ArrayList<ArrayList<Vector2f>> hullList;
if (BuildingManager._hull_data.get(meshID) == null) { if (BuildingManager._hull_data.get(meshID) == null) {
meshList = new ArrayList<>(); hullList = new ArrayList<>();
meshList.add(vectors); hullList.add(convexHull);
BuildingManager._hull_data.put(meshID, meshList); BuildingManager._hull_data.put(meshID, hullList);
} else { } else {
meshList = BuildingManager._hull_data.get(meshID); hullList = BuildingManager._hull_data.get(meshID);
meshList.add(vectors); hullList.add(convexHull);
} }
} }

2
src/engine/gameManager/BuildingManager.java

@ -40,8 +40,6 @@ import java.util.concurrent.ThreadLocalRandom;
public enum BuildingManager { public enum BuildingManager {
BUILDINGMANAGER; BUILDINGMANAGER;
public static HashMap<Integer, ArrayList<Integer>> _prop_subMeshes = new HashMap<>();
public static HashMap<Integer, ArrayList<ArrayList<Vector2f>>> _hull_data = new HashMap<>(); public static HashMap<Integer, ArrayList<ArrayList<Vector2f>>> _hull_data = new HashMap<>();
public static HashMap<Integer, ArrayList<BuildingLocation>> _stuckLocations = new HashMap<>(); public static HashMap<Integer, ArrayList<BuildingLocation>> _stuckLocations = new HashMap<>();
public static HashMap<Integer, ArrayList<BuildingLocation>> _slotLocations = new HashMap<>(); public static HashMap<Integer, ArrayList<BuildingLocation>> _slotLocations = new HashMap<>();

3
src/engine/server/world/WorldServer.java

@ -403,9 +403,6 @@ public class WorldServer {
Logger.info("Loading building slot/stuck location data."); Logger.info("Loading building slot/stuck location data.");
BuildingLocation.loadBuildingLocations(); BuildingLocation.loadBuildingLocations();
Logger.info("Loading sub-mesh lookup.");
DbManager.BuildingQueries.LOAD_SUBMESH_LOOKUP();
Logger.info("Loading mesh hulls."); Logger.info("Loading mesh hulls.");
DbManager.BuildingQueries.LOAD_CONVEX_HULLS(); DbManager.BuildingQueries.LOAD_CONVEX_HULLS();

Loading…
Cancel
Save