Problem
When using scripts to generate terrain, I discovered that Terrain:FillBall()
has an arbitrary radius limit of 812. Any attempt to exceed 812 in the radius field throws an error Extents are too large
. Additionally, this limit is not mentioned anywhere in the documentation.
What I expect to happen is that there is no limit or that the limit is very large (> 4096).
Not sure why this is in place (I suspect it’s for performance reasons), but since I’m running this from the Studio command line (game is not running), performance shouldn’t be an issue as I just let the machine crunch the numbers and it finishes when it finishes.
Parameter | Value |
---|---|
Area | Engine: Studio |
Type | Terrain |
First Noticed | Today (12 Aug 2023) |
Frequency | Constant |
Impact | Moderate |
Visuals
As one can see in the above illustration, a radius value of 812 works. However when one tries 813 as a radius value, an error is thrown.
The above image shows that there is no mention of this limit in the documentation.
Reproduction
The steps to reproduce this is as follows:
- In Studio, start with a baseplate template.
- Remove the baseplate and spawn location.
- Enter the following command on the command line:
game.Workspace.Terrain:FillBall(Vector3.new(0, 0, 0), 813, Enum.Material.Rock)
- Observe the error.
Note: You can change 813 to 812 and it will generate the terrain sphere.
Workaround
I have developed the following function to get around this:
local function generateTerrainSphere(center, radius, material)
local terrain = game.Workspace.Terrain
if radius > 812 then
for y = 0, radius, 1 do
local x = math.sqrt((radius * radius) - (y * y))
local vp = Vector3.new(center.X, center.Y + y, center.Z)
local vm = Vector3.new(center.X, center.Y - y, center.Z)
if x > 0 then
terrain:FillCylinder(CFrame.new(vp), 1, x, material)
terrain:FillCylinder(CFrame.new(vm), 1, x, material)
end
end
else
terrain:FillBall(center, radius, material)
end
end