Improve speed and reduce LuaJIT out of memory crashes by not allocating a new voxel buffer every on_generated()
This fix requires Minetest v4.15 or later.
Reference: paramat's explanation of #3https://forum.minetest.net/viewtopic.php?t=16043
multi_map settings like number_of_layers must be finalized before invoking mmgen_*.lua files, as they invoke multi_map.register_global_2dmap() which create an array of global_2d_params - one for each layer.
parameterized the levels generator settings so they can now be
passed on generator registration, changed levels local noises to
global noises. Fixed HUD offset issue, where it would show the
wrong zone and relative coordinates off by 1. Added support for
per layer specific settings such as enabling/ disabling bedrock
or skyrock per layer, overriding certain other settings or
behavior, etc.
run of on_generated. Added caching of the perlin maps, i.e. when
the on_generated is called, the noise map array is stored when
it is retrieved by a generator plugin and kept until the on_generated
is finished. This allows chained generators to retrieve the same
global map without having to reinitialize it.
register their 2D noises with multi_map globally and retrieve
them during map generation. multi_map takes care of reusing last
cached map in case the same layer is used for performance/ memory
reasons. In addition, it prepares an array of parameters so that
the noises can be used in any layer (truly availble globally) with
seeds different for each layer (but based on the seed passed
during registration via random seeding). Placeholder for global
3D maps added, but not implemented yet.
sort of cached table as per duane's underworlds mod. Introduced
shorthand alias mm for multi_map in case not other mods named mm
exist, so that it can be more easily used to reference the API, e.g.
to do vm_data[vi] = mm.node["default:cobble"] instead of having to
fully spell out multi_map
as per paramat's recommendation a temporary "shadow caster" layer
is written above the chunk when underground relative to the current
layer. This works perfectly and lighting works properly while at
the same time it is calculated by the engine. A major change in the
API was however necessary to limit memory usage. The VM, are and
VM data are now initialized in the multi_map core, and passed on
to the generators as otherwise multiple data arrays were created
(one for the shadow caster, one of the generator, one to remove
the shadow caster again) and multiple calls to set_data and
write_to_map... This is also much better in case generators
are chained (i.e. multiple generators being called within a
single mapgen on_generated call)