mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-29 10:23:00 +00:00
//subdivide: Fix more issues, there are a few more to go
This commit is contained in:
parent
2ac6ea03a7
commit
008519177c
2 changed files with 12 additions and 6 deletions
|
@ -31,7 +31,7 @@ local function make_stats_obj(state)
|
||||||
chunks_total = state.chunks_total,
|
chunks_total = state.chunks_total,
|
||||||
chunks_completed = state.chunks_completed,
|
chunks_completed = state.chunks_completed,
|
||||||
chunk_size = state.chunk_size,
|
chunk_size = state.chunk_size,
|
||||||
volume_nodes = stats.volume_nodes,
|
volume_nodes = state.volume_nodes,
|
||||||
emerge = state.stats_emerge,
|
emerge = state.stats_emerge,
|
||||||
times = state.times,
|
times = state.times,
|
||||||
eta = state.eta,
|
eta = state.eta,
|
||||||
|
@ -52,7 +52,7 @@ end
|
||||||
local function subdivide_step_beforeload(state)
|
local function subdivide_step_beforeload(state)
|
||||||
state.cpos.z = state.cpos.z - (state.chunk_size.z + 1)
|
state.cpos.z = state.cpos.z - (state.chunk_size.z + 1)
|
||||||
if state.cpos.z <= state.pos1.z then
|
if state.cpos.z <= state.pos1.z then
|
||||||
state.cpoz.z = state.pos2.z
|
state.cpos.z = state.pos2.z
|
||||||
state.cpos.y = state.cpos.y - (state.chunk_size.y + 1)
|
state.cpos.y = state.cpos.y - (state.chunk_size.y + 1)
|
||||||
if state.cpos.y <= state.pos1.y then
|
if state.cpos.y <= state.pos1.y then
|
||||||
state.cpos.y = state.pos2.y
|
state.cpos.y = state.pos2.y
|
||||||
|
@ -76,8 +76,9 @@ local function subdivide_step_beforeload(state)
|
||||||
if state.cpos1.z < state.pos1.z then state.cpos1.z = state.pos1.z end
|
if state.cpos1.z < state.pos1.z then state.cpos1.z = state.pos1.z end
|
||||||
|
|
||||||
state.times.emerge_last = wea.get_ms_time()
|
state.times.emerge_last = wea.get_ms_time()
|
||||||
worldeditadditions.emerge_area(state.pos1, state.pos2, subdivide_step_afterload, state)
|
worldeditadditions.emerge_area(state.pos1, state.pos2, state.__afterload, state)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function subdivide_step_afterload(state_emerge, state_ours)
|
local function subdivide_step_afterload(state_emerge, state_ours)
|
||||||
state_ours.times.emerge_last = wea.get_ms_time() - state_ours.times.emerge_last
|
state_ours.times.emerge_last = wea.get_ms_time() - state_ours.times.emerge_last
|
||||||
table.insert(state_ours.times.emerge, state_ours.times.emerge_last)
|
table.insert(state_ours.times.emerge, state_ours.times.emerge_last)
|
||||||
|
@ -104,7 +105,7 @@ local function subdivide_step_afterload(state_emerge, state_ours)
|
||||||
state_ours.emerge_overhead = total_emerge / total_steps
|
state_ours.emerge_overhead = total_emerge / total_steps
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.after(0, subdivide_step_beforeload, state_ours)
|
minetest.after(0, state_ours.__beforeload, state_ours)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Calls the given callback function once for each block in the defined area.
|
--- Calls the given callback function once for each block in the defined area.
|
||||||
|
@ -156,7 +157,10 @@ function worldeditadditions.subdivide(pos1, pos2, chunk_size, callback_subblock,
|
||||||
-- The number of chunks processed so far
|
-- The number of chunks processed so far
|
||||||
chunks_completed = 0,
|
chunks_completed = 0,
|
||||||
callback_subblock = callback_subblock,
|
callback_subblock = callback_subblock,
|
||||||
callback_complete = callback_complete
|
callback_complete = callback_complete,
|
||||||
|
|
||||||
|
__beforeload = subdivide_step_beforeload,
|
||||||
|
__afterload = subdivide_step_afterload
|
||||||
}
|
}
|
||||||
|
|
||||||
subdivide_step_beforeload(state)
|
subdivide_step_beforeload(state)
|
||||||
|
|
|
@ -57,7 +57,8 @@ local function emerge_callback(pos, action, num_calls_remaining, state)
|
||||||
state.loaded_blocks = state.loaded_blocks + 1
|
state.loaded_blocks = state.loaded_blocks + 1
|
||||||
|
|
||||||
if state.loaded_blocks == state.total then
|
if state.loaded_blocks == state.total then
|
||||||
state.callback(state, callback_state)
|
print("[DEBUG] after", state.callback)
|
||||||
|
state.callback(state, state.callback_state)
|
||||||
else
|
else
|
||||||
if action == minetest.EMERGE_CANCELLED then
|
if action == minetest.EMERGE_CANCELLED then
|
||||||
state.stats.cancelled = state.stats.cancelled + 1
|
state.stats.cancelled = state.stats.cancelled + 1
|
||||||
|
@ -86,5 +87,6 @@ function worldeditadditions.emerge_area(pos1, pos2, callback, callback_state)
|
||||||
callback = callback,
|
callback = callback,
|
||||||
callback_state = callback_state
|
callback_state = callback_state
|
||||||
}
|
}
|
||||||
|
print("[DEBUG] before", state.callback)
|
||||||
minetest.emerge_area(pos1, pos2, emerge_callback, state)
|
minetest.emerge_area(pos1, pos2, emerge_callback, state)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue