Skip to content

Commit

Permalink
VOXELGENERATOR: speed up lua scripts by not yielding if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Jan 13, 2025
1 parent 6ac0f18 commit 7869cf0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/modules/voxelgenerator/lua/scripts/modules/volume.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ end
function module.countEmptyAround(volume, x, y, z, size)
local adjacent = 0
for sx = -size, size, 1 do
coroutine.yield()
if (size > 2) then
coroutine.yield()
end
for sy = -size, size, 1 do
for sz = -size, size, 1 do
if (sx ~= 0 or sy ~= 0 or sz ~= 0) then
Expand All @@ -85,7 +87,9 @@ end
function module.countEmptyAroundOnY(volume, x, y, z, size)
local adjacent = 0
for sx = -size, size, 1 do
coroutine.yield()
if (size > 2) then
coroutine.yield()
end
for sz = -size, size, 1 do
if (sx ~= 0 or sz ~= 0) then
local color = volume:voxel(x + sx, y, z + sz)
Expand Down

0 comments on commit 7869cf0

Please sign in to comment.