Mgfractal: Move julia set selection into formula parameter
[oweals/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 class BiomeManager;
29
30 extern FlagDesc flagdesc_mapgen_fractal[];
31
32
33 struct MapgenFractalParams : public MapgenSpecificParams {
34         u32 spflags;
35
36         u16 formula;
37         u16 iterations;
38         v3f scale;
39         v3f offset;
40         float slice_w;
41
42         float julia_x;
43         float julia_y;
44         float julia_z;
45         float julia_w;
46
47         NoiseParams np_seabed;
48         NoiseParams np_filler_depth;
49         NoiseParams np_cave1;
50         NoiseParams np_cave2;
51
52         MapgenFractalParams();
53         ~MapgenFractalParams() {}
54
55         void readParams(const Settings *settings);
56         void writeParams(Settings *settings) const;
57 };
58
59 class MapgenFractal : public Mapgen {
60 public:
61         EmergeManager *m_emerge;
62         BiomeManager *bmgr;
63
64         int ystride;
65         int zstride;
66         u32 spflags;
67
68         v3s16 node_min;
69         v3s16 node_max;
70         v3s16 full_node_min;
71         v3s16 full_node_max;
72
73         u16 formula;
74         u16 iterations;
75         v3f scale;
76         v3f offset;
77         float slice_w;
78
79         float julia_x;
80         float julia_y;
81         float julia_z;
82         float julia_w;
83
84         Noise *noise_seabed;
85         Noise *noise_filler_depth;
86         Noise *noise_cave1;
87         Noise *noise_cave2;
88
89         Noise *noise_heat;
90         Noise *noise_humidity;
91         Noise *noise_heat_blend;
92         Noise *noise_humidity_blend;
93
94         content_t c_stone;
95         content_t c_water_source;
96         content_t c_lava_source;
97         content_t c_desert_stone;
98         content_t c_ice;
99         content_t c_sandstone;
100
101         content_t c_cobble;
102         content_t c_stair_cobble;
103         content_t c_mossycobble;
104         content_t c_sandstonebrick;
105         content_t c_stair_sandstonebrick;
106
107         MapgenFractal(int mapgenid, MapgenParams *params, EmergeManager *emerge);
108         ~MapgenFractal();
109
110         virtual void makeChunk(BlockMakeData *data);
111         int getGroundLevelAtPoint(v2s16 p);
112         void calculateNoise();
113         bool getFractalAtPoint(s16 x, s16 y, s16 z);
114         s16 generateTerrain();
115         MgStoneType generateBiomes(float *heat_map, float *humidity_map);
116         void dustTopNodes();
117         void generateCaves(s16 max_stone_y);
118 };
119
120 struct MapgenFactoryFractal : public MapgenFactory {
121         Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge)
122         {
123                 return new MapgenFractal(mgid, params, emerge);
124         };
125
126         MapgenSpecificParams *createMapgenParams()
127         {
128                 return new MapgenFractalParams();
129         };
130 };
131
132 #endif