3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser 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.
23 #include "irrlichttypes_extrabloated.h"
24 #include "util/container.h" // UniqueQueue
29 class BiomeDefManager;
32 //struct BlockMakeData;
34 class ManualMapVoxelManipulator;
35 class INodeDefManager;
37 struct BlockMakeData {
39 ManualMapVoxelManipulator *vmanip;
43 v3s16 blockpos_requested;
44 UniqueQueue<v3s16> transforming_liquid;
45 INodeDefManager *nodedef;
54 ManualMapVoxelManipulator *vmanip;
55 INodeDefManager *ndef;
56 BiomeDefManager *biomedef;
68 Noise *noise_humidity;
81 NoiseParams *np_terrain;
82 NoiseParams *np_bgroup;
84 NoiseParams *np_humidity;
86 //should these be broken off into a "commonly used nodes" class?
91 Mapgen(BiomeDefManager *biomedef, int mapgenid=0, u64 seed=0);
92 Mapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
93 NoiseParams *np_terrain, NoiseParams *np_bgroup,
94 NoiseParams *np_heat, NoiseParams *np_humidity);
95 void initMapgen(BiomeDefManager *biomedef, int mapgenid, u64 seed,
96 NoiseParams *np_terrain, NoiseParams *np_bgroup,
97 NoiseParams *np_heat, NoiseParams *np_humidity);
100 void makeChunk(BlockMakeData *data);
101 void updateLiquid(v3s16 node_min, v3s16 node_max);
102 void updateLighting(v3s16 node_min, v3s16 node_max);
104 //Legacy functions for Farmesh (pending removal)
105 static bool get_have_beach(u64 seed, v2s16 p2d);
106 static double tree_amount_2d(u64 seed, v2s16 p);
107 static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
110 class EmergeManager {
115 NoiseParams *np_terrain;
116 NoiseParams *np_bgroup;
117 NoiseParams *np_heat;
118 NoiseParams *np_humidity;
121 BiomeDefManager *biomedef;
123 //mapgen objects here
125 EmergeManager(IGameDef *gamedef);
127 void addBlockToQueue();
131 //mapgen helper methods
132 Biome *getBiomeAtPoint(v3s16 p);
133 int getGroundLevelAtPoint(v2s16 p);
134 bool isBlockUnderground(v3s16 blockpos);
135 u32 getBlockSeed(v3s16 p);
142 // Finds precise ground level at any position
143 s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
145 // Find out if block is completely underground
146 bool block_is_underground(u64 seed, v3s16 blockpos);
148 // Get a pseudorandom seed for a position on the map
149 u32 get_blockseed(u64 seed, v3s16 p);
151 // Main map generation routine
152 void make_block(BlockMakeData *data);
155 //These are used by FarMesh
156 bool get_have_beach(u64 seed, v2s16 p2d);
157 double tree_amount_2d(u64 seed, v2s16 p);
162 ManualMapVoxelManipulator *vmanip; // Destructor deletes
166 v3s16 blockpos_requested;
167 UniqueQueue<v3s16> transforming_liquid;
168 INodeDefManager *nodedef;
174 }; // namespace mapgen