Browse Source

Update to hull loading

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

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

@ -549,29 +549,6 @@ public class dbBuildingHandler extends dbHandlerBase { @@ -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 { @@ -586,40 +563,39 @@ public class dbBuildingHandler extends dbHandlerBase {
recordsRead++;
int meshID = rs.getInt("meshID");
String[] vertStrings = rs.getString("convexHull").split(";");
ArrayList<Vector2f> 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<Vector2f> vectors = new ArrayList<>();
ArrayList<Vector2f> convexHull = new ArrayList<>();
ArrayList<Float> 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)));
convexHull.add(new Vector2f(floats.get(0), floats.get(1)));
floats.clear();
}
}
ArrayList<ArrayList<Vector2f>> meshList;
ArrayList<ArrayList<Vector2f>> 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);
}
}

2
src/engine/gameManager/BuildingManager.java

@ -40,8 +40,6 @@ import java.util.concurrent.ThreadLocalRandom; @@ -40,8 +40,6 @@ import java.util.concurrent.ThreadLocalRandom;
public enum 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<BuildingLocation>> _stuckLocations = 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 { @@ -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();

Loading…
Cancel
Save