1a29d90d938d724689fc1549a15560ffe0d0bfd5
[oweals/minetest.git] / src / mapgen.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MAPGEN_HEADER
21 #define MAPGEN_HEADER
22
23 #include "common_irrlicht.h"
24 #include "utility.h" // UniqueQueue
25
26 struct BlockMakeData;
27 class MapBlock;
28 class ManualMapVoxelManipulator;
29 class INodeDefManager;
30
31 namespace mapgen
32 {
33         // Finds precise ground level at any position
34         s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
35
36         // Find out if block is completely underground
37         bool block_is_underground(u64 seed, v3s16 blockpos);
38
39         // Get a pseudorandom seed for a position on the map
40         u32 get_blockseed(u64 seed, v3s16 p);
41
42         // Main map generation routine
43         void make_block(BlockMakeData *data);
44         
45         // Add a tree
46         void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
47                         bool is_apple_tree, INodeDefManager *ndef);
48         
49         /*
50                 These are used by FarMesh
51         */
52         bool get_have_beach(u64 seed, v2s16 p2d);
53         double tree_amount_2d(u64 seed, v2s16 p);
54
55         struct BlockMakeData
56         {
57                 bool no_op;
58                 ManualMapVoxelManipulator *vmanip; // Destructor deletes
59                 u64 seed;
60                 v3s16 blockpos_min;
61                 v3s16 blockpos_max;
62                 v3s16 blockpos_requested;
63                 UniqueQueue<v3s16> transforming_liquid;
64                 INodeDefManager *nodedef;
65
66                 BlockMakeData();
67                 ~BlockMakeData();
68         };
69
70 }; // namespace mapgen
71
72 #endif
73