Merge pull request #2 from Treer/memory_optimize2

Optimize memory usage to reduce LuaJIT OOM errors
This commit is contained in:
Emiel van Rooijen 2019-02-11 12:50:07 +01:00 committed by GitHub
commit 792b695902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -31,6 +31,8 @@ multi_map.generators = {}
-- When no suitable generator is found, this generator is used as a fallback
multi_map.fallback_generator = nil
local vm_data = {} -- reuse the massive VoxelManip memory buffer instead of creating on every on_generate()
-- Set the current layer which the mapgen is generating
-- y = absolute y value to be translated to layer
function multi_map.set_current_layer(y)
@ -322,7 +324,7 @@ minetest.register_on_generated(function(minp, maxp)
then
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
local vm_data = vm:get_data()
vm:get_data(vm_data)
if multi_map.layers[multi_map.current_layer] and
multi_map.layers[multi_map.current_layer].bedrock_generator
@ -342,7 +344,7 @@ minetest.register_on_generated(function(minp, maxp)
then
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
local vm_data = vm:get_data()
vm:get_data(vm_data)
if multi_map.layers[multi_map.current_layer] and
multi_map.layers[multi_map.current_layer].skyrock_generator
@ -359,7 +361,7 @@ minetest.register_on_generated(function(minp, maxp)
elseif multi_map.wrap_layers and multi_map.in_skip_area({ x = minp.x, y = minp.z }) then
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
local vm_data = vm:get_data()
vm:get_data(vm_data)
multi_map.generate_singlenode_chunk(minp, maxp, area, vm_data, multi_map.node["multi_map_core:skyrock"])
vm:set_data(vm_data)
vm:calc_lighting(false)
@ -367,7 +369,7 @@ minetest.register_on_generated(function(minp, maxp)
else
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
local vm_data = vm:get_data()
vm:get_data(vm_data)
local remove_shadow_caster = false
-- Add a temporary shadow caster layer above the chunk to ensure caves are dark