diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index f6585b4e..4b2c4037 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -966,24 +966,29 @@ public enum BuildingManager { 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 - // prop's convex hull + // convex hull meshes that comprise the prop. ArrayList> convexHullList; convexHullList = _hull_data.get(building.meshUUID); for (ArrayList meshEntry : convexHullList) { - Path2D.Float stencil = new Path2D.Float(); + Path2D.Float stencilPath = new Path2D.Float(); 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); }