3 Copyright (C) 2010-2015 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
4 Copyright (C) 2010-2015 paramat, Matt Gregory
5 Copyright (C) 2016 Duane Robertson <duane@duanerobertson.com>
7 Based on Valleys Mapgen by Gael de Sailly
8 (https://forum.minetest.net/viewtopic.php?f=9&t=11430)
9 and mapgen_v7 by kwolekr and paramat.
11 Licensing changed by permission of Gael de Sailly.
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU Lesser General Public License as published by
15 the Free Software Foundation; either version 2.1 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU Lesser General Public License for more details.
23 You should have received a copy of the GNU Lesser General Public License along
24 with this program; if not, write to the Free Software Foundation, Inc.,
25 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #ifndef MAPGEN_VALLEYS_HEADER
29 #define MAPGEN_VALLEYS_HEADER
33 ////////////// Mapgen Valleys flags
34 #define MGVALLEYS_ALT_CHILL 0x01
35 #define MGVALLEYS_HUMID_RIVERS 0x02
37 // Feed only one variable into these.
38 #define MYSQUARE(x) (x) * (x)
39 #define MYCUBE(x) (x) * (x) * (x)
45 //extern Profiler *mapgen_profiler;
48 struct MapgenValleysParams : public MapgenSpecificParams {
52 s16 massive_cave_depth;
59 NoiseParams np_biome_heat;
60 NoiseParams np_biome_heat_blend;
61 NoiseParams np_biome_humidity;
62 NoiseParams np_biome_humidity_blend;
65 NoiseParams np_filler_depth;
66 NoiseParams np_inter_valley_fill;
67 NoiseParams np_inter_valley_slope;
68 NoiseParams np_rivers;
69 NoiseParams np_massive_caves;
70 NoiseParams np_terrain_height;
71 NoiseParams np_valley_depth;
72 NoiseParams np_valley_profile;
74 MapgenValleysParams();
75 ~MapgenValleysParams() {}
77 void readParams(const Settings *settings);
78 void writeParams(Settings *settings) const;
89 float inter_valley_fill;
92 class MapgenValleys : public Mapgen {
95 MapgenValleys(int mapgenid, MapgenParams *params, EmergeManager *emerge);
98 virtual void makeChunk(BlockMakeData *data);
99 int getSpawnLevelAtPoint(v2s16 p);
101 s16 large_cave_depth;
104 EmergeManager *m_emerge;
115 bool use_altitude_chill;
122 Noise *noise_filler_depth;
127 Noise *noise_heat_blend;
128 Noise *noise_humidity;
129 Noise *noise_humidity_blend;
130 Noise *noise_inter_valley_fill;
131 Noise *noise_inter_valley_slope;
133 Noise *noise_massive_caves;
134 Noise *noise_terrain_height;
135 Noise *noise_valley_depth;
136 Noise *noise_valley_profile;
138 float altitude_chill;
139 s16 cave_water_max_height;
140 float humidity_adjust;
141 s16 lava_features_lim;
143 s16 massive_cave_depth;
144 float river_depth_bed;
145 float river_size_factor;
147 s16 water_features_lim;
150 content_t c_desert_stone;
153 content_t c_lava_source;
154 content_t c_mossycobble;
155 content_t c_river_water_source;
157 content_t c_sandstone;
158 content_t c_sandstonebrick;
159 content_t c_stair_cobble;
160 content_t c_stair_sandstonebrick;
162 content_t c_water_source;
164 float terrainLevelAtPoint(s16 x, s16 z);
166 void calculateNoise();
168 virtual int generateTerrain();
169 float terrainLevelFromNoise(TerrainNoise *tn);
170 float adjustedTerrainLevelFromNoise(TerrainNoise *tn);
172 float humidityByTerrain(float humidity_base, float mount, float rivers, float valley);
174 MgStoneType generateBiomes(float *heat_map, float *humidity_map);
177 void generateCaves(s16 max_stone_y);
180 struct MapgenFactoryValleys : public MapgenFactory {
181 Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge)
183 return new MapgenValleys(mgid, params, emerge);
186 MapgenSpecificParams *createMapgenParams()
188 return new MapgenValleysParams();