Browse Source

load mesh data and structure meshes

server-collision
FatBoy-DOTC 12 months ago
parent
commit
c77f38dec1
  1. 23
      src/engine/db/handlers/dbBuildingHandler.java

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

@ -861,14 +861,14 @@ public class dbBuildingHandler extends dbHandlerBase {
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
BuildingManager.prop_meshes = new HashMap<>(); BuildingManager.prop_meshes = new HashMap<>();
while (rs.next()) { while (rs.next()) {
if(BuildingManager.prop_meshes.containsKey(rs.getInt("propId")) == false){ if(BuildingManager.prop_meshes.containsKey(rs.getInt("propID")) == false){
ArrayList<Integer> meshList = new ArrayList<>(); ArrayList<Integer> meshList = new ArrayList<>();
meshList.add(rs.getInt("meshID")); meshList.add(rs.getInt("meshID"));
BuildingManager.prop_meshes.put(rs.getInt("propId"),meshList); BuildingManager.prop_meshes.put(rs.getInt("propID"),meshList);
} }
else else
{ {
BuildingManager.prop_meshes.get(rs.getInt("propId")).add(rs.getInt("meshID")); BuildingManager.prop_meshes.get(rs.getInt("propID")).add(rs.getInt("meshID"));
} }
} }
@ -881,11 +881,10 @@ public class dbBuildingHandler extends dbHandlerBase {
public void LOAD_MESH_DATA() { public void LOAD_MESH_DATA() {
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `new-static_mesh_triangles`")) { PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_mesh_triangles`")) {
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
BuildingManager.mesh_triangle_points = new HashMap<>(); BuildingManager.mesh_triangle_points = new HashMap<>();
BuildingManager.mesh_heights = new HashMap<>();
while (rs.next()) { while (rs.next()) {
ArrayList<Float> floatPoints = new ArrayList<>(); ArrayList<Float> floatPoints = new ArrayList<>();
@ -907,6 +906,19 @@ public class dbBuildingHandler extends dbHandlerBase {
{ {
BuildingManager.mesh_triangle_points.get(rs.getInt("meshID")).add(triPoints); BuildingManager.mesh_triangle_points.get(rs.getInt("meshID")).add(triPoints);
} }
}
} catch (SQLException e) {
Logger.error(e);
}
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_mesh_heights`")) {
ResultSet rs = preparedStatement.executeQuery();
BuildingManager.mesh_heights = new HashMap<>();
while (rs.next()) {
if(BuildingManager.mesh_heights.containsKey(rs.getInt("meshID")) == false){ if(BuildingManager.mesh_heights.containsKey(rs.getInt("meshID")) == false){
Vector2f heights = new Vector2f(rs.getFloat("maxY"),rs.getFloat("minY")); Vector2f heights = new Vector2f(rs.getFloat("maxY"),rs.getFloat("minY"));
BuildingManager.mesh_heights.put(rs.getInt("meshID"),heights); BuildingManager.mesh_heights.put(rs.getInt("meshID"),heights);
@ -916,6 +928,7 @@ public class dbBuildingHandler extends dbHandlerBase {
} catch (SQLException e) { } catch (SQLException e) {
Logger.error(e); Logger.error(e);
} }
} }
public void LOAD_MESH_BOUNDING_BOXES() { public void LOAD_MESH_BOUNDING_BOXES() {

Loading…
Cancel
Save