Method made static and moved to manager.

This commit is contained in:
2023-11-06 11:37:50 -05:00
parent e473aa5f08
commit 19d43cbcb0
2 changed files with 30 additions and 31 deletions
@@ -28,6 +28,8 @@ import engine.objects.*;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.awt.geom.Area;
import java.awt.geom.Path2D;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
@@ -962,4 +964,31 @@ public enum BuildingManager {
return null;
}
public static void bakeNavMesh(Building building) {
// Build up navmesh by stencil of the
// prop's convex hull
ArrayList<ArrayList<Vector2f>> convexHullList;
convexHullList = _hull_data.get(building.meshUUID);
for (ArrayList<Vector2f> meshEntry : convexHullList) {
Path2D.Float stencil = new Path2D.Float();
for (Vector2f vertex : meshEntry)
stencil.moveTo(vertex.x, vertex.y);
// enclose polygon
stencil.moveTo(meshEntry.get(0).x, meshEntry.get(0).y);
Area stencilArea = new Area(stencil);
building.parentZone.navMesh.subtract(stencilArea);
}
//add in all the regions to the navMesh
for (Regions region : building.getBounds().getRegions())
building.parentZone.navMesh.add(region.getArea());
}
}