/// <summary> /// This one ignores finding openings within specific shapes as we'll be doing this for rooms in floorplan gen /// </summary> /// <param name="building"></param> /// <param name="volume"></param> /// <returns></returns> public static VerticalOpening[] GetOpeningsQuick(IBuilding building, IVolume volume) { List <VerticalOpening> output = new List <VerticalOpening>(); int count = building.openingCount; VerticalOpening[] openings = building.GetAllOpenings(); int volumeBaseFloor = building.VolumeBaseFloor(volume); int volumeTopFloor = volumeBaseFloor + volume.floors; for (int i = 0; i < count; i++) { VerticalOpening opening = openings[i]; int openingBaseFloor = opening.baseFloor; int openingTopFloor = openingBaseFloor + opening.floors; // Debug.Log("CHECK IT " + openingTopFloor + " " + volume.name); // Debug.Log(volumeBaseFloor + " < " + openingTopFloor + " && " + openingBaseFloor + " < " + volumeTopFloor); if (volumeBaseFloor <= openingTopFloor && openingBaseFloor < volumeTopFloor)//opening and volume floors intersect { // Debug.Log("opening " + openingTopFloor + " "+ volume.name); FlatBounds volumeBounds = new FlatBounds(volume.bounds); volumeBounds.Expand(VerticalOpening.WALL_THICKNESS); Vector2[] openingPoints = opening.PointsRotated(); FlatBounds openingBounds = new FlatBounds(openingPoints); // if(volume.name == "Roof Exit") // { // Debug.Log(volumeBounds.Overlaps(openingBounds, true)); // Debug.Log(openingBounds.Overlaps(volumeBounds, true)); // volumeBounds.DrawDebug(Color.red); // openingBounds.DrawDebug(Color.green); // } if (openingBounds.Overlaps(volumeBounds, true))// opening is within the AABB bounds of the volume { output.Add(opening); // Debug.Log("opening bounds " + openingTopFloor + " " + volume.name); } else { // Debug.Log("opening NOT " + openingTopFloor + " " + volume.name); } } // Debug.Log("================================="); } return(output.ToArray()); }