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 VoxelManipulator;
36 class INodeDefManager;
46 struct BlockMakeData {
48 ManualMapVoxelManipulator *vmanip;
52 v3s16 blockpos_requested;
53 UniqueQueue<v3s16> transforming_liquid;
54 INodeDefManager *nodedef;
71 //virtual Mapgen(BiomeDefManager *biomedef, int mapgenid=0, u64 seed=0);
73 virtual void makeChunk(BlockMakeData *data) {};
75 //Legacy functions for Farmesh (pending removal)
76 static bool get_have_beach(u64 seed, v2s16 p2d);
77 static double tree_amount_2d(u64 seed, v2s16 p);
78 static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
82 class MapgenV6 : public Mapgen {
84 //ManualMapVoxelManipulator &vmanip;
92 Noise *noise_terrain_base;
93 Noise *noise_terrain_higher;
94 Noise *noise_steepness;
95 Noise *noise_height_select;
102 float *map_terrain_base;
103 float *map_terrain_higher;
104 float *map_steepness;
105 float *map_height_select;
112 bool use_smooth_biome_trans;
114 MapgenV6(int mapgenid=0, u64 seed=0);
117 void makeChunk(BlockMakeData *data);
120 static s16 find_ground_level(VoxelManipulator &vmanip, v2s16 p2d, INodeDefManager *ndef);
121 static s16 find_stone_level(VoxelManipulator &vmanip, v2s16 p2d, INodeDefManager *ndef);
122 void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0, bool is_apple_tree, INodeDefManager *ndef);
123 double tree_amount_2d(u64 seed, v2s16 p);
124 bool block_is_underground(u64 seed, v3s16 blockpos);
125 double base_rock_level_2d(u64 seed, v2s16 p);
126 s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
127 double get_mud_add_amount(u64 seed, v2s16 p);
128 bool get_have_beach(u64 seed, v2s16 p2d);
129 BiomeType get_biome(u64 seed, v2s16 p2d);
130 u32 get_blockseed(u64 seed, v3s16 p);
134 class MapgenV7 : public Mapgen {
137 ManualMapVoxelManipulator *vmanip;
138 INodeDefManager *ndef;
139 BiomeDefManager *biomedef;
148 Noise *noise_terrain;
151 Noise *noise_humidity;
164 NoiseParams *np_terrain;
165 NoiseParams *np_bgroup;
166 NoiseParams *np_heat;
167 NoiseParams *np_humidity;
169 //should these be broken off into a "commonly used nodes" class?
174 MapgenV7(BiomeDefManager *biomedef, int mapgenid=0, u64 seed=0);
175 MapgenV7(BiomeDefManager *biomedef, int mapgenid, u64 seed,
176 NoiseParams *np_terrain, NoiseParams *np_bgroup,
177 NoiseParams *np_heat, NoiseParams *np_humidity);
178 void init(BiomeDefManager *biomedef, int mapgenid, u64 seed,
179 NoiseParams *np_terrain, NoiseParams *np_bgroup,
180 NoiseParams *np_heat, NoiseParams *np_humidity);
183 void makeChunk(BlockMakeData *data);
184 void updateLiquid(v3s16 node_min, v3s16 node_max);
185 void updateLighting(v3s16 node_min, v3s16 node_max);
187 //Legacy functions for Farmesh (pending removal)
188 // static bool get_have_beach(u64 seed, v2s16 p2d);
189 // static double tree_amount_2d(u64 seed, v2s16 p);
190 // static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
193 class EmergeManager {
198 NoiseParams *np_terrain;
199 NoiseParams *np_bgroup;
200 NoiseParams *np_heat;
201 NoiseParams *np_humidity;
204 BiomeDefManager *biomedef;
206 //mapgen objects here
208 EmergeManager(IGameDef *gamedef);
210 void addBlockToQueue();
214 //mapgen helper methods
215 Biome *getBiomeAtPoint(v3s16 p);
216 int getGroundLevelAtPoint(v2s16 p);
217 bool isBlockUnderground(v3s16 blockpos);
218 u32 getBlockSeed(v3s16 p);
225 // Finds precise ground level at any position
226 s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
228 // Find out if block is completely underground
229 bool block_is_underground(u64 seed, v3s16 blockpos);
231 // Get a pseudorandom seed for a position on the map
232 u32 get_blockseed(u64 seed, v3s16 p);
234 // Main map generation routine
235 void make_block(BlockMakeData *data);
238 //These are used by FarMesh
239 bool get_have_beach(u64 seed, v2s16 p2d);
240 double tree_amount_2d(u64 seed, v2s16 p);
245 ManualMapVoxelManipulator *vmanip; // Destructor deletes
249 v3s16 blockpos_requested;
250 UniqueQueue<v3s16> transforming_liquid;
251 INodeDefManager *nodedef;
257 }; // namespace mapgen