mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2024-09-28 07:20:35 +02:00
Corrected volume formula
This commit is contained in:
parent
df4f55bdcd
commit
07335d0817
|
@ -52,7 +52,7 @@ end
|
|||
-- @param node_name Name of node to make torus of.
|
||||
-- @param hollow Whether the torus should be hollow.
|
||||
-- @return The number of nodes added.
|
||||
function worldedit.torus(pos, radius, tr, node_name, hollow)
|
||||
function worldedit.torus(pos, radius, tr, node_name)
|
||||
local radius_out=radius+tr
|
||||
local radius_in=radius-tr
|
||||
local manip, area = mh.init_radius(pos, radius_out)
|
||||
|
|
|
@ -698,7 +698,12 @@ local check_torus = function(param)
|
|||
if not node then
|
||||
return false, "invalid node name: " .. nodename
|
||||
end
|
||||
return true, tonumber(radius), tonumber(tr), node
|
||||
local n_radius= tonumber(radius)
|
||||
local tr = tonumber(tr)
|
||||
if tr>n_radius then
|
||||
return false, "Thickness cannot be greater than radius"
|
||||
end
|
||||
return true, radius, tr, node
|
||||
end
|
||||
|
||||
|
||||
|
@ -737,7 +742,7 @@ worldedit.register_command("torus", {
|
|||
require_pos = 1,
|
||||
parse = check_torus,
|
||||
nodes_needed = function(name, radius, tr, node)
|
||||
return math.ceil((4 * math.pi * (radius ^ 3)) / 3) --volume of sphere
|
||||
return math.ceil( 2 * math.pi * math.pi * radius *tr *tr)
|
||||
end,
|
||||
func = function(name, radius, tr, node)
|
||||
local count = worldedit.torus(worldedit.pos1[name], radius, tr, node)
|
||||
|
|
Loading…
Reference in New Issue
Block a user