3 Copyright (C) 2016-2018 Duane Robertson <duane@duanerobertson.com>
4 Copyright (C) 2016-2018 paramat
6 Based on Valleys Mapgen by Gael de Sailly
7 (https://forum.minetest.net/viewtopic.php?f=9&t=11430)
8 and mapgen_v7 by kwolekr and paramat.
10 Licensing changed by permission of Gael de Sailly.
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License along
23 with this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 ////////////// Mapgen Valleys flags
32 #define MGVALLEYS_ALT_CHILL 0x01
33 #define MGVALLEYS_HUMID_RIVERS 0x02
35 // Feed only one variable into these.
36 #define MYSQUARE(x) (x) * (x)
37 #define MYCUBE(x) (x) * (x) * (x)
40 class BiomeGenOriginal;
44 //extern Profiler *mapgen_profiler;
47 struct MapgenValleysParams : public MapgenParams {
48 u32 spflags = MGVALLEYS_HUMID_RIVERS | MGVALLEYS_ALT_CHILL;
49 s16 large_cave_depth = -33;
50 s16 massive_cave_depth = -256; // highest altitude of massive caves
51 u16 altitude_chill = 90; // The altitude at which temperature drops by 20C.
52 u16 lava_features = 0; // How often water will occur in caves.
53 u16 river_depth = 4; // How deep to carve river channels.
54 u16 river_size = 5; // How wide to make rivers.
55 u16 water_features = 0; // How often water will occur in caves.
56 float cave_width = 0.09f;
57 s16 dungeon_ymin = -31000;
58 s16 dungeon_ymax = 63; // No higher than surface mapchunks
62 NoiseParams np_filler_depth;
63 NoiseParams np_inter_valley_fill;
64 NoiseParams np_inter_valley_slope;
65 NoiseParams np_rivers;
66 NoiseParams np_massive_caves;
67 NoiseParams np_terrain_height;
68 NoiseParams np_valley_depth;
69 NoiseParams np_valley_profile;
71 MapgenValleysParams();
72 ~MapgenValleysParams() = default;
74 void readParams(const Settings *settings);
75 void writeParams(Settings *settings) const;
86 float inter_valley_fill;
89 class MapgenValleys : public MapgenBasic {
92 MapgenValleys(int mapgenid, MapgenValleysParams *params, EmergeManager *emerge);
95 virtual MapgenType getType() const { return MAPGEN_VALLEYS; }
97 virtual void makeChunk(BlockMakeData *data);
98 int getSpawnLevelAtPoint(v2s16 p);
100 s16 large_cave_depth;
103 BiomeGenOriginal *m_bgen;
105 float altitude_chill;
106 s16 massive_cave_depth;
111 bool use_altitude_chill;
112 float humidity_adjust;
113 s16 cave_water_max_height;
115 s16 lava_features_lim;
116 float river_depth_bed;
117 float river_size_factor;
119 s16 water_features_lim;
121 Noise *noise_inter_valley_fill;
122 Noise *noise_inter_valley_slope;
126 Noise *noise_massive_caves;
127 Noise *noise_terrain_height;
128 Noise *noise_valley_depth;
129 Noise *noise_valley_profile;
131 float terrainLevelAtPoint(s16 x, s16 z);
133 void calculateNoise();
135 virtual int generateTerrain();
136 float terrainLevelFromNoise(TerrainNoise *tn);
137 float adjustedTerrainLevelFromNoise(TerrainNoise *tn);
139 virtual void generateCaves(s16 max_stone_y, s16 large_cave_depth);