/// <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()); }
public FloorSegment(float area, FlatBounds bounds, params Vector2Int[] input) { int inputCount = input.Length; points = new Vector2Int[inputCount]; this.bounds = bounds; for (int p = 0; p < inputCount; p++) { points[p] = input[p]; } // CalculateNormals(); position = new Vector2Int(bounds.center); nBounds = new FlatBounds(bounds); nBounds.Expand(0.25f); this.area = area; neighbours = new List <FloorSegment>(); }