diff options
author | paramat <paramat@users.noreply.github.com> | 2017-07-24 22:50:42 +0100 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2017-07-26 02:41:30 +0100 |
commit | f61928d3fc5ef90bd913af2e633275d65adce057 (patch) | |
tree | 504566887ee98d60f9ae6e8612e899f2cb86568b /src/mapgen_v7.cpp | |
parent | 31b84ce1f2c4f9c6264f32427c3e7be1215360f1 (diff) | |
download | minetest-f61928d3fc5ef90bd913af2e633275d65adce057.tar.gz minetest-f61928d3fc5ef90bd913af2e633275d65adce057.tar.bz2 minetest-f61928d3fc5ef90bd913af2e633275d65adce057.zip |
Mgv7: Add 'mount_zero_level' parameter
Allows setting of the mountain 'zero level' (y where density gradient is zero).
It is easy to vertically shift smooth terrain by editing noise parameter 'offset',
but vertically shifting mountain terrain was complex and imprecise, involving
making a calculation based on an average of the mountain height parameter.
Diffstat (limited to 'src/mapgen_v7.cpp')
-rw-r--r-- | src/mapgen_v7.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp index cdf76993d..4b74825fd 100644 --- a/src/mapgen_v7.cpp +++ b/src/mapgen_v7.cpp @@ -56,6 +56,7 @@ MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge) : MapgenBasic(mapgenid, params, emerge) { spflags = params->spflags; + mount_zero_level = params->mount_zero_level; cave_width = params->cave_width; large_cave_depth = params->large_cave_depth; lava_depth = params->lava_depth; @@ -149,6 +150,7 @@ MapgenV7Params::MapgenV7Params() void MapgenV7Params::readParams(const Settings *settings) { settings->getFlagStrNoEx("mgv7_spflags", spflags, flagdesc_mapgen_v7); + settings->getS16NoEx("mgv7_mount_zero_level", mount_zero_level); settings->getFloatNoEx("mgv7_cave_width", cave_width); settings->getS16NoEx("mgv7_large_cave_depth", large_cave_depth); settings->getS16NoEx("mgv7_lava_depth", lava_depth); @@ -180,6 +182,7 @@ void MapgenV7Params::readParams(const Settings *settings) void MapgenV7Params::writeParams(Settings *settings) const { settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7, U32_MAX); + settings->setS16("mgv7_mount_zero_level", mount_zero_level); settings->setFloat("mgv7_cave_width", cave_width); settings->setS16("mgv7_large_cave_depth", large_cave_depth); settings->setS16("mgv7_lava_depth", lava_depth); @@ -397,7 +400,7 @@ bool MapgenV7::getMountainTerrainAtPoint(s16 x, s16 y, s16 z) { float mnt_h_n = MYMAX(NoisePerlin2D(&noise_mount_height->np, x, z, seed), 1.0f); - float density_gradient = -((float)y / mnt_h_n); + float density_gradient = -((float)(y - mount_zero_level) / mnt_h_n); float mnt_n = NoisePerlin3D(&noise_mountain->np, x, y, z, seed); return mnt_n + density_gradient >= 0.0; @@ -407,7 +410,7 @@ bool MapgenV7::getMountainTerrainAtPoint(s16 x, s16 y, s16 z) bool MapgenV7::getMountainTerrainFromMap(int idx_xyz, int idx_xz, s16 y) { float mounthn = MYMAX(noise_mount_height->result[idx_xz], 1.0f); - float density_gradient = -((float)y / mounthn); + float density_gradient = -((float)(y - mount_zero_level) / mounthn); float mountn = noise_mountain->result[idx_xyz]; return mountn + density_gradient >= 0.0; |