[*Mapgen V7]
# Map generation attributes specific to Mapgen v7.
-# 'ridges' enables the rivers.
+# 'ridges': Rivers.
+# 'floatlands': Floating land masses in the atmosphere.
+# 'caverns': Giant caves deep underground.
mgv7_spflags (Mapgen V7 specific flags) flags mountains,ridges,nofloatlands,caverns mountains,ridges,floatlands,caverns,nomountains,noridges,nofloatlands,nocaverns
# Y of mountain density gradient zero level. Used to shift mountains vertically.
mgv7_mount_zero_level (Mountain zero level) int 0
+# Lower Y limit of floatlands.
+mgv7_floatland_ymin (Floatland minimum Y) int 1024
+
+# Upper Y limit of floatlands.
+mgv7_floatland_ymax (Floatland maximum Y) int 4096
+
+# Y-distance over which floatlands taper from full density to nothing.
+# Tapering starts at this distance from the Y limit.
+# For a solid floatland layer, this controls the height of hills/mountains.
+# Must be less than or equal to half the distance between the Y limits.
+mgv7_floatland_taper (Floatland tapering distance) int 256
+
+# Exponent of the floatland tapering. Alters the tapering behaviour.
+# Value = 1.0 creates a uniform, linear tapering.
+# Values > 1.0 create a smooth tapering suitable for the default separated
+# floatlands.
+# Values < 1.0 (for example 0.25) create a more defined surface level with
+# flatter lowlands, suitable for a solid floatland layer.
+mgv7_float_taper_exp (Floatland taper exponent) float 2.0
+
+# Adjusts the density of the floatland layer.
+# Increase value to increase density. Can be positive or negative.
+# Value = 0.0: 50% of volume is floatland.
+# Value = 2.0 (can be higher depending on 'mgv7_np_floatland', always test
+# to be sure) creates a solid floatland layer.
+mgv7_floatland_density (Floatland density) float -0.9
+
+# Surface level of optional water placed on a solid floatland layer.
+# Water is disabled by default and will only be placed if this value is set
+# to above 'mgv7_floatland_ymax' - 'mgv7_floatland_taper' (the start of the
+# upper tapering).
+# ***WARNING, POTENTIAL DANGER TO WORLDS AND SERVER PERFORMANCE***:
+# When enabling water placement the floatlands must be configured and tested
+# to be a solid layer by setting 'mgv7_floatland_density' to 2.0 (or other
+# required value depending on 'mgv7_np_floatland'), to avoid
+# server-intensive extreme water flow and to avoid vast flooding of the
+# world surface below.
+mgv7_floatland_ywater (Floatland water level) int -31000
+
# Controls width of tunnels, a smaller value creates wider tunnels.
# Value >= 10.0 completely disables generation of tunnels and avoids the
# intensive noise calculations.
# 3D noise defining structure of river canyon walls.
mgv7_np_ridge (Ridge noise) noise_params_3d 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0
+# 3D noise defining structure of floatlands.
+# If altered from the default, the noise 'scale' (0.7 by default) may need
+# to be adjusted, as floatland tapering functions best when this noise has
+# a value range of approximately -2.0 to 2.0.
+mgv7_np_floatland (Floatland noise) noise_params_3d 0, 0.7, (384, 96, 384), 1009, 4, 0.75, 1.618
+
# 3D noise defining giant caverns.
mgv7_np_cavern (Cavern noise) noise_params_3d 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0
/*
Minetest
-Copyright (C) 2013-2019 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
-Copyright (C) 2014-2019 paramat
+Copyright (C) 2014-2020 paramat
+Copyright (C) 2013-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
{
spflags = params->spflags;
mount_zero_level = params->mount_zero_level;
+ floatland_ymin = params->floatland_ymin;
+ floatland_ymax = params->floatland_ymax;
+ floatland_taper = params->floatland_taper;
+ float_taper_exp = params->float_taper_exp;
+ floatland_density = params->floatland_density;
+ floatland_ywater = params->floatland_ywater;
cave_width = params->cave_width;
large_cave_depth = params->large_cave_depth;
dungeon_ymin = params->dungeon_ymin;
dungeon_ymax = params->dungeon_ymax;
+ // Allocate floatland noise offset cache
+ this->float_offset_cache = new float[csize.Y + 2];
+
// 2D noise
noise_terrain_base =
new Noise(¶ms->np_terrain_base, seed, csize.X, csize.Z);
new Noise(¶ms->np_ridge, seed, csize.X, csize.Y + 2, csize.Z);
}
+ if (spflags & MGV7_FLOATLANDS) {
+ // 3D noise, 1 up, 1 down overgeneration
+ noise_floatland =
+ new Noise(¶ms->np_floatland, seed, csize.X, csize.Y + 2, csize.Z);
+ }
+
// 3D noise, 1 down overgeneration
MapgenBasic::np_cave1 = params->np_cave1;
MapgenBasic::np_cave2 = params->np_cave2;
delete noise_ridge_uwater;
delete noise_ridge;
}
+
+ if (spflags & MGV7_FLOATLANDS) {
+ delete noise_floatland;
+ }
+
+ delete []float_offset_cache;
}
np_ridge_uwater (0.0, 1.0, v3f(1000, 1000, 1000), 85039, 5, 0.6, 2.0),
np_mountain (-0.6, 1.0, v3f(250, 350, 250), 5333, 5, 0.63, 2.0),
np_ridge (0.0, 1.0, v3f(100, 100, 100), 6467, 4, 0.75, 2.0),
+ np_floatland (0.0, 0.7, v3f(384, 96, 384), 1009, 4, 0.75, 1.618),
np_cavern (0.0, 1.0, v3f(384, 128, 384), 723, 5, 0.63, 2.0),
np_cave1 (0.0, 12.0, v3f(61, 61, 61), 52534, 3, 0.5, 2.0),
np_cave2 (0.0, 12.0, v3f(67, 67, 67), 10325, 3, 0.5, 2.0),
{
settings->getFlagStrNoEx("mgv7_spflags", spflags, flagdesc_mapgen_v7);
settings->getS16NoEx("mgv7_mount_zero_level", mount_zero_level);
+ settings->getS16NoEx("mgv7_floatland_ymin", floatland_ymin);
+ settings->getS16NoEx("mgv7_floatland_ymax", floatland_ymax);
+ settings->getS16NoEx("mgv7_floatland_taper", floatland_taper);
+ settings->getFloatNoEx("mgv7_float_taper_exp", float_taper_exp);
+ settings->getFloatNoEx("mgv7_floatland_density", floatland_density);
+ settings->getS16NoEx("mgv7_floatland_ywater", floatland_ywater);
+
settings->getFloatNoEx("mgv7_cave_width", cave_width);
settings->getS16NoEx("mgv7_large_cave_depth", large_cave_depth);
settings->getU16NoEx("mgv7_small_cave_num_min", small_cave_num_min);
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_floatland", np_floatland);
settings->getNoiseParams("mgv7_np_cavern", np_cavern);
settings->getNoiseParams("mgv7_np_cave1", np_cave1);
settings->getNoiseParams("mgv7_np_cave2", np_cave2);
{
settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7);
settings->setS16("mgv7_mount_zero_level", mount_zero_level);
+ settings->setS16("mgv7_floatland_ymin", floatland_ymin);
+ settings->setS16("mgv7_floatland_ymax", floatland_ymax);
+ settings->setS16("mgv7_floatland_taper", floatland_taper);
+ settings->setFloat("mgv7_float_taper_exp", float_taper_exp);
+ settings->setFloat("mgv7_floatland_density", floatland_density);
+ settings->setS16("mgv7_floatland_ywater", floatland_ywater);
+
settings->setFloat("mgv7_cave_width", cave_width);
settings->setS16("mgv7_large_cave_depth", large_cave_depth);
settings->setU16("mgv7_small_cave_num_min", small_cave_num_min);
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_floatland", np_floatland);
settings->setNoiseParams("mgv7_np_cavern", np_cavern);
settings->setNoiseParams("mgv7_np_cave1", np_cave1);
settings->setNoiseParams("mgv7_np_cave2", np_cave2);
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
// Calculate lighting
- // TODO disable in and just below floatlands
- bool propagate_shadow = true;
+ // Limit floatland shadows
+ bool propagate_shadow = !((spflags & MGV7_FLOATLANDS) &&
+ node_max.Y >= floatland_ymin - csize.Y * 2 && node_min.Y <= floatland_ymax);
if (flags & MG_LIGHT)
calcLighting(node_min - v3s16(0, 1, 0), node_max + v3s16(0, 1, 0),
}
+bool MapgenV7::getFloatlandTerrainFromMap(int idx_xyz, float float_offset)
+{
+ return noise_floatland->result[idx_xyz] + floatland_density - float_offset >= 0.0f;
+}
+
+
int MapgenV7::generateTerrain()
{
MapNode n_air(CONTENT_AIR);
noise_mountain->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);
}
+ //// Floatlands
+ // 'Generate floatlands in this mapchunk' bool for
+ // simplification of condition checks in y-loop.
+ bool gen_floatlands = false;
+ u8 cache_index = 0;
+ // Y values where floatland tapering starts
+ s16 float_taper_ymax = floatland_ymax - floatland_taper;
+ s16 float_taper_ymin = floatland_ymin + floatland_taper;
+
+ if ((spflags & MGV7_FLOATLANDS) &&
+ node_max.Y >= floatland_ymin && node_min.Y <= floatland_ymax) {
+ gen_floatlands = true;
+ // Calculate noise for floatland generation
+ noise_floatland->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);
+
+ // Cache floatland noise offset values, for floatland tapering
+ for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++, cache_index++) {
+ float float_offset = 0.0f;
+ if (y > float_taper_ymax) {
+ float_offset = std::pow((y - float_taper_ymax) / (float)floatland_taper,
+ float_taper_exp) * 4.0f;
+ } else if (y < float_taper_ymin) {
+ float_offset = std::pow((float_taper_ymin - y) / (float)floatland_taper,
+ float_taper_exp) * 4.0f;
+ }
+ float_offset_cache[cache_index] = float_offset;
+ }
+ }
+
//// Place nodes
const v3s16 &em = vm->m_area.getExtent();
s16 stone_surface_max_y = -MAX_MAP_GENERATION_LIMIT;
if (surface_y > stone_surface_max_y)
stone_surface_max_y = surface_y;
+ cache_index = 0;
u32 vi = vm->m_area.index(x, node_min.Y - 1, z);
u32 index3d = (z - node_min.Z) * zstride_1u1d + (x - node_min.X);
for (s16 y = node_min.Y - 1; y <= node_max.Y + 1;
y++,
index3d += ystride,
- VoxelArea::add_y(em, vi, 1)) {
+ VoxelArea::add_y(em, vi, 1),
+ cache_index++) {
if (vm->m_data[vi].getContent() != CONTENT_IGNORE)
continue;
vm->m_data[vi] = n_stone; // Mountain terrain
if (y > stone_surface_max_y)
stone_surface_max_y = y;
- } else if (y <= water_level) {
+ } else if (gen_floatlands &&
+ getFloatlandTerrainFromMap(index3d,
+ float_offset_cache[cache_index])) {
+ vm->m_data[vi] = n_stone; // Floatland terrain
+ if (y > stone_surface_max_y)
+ stone_surface_max_y = y;
+ } else if (y <= water_level) { // Surface water
vm->m_data[vi] = n_water;
+ } else if (gen_floatlands && y >= float_taper_ymax && y <= floatland_ywater) {
+ vm->m_data[vi] = n_water; // Water for solid floatland layer only
} else {
- vm->m_data[vi] = n_air;
+ vm->m_data[vi] = n_air; // Air
}
}
}
void MapgenV7::generateRidgeTerrain()
{
- // TODO disable river canyons in floatlands
- if (node_max.Y < water_level - 16)
+ if (node_max.Y < water_level - 16 ||
+ (node_max.Y >= floatland_ymin && node_min.Y <= floatland_ymax))
return;
noise_ridge->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);