mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-16 21:12:59 +00:00
Starbeamrainbowlabs
fd5804dd9c
Specifically, I'm unsure about whether I'm happy with the effects of the algorithm. Also, we convolve with a 3x3 gaussian kernel after erosion is complete - and we have verified that the erosion is having an positive effect at "roughening up" a terrain surface. It seems like the initial blog post was correct: the algorithm does tend to make steep surfaces steeper. It also appears that it's more effective on larger areas, and 'gentler' curves. THis might be because the surface normals are more conducive to making the snowballs roll. Finally, we need to decide whether we want to keep the precomputed normals as we have now, or whether we want to dynamically compute them at the some of request.
30 lines
906 B
Lua
30 lines
906 B
Lua
--- Shallow clones a table.
|
|
-- @source http://lua-users.org/wiki/CopyTable
|
|
-- @param orig table The table to clone.
|
|
-- @return table The cloned table.
|
|
function worldeditadditions.shallowcopy(orig)
|
|
local orig_type = type(orig)
|
|
local copy
|
|
if orig_type == 'table' then
|
|
copy = {}
|
|
for orig_key, orig_value in pairs(orig) do
|
|
copy[orig_key] = orig_value
|
|
end
|
|
else -- number, string, boolean, etc
|
|
copy = orig
|
|
end
|
|
return copy
|
|
end
|
|
|
|
--- SHALLOWLY applies the values in source to overwrite the equivalent keys in target.
|
|
-- Warning: This function mutates target!
|
|
-- @param source table The source to take values from
|
|
-- @param target table The target to write values to
|
|
function worldeditadditions.table_apply(source, target)
|
|
print("[table_apply] start")
|
|
for key, value in pairs(source) do
|
|
print("[table_apply] Applying", key, "=", value)
|
|
target[key] = value
|
|
end
|
|
print("[table_apply] end")
|
|
end
|