Browse Source

hull 7

hull7
FatBoy-DOTC 11 months ago
parent
commit
d097e744b9
  1. 19
      src/engine/gameManager/BuildingManager.java
  2. 1
      src/engine/objects/Building.java

19
src/engine/gameManager/BuildingManager.java

@ -29,6 +29,7 @@ import engine.objects.*; @@ -29,6 +29,7 @@ import engine.objects.*;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.awt.geom.AffineTransform;
import java.awt.geom.Path2D;
import java.time.LocalDateTime;
import java.time.ZoneId;
@ -965,7 +966,7 @@ public enum BuildingManager { @@ -965,7 +966,7 @@ public enum BuildingManager {
}
public static void bakeNavMesh(Building building) {
building.meshes = new ArrayList<>();
if (building.parentZone == null) {
Logger.error("Attempt to bake navmesh with no parent: " + building.getObjectUUID());
return;
@ -982,10 +983,6 @@ public enum BuildingManager { @@ -982,10 +983,6 @@ public enum BuildingManager {
return;
}
for (Path2D.Float meshEntry : convexHullList) {
building.meshes.add(meshEntry);
building.parentZone.navObstacles.add(meshEntry);
}
//add navNodes to parent zone list
float X = building.getBounds().getHalfExtents().x;
float Y = building.getBounds().getHalfExtents().y;
@ -1043,4 +1040,16 @@ public enum BuildingManager { @@ -1043,4 +1040,16 @@ public enum BuildingManager {
outPath.closePath();
return outPath;
}
public static void loadColliders(Building building){
building.meshes = new ArrayList<>();
for(Path2D.Float path : _hull_data.get(building.meshUUID)){
Path2D.Float translatedPath = new Path2D.Float(path);
AffineTransform offset = AffineTransform.getTranslateInstance(building.loc.x , building.loc.y);
translatedPath.transform(offset);
AffineTransform rotate = AffineTransform.getRotateInstance(Math.toRadians(building.getRot().y), building.loc.x, building.loc.z);
translatedPath.transform(rotate);
building.meshes.add(translatedPath);
}
}
}

1
src/engine/objects/Building.java

@ -1008,6 +1008,7 @@ public class Building extends AbstractWorldObject { @@ -1008,6 +1008,7 @@ public class Building extends AbstractWorldObject {
if (this.upgradeDateTime != null)
BuildingManager.submitUpgradeJob(this);
BuildingManager.loadColliders(this); // load building colliders
BuildingManager.bakeNavMesh(this); // update the navmesh of the parent zone
}

Loading…
Cancel
Save