|
|
@ -966,24 +966,29 @@ public enum BuildingManager { |
|
|
|
|
|
|
|
|
|
|
|
public static void bakeNavMesh(Building building) { |
|
|
|
public static void bakeNavMesh(Building building) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (building.parentZone == null) |
|
|
|
|
|
|
|
Logger.error("Attempt to bake navmesh with no parent: " + building.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
// Build up navmesh by stencil of the
|
|
|
|
// Build up navmesh by stencil of the
|
|
|
|
// prop's convex hull
|
|
|
|
// convex hull meshes that comprise the prop.
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<ArrayList<Vector2f>> convexHullList; |
|
|
|
ArrayList<ArrayList<Vector2f>> convexHullList; |
|
|
|
convexHullList = _hull_data.get(building.meshUUID); |
|
|
|
convexHullList = _hull_data.get(building.meshUUID); |
|
|
|
|
|
|
|
|
|
|
|
for (ArrayList<Vector2f> meshEntry : convexHullList) { |
|
|
|
for (ArrayList<Vector2f> meshEntry : convexHullList) { |
|
|
|
|
|
|
|
|
|
|
|
Path2D.Float stencil = new Path2D.Float(); |
|
|
|
Path2D.Float stencilPath = new Path2D.Float(); |
|
|
|
|
|
|
|
|
|
|
|
for (Vector2f vertex : meshEntry) |
|
|
|
for (Vector2f vertex : meshEntry) |
|
|
|
stencil.moveTo(vertex.x, vertex.y); |
|
|
|
stencilPath.moveTo(vertex.x, vertex.y); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// enclose the path
|
|
|
|
|
|
|
|
|
|
|
|
// enclose polygon
|
|
|
|
stencilPath.moveTo(meshEntry.get(0).x, meshEntry.get(0).y); |
|
|
|
|
|
|
|
|
|
|
|
stencil.moveTo(meshEntry.get(0).x, meshEntry.get(0).y); |
|
|
|
// subtract stencil from zone navmesh
|
|
|
|
|
|
|
|
|
|
|
|
Area stencilArea = new Area(stencil); |
|
|
|
Area stencilArea = new Area(stencilPath); |
|
|
|
building.parentZone.navMesh.subtract(stencilArea); |
|
|
|
building.parentZone.navMesh.subtract(stencilArea); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|