Give the Mapgen on each EmergeThread its own Biome/Ore/Deco/SchemManager copy
[oweals/minetest.git] / src / mapgen / mapgen_carpathian.h
1 /*
2 Minetest
3 Copyright (C) 2017-2019 vlapsley, Vaughan Lapsley <vlapsley@gmail.com>
4 Copyright (C) 2017-2019 paramat
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #pragma once
22
23 #include "mapgen.h"
24
25 #define MGCARPATHIAN_CAVERNS 0x01
26 #define MGCARPATHIAN_RIVERS  0x02
27
28 class BiomeManager;
29
30 extern FlagDesc flagdesc_mapgen_carpathian[];
31
32
33 struct MapgenCarpathianParams : public MapgenParams
34 {
35         float base_level       = 12.0f;
36         float river_width      = 0.05f;
37         float river_depth      = 24.0f;
38         float valley_width     = 0.25f;
39
40         float cave_width         = 0.09f;
41         s16 large_cave_depth     = -33;
42         u16 small_cave_num_min   = 0;
43         u16 small_cave_num_max   = 0;
44         u16 large_cave_num_min   = 0;
45         u16 large_cave_num_max   = 2;
46         float large_cave_flooded = 0.5f;
47         s16 cavern_limit         = -256;
48         s16 cavern_taper         = 256;
49         float cavern_threshold   = 0.7f;
50         s16 dungeon_ymin         = -31000;
51         s16 dungeon_ymax         = 31000;
52
53         NoiseParams np_filler_depth;
54         NoiseParams np_height1;
55         NoiseParams np_height2;
56         NoiseParams np_height3;
57         NoiseParams np_height4;
58         NoiseParams np_hills_terrain;
59         NoiseParams np_ridge_terrain;
60         NoiseParams np_step_terrain;
61         NoiseParams np_hills;
62         NoiseParams np_ridge_mnt;
63         NoiseParams np_step_mnt;
64         NoiseParams np_rivers;
65         NoiseParams np_mnt_var;
66         NoiseParams np_cave1;
67         NoiseParams np_cave2;
68         NoiseParams np_cavern;
69         NoiseParams np_dungeons;
70
71         MapgenCarpathianParams();
72         ~MapgenCarpathianParams() = default;
73
74         void readParams(const Settings *settings);
75         void writeParams(Settings *settings) const;
76         void setDefaultSettings(Settings *settings);
77 };
78
79 class MapgenCarpathian : public MapgenBasic
80 {
81 public:
82         MapgenCarpathian(MapgenCarpathianParams *params, EmergeParams *emerge);
83         ~MapgenCarpathian();
84
85         virtual MapgenType getType() const { return MAPGEN_CARPATHIAN; }
86
87         virtual void makeChunk(BlockMakeData *data);
88         int getSpawnLevelAtPoint(v2s16 p);
89
90 private:
91         float base_level;
92         float river_width;
93         float river_depth;
94         float valley_width;
95
96         Noise *noise_height1;
97         Noise *noise_height2;
98         Noise *noise_height3;
99         Noise *noise_height4;
100         Noise *noise_hills_terrain;
101         Noise *noise_ridge_terrain;
102         Noise *noise_step_terrain;
103         Noise *noise_hills;
104         Noise *noise_ridge_mnt;
105         Noise *noise_step_mnt;
106         Noise *noise_rivers = nullptr;
107         Noise *noise_mnt_var;
108
109         s32 grad_wl;
110
111         float getSteps(float noise);
112         inline float getLerp(float noise1, float noise2, float mod);
113         int generateTerrain();
114 };