Final schema for convex hull data.

This commit is contained in:
2023-11-16 13:00:49 -05:00
parent 343bfd1003
commit 9b8be777f1
3 changed files with 24 additions and 23 deletions
+21 -20
View File
@@ -549,22 +549,22 @@ public class dbBuildingHandler extends dbHandlerBase {
return false;
}
public void POPULATE_RENDER_LOOKUP() {
public void LOAD_SUBMESH_LOOKUP() {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_structure_renders`")) {
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_render_submesh`")) {
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
int structureID = rs.getInt("structureID");
int renderID = rs.getInt("renderID");
int structureID = rs.getInt("propID");
int renderID = rs.getInt("meshID");
if (!BuildingManager._render_lookup.containsKey(structureID))
BuildingManager._render_lookup.put(structureID, new ArrayList<>());
if (!BuildingManager._prop_subMeshes.containsKey(structureID))
BuildingManager._prop_subMeshes.put(structureID, new ArrayList<>());
BuildingManager._render_lookup.get(structureID).add(renderID);
BuildingManager._prop_subMeshes.get(structureID).add(renderID);
}
} catch (SQLException e) {
@@ -572,12 +572,12 @@ public class dbBuildingHandler extends dbHandlerBase {
}
}
public void LOAD_MESH_HULLS() {
public void LOAD_CONVEX_HULLS() {
int recordsRead = 0;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_verts")) {
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_convex_hulls")) {
ResultSet rs = preparedStatement.executeQuery();
@@ -585,39 +585,40 @@ public class dbBuildingHandler extends dbHandlerBase {
recordsRead++;
int propID = rs.getInt("propID");
String[] vertStrings = rs.getString("vertices").split(";");
int meshID = rs.getInt("meshID");
String[] vertStrings = rs.getString("convexHull").split(";");
ArrayList<Vector2f> vertArrayList = new ArrayList<>();
// Filter things that couldn't be wrapped
if (vertStrings.length < 3) {
Logger.error("Prop : " + propID + " has less than 3 vertices.");
Logger.error("Mesh : " + meshID + " has less than 3 vertices.");
continue;
}
ArrayList<Vector2f> vectors = new ArrayList<>();
ArrayList<Float> floats = new ArrayList<>();
for(String read : vertStrings){
floats.add(Float.parseFloat(read));
if(floats.size() == 2) {
vectors.add(new Vector2f(floats.get(0), floats.get(1)));
floats = new ArrayList<>();
floats.clear();
}
}
//for (int i = 0; i < vertStrings.length; i += 2)
// vertArrayList.add(new Vector2f(Float.parseFloat(vertStrings[i]), Float.parseFloat(vertStrings[1 + 1])));
ArrayList<ArrayList<Vector2f>> meshList;
if (BuildingManager._hull_data.get(propID) == null) {
if (BuildingManager._hull_data.get(meshID) == null) {
meshList = new ArrayList<>();
meshList.add(vectors);
BuildingManager._hull_data.put(propID, meshList);
BuildingManager._hull_data.put(meshID, meshList);
} else {
meshList = BuildingManager._hull_data.get(propID);
meshList = BuildingManager._hull_data.get(meshID);
meshList.add(vectors);
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ public enum BuildingManager {
BUILDINGMANAGER;
public static HashMap<Integer, ArrayList<Integer>> _render_lookup = new HashMap<>();
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<>();
+2 -2
View File
@@ -404,10 +404,10 @@ public class WorldServer {
BuildingLocation.loadBuildingLocations();
Logger.info("Populating structure to render lookup.");
DbManager.BuildingQueries.POPULATE_RENDER_LOOKUP();
DbManager.BuildingQueries.LOAD_SUBMESH_LOOKUP();
Logger.info("Loading mesh hulls.");
DbManager.BuildingQueries.LOAD_MESH_HULLS();
DbManager.BuildingQueries.LOAD_CONVEX_HULLS();
// Starting before loading of structures/guilds/characters
// so the database connections are available to write