sbrl / Minetest-WorldEditAdditions

Extra tools and commands to extend WorldEdit for Minetest
https://worldeditadditions.mooncarrot.space/
Mozilla Public License 2.0
16 stars 3 forks source link

Issues with large //subdivide calls #24

Closed sbrl closed 3 years ago

sbrl commented 3 years ago

If one executes an extremely large //subdivide, it becomes increasingly likely that all the nodes in the defined region will not actually be loaded into memory all at once. To this end, we should refactor //subdivide to use minetest.emerge_area() to load each block before we execute the command on it. We should be careful to avoid loading the entire area in 1 enormous minetest.emerge_area() call though, because that won't scale to the sizes we are looking to support here.

There's a nice tutorial on how to use minetest.emerge_area() here: https://rubenwardy.com/minetest_modding_book/en/map/environment.html#loading-blocks.

We might as well take the time to refactor //subdivide a bit to use the step-based approach we use for the //many command too, in order to make it asynchronous. It's a shame Lua doesn't support Promises or async/await....

sbrl commented 3 years ago

Fixed it. We've got a pretty sweet new animation effect now too :D

It was trivial to update the worldedit region markers that are shown on screen at the same time, so we do that too and you can see it whizzing across the screen now :D