Compare commits

..

25 Commits

Author SHA1 Message Date
MagicBot 7405d71a90 Comment cleanup 2023-11-21 09:22:35 -05:00
MagicBot 89f9c0471f Update to hull loading 2023-11-21 08:48:17 -05:00
MagicBot a94056e9e1 String fix to mirror schema 2023-11-16 13:09:39 -05:00
MagicBot 021a5a5a5a Merge remote-tracking branch 'origin/magicbox-1.5.2' into convex-data 2023-11-16 13:04:39 -05:00
MagicBot 892174ffe1 Revert needs new branch. 2023-11-16 13:02:02 -05:00
MagicBot 536ccc2143 Height and width flipped. 2023-11-16 13:02:01 -05:00
MagicBot 2ced2f75af Height and width flipped. 2023-11-16 13:02:00 -05:00
MagicBot 63248ef577 IDA says 256. 2023-11-16 13:01:59 -05:00
MagicBot 72412a98dd Devcmd updated. 2023-11-16 13:01:58 -05:00
MagicBot a664c8790e Dev cmd updated 2023-11-16 13:01:57 -05:00
MagicBot 9663d87088 Dev cmd updated 2023-11-16 13:01:56 -05:00
MagicBot 4e642b0f42 Dev cmd updated 2023-11-16 13:01:55 -05:00
MagicBot f9fafe90d5 Dev cmd updated 2023-11-16 13:01:55 -05:00
MagicBot 3181c465cb Dev cmd updated 2023-11-16 13:01:54 -05:00
MagicBot 9b8be777f1 Final schema for convex hull data. 2023-11-16 13:00:49 -05:00
MagicBot eb5bc14974 Revert needs new branch. 2023-11-12 11:21:30 -05:00
MagicBot 7e99e8c7a4 Height and width flipped. 2023-11-12 11:13:27 -05:00
MagicBot 9b0f4d5aef Height and width flipped. 2023-11-12 11:09:29 -05:00
MagicBot b58049968f IDA says 256. 2023-11-12 07:36:56 -05:00
MagicBot 9bf0d3f7d1 Devcmd updated. 2023-11-11 07:10:46 -05:00
MagicBot 8300c47e4a Dev cmd updated 2023-11-08 11:59:52 -05:00
MagicBot c73fcc19f2 Dev cmd updated 2023-11-08 11:34:33 -05:00
MagicBot f93573177a Dev cmd updated 2023-11-08 11:27:44 -05:00
MagicBot fe9c6437d8 Dev cmd updated 2023-11-08 11:27:36 -05:00
MagicBot c110ffc4b1 Dev cmd updated 2023-11-02 09:08:28 -04:00
4 changed files with 25 additions and 54 deletions
+23 -46
View File
@@ -549,35 +549,12 @@ public class dbBuildingHandler extends dbHandlerBase {
return false;
}
public void POPULATE_RENDER_LOOKUP() {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_structure_renders`")) {
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
int structureID = rs.getInt("structureID");
int renderID = rs.getInt("renderID");
if (!BuildingManager._render_lookup.containsKey(structureID))
BuildingManager._render_lookup.put(structureID, new ArrayList<>());
BuildingManager._render_lookup.get(structureID).add(renderID);
}
} catch (SQLException e) {
Logger.error(e);
}
}
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,40 +562,40 @@ public class dbBuildingHandler extends dbHandlerBase {
recordsRead++;
int propID = rs.getInt("propID");
String[] vertStrings = rs.getString("vertices").split(";");
ArrayList<Vector2f> vertArrayList = new ArrayList<>();
int meshID = rs.getInt("meshID");
String[] hullString = rs.getString("vertices").split(";");
// Filter things that couldn't be wrapped
if (vertStrings.length < 3) {
Logger.error("Prop : " + propID + " has less than 3 vertices.");
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)));
floats = new ArrayList<>();
if (floats.size() == 2) {
convexHull.add(new Vector2f(floats.get(0), floats.get(1)));
floats.clear();
}
}
ArrayList<ArrayList<Vector2f>> hullList;
//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) {
meshList = new ArrayList<>();
meshList.add(vectors);
BuildingManager._hull_data.put(propID, meshList);
if (BuildingManager._hull_data.get(meshID) == null) {
hullList = new ArrayList<>();
hullList.add(convexHull);
BuildingManager._hull_data.put(meshID, hullList);
} else {
meshList = BuildingManager._hull_data.get(propID);
meshList.add(vectors);
hullList = BuildingManager._hull_data.get(meshID);
hullList.add(convexHull);
}
}
@@ -40,8 +40,6 @@ import java.util.concurrent.ThreadLocalRandom;
public enum BuildingManager {
BUILDINGMANAGER;
public static HashMap<Integer, ArrayList<Integer>> _render_lookup = 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<>();
+1 -2
View File
@@ -34,7 +34,6 @@ import engine.net.client.msg.UpdateObjectMsg;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.awt.geom.Area;
import java.awt.geom.Path2D;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -914,7 +913,7 @@ public class Building extends AbstractWorldObject {
// Note: We handle R8 tree edge case for mesh and health
// after city is loaded to avoid recursive result set call
// in City resulting in a stack ovreflow.
// in City resulting in a stack overflow.
if (blueprint != null) {
+1 -4
View File
@@ -403,11 +403,8 @@ public class WorldServer {
Logger.info("Loading building slot/stuck location data.");
BuildingLocation.loadBuildingLocations();
Logger.info("Populating structure to render lookup.");
DbManager.BuildingQueries.POPULATE_RENDER_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