Skip to content
Permalink
Browse files

Mapgen: Make 3D noise tunnels' width settable

Correct parameter names mg_valleys to mgvalleys
Remove biome NoiseParams from MapgenValleysParams
Improve format of parameter code
  • Loading branch information
paramat authored and kwolekr committed Apr 29, 2016
1 parent 46fd114 commit 8b1f8e99cf860625ebd20531ab7f3e8316a66b51
Showing with 248 additions and 209 deletions.
  1. +32 −17 builtin/settingtypes.txt
  2. +38 −18 minetest.conf.example
  3. +19 −18 src/mapgen_flat.cpp
  4. +3 −4 src/mapgen_flat.h
  5. +50 −53 src/mapgen_fractal.cpp
  6. +2 −6 src/mapgen_fractal.h
  7. +10 −5 src/mapgen_v5.cpp
  8. +3 −1 src/mapgen_v5.h
  9. +10 −5 src/mapgen_v7.cpp
  10. +3 −1 src/mapgen_v7.h
  11. +61 −59 src/mapgen_valleys.cpp
  12. +17 −22 src/mapgen_valleys.h
@@ -886,6 +886,9 @@ mg_biome_np_humidity_blend (Mapgen biome humidity blend noise parameters) noise_

[***Mapgen v5]

# Controls width of tunnels, a smaller value creates wider tunnels.
mgv5_cave_width (Mapgen v5 cave width) float 0.125

mgv5_np_filler_depth (Mapgen v5 filler depth noise parameters) noise_params 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0
mgv5_np_factor (Mapgen v5 factor noise parameters) noise_params 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0
mgv5_np_height (Mapgen v5 height noise parameters) noise_params 0, 10, (250, 250, 250), 84174, 4, 0.5, 2.0
@@ -940,6 +943,9 @@ mgv6_np_apple_trees (Mapgen v6 apple trees noise parameters) noise_params 0, 1,
# Flags starting with 'no' are used to explicitly disable them.
mgv7_spflags (Mapgen v7 flags) flags mountains,ridges mountains,ridges,nomountains,noridges

# Controls width of tunnels, a smaller value creates wider tunnels.
mgv7_cave_width (Mapgen v7 cave width) float 0.3

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
@@ -968,6 +974,9 @@ mgflat_ground_level (Mapgen flat ground level) int 8
# Y of upper limit of large pseudorandom caves.
mgflat_large_cave_depth (Mapgen flat large cave depth) int -33

# Controls width of tunnels, a smaller value creates wider tunnels.
mgflat_cave_width (Mapgen flat cave width) float 0.3

