[***Mapgen v7]
# Map generation attributes specific to Mapgen v7.
-# The 'ridges' flag controls the rivers.
+# The 'ridges' flag enables the rivers.
+# Floatlands are currently experimental and subject to change.
# Flags that are not specified in the flag string are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them.
-mgv7_spflags (Mapgen v7 flags) flags mountains,ridges mountains,ridges,nomountains,noridges
+mgv7_spflags (Mapgen v7 flags) flags mountains,ridges mountains,ridges,floatlands,nomountains,noridges,nofloatlands
# Controls width of tunnels, a smaller value creates wider tunnels.
mgv7_cave_width (Mapgen v7 cave width) float 0.2
+# Controls the density of floatland mountain terrain.
+# Is an offset added to the 'np_mountain' noise value.
+mgv7_float_mount_density (Mapgen v7 floatland mountain density) float 0.6
+
+# Typical maximum height, above and below midpoint, of floatland mountain terrain.
+mgv7_float_mount_height (Mapgen v7 floatland mountain height) float 128.0
+
+# Y-level of floatland midpoint and lake surface.
+mgv7_floatland_level (Mapgen v7 floatland level) int 1280
+
+# Y-level to which floatland shadows extend.
+mgv7_shadow_limit (Mapgen v7 shadow limit) int 1024
+
mgv7_np_terrain_base (Mapgen v7 terrain base noise parameters) noise_params 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0
mgv7_np_terrain_alt (Mapgen v7 terrain altitude noise parameters) noise_params 4, 25, (600, 600, 600), 5934, 5, 0.6, 2.0
mgv7_np_terrain_persist (Mapgen v7 terrain persistation noise parameters) noise_params 0.6, 0.1, (2000, 2000, 2000), 539, 3, 0.6, 2.0
mgv7_np_height_select (Mapgen v7 height select noise parameters) noise_params -8, 16, (500, 500, 500), 4213, 6, 0.7, 2.0
mgv7_np_filler_depth (Mapgen v7 filler depth noise parameters) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0
mgv7_np_mount_height (Mapgen v7 mount height noise parameters) noise_params 256, 112, (1000, 1000, 1000), 72449, 3, 0.6, 2.0
-mgv7_np_ridge_uwater (Mapgen v7 ridge water noise parameters) noise_params 0, 1, (1000, 1000, 1000), 85039, 5, 0.6, 2.0
+mgv7_np_ridge_uwater (Mapgen v7 river course noise parameters) noise_params 0, 1, (1000, 1000, 1000), 85039, 5, 0.6, 2.0
+mgv7_np_floatland_base (Mapgen v7 floatland base terrain noise parameters) noise_params -0.6, 1.5, (600, 600, 600), 114, 5, 0.6, 2.0
+mgv7_np_float_base_height (Mapgen v7 floatland base terrain height noise parameters) noise_params 48, 24, (300, 300, 300), 907, 4, 0.7, 2.0
mgv7_np_mountain (Mapgen v7 mountain noise parameters) noise_params -0.6, 1, (250, 350, 250), 5333, 5, 0.63, 2.0
-mgv7_np_ridge (Mapgen v7 ridge noise parameters) noise_params 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0
+mgv7_np_ridge (Mapgen v7 river channel wall noise parameters) noise_params 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0
mgv7_np_cave1 (Mapgen v7 cave1 noise parameters) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0
mgv7_np_cave2 (Mapgen v7 cave2 noise parameters) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0
FlagDesc flagdesc_mapgen_v7[] = {
- {"mountains", MGV7_MOUNTAINS},
- {"ridges", MGV7_RIDGES},
- {NULL, 0}
+ {"mountains", MGV7_MOUNTAINS},
+ {"ridges", MGV7_RIDGES},
+ {"floatlands", MGV7_FLOATLANDS},
+ {NULL, 0}
};
MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge)
: MapgenBasic(mapgenid, params, emerge)
{
- this->spflags = params->spflags;
- this->cave_width = params->cave_width;
+ this->spflags = params->spflags;
+ this->cave_width = params->cave_width;
+ this->float_mount_density = params->float_mount_density;
+ this->float_mount_height = params->float_mount_height;
+ this->floatland_level = params->floatland_level;
+ this->shadow_limit = params->shadow_limit;
//// Terrain noise
- noise_terrain_base = new Noise(¶ms->np_terrain_base, seed, csize.X, csize.Z);
- noise_terrain_alt = new Noise(¶ms->np_terrain_alt, seed, csize.X, csize.Z);
- noise_terrain_persist = new Noise(¶ms->np_terrain_persist, seed, csize.X, csize.Z);
- noise_height_select = new Noise(¶ms->np_height_select, seed, csize.X, csize.Z);
- noise_filler_depth = new Noise(¶ms->np_filler_depth, seed, csize.X, csize.Z);
- noise_mount_height = new Noise(¶ms->np_mount_height, seed, csize.X, csize.Z);
- noise_ridge_uwater = new Noise(¶ms->np_ridge_uwater, seed, csize.X, csize.Z);
+ noise_terrain_base = new Noise(¶ms->np_terrain_base, seed, csize.X, csize.Z);
+ noise_terrain_alt = new Noise(¶ms->np_terrain_alt, seed, csize.X, csize.Z);
+ noise_terrain_persist = new Noise(¶ms->np_terrain_persist, seed, csize.X, csize.Z);
+ noise_height_select = new Noise(¶ms->np_height_select, seed, csize.X, csize.Z);
+ noise_filler_depth = new Noise(¶ms->np_filler_depth, seed, csize.X, csize.Z);
+ noise_mount_height = new Noise(¶ms->np_mount_height, seed, csize.X, csize.Z);
+ noise_ridge_uwater = new Noise(¶ms->np_ridge_uwater, seed, csize.X, csize.Z);
+ noise_floatland_base = new Noise(¶ms->np_floatland_base, seed, csize.X, csize.Z);
+ noise_float_base_height = new Noise(¶ms->np_float_base_height, seed, csize.X, csize.Z);
//// 3d terrain noise
// 1-up 1-down overgeneration
delete noise_filler_depth;
delete noise_mount_height;
delete noise_ridge_uwater;
+ delete noise_floatland_base;
+ delete noise_float_base_height;
delete noise_mountain;
delete noise_ridge;
}
MapgenV7Params::MapgenV7Params()
{
- spflags = MGV7_MOUNTAINS | MGV7_RIDGES;
- cave_width = 0.2;
-
- np_terrain_base = NoiseParams(4, 70, v3f(600, 600, 600), 82341, 5, 0.6, 2.0);
- np_terrain_alt = NoiseParams(4, 25, v3f(600, 600, 600), 5934, 5, 0.6, 2.0);
- np_terrain_persist = NoiseParams(0.6, 0.1, v3f(2000, 2000, 2000), 539, 3, 0.6, 2.0);
- np_height_select = NoiseParams(-8, 16, v3f(500, 500, 500), 4213, 6, 0.7, 2.0);
- np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0);
- np_mount_height = NoiseParams(256, 112, v3f(1000, 1000, 1000), 72449, 3, 0.6, 2.0);
- np_ridge_uwater = NoiseParams(0, 1, v3f(1000, 1000, 1000), 85039, 5, 0.6, 2.0);
- np_mountain = NoiseParams(-0.6, 1, v3f(250, 350, 250), 5333, 5, 0.63, 2.0);
- np_ridge = NoiseParams(0, 1, v3f(100, 100, 100), 6467, 4, 0.75, 2.0);
- np_cave1 = NoiseParams(0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0);
- np_cave2 = NoiseParams(0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0);
+ spflags = MGV7_MOUNTAINS | MGV7_RIDGES;
+ cave_width = 0.2;
+ float_mount_density = 0.6;
+ float_mount_height = 128.0;
+ floatland_level = 1280;
+ shadow_limit = 1024;
+
+ np_terrain_base = NoiseParams(4, 70, v3f(600, 600, 600), 82341, 5, 0.6, 2.0);
+ np_terrain_alt = NoiseParams(4, 25, v3f(600, 600, 600), 5934, 5, 0.6, 2.0);
+ np_terrain_persist = NoiseParams(0.6, 0.1, v3f(2000, 2000, 2000), 539, 3, 0.6, 2.0);
+ np_height_select = NoiseParams(-8, 16, v3f(500, 500, 500), 4213, 6, 0.7, 2.0);
+ np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0);
+ np_mount_height = NoiseParams(256, 112, v3f(1000, 1000, 1000), 72449, 3, 0.6, 2.0);
+ np_ridge_uwater = NoiseParams(0, 1, v3f(1000, 1000, 1000), 85039, 5, 0.6, 2.0);
+ np_floatland_base = NoiseParams(-0.6, 1.5, v3f(600, 600, 600), 114, 5, 0.6, 2.0);
+ np_float_base_height = NoiseParams(48, 24, v3f(300, 300, 300), 907, 4, 0.7, 2.0);
+ np_mountain = NoiseParams(-0.6, 1, v3f(250, 350, 250), 5333, 5, 0.63, 2.0);
+ np_ridge = NoiseParams(0, 1, v3f(100, 100, 100), 6467, 4, 0.75, 2.0);
+ np_cave1 = NoiseParams(0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0);
+ np_cave2 = NoiseParams(0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0);
}
void MapgenV7Params::readParams(const Settings *settings)
{
- settings->getFlagStrNoEx("mgv7_spflags", spflags, flagdesc_mapgen_v7);
- settings->getFloatNoEx("mgv7_cave_width", cave_width);
-
- settings->getNoiseParams("mgv7_np_terrain_base", np_terrain_base);
- settings->getNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
- settings->getNoiseParams("mgv7_np_terrain_persist", np_terrain_persist);
- settings->getNoiseParams("mgv7_np_height_select", np_height_select);
- settings->getNoiseParams("mgv7_np_filler_depth", np_filler_depth);
- settings->getNoiseParams("mgv7_np_mount_height", np_mount_height);
- settings->getNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater);
- settings->getNoiseParams("mgv7_np_mountain", np_mountain);
- settings->getNoiseParams("mgv7_np_ridge", np_ridge);
- settings->getNoiseParams("mgv7_np_cave1", np_cave1);
- settings->getNoiseParams("mgv7_np_cave2", np_cave2);
+ settings->getFlagStrNoEx("mgv7_spflags", spflags, flagdesc_mapgen_v7);
+ settings->getFloatNoEx("mgv7_cave_width", cave_width);
+ settings->getFloatNoEx("mgv7_float_mount_density", float_mount_density);
+ settings->getFloatNoEx("mgv7_float_mount_height", float_mount_height);
+ settings->getS16NoEx("mgv7_floatland_level", floatland_level);
+ settings->getS16NoEx("mgv7_shadow_limit", shadow_limit);
+
+ settings->getNoiseParams("mgv7_np_terrain_base", np_terrain_base);
+ settings->getNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
+ settings->getNoiseParams("mgv7_np_terrain_persist", np_terrain_persist);
+ settings->getNoiseParams("mgv7_np_height_select", np_height_select);
+ settings->getNoiseParams("mgv7_np_filler_depth", np_filler_depth);
+ settings->getNoiseParams("mgv7_np_mount_height", np_mount_height);
+ settings->getNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater);
+ settings->getNoiseParams("mgv7_np_floatland_base", np_floatland_base);
+ settings->getNoiseParams("mgv7_np_float_base_height", np_float_base_height);
+ settings->getNoiseParams("mgv7_np_mountain", np_mountain);
+ settings->getNoiseParams("mgv7_np_ridge", np_ridge);
+ settings->getNoiseParams("mgv7_np_cave1", np_cave1);
+ settings->getNoiseParams("mgv7_np_cave2", np_cave2);
}
void MapgenV7Params::writeParams(Settings *settings) const
{
- settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7, U32_MAX);
- settings->setFloat("mgv7_cave_width", cave_width);
-
- settings->setNoiseParams("mgv7_np_terrain_base", np_terrain_base);
- settings->setNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
- settings->setNoiseParams("mgv7_np_terrain_persist", np_terrain_persist);
- settings->setNoiseParams("mgv7_np_height_select", np_height_select);
- settings->setNoiseParams("mgv7_np_filler_depth", np_filler_depth);
- settings->setNoiseParams("mgv7_np_mount_height", np_mount_height);
- settings->setNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater);
- settings->setNoiseParams("mgv7_np_mountain", np_mountain);
- settings->setNoiseParams("mgv7_np_ridge", np_ridge);
- settings->setNoiseParams("mgv7_np_cave1", np_cave1);
- settings->setNoiseParams("mgv7_np_cave2", np_cave2);
+ settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7, U32_MAX);
+ settings->setFloat("mgv7_cave_width", cave_width);
+ settings->setFloat("mgv7_float_mount_density", float_mount_density);
+ settings->setFloat("mgv7_float_mount_height", float_mount_height);
+ settings->setS16("mgv7_floatland_level", floatland_level);
+ settings->setS16("mgv7_shadow_limit", shadow_limit);
+
+ settings->setNoiseParams("mgv7_np_terrain_base", np_terrain_base);
+ settings->setNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
+ settings->setNoiseParams("mgv7_np_terrain_persist", np_terrain_persist);
+ settings->setNoiseParams("mgv7_np_height_select", np_height_select);
+ settings->setNoiseParams("mgv7_np_filler_depth", np_filler_depth);
+ settings->setNoiseParams("mgv7_np_mount_height", np_mount_height);
+ settings->setNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater);
+ settings->setNoiseParams("mgv7_np_floatland_base", np_floatland_base);
+ settings->setNoiseParams("mgv7_np_float_base_height", np_float_base_height);
+ settings->setNoiseParams("mgv7_np_mountain", np_mountain);
+ settings->setNoiseParams("mgv7_np_ridge", np_ridge);
+ settings->setNoiseParams("mgv7_np_cave1", np_cave1);
+ settings->setNoiseParams("mgv7_np_cave2", np_cave2);
}
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
+ // Limit floatland shadow
+ bool propagate_shadow = !((spflags & MGV7_FLOATLANDS) &&
+ node_min.Y <= shadow_limit && node_max.Y >= shadow_limit);
+
if (flags & MG_LIGHT)
calcLighting(node_min - v3s16(0, 1, 0), node_max + v3s16(0, 1, 0),
- full_node_min, full_node_max);
+ full_node_min, full_node_max, propagate_shadow);
//setLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
// node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE, 0xFF);
}
+bool MapgenV7::getFloatlandMountainFromMap(int idx_xyz, int idx_xz, s16 y)
+{
+ float density_gradient =
+ -pow(fabs((float)(y - floatland_level) / float_mount_height), 0.8f);
+ float floatn = noise_mountain->result[idx_xyz] + float_mount_density;
+
+ return floatn + density_gradient >= 0.0f;
+}
+
+
+void MapgenV7::floatBaseExtentFromMap(s16 *float_base_min, s16 *float_base_max, int idx_xz)
+{
+ // '+1' to avoid a layer of stone at y = MAX_MAP_GENERATION_LIMIT
+ s16 base_min = MAX_MAP_GENERATION_LIMIT + 1;
+ s16 base_max = MAX_MAP_GENERATION_LIMIT;
+
+ float n_base = noise_floatland_base->result[idx_xz];
+ if (n_base > 0.0f) {
+ float n_base_height =
+ MYMAX(noise_float_base_height->result[idx_xz], 0.0f);
+ float amp = n_base * n_base_height;
+ float ridge = n_base_height / 3.0f;
+ base_min = floatland_level - amp / 2.0f;
+
+ if (amp > ridge * 2.0f) {
+ // Lake bed
+ base_max = floatland_level - (amp - ridge * 2.0f) / 2.0f;
+ } else {
+ // Hills and ridges
+ float diff = fabs(amp - ridge) / ridge;
+ // Smooth ridges using the 'smoothstep function'
+ float smooth_diff = diff * diff * (3.0f - 2.0f * diff);
+ base_max = floatland_level + ridge - smooth_diff * ridge;
+ }
+ }
+
+ *float_base_min = base_min;
+ *float_base_max = base_max;
+}
+
+
int MapgenV7::generateTerrain()
{
MapNode n_air(CONTENT_AIR);
noise_terrain_alt->perlinMap2D(node_min.X, node_min.Z, persistmap);
noise_height_select->perlinMap2D(node_min.X, node_min.Z);
- if (spflags & MGV7_MOUNTAINS) {
+ if ((spflags & MGV7_MOUNTAINS) || (spflags & MGV7_FLOATLANDS)) {
noise_mountain->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);
+ }
+
+ if (spflags & MGV7_MOUNTAINS) {
noise_mount_height->perlinMap2D(node_min.X, node_min.Z);
}
+ if (spflags & MGV7_FLOATLANDS) {
+ noise_floatland_base->perlinMap2D(node_min.X, node_min.Z);
+ noise_float_base_height->perlinMap2D(node_min.X, node_min.Z);
+ }
+
//// Place nodes
v3s16 em = vm->m_area.getExtent();
s16 stone_surface_max_y = -MAX_MAP_GENERATION_LIMIT;
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
s16 surface_y = baseTerrainLevelFromMap(index2d);
-
if (surface_y > stone_surface_max_y)
stone_surface_max_y = surface_y;
+ // Get extent of floatland base terrain
+ // '+1' to avoid a layer of stone at y = MAX_MAP_GENERATION_LIMIT
+ s16 float_base_min = MAX_MAP_GENERATION_LIMIT + 1;
+ s16 float_base_max = MAX_MAP_GENERATION_LIMIT;
+ if (spflags & MGV7_FLOATLANDS)
+ floatBaseExtentFromMap(&float_base_min, &float_base_max, index2d);
+
u32 vi = vm->m_area.index(x, node_min.Y - 1, z);
u32 index3d = (z - node_min.Z) * zstride_1u1d + (x - node_min.X);
vm->m_data[vi] = n_stone; // Mountain terrain
if (y > stone_surface_max_y)
stone_surface_max_y = y;
+ } else if ((spflags & MGV7_FLOATLANDS) &&
+ ((y >= float_base_min && y <= float_base_max) ||
+ getFloatlandMountainFromMap(index3d, index2d, y))) {
+ vm->m_data[vi] = n_stone; // Floatland terrain
+ stone_surface_max_y = node_max.Y;
} else if (y <= water_level) {
- vm->m_data[vi] = n_water;
+ vm->m_data[vi] = n_water; // Ground level water
+ } else if ((spflags & MGV7_FLOATLANDS) &&
+ (y >= float_base_max && y <= floatland_level)) {
+ vm->m_data[vi] = n_water; // Floatland water
} else {
vm->m_data[vi] = n_air;
}
void MapgenV7::generateRidgeTerrain()
{
- if (node_max.Y < water_level - 16)
+ if ((node_max.Y < water_level - 16) || (node_max.Y > shadow_limit))
return;
noise_ridge->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);