]> git.lizzy.rs Git - minetest.git/blob - src/mapgen_valleys.h
Isolate irrlicht references and use a singleton (#6041)
[minetest.git] / src / mapgen_valleys.h
1 /*
2 Minetest Valleys C
3 Copyright (C) 2016-2017 Duane Robertson <duane@duanerobertson.com>
4 Copyright (C) 2016-2017 paramat
5
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.
9
10 Licensing changed by permission of Gael de Sailly.
11
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.
16
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.
21
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.
25 */
26
27 #ifndef MAPGEN_VALLEYS_HEADER
28 #define MAPGEN_VALLEYS_HEADER
29
30 #include "mapgen.h"
31
32 ////////////// Mapgen Valleys flags
33 #define MGVALLEYS_ALT_CHILL    0x01
34 #define MGVALLEYS_HUMID_RIVERS 0x02
35
36 // Feed only one variable into these.
37 #define MYSQUARE(x) (x) * (x)
38 #define MYCUBE(x) (x) * (x) * (x)
39
40 class BiomeManager;
41 class BiomeGenOriginal;
42
43 // Global profiler
44 //class Profiler;
45 //extern Profiler *mapgen_profiler;
46
47
48 struct MapgenValleysParams : public MapgenParams {
49         u32 spflags = MGVALLEYS_HUMID_RIVERS | MGVALLEYS_ALT_CHILL;
50         s16 large_cave_depth = -33;
51         s16 massive_cave_depth = -256; // highest altitude of massive caves
52         u16 altitude_chill = 90; // The altitude at which temperature drops by 20C.
53         u16 lava_features = 0; // How often water will occur in caves.
54         u16 river_depth = 4; // How deep to carve river channels.
55         u16 river_size = 5; // How wide to make rivers.
56         u16 water_features = 0; // How often water will occur in caves.
57         float cave_width = 0.09f;
58         NoiseParams np_cave1;
59         NoiseParams np_cave2;
60         NoiseParams np_filler_depth;
61         NoiseParams np_inter_valley_fill;
62         NoiseParams np_inter_valley_slope;
63         NoiseParams np_rivers;
64         NoiseParams np_massive_caves;
65         NoiseParams np_terrain_height;
66         NoiseParams np_valley_depth;
67         NoiseParams np_valley_profile;
68
69         MapgenValleysParams();
70         ~MapgenValleysParams() {}
71
72         void readParams(const Settings *settings);
73         void writeParams(Settings *settings) const;
74 };
75
76 struct TerrainNoise {
77         s16 x;
78         s16 z;
79         float terrain_height;
80         float *rivers;
81         float *valley;
82         float valley_profile;
83         float *slope;
84         float inter_valley_fill;
85 };
86
87 class MapgenValleys : public MapgenBasic {
88 public:
89
90         MapgenValleys(int mapgenid, MapgenValleysParams *params, EmergeManager *emerge);
91         ~MapgenValleys();
92
93         virtual MapgenType getType() const { return MAPGEN_VALLEYS; }
94
95         virtual void makeChunk(BlockMakeData *data);
96         int getSpawnLevelAtPoint(v2s16 p);
97
98         s16 large_cave_depth;
99
100 private:
101         BiomeGenOriginal *m_bgen;
102
103         bool humid_rivers;
104         bool use_altitude_chill;
105         float humidity_adjust;
106         s16 cave_water_max_height;
107         s16 lava_max_height;
108
109         float altitude_chill;
110         s16 lava_features_lim;
111         s16 massive_cave_depth;
112         float river_depth_bed;
113         float river_size_factor;
114         float *tcave_cache;
115         s16 water_features_lim;
116         Noise *noise_inter_valley_fill;
117         Noise *noise_inter_valley_slope;
118         Noise *noise_rivers;
119         Noise *noise_cave1;
120         Noise *noise_cave2;
121         Noise *noise_massive_caves;
122         Noise *noise_terrain_height;
123         Noise *noise_valley_depth;
124         Noise *noise_valley_profile;
125
126         float terrainLevelAtPoint(s16 x, s16 z);
127
128         void calculateNoise();
129
130         virtual int generateTerrain();
131         float terrainLevelFromNoise(TerrainNoise *tn);
132         float adjustedTerrainLevelFromNoise(TerrainNoise *tn);
133
134         virtual void generateCaves(s16 max_stone_y, s16 large_cave_depth);
135 };
136
137 #endif