# Terrain noise threshold for lakes.
# Controls proportion of world area covered by lakes.
# Adjust towards 0.0 for a larger proportion.
@@ -995,6 +1004,9 @@ mgflat_np_cave2 (Mapgen flat cave2 noise parameters) noise_params 0, 12, (128, 1

[***Mapgen fractal]

# Controls width of tunnels, a smaller value creates wider tunnels.
mgfractal_cave_width (Mapgen fractal cave width) float 0.3

# Choice of 18 fractals from 9 formulas.
# 1 = 4D "Roundy" mandelbrot set.
# 2 = 4D "Roundy" julia set.
@@ -1074,60 +1086,63 @@ mgfractal_np_cave2 (Mapgen fractal cave2 noise parameters) noise_params 0, 12, (
mg_valleys_spflags (Valleys C Flags) flags altitude_chill,humid_rivers altitude_chill,noaltitude_chill,humid_rivers,nohumid_rivers

# The altitude at which temperature drops by 20C
mg_valleys_altitude_chill (Altitude Chill) int 90
mgvalleys_altitude_chill (Altitude Chill) int 90

# Depth below which you'll find large caves.
mg_valleys_large_cave_depth (Large cave depth) int -33
mgvalleys_large_cave_depth (Large cave depth) int -33

# Creates unpredictable lava features in caves.
# These can make mining difficult. Zero disables them. (0-10)
mg_valleys_lava_features (Lava Features) int 0
mgvalleys_lava_features (Lava Features) int 0

# Depth below which you'll find massive caves.
mg_valleys_massive_cave_depth (Massive cave depth) int -256
mgvalleys_massive_cave_depth (Massive cave depth) int -256

# How deep to make rivers
mg_valleys_river_depth (River Depth) int 4
mgvalleys_river_depth (River Depth) int 4

# How wide to make rivers
mg_valleys_river_size (River Size) int 5
mgvalleys_river_size (River Size) int 5

# Creates unpredictable water features in caves.
# These can make mining difficult. Zero disables them. (0-10)
mg_valleys_water_features (Water Features) int 0
mgvalleys_water_features (Water Features) int 0

# Controls width of tunnels, a smaller value creates wider tunnels.
mgvalleys_cave_width (Cave width) float 0.3

# Noise parameters
[****Noises]

# Caves and tunnels form at the intersection of the two noises
mg_valleys_np_cave1 (Cave noise #1) noise_params 0, 12, (100, 100, 100), 52534, 4, 0.5, 2.0
mgvalleys_np_cave1 (Cave noise #1) noise_params 0, 12, (100, 100, 100), 52534, 4, 0.5, 2.0

# Caves and tunnels form at the intersection of the two noises
mg_valleys_np_cave2 (Cave noise #2) noise_params 0, 12, (100, 100, 100), 10325, 4, 0.5, 2.0
mgvalleys_np_cave2 (Cave noise #2) noise_params 0, 12, (100, 100, 100), 10325, 4, 0.5, 2.0

# The depth of dirt or other filler
mg_valleys_np_filler_depth (Filler Depth) noise_params 0, 1.2, (256, 256, 256), 1605, 3, 0.5, 2.0
mgvalleys_np_filler_depth (Filler Depth) noise_params 0, 1.2, (256, 256, 256), 1605, 3, 0.5, 2.0

# Massive caves form here.
mg_valleys_np_massive_caves (Massive cave noise) noise_params 0, 1, (768, 256, 768), 59033, 6, 0.63, 2.0
mgvalleys_np_massive_caves (Massive cave noise) noise_params 0, 1, (768, 256, 768), 59033, 6, 0.63, 2.0

# River noise -- rivers occur close to zero
mg_valleys_np_rivers (River Noise) noise_params 0, 1, (256, 256, 256), -6050, 5, 0.6, 2.0
mgvalleys_np_rivers (River Noise) noise_params 0, 1, (256, 256, 256), -6050, 5, 0.6, 2.0

# Base terrain height
mg_valleys_np_terrain_height (Terrain Height) noise_params -10, 50, (1024, 1024, 1024), 5202, 6, 0.4, 2.0
mgvalleys_np_terrain_height (Terrain Height) noise_params -10, 50, (1024, 1024, 1024), 5202, 6, 0.4, 2.0

# Raises terrain to make valleys around the rivers
mg_valleys_np_valley_depth (Valley Depth) noise_params 5, 4, (512, 512, 512), -1914, 1, 1.0, 2.0
mgvalleys_np_valley_depth (Valley Depth) noise_params 5, 4, (512, 512, 512), -1914, 1, 1.0, 2.0

# Slope and fill work together to modify the heights
mg_valleys_np_inter_valley_fill (Valley Fill) noise_params 0, 1, (256, 512, 256), 1993, 6, 0.8, 2.0
mgvalleys_np_inter_valley_fill (Valley Fill) noise_params 0, 1, (256, 512, 256), 1993, 6, 0.8, 2.0

# Amplifies the valleys
mg_valleys_np_valley_profile (Valley Profile) noise_params 0.6, 0.5, (512, 512, 512), 777, 1, 1.0, 2.0
mgvalleys_np_valley_profile (Valley Profile) noise_params 0.6, 0.5, (512, 512, 512), 777, 1, 1.0, 2.0

# Slope and fill work together to modify the heights
mg_valleys_np_inter_valley_slope (Valley Slope) noise_params 0.5, 0.5, (128, 128, 128), 746, 1, 1.0, 2.0
mgvalleys_np_inter_valley_slope (Valley Slope) noise_params 0.5, 0.5, (128, 128, 128), 746, 1, 1.0, 2.0

[*Security]

@@ -1098,6 +1098,10 @@

#### Mapgen v5

# Controls width of tunnels, a smaller value creates wider tunnels.
# type: float
# mgv5_cave_width = 0.125

# type: noise_params
# mgv5_np_filler_depth = 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0

@@ -1176,6 +1180,10 @@
# type: flags possible values: mountains, ridges, nomountains, noridges
# mgv7_spflags = mountains,ridges

# Controls width of tunnels, a smaller value creates wider tunnels.
# type: float
# mgv7_cave_width = 0.3

# type: noise_params
# mgv7_np_terrain_base = 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0

@@ -1228,6 +1236,10 @@
# type: int
# mgflat_large_cave_depth = -33

# Controls width of tunnels, a smaller value creates wider tunnels.
# type: float
# mgflat_cave_width = 0.3

# Terrain noise threshold for lakes.
# Controls proportion of world area covered by lakes.
# Adjust towards 0.0 for a larger proportion.
@@ -1265,6 +1277,10 @@

#### Mapgen fractal

# Controls width of tunnels, a smaller value creates wider tunnels.
# type: float
# mgfractal_cave_width = 0.3

# Choice of 18 fractals from 9 formulas.
# 1 = 4D "Roundy" mandelbrot set.
# 2 = 4D "Roundy" julia set.
@@ -1356,79 +1372,83 @@
# 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.
# type: flags possible values: altitude_chill, noaltitude_chill, humid_rivers, nohumid_rivers
# mg_valleys_spflags = altitude_chill,humid_rivers
# mgvalleys_spflags = altitude_chill,humid_rivers

# The altitude at which temperature drops by 20C
# type: int
# mg_valleys_altitude_chill = 90
# mgvalleys_altitude_chill = 90

# Depth below which you'll find large caves.
# type: int
# mg_valleys_large_cave_depth = -33
# mgvalleys_large_cave_depth = -33

# Creates unpredictable lava features in caves.
# These can make mining difficult. Zero disables them. (0-10)
# type: int
# mg_valleys_lava_features = 0
# mgvalleys_lava_features = 0

# Depth below which you'll find massive caves.
# type: int
# mg_valleys_massive_cave_depth = -256
# mgvalleys_massive_cave_depth = -256

# How deep to make rivers
# type: int
# mg_valleys_river_depth = 4
# mgvalleys_river_depth = 4

# How wide to make rivers
# type: int
# mg_valleys_river_size = 5
# mgvalleys_river_size = 5

# Creates unpredictable water features in caves.
# These can make mining difficult. Zero disables them. (0-10)
# type: int
# mg_valleys_water_features = 0
# mgvalleys_water_features = 0

# Controls width of tunnels, a smaller value creates wider tunnels.
# type: float
# mgvalleys_cave_width = 0.3

##### Noises

# Caves and tunnels form at the intersection of the two noises
# type: noise_params
# mg_valleys_np_cave1 = 0, 12, (100, 100, 100), 52534, 4, 0.5, 2.0
# mgvalleys_np_cave1 = 0, 12, (100, 100, 100), 52534, 4, 0.5, 2.0

# Caves and tunnels form at the intersection of the two noises
# type: noise_params
# mg_valleys_np_cave2 = 0, 12, (100, 100, 100), 10325, 4, 0.5, 2.0
# mgvalleys_np_cave2 = 0, 12, (100, 100, 100), 10325, 4, 0.5, 2.0

# The depth of dirt or other filler
# type: noise_params
# mg_valleys_np_filler_depth = 0, 1.2, (256, 256, 256), 1605, 3, 0.5, 2.0
# mgvalleys_np_filler_depth = 0, 1.2, (256, 256, 256), 1605, 3, 0.5, 2.0

# Massive caves form here.
# type: noise_params
# mg_valleys_np_massive_caves = 0, 1, (768, 256, 768), 59033, 6, 0.63, 2.0
# mgvalleys_np_massive_caves = 0, 1, (768, 256, 768), 59033, 6, 0.63, 2.0

# River noise -- rivers occur close to zero
# type: noise_params
# mg_valleys_np_rivers = 0, 1, (256, 256, 256), -6050, 5, 0.6, 2.0
# mgvalleys_np_rivers = 0, 1, (256, 256, 256), -6050, 5, 0.6, 2.0

# Base terrain height
# type: noise_params
# mg_valleys_np_terrain_height = -10, 50, (1024, 1024, 1024), 5202, 6, 0.4, 2.0
# mgvalleys_np_terrain_height = -10, 50, (1024, 1024, 1024), 5202, 6, 0.4, 2.0

# Raises terrain to make valleys around the rivers
# type: noise_params
# mg_valleys_np_valley_depth = 5, 4, (512, 512, 512), -1914, 1, 1.0, 2.0
# mgvalleys_np_valley_depth = 5, 4, (512, 512, 512), -1914, 1, 1.0, 2.0

# Slope and fill work together to modify the heights
# type: noise_params
# mg_valleys_np_inter_valley_fill = 0, 1, (256, 512, 256), 1993, 6, 0.8, 2.0
# mgvalleys_np_inter_valley_fill = 0, 1, (256, 512, 256), 1993, 6, 0.8, 2.0

# Amplifies the valleys
# type: noise_params
# mg_valleys_np_valley_profile = 0.6, 0.5, (512, 512, 512), 777, 1, 1.0, 2.0
# mgvalleys_np_valley_profile = 0.6, 0.5, (512, 512, 512), 777, 1, 1.0, 2.0

# Slope and fill work together to modify the heights
# type: noise_params
# mg_valleys_np_inter_valley_slope = 0.5, 0.5, (128, 128, 128), 746, 1, 1.0, 2.0
# mgvalleys_np_inter_valley_slope = 0.5, 0.5, (128, 128, 128), 746, 1, 1.0, 2.0

## Security

@@ -67,14 +67,15 @@ MapgenFlat::MapgenFlat(int mapgenid, MapgenParams *params, EmergeManager *emerge
this->humidmap = NULL;

MapgenFlatParams *sp = (MapgenFlatParams *)params->sparams;
this->spflags = sp->spflags;

this->ground_level = sp->ground_level;
this->spflags = sp->spflags;
this->ground_level = sp->ground_level;
this->large_cave_depth = sp->large_cave_depth;
this->lake_threshold = sp->lake_threshold;
this->lake_steepness = sp->lake_steepness;
this->hill_threshold = sp->hill_threshold;
this->hill_steepness = sp->hill_steepness;
this->cave_width = sp->cave_width;
this->lake_threshold = sp->lake_threshold;
this->lake_steepness = sp->lake_steepness;
this->hill_threshold = sp->hill_threshold;
this->hill_steepness = sp->hill_steepness;

//// 2D noise
noise_terrain = new Noise(&sp->np_terrain, seed, csize.X, csize.Z);
@@ -139,14 +140,14 @@ MapgenFlat::~MapgenFlat()

MapgenFlatParams::MapgenFlatParams()
{
spflags = 0;

ground_level = 8;
spflags = 0;
ground_level = 8;
large_cave_depth = -33;
lake_threshold = -0.45;
lake_steepness = 48.0;
hill_threshold = 0.45;
hill_steepness = 64.0;
cave_width = 0.3;
lake_threshold = -0.45;
lake_steepness = 48.0;
hill_threshold = 0.45;
hill_steepness = 64.0;

np_terrain = NoiseParams(0, 1, v3f(600, 600, 600), 7244, 5, 0.6, 2.0);
np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0);
@@ -157,10 +158,10 @@ MapgenFlatParams::MapgenFlatParams()

void MapgenFlatParams::readParams(const Settings *settings)
{
settings->getFlagStrNoEx("mgflat_spflags", spflags, flagdesc_mapgen_flat);

settings->getFlagStrNoEx("mgflat_spflags", spflags, flagdesc_mapgen_flat);
settings->getS16NoEx("mgflat_ground_level", ground_level);
settings->getS16NoEx("mgflat_large_cave_depth", large_cave_depth);
settings->getFloatNoEx("mgflat_cave_width", cave_width);
settings->getFloatNoEx("mgflat_lake_threshold", lake_threshold);
settings->getFloatNoEx("mgflat_lake_steepness", lake_steepness);
settings->getFloatNoEx("mgflat_hill_threshold", hill_threshold);
@@ -175,10 +176,10 @@ void MapgenFlatParams::readParams(const Settings *settings)

void MapgenFlatParams::writeParams(Settings *settings) const
{
settings->setFlagStr("mgflat_spflags", spflags, flagdesc_mapgen_flat, U32_MAX);

settings->setFlagStr("mgflat_spflags", spflags, flagdesc_mapgen_flat, U32_MAX);
settings->setS16("mgflat_ground_level", ground_level);
settings->setS16("mgflat_large_cave_depth", large_cave_depth);
settings->setFloat("mgflat_cave_width", cave_width);
settings->setFloat("mgflat_lake_threshold", lake_threshold);
settings->setFloat("mgflat_lake_steepness", lake_steepness);
settings->setFloat("mgflat_hill_threshold", hill_threshold);
@@ -592,7 +593,7 @@ void MapgenFlat::generateCaves(s16 max_stone_y)
float d1 = contour(noise_cave1->result[index3d]);
float d2 = contour(noise_cave2->result[index3d]);

if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
if (d1 * d2 > cave_width && ndef->get(c).is_ground_content) {
// In tunnel and ground content, excavate
vm->m_data[vi] = MapNode(CONTENT_AIR);
is_tunnel = true;
@@ -34,14 +34,13 @@ extern FlagDesc flagdesc_mapgen_flat[];

struct MapgenFlatParams : public MapgenSpecificParams {
u32 spflags;

s16 ground_level;
s16 large_cave_depth;
float cave_width;
float lake_threshold;
float lake_steepness;
float hill_threshold;
float hill_steepness;

NoiseParams np_terrain;
NoiseParams np_filler_depth;
NoiseParams np_cave1;
@@ -61,20 +60,20 @@ class MapgenFlat : public Mapgen {

int ystride;
int zstride_1d;
u32 spflags;

v3s16 node_min;
v3s16 node_max;
v3s16 full_node_min;
v3s16 full_node_max;

u32 spflags;
s16 ground_level;
s16 large_cave_depth;
float cave_width;
float lake_threshold;
float lake_steepness;
float hill_threshold;
float hill_steepness;

Noise *noise_terrain;
Noise *noise_filler_depth;
Noise *noise_cave1;

0 comments on commit 8b1f8e9

Please sign in to comment.
You can’t perform that action at this time.