mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 18:41:09 +01:00
Explosions: Reduce repeated code
This commit is contained in:
parent
772ea01aff
commit
679e2b1b70
1 changed files with 34 additions and 67 deletions
|
@ -55,6 +55,7 @@ local function compute_sphere_rays(radius)
|
||||||
local rays = {}
|
local rays = {}
|
||||||
local sphere = {}
|
local sphere = {}
|
||||||
|
|
||||||
|
for i=1, 2 do
|
||||||
for y = -radius, radius do
|
for y = -radius, radius do
|
||||||
for z = -radius, radius do
|
for z = -radius, radius do
|
||||||
for x = -radius, 0, 1 do
|
for x = -radius, 0, 1 do
|
||||||
|
@ -67,20 +68,9 @@ local function compute_sphere_rays(radius)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for y = -radius, radius do
|
|
||||||
for z = -radius, radius do
|
|
||||||
for x = radius, 0, -1 do
|
|
||||||
local d = x * x + y * y + z * z
|
|
||||||
if d <= radius * radius then
|
|
||||||
local pos = { x = x, y = y, z = z }
|
|
||||||
sphere[minetest.hash_node_position(pos)] = pos
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for i=1,2 do
|
||||||
for x = -radius, radius do
|
for x = -radius, radius do
|
||||||
for z = -radius, radius do
|
for z = -radius, radius do
|
||||||
for y = -radius, 0, 1 do
|
for y = -radius, 0, 1 do
|
||||||
|
@ -93,20 +83,9 @@ local function compute_sphere_rays(radius)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for x = -radius, radius do
|
|
||||||
for z = -radius, radius do
|
|
||||||
for y = radius, 0, -1 do
|
|
||||||
local d = x * x + y * y + z * z
|
|
||||||
if d <= radius * radius then
|
|
||||||
local pos = { x = x, y = y, z = z }
|
|
||||||
sphere[minetest.hash_node_position(pos)] = pos
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for i=1,2 do
|
||||||
for x = -radius, radius do
|
for x = -radius, radius do
|
||||||
for y = -radius, radius do
|
for y = -radius, radius do
|
||||||
for z = -radius, 0, 1 do
|
for z = -radius, 0, 1 do
|
||||||
|
@ -119,18 +98,6 @@ local function compute_sphere_rays(radius)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for x = -radius, radius do
|
|
||||||
for y = -radius, radius do
|
|
||||||
for z = radius, 0, -1 do
|
|
||||||
local d = x * x + y * y + z * z
|
|
||||||
if d <= radius * radius then
|
|
||||||
local pos = { x = x, y = y, z = z }
|
|
||||||
sphere[minetest.hash_node_position(pos)] = pos
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, pos in pairs(sphere) do
|
for _, pos in pairs(sphere) do
|
||||||
|
|
Loading…
Reference in a new issue