]> git.lizzy.rs Git - minetest.git/blob - src/mapgen_fractal.h
1b6683f1f218c2684c6fad9f81985433fdc195f6
[minetest.git] / src / mapgen_fractal.h
1 /*
2 Minetest
3 Copyright (C) 2010-2015 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
4 Copyright (C) 2010-2015 paramat, Matt Gregory
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 #ifndef MAPGEN_FRACTAL_HEADER
22 #define MAPGEN_FRACTAL_HEADER
23
24 #include "mapgen.h"
25
26 #define MGFRACTAL_LARGE_CAVE_DEPTH -33
27
28 /////////////////// Mapgen Fractal flags
29 #define MGFRACTAL_JULIA 0x01
30
31 class BiomeManager;
32
33 extern FlagDesc flagdesc_mapgen_fractal[];
34
35
36 struct MapgenFractalParams : public MapgenSpecificParams {
37         u32 spflags;
38
39         u16 formula;
40
41         u16 m_iterations;
42         v3f m_scale;
43         v3f m_offset;
44         float m_slice_w;
45
46         u16 j_iterations;
47         v3f j_scale;
48         v3f j_offset;
49         float j_slice_w;
50         float julia_x;
51         float julia_y;
52         float julia_z;
53         float julia_w;
54
55         NoiseParams np_seabed;
56         NoiseParams np_filler_depth;
57         NoiseParams np_cave1;
58         NoiseParams np_cave2;
59
60         MapgenFractalParams();
61         ~MapgenFractalParams() {}
62
63         void readParams(const Settings *settings);
64         void writeParams(Settings *settings) const;
65 };
66
67 class MapgenFractal : public Mapgen {
68 public:
69         EmergeManager *m_emerge;
70         BiomeManager *bmgr;
71
72         int ystride;
73         int zstride;
74         u32 spflags;
75
76         v3s16 node_min;
77         v3s16 node_max;
78         v3s16 full_node_min;
79         v3s16 full_node_max;
80
81         u16 formula;
82
83         u16 m_iterations;
84         v3f m_scale;
85         v3f m_offset;
86         float m_slice_w;
87
88         u16 j_iterations;
89         v3f j_scale;
90         v3f j_offset;
91         float j_slice_w;
92         float julia_x;
93         float julia_y;
94         float julia_z;
95         float julia_w;
96
97         Noise *noise_seabed;
98         Noise *noise_filler_depth;
99         Noise *noise_cave1;
100         Noise *noise_cave2;
101
102         Noise *noise_heat;
103         Noise *noise_humidity;
104         Noise *noise_heat_blend;
105         Noise *noise_humidity_blend;
106
107         content_t c_stone;
108         content_t c_water_source;
109         content_t c_lava_source;
110         content_t c_desert_stone;
111         content_t c_ice;
112         content_t c_sandstone;
113
114         content_t c_cobble;
115         content_t c_stair_cobble;
116         content_t c_mossycobble;
117         content_t c_sandstonebrick;
118         content_t c_stair_sandstonebrick;
119
120         MapgenFractal(int mapgenid, MapgenParams *params, EmergeManager *emerge);
121         ~MapgenFractal();
122
123         virtual void makeChunk(BlockMakeData *data);
124         int getGroundLevelAtPoint(v2s16 p);
125         void calculateNoise();
126         bool getFractalAtPoint(s16 x, s16 y, s16 z);
127         s16 generateTerrain();
128         MgStoneType generateBiomes(float *heat_map, float *humidity_map);
129         void dustTopNodes();
130         void generateCaves(s16 max_stone_y);
131 };
132
133 struct MapgenFactoryFractal : public MapgenFactory {
134         Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge)
135         {
136                 return new MapgenFractal(mgid, params, emerge);
137         };
138
139         MapgenSpecificParams *createMapgenParams()
140         {
141                 return new MapgenFractalParams();
142         };
143 };
144
145 #endif