]> git.lizzy.rs Git - minetest.git/blob - src/mapgen/mapgen_fractal.h
e317f759d7347ba388f171ac43d081ffc8ffee31
[minetest.git] / src / mapgen / mapgen_fractal.h
1 /*
2 Minetest
3 Copyright (C) 2015-2019 paramat
4 Copyright (C) 2015-2016 kwolekr, Ryan Kwolek
5
6 Fractal formulas from http://www.bugman123.com/Hypercomplex/index.html
7 by Paul Nylander, and from http://www.fractalforums.com, thank you.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License along
20 with this program; if not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24 #pragma once
25
26 #include "mapgen.h"
27
28 ///////////// Mapgen Fractal flags
29 #define MGFRACTAL_TERRAIN     0x01
30
31 class BiomeManager;
32
33 extern FlagDesc flagdesc_mapgen_fractal[];
34
35
36 struct MapgenFractalParams : public MapgenParams
37 {
38         u32 spflags = MGFRACTAL_TERRAIN;
39         float cave_width = 0.09f;
40         s16 large_cave_depth = -33;
41         s16 lava_depth = -256;
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 dungeon_ymin = -31000;
48         s16 dungeon_ymax = 31000;
49         u16 fractal = 1;
50         u16 iterations = 11;
51         v3f scale = v3f(4096.0, 1024.0, 4096.0);
52         v3f offset = v3f(1.52, 0.0, 0.0);
53         float slice_w = 0.0f;
54         float julia_x = 0.267f;
55         float julia_y = 0.2f;
56         float julia_z = 0.133f;
57         float julia_w = 0.067f;
58
59         NoiseParams np_seabed;
60         NoiseParams np_filler_depth;
61         NoiseParams np_cave1;
62         NoiseParams np_cave2;
63         NoiseParams np_dungeons;
64
65         MapgenFractalParams();
66         ~MapgenFractalParams() = default;
67
68         void readParams(const Settings *settings);
69         void writeParams(Settings *settings) const;
70 };
71
72
73 class MapgenFractal : public MapgenBasic
74 {
75 public:
76         MapgenFractal(MapgenFractalParams *params, EmergeManager *emerge);
77         ~MapgenFractal();
78
79         virtual MapgenType getType() const { return MAPGEN_FRACTAL; }
80
81         virtual void makeChunk(BlockMakeData *data);
82         int getSpawnLevelAtPoint(v2s16 p);
83         bool getFractalAtPoint(s16 x, s16 y, s16 z);
84         s16 generateTerrain();
85
86 private:
87         u16 formula;
88         bool julia;
89
90         s16 large_cave_depth;
91         s16 dungeon_ymin;
92         s16 dungeon_ymax;
93         u16 fractal;
94         u16 iterations;
95         v3f scale;
96         v3f offset;
97         float slice_w;
98         float julia_x;
99         float julia_y;
100         float julia_z;
101         float julia_w;
102         Noise *noise_seabed = nullptr;
103 };