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
30 /////////////////// Mapgen flags
33 #define MG_DUNGEONS 0x04
34 #define MGV6_FORESTS 0x08
35 #define MGV6_BIOME_BLEND 0x10
37 #define AVERAGE_MUD_AMOUNT 4
39 class BiomeDefManager;
42 //struct BlockMakeData;
44 class ManualMapVoxelManipulator;
45 class VoxelManipulator;
46 class INodeDefManager;
48 extern NoiseParams nparams_v6_def_terrain_base;
49 extern NoiseParams nparams_v6_def_terrain_higher;
50 extern NoiseParams nparams_v6_def_steepness;
51 extern NoiseParams nparams_v6_def_height_select;
52 extern NoiseParams nparams_v6_def_trees;
53 extern NoiseParams nparams_v6_def_mud;
54 extern NoiseParams nparams_v6_def_beach;
55 extern NoiseParams nparams_v6_def_biome;
56 extern NoiseParams nparams_v6_def_cave;
58 extern NoiseParams nparams_v7_def_terrain;
59 extern NoiseParams nparams_v7_def_bgroup;
60 extern NoiseParams nparams_v7_def_heat;
61 extern NoiseParams nparams_v7_def_humidity;
70 struct BlockMakeData {
72 ManualMapVoxelManipulator *vmanip;
76 v3s16 blockpos_requested;
77 UniqueQueue<v3s16> transforming_liquid;
78 INodeDefManager *nodedef;
97 flags = MG_TREES | MG_CAVES | MGV6_BIOME_BLEND;
100 static MapgenParams *createMapgenParams(int mgver);
101 static MapgenParams *getParamsFromSettings(Settings *settings);
105 struct MapgenV6Params : public MapgenParams {
108 NoiseParams *np_terrain_base;
109 NoiseParams *np_terrain_higher;
110 NoiseParams *np_steepness;
111 NoiseParams *np_height_select;
112 NoiseParams *np_trees;
114 NoiseParams *np_beach;
115 NoiseParams *np_biome;
116 NoiseParams *np_cave;
121 np_terrain_base = &nparams_v6_def_terrain_base;
122 np_terrain_higher = &nparams_v6_def_terrain_higher;
123 np_steepness = &nparams_v6_def_steepness;
124 np_height_select = &nparams_v6_def_height_select;
125 np_trees = &nparams_v6_def_trees;
126 np_mud = &nparams_v6_def_mud;
127 np_beach = &nparams_v6_def_beach;
128 np_biome = &nparams_v6_def_biome;
129 np_cave = &nparams_v6_def_cave;
141 virtual void makeChunk(BlockMakeData *data) {};
142 virtual int getGroundLevelAtPoint(v2s16 p) = 0;
144 //Legacy functions for Farmesh (pending removal)
145 static bool get_have_beach(u64 seed, v2s16 p2d);
146 static double tree_amount_2d(u64 seed, v2s16 p);
147 static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
151 class MapgenV6 : public Mapgen {
153 //ManualMapVoxelManipulator &vmanip;
161 Noise *noise_terrain_base;
162 Noise *noise_terrain_higher;
163 Noise *noise_steepness;
164 Noise *noise_height_select;
170 float *map_terrain_base;
171 float *map_terrain_higher;
172 float *map_steepness;
173 float *map_height_select;
179 NoiseParams *np_cave;
185 MapgenV6(int mapgenid, MapgenV6Params *params);
188 void makeChunk(BlockMakeData *data);
189 int getGroundLevelAtPoint(v2s16 p);
191 double baseRockLevelFromNoise(v2s16 p);
192 static s16 find_ground_level(VoxelManipulator &vmanip, v2s16 p2d, INodeDefManager *ndef);
193 static s16 find_stone_level(VoxelManipulator &vmanip, v2s16 p2d, INodeDefManager *ndef);
194 void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0, bool is_apple_tree, INodeDefManager *ndef);
195 double tree_amount_2d(u64 seed, v2s16 p);
196 bool block_is_underground(u64 seed, v3s16 blockpos);
197 double base_rock_level_2d(u64 seed, v2s16 p);
198 s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
199 double get_mud_add_amount(u64 seed, v2s16 p);
200 bool get_have_beach(u64 seed, v2s16 p2d);
201 BiomeType get_biome(u64 seed, v2s16 p2d);
202 u32 get_blockseed(u64 seed, v3s16 p);
206 class EmergeManager {
209 MapgenParams *params;
211 //mapgen objects here
215 BiomeDefManager *biomedef;
217 EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef, MapgenParams *mgparams);
221 void addBlockToQueue();
223 //mapgen helper methods
224 Biome *getBiomeAtPoint(v3s16 p);
225 int getGroundLevelAtPoint(v2s16 p);
226 bool isBlockUnderground(v3s16 blockpos);
227 u32 getBlockSeed(v3s16 p);