function RoomPackager.RegionsFromBasePlate(C,m)local W=C:TopCornersOfBasePlate(m)local e=W[1]local U=e.X local h=e.Z local Y=e.X local N=e.Z for m,C in pairs(W)do U=math.min(U,C.X)h=math.min(h,C.Z)Y=math.max(Y,C.X)N=math.max(N,C.Z)end local c=W[1].Y local B=Vector3.new(U,c,h)local b=c+70 local j=Vector3.new(Y,b,N)local y=math.floor(100000/(math.abs(Y-U)*math.abs(N-h)))local G={}local L=c while L-c<70 do L=L+y B=Vector3.new(B.x,L-y,B.z)j=Vector3.new(j.x,L,j.z)table.insert(G,Region3.new(B,j))end return G end

function RoomPackager:RegionsFromBasePlate(basePlate)
	local topCorners = self:TopCornersOfBasePlate(basePlate)

	--we farm the min and max x's and z's from the top corners
	--to get x and z coordinates for the region3 that will contain the room
	--we choose an arbitrary corner so that the initial values are in the data set
	local arbitraryCorner = topCorners[1]
	local minX = arbitraryCorner.X
	local minZ = arbitraryCorner.Z
	local maxX = arbitraryCorner.X
	local maxZ = arbitraryCorner.Z
	for _, corner in pairs(topCorners) do
		minX = math.min(minX, corner.X)
		minZ = math.min(minZ, corner.Z)
		maxX = math.max(maxX, corner.X)
		maxZ = math.max(maxZ, corner.Z)
	end

	--construct the region using these new corners we have constructed
	--keeping in mind that all corners in topCorners *should* have the same y value
	local minY = topCorners[1].Y
	local lowerCorner = Vector3.new(minX, minY, minZ)
	local maxY = minY + 70
	local upperCorner = Vector3.new(maxX, maxY, maxZ)

	local segmentHeight = math.floor(100000/(math.abs(maxX-minX)*math.abs(maxZ-minZ)))

	local regions = {}

	local currentHeight = minY
	while currentHeight - minY < 70 do
		currentHeight = currentHeight + segmentHeight
		lowerCorner = Vector3.new(lowerCorner.x, currentHeight - segmentHeight, lowerCorner.z)
		upperCorner = Vector3.new(upperCorner.x, currentHeight, upperCorner.z)
		table.insert(regions, Region3.new(lowerCorner, upperCorner))
	end

	return regions
end
