3 Copyright (C) 2010-2015 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
4 Copyright (C) 2010-2015 paramat, Matt Gregory
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "content_sao.h"
30 #include "voxelalgorithms.h"
31 //#include "profiler.h" // For TimeTaker
32 #include "settings.h" // For g_settings
34 #include "dungeongen.h"
39 #include "mg_decoration.h"
40 #include "mapgen_v7.h"
43 FlagDesc flagdesc_mapgen_v7[] = {
44 {"mountains", MGV7_MOUNTAINS},
45 {"ridges", MGV7_RIDGES},
50 ///////////////////////////////////////////////////////////////////////////////
53 MapgenV7::MapgenV7(int mapgenid, MapgenParams *params, EmergeManager *emerge)
54 : MapgenBasic(mapgenid, params, emerge)
56 this->m_emerge = emerge;
57 this->bmgr = emerge->biomemgr;
59 //// amount of elements to skip for the next index
60 //// for noise/height/biome maps (not vmanip)
61 this->ystride = csize.X;
62 // 1-up 1-down overgeneration
63 this->zstride_1u1d = csize.X * (csize.Y + 2);
64 // 1-down overgeneration
65 this->zstride_1d = csize.X * (csize.Y + 1);
67 this->heightmap = new s16[csize.X * csize.Z];
68 this->ridge_heightmap = new s16[csize.X * csize.Z];
70 MapgenV7Params *sp = (MapgenV7Params *)params->sparams;
72 this->spflags = sp->spflags;
73 this->cave_width = sp->cave_width;
76 noise_terrain_base = new Noise(&sp->np_terrain_base, seed, csize.X, csize.Z);
77 noise_terrain_alt = new Noise(&sp->np_terrain_alt, seed, csize.X, csize.Z);
78 noise_terrain_persist = new Noise(&sp->np_terrain_persist, seed, csize.X, csize.Z);
79 noise_height_select = new Noise(&sp->np_height_select, seed, csize.X, csize.Z);
80 noise_filler_depth = new Noise(&sp->np_filler_depth, seed, csize.X, csize.Z);
81 noise_mount_height = new Noise(&sp->np_mount_height, seed, csize.X, csize.Z);
82 noise_ridge_uwater = new Noise(&sp->np_ridge_uwater, seed, csize.X, csize.Z);
85 // 1-up 1-down overgeneration
86 noise_mountain = new Noise(&sp->np_mountain, seed, csize.X, csize.Y + 2, csize.Z);
87 noise_ridge = new Noise(&sp->np_ridge, seed, csize.X, csize.Y + 2, csize.Z);
88 // 1-down overgeneraion
89 noise_cave1 = new Noise(&sp->np_cave1, seed, csize.X, csize.Y + 1, csize.Z);
90 noise_cave2 = new Noise(&sp->np_cave2, seed, csize.X, csize.Y + 1, csize.Z);
92 // TODO(hmmmm): should we have a way to disable biomemanager biomes?
93 //// Initialize biome generator
94 biomegen = emerge->biomemgr->createBiomeGen(
95 BIOMEGEN_ORIGINAL, params->bparams, csize);
96 biomemap = biomegen->biomemap;
98 //// Resolve nodes to be used
99 c_stone = ndef->getId("mapgen_stone");
100 c_water_source = ndef->getId("mapgen_water_source");
101 c_lava_source = ndef->getId("mapgen_lava_source");
102 c_desert_stone = ndef->getId("mapgen_desert_stone");
103 c_ice = ndef->getId("mapgen_ice");
104 c_sandstone = ndef->getId("mapgen_sandstone");
106 c_cobble = ndef->getId("mapgen_cobble");
107 c_stair_cobble = ndef->getId("mapgen_stair_cobble");
108 c_mossycobble = ndef->getId("mapgen_mossycobble");
109 c_sandstonebrick = ndef->getId("mapgen_sandstonebrick");
110 c_stair_sandstonebrick = ndef->getId("mapgen_stair_sandstonebrick");
112 if (c_ice == CONTENT_IGNORE)
114 if (c_mossycobble == CONTENT_IGNORE)
115 c_mossycobble = c_cobble;
116 if (c_stair_cobble == CONTENT_IGNORE)
117 c_stair_cobble = c_cobble;
118 if (c_sandstonebrick == CONTENT_IGNORE)
119 c_sandstonebrick = c_sandstone;
120 if (c_stair_sandstonebrick == CONTENT_IGNORE)
121 c_stair_sandstonebrick = c_sandstone;
125 MapgenV7::~MapgenV7()
127 delete noise_terrain_base;
128 delete noise_terrain_persist;
129 delete noise_height_select;
130 delete noise_terrain_alt;
131 delete noise_filler_depth;
132 delete noise_mount_height;
133 delete noise_ridge_uwater;
134 delete noise_mountain;
141 delete[] ridge_heightmap;
146 MapgenV7Params::MapgenV7Params()
148 spflags = MGV7_MOUNTAINS | MGV7_RIDGES;
151 np_terrain_base = NoiseParams(4, 70, v3f(600, 600, 600), 82341, 5, 0.6, 2.0);
152 np_terrain_alt = NoiseParams(4, 25, v3f(600, 600, 600), 5934, 5, 0.6, 2.0);
153 np_terrain_persist = NoiseParams(0.6, 0.1, v3f(2000, 2000, 2000), 539, 3, 0.6, 2.0);
154 np_height_select = NoiseParams(-8, 16, v3f(500, 500, 500), 4213, 6, 0.7, 2.0);
155 np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0);
156 np_mount_height = NoiseParams(256, 112, v3f(1000, 1000, 1000), 72449, 3, 0.6, 2.0);
157 np_ridge_uwater = NoiseParams(0, 1, v3f(1000, 1000, 1000), 85039, 5, 0.6, 2.0);
158 np_mountain = NoiseParams(-0.6, 1, v3f(250, 350, 250), 5333, 5, 0.63, 2.0);
159 np_ridge = NoiseParams(0, 1, v3f(100, 100, 100), 6467, 4, 0.75, 2.0);
160 np_cave1 = NoiseParams(0, 12, v3f(96, 96, 96), 52534, 4, 0.5, 2.0);
161 np_cave2 = NoiseParams(0, 12, v3f(96, 96, 96), 10325, 4, 0.5, 2.0);
165 void MapgenV7Params::readParams(const Settings *settings)
167 settings->getFlagStrNoEx("mgv7_spflags", spflags, flagdesc_mapgen_v7);
168 settings->getFloatNoEx("mgv7_cave_width", cave_width);
170 settings->getNoiseParams("mgv7_np_terrain_base", np_terrain_base);
171 settings->getNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
172 settings->getNoiseParams("mgv7_np_terrain_persist", np_terrain_persist);
173 settings->getNoiseParams("mgv7_np_height_select", np_height_select);
174 settings->getNoiseParams("mgv7_np_filler_depth", np_filler_depth);
175 settings->getNoiseParams("mgv7_np_mount_height", np_mount_height);
176 settings->getNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater);
177 settings->getNoiseParams("mgv7_np_mountain", np_mountain);
178 settings->getNoiseParams("mgv7_np_ridge", np_ridge);
179 settings->getNoiseParams("mgv7_np_cave1", np_cave1);
180 settings->getNoiseParams("mgv7_np_cave2", np_cave2);
184 void MapgenV7Params::writeParams(Settings *settings) const
186 settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7, U32_MAX);
187 settings->setFloat("mgv7_cave_width", cave_width);
189 settings->setNoiseParams("mgv7_np_terrain_base", np_terrain_base);
190 settings->setNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
191 settings->setNoiseParams("mgv7_np_terrain_persist", np_terrain_persist);
192 settings->setNoiseParams("mgv7_np_height_select", np_height_select);
193 settings->setNoiseParams("mgv7_np_filler_depth", np_filler_depth);
194 settings->setNoiseParams("mgv7_np_mount_height", np_mount_height);
195 settings->setNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater);
196 settings->setNoiseParams("mgv7_np_mountain", np_mountain);
197 settings->setNoiseParams("mgv7_np_ridge", np_ridge);
198 settings->setNoiseParams("mgv7_np_cave1", np_cave1);
199 settings->setNoiseParams("mgv7_np_cave2", np_cave2);
203 ///////////////////////////////////////////////////////////////////////////////
206 int MapgenV7::getSpawnLevelAtPoint(v2s16 p)
208 // Base terrain calculation
209 s16 y = baseTerrainLevelAtPoint(p.X, p.Y);
211 // Ridge/river terrain calculation
213 float uwatern = NoisePerlin2D(&noise_ridge_uwater->np, p.X, p.Y, seed) * 2;
214 // if inside a river this is an unsuitable spawn point
215 if (fabs(uwatern) <= width)
216 return MAX_MAP_GENERATION_LIMIT;
218 // Mountain terrain calculation
221 if (!getMountainTerrainAtPoint(p.X, y + 1, p.Y)) { // Air, y is ground level
222 if (y <= water_level || y > water_level + 16)
223 return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
230 // Unsuitable spawn point, no ground surface found
231 return MAX_MAP_GENERATION_LIMIT;
235 void MapgenV7::makeChunk(BlockMakeData *data)
238 assert(data->vmanip);
239 assert(data->nodedef);
240 assert(data->blockpos_requested.X >= data->blockpos_min.X &&
241 data->blockpos_requested.Y >= data->blockpos_min.Y &&
242 data->blockpos_requested.Z >= data->blockpos_min.Z);
243 assert(data->blockpos_requested.X <= data->blockpos_max.X &&
244 data->blockpos_requested.Y <= data->blockpos_max.Y &&
245 data->blockpos_requested.Z <= data->blockpos_max.Z);
247 this->generating = true;
248 this->vm = data->vmanip;
249 this->ndef = data->nodedef;
250 //TimeTaker t("makeChunk");
252 v3s16 blockpos_min = data->blockpos_min;
253 v3s16 blockpos_max = data->blockpos_max;
254 node_min = blockpos_min * MAP_BLOCKSIZE;
255 node_max = (blockpos_max + v3s16(1, 1, 1)) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
256 full_node_min = (blockpos_min - 1) * MAP_BLOCKSIZE;
257 full_node_max = (blockpos_max + 2) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
259 blockseed = getBlockSeed2(full_node_min, seed);
264 // Generate terrain and ridges with initial heightmaps
265 s16 stone_surface_max_y = generateTerrain();
267 if (spflags & MGV7_RIDGES)
268 generateRidgeTerrain();
270 // Update heightmap to include mountain terrain
271 updateHeightmap(node_min, node_max);
273 // Init biome generator, place biome-specific nodes, and build biomemap
274 biomegen->calcBiomeNoise(node_min);
275 biomegen->getBiomes(heightmap);
276 MgStoneType stone_type = generateBiomes();
278 if (flags & MG_CAVES)
279 generateCaves(stone_surface_max_y, water_level);
281 if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) {
284 dp.np_rarity = nparams_dungeon_rarity;
285 dp.np_density = nparams_dungeon_density;
286 dp.np_wetness = nparams_dungeon_wetness;
287 dp.c_water = c_water_source;
288 if (stone_type == MGSTONE_STONE) {
289 dp.c_cobble = c_cobble;
290 dp.c_moss = c_mossycobble;
291 dp.c_stair = c_stair_cobble;
293 dp.diagonal_dirs = false;
295 dp.holesize = v3s16(1, 2, 1);
296 dp.roomsize = v3s16(0, 0, 0);
297 dp.notifytype = GENNOTIFY_DUNGEON;
298 } else if (stone_type == MGSTONE_DESERT_STONE) {
299 dp.c_cobble = c_desert_stone;
300 dp.c_moss = c_desert_stone;
301 dp.c_stair = c_desert_stone;
303 dp.diagonal_dirs = true;
305 dp.holesize = v3s16(2, 3, 2);
306 dp.roomsize = v3s16(2, 5, 2);
307 dp.notifytype = GENNOTIFY_TEMPLE;
308 } else if (stone_type == MGSTONE_SANDSTONE) {
309 dp.c_cobble = c_sandstonebrick;
310 dp.c_moss = c_sandstonebrick;
311 dp.c_stair = c_sandstonebrick;
313 dp.diagonal_dirs = false;
315 dp.holesize = v3s16(2, 2, 2);
316 dp.roomsize = v3s16(2, 0, 2);
317 dp.notifytype = GENNOTIFY_DUNGEON;
320 DungeonGen dgen(this, &dp);
321 dgen.generate(blockseed, full_node_min, full_node_max);
324 // Generate the registered decorations
325 if (flags & MG_DECORATIONS)
326 m_emerge->decomgr->placeAllDecos(this, blockseed, node_min, node_max);
328 // Generate the registered ores
329 m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
331 // Sprinkle some dust on top after everything else was generated
334 //printf("makeChunk: %dms\n", t.stop());
336 updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
338 if (flags & MG_LIGHT)
339 calcLighting(node_min - v3s16(0, 1, 0), node_max + v3s16(0, 1, 0),
340 full_node_min, full_node_max);
342 //setLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
343 // node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE, 0xFF);
345 this->generating = false;
349 void MapgenV7::calculateNoise()
351 //TimeTaker t("calculateNoise", NULL, PRECISION_MICRO);
353 s16 y = node_min.Y - 1;
356 noise_terrain_persist->perlinMap2D(x, z);
357 float *persistmap = noise_terrain_persist->result;
359 noise_terrain_base->perlinMap2D(x, z, persistmap);
360 noise_terrain_alt->perlinMap2D(x, z, persistmap);
361 noise_height_select->perlinMap2D(x, z);
363 if (spflags & MGV7_MOUNTAINS) {
364 noise_mountain->perlinMap3D(x, y, z);
365 noise_mount_height->perlinMap2D(x, z);
368 if ((spflags & MGV7_RIDGES) && node_max.Y >= water_level) {
369 noise_ridge->perlinMap3D(x, y, z);
370 noise_ridge_uwater->perlinMap2D(x, z);
373 // Cave noises are calculated in generateCaves()
374 // only if solid terrain is present in mapchunk
376 //printf("calculateNoise: %dus\n", t.stop());
380 float MapgenV7::baseTerrainLevelAtPoint(s16 x, s16 z)
382 float hselect = NoisePerlin2D(&noise_height_select->np, x, z, seed);
383 hselect = rangelim(hselect, 0.0, 1.0);
385 float persist = NoisePerlin2D(&noise_terrain_persist->np, x, z, seed);
387 noise_terrain_base->np.persist = persist;
388 float height_base = NoisePerlin2D(&noise_terrain_base->np, x, z, seed);
390 noise_terrain_alt->np.persist = persist;
391 float height_alt = NoisePerlin2D(&noise_terrain_alt->np, x, z, seed);
393 if (height_alt > height_base)
396 return (height_base * hselect) + (height_alt * (1.0 - hselect));
400 float MapgenV7::baseTerrainLevelFromMap(int index)
402 float hselect = rangelim(noise_height_select->result[index], 0.0, 1.0);
403 float height_base = noise_terrain_base->result[index];
404 float height_alt = noise_terrain_alt->result[index];
406 if (height_alt > height_base)
409 return (height_base * hselect) + (height_alt * (1.0 - hselect));
413 bool MapgenV7::getMountainTerrainAtPoint(s16 x, s16 y, s16 z)
415 float mnt_h_n = NoisePerlin2D(&noise_mount_height->np, x, z, seed);
416 float density_gradient = -((float)y / mnt_h_n);
417 float mnt_n = NoisePerlin3D(&noise_mountain->np, x, y, z, seed);
419 return mnt_n + density_gradient >= 0.0;
423 bool MapgenV7::getMountainTerrainFromMap(int idx_xyz, int idx_xz, s16 y)
425 float mounthn = noise_mount_height->result[idx_xz];
426 float density_gradient = -((float)y / mounthn);
427 float mountn = noise_mountain->result[idx_xyz];
429 return mountn + density_gradient >= 0.0;
433 int MapgenV7::generateTerrain()
435 MapNode n_air(CONTENT_AIR);
436 MapNode n_stone(c_stone);
437 MapNode n_water(c_water_source);
439 v3s16 em = vm->m_area.getExtent();
440 s16 stone_surface_max_y = -MAX_MAP_GENERATION_LIMIT;
442 bool mountain_flag = spflags & MGV7_MOUNTAINS;
444 for (s16 z = node_min.Z; z <= node_max.Z; z++)
445 for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
446 s16 surface_y = baseTerrainLevelFromMap(index2d);
447 heightmap[index2d] = surface_y; // Create base terrain heightmap
448 ridge_heightmap[index2d] = surface_y;
450 if (surface_y > stone_surface_max_y)
451 stone_surface_max_y = surface_y;
453 u32 vi = vm->m_area.index(x, node_min.Y - 1, z);
454 u32 index3d = (z - node_min.Z) * zstride_1u1d + (x - node_min.X);
456 for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
457 if (vm->m_data[vi].getContent() == CONTENT_IGNORE) {
458 if (y <= surface_y) {
459 vm->m_data[vi] = n_stone; // Base terrain
460 } else if (mountain_flag &&
461 getMountainTerrainFromMap(index3d, index2d, y)) {
462 vm->m_data[vi] = n_stone; // Mountain terrain
463 if (y > stone_surface_max_y)
464 stone_surface_max_y = y;
465 } else if (y <= water_level) {
466 vm->m_data[vi] = n_water;
468 vm->m_data[vi] = n_air;
471 vm->m_area.add_y(em, vi, 1);
476 return stone_surface_max_y;
480 void MapgenV7::generateRidgeTerrain()
482 if (node_max.Y < water_level - 16)
485 MapNode n_water(c_water_source);
486 MapNode n_air(CONTENT_AIR);
490 for (s16 z = node_min.Z; z <= node_max.Z; z++)
491 for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
492 u32 vi = vm->m_area.index(node_min.X, y, z);
493 for (s16 x = node_min.X; x <= node_max.X; x++, index++, vi++) {
494 int j = (z - node_min.Z) * csize.X + (x - node_min.X);
496 if (heightmap[j] < water_level - 16) // Use base terrain heightmap
499 float uwatern = noise_ridge_uwater->result[j] * 2;
500 if (fabs(uwatern) > width)
503 float altitude = y - water_level;
504 float height_mod = (altitude + 17) / 2.5;
505 float width_mod = width - fabs(uwatern);
506 float nridge = noise_ridge->result[index] * MYMAX(altitude, 0) / 7.0;
508 if (nridge + width_mod * height_mod < 0.6)
511 if (y < ridge_heightmap[j])
512 ridge_heightmap[j] = y - 1;
514 vm->m_data[vi] = (y > water_level) ? n_air : n_water;
520 ////////////////////////////////////////////////////////////////////////////////
523 //// Much of the stuff here has potential to become useful again at some point
524 //// in the future, but we don't want it to get lost or forgotten in version
529 int MapgenV7::generateMountainTerrain(s16 ymax)
531 MapNode n_stone(c_stone);
534 for (s16 z = node_min.Z; z <= node_max.Z; z++)
535 for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
536 u32 vi = vm->m_area.index(node_min.X, y, z);
537 for (s16 x = node_min.X; x <= node_max.X; x++) {
538 int index = (z - node_min.Z) * csize.X + (x - node_min.X);
539 content_t c = vm->m_data[vi].getContent();
541 if (getMountainTerrainFromMap(j, index, y)
542 && (c == CONTENT_AIR || c == c_water_source)) {
543 vm->m_data[vi] = n_stone;
559 void MapgenV7::carveRivers() {
560 MapNode n_air(CONTENT_AIR), n_water_source(c_water_source);
561 MapNode n_stone(c_stone);
566 for (s16 z = node_min.Z; z <= node_max.Z; z++)
567 for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
568 float terrain_mod = noise_terrain_mod->result[index];
569 NoiseParams *np = noise_terrain_river->np;
570 np.persist = noise_terrain_persist->result[index];
571 float terrain_river = NoisePerlin2DNoTxfm(np, x, z, seed);
572 float height = terrain_river * (1 - abs(terrain_mod)) *
573 noise_terrain_river->np.scale;
574 height = log(height * height); //log(h^3) is pretty interesting for terrain
576 s16 y = heightmap[index];
577 if (height < 1.0 && y > river_depth &&
578 y - river_depth >= node_min.Y && y <= node_max.Y) {
580 for (s16 ry = y; ry != y - river_depth; ry--) {
581 u32 vi = vm->m_area.index(x, ry, z);
582 vm->m_data[vi] = n_air;
585 u32 vi = vm->m_area.index(x, y - river_depth, z);
586 vm->m_data[vi] = n_water_source;
594 void MapgenV7::addTopNodes()
596 v3s16 em = vm->m_area.getExtent();
600 for (s16 z = node_min.Z; z <= node_max.Z; z++)
601 for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
602 Biome *biome = bmgr->biomes[biomemap[index]];
604 //////////////////// First, add top nodes below the ridge
605 s16 y = ridge_heightmap[index];
607 // This cutoff is good enough, but not perfect.
608 // It will cut off potentially placed top nodes at chunk boundaries
611 if (y > node_max.Y) {
612 y = node_max.Y; // Let's see if we can still go downward anyway
613 u32 vi = vm->m_area.index(x, y, z);
614 content_t c = vm->m_data[vi].getContent();
615 if (ndef->get(c).walkable)
619 // N.B. It is necessary to search downward since ridge_heightmap[i]
620 // might not be the actual height, just the lowest part in the chunk
621 // where a ridge had been carved
622 u32 i = vm->m_area.index(x, y, z);
623 for (; y >= node_min.Y; y--) {
624 content_t c = vm->m_data[i].getContent();
625 if (ndef->get(c).walkable)
627 vm->m_area.add_y(em, i, -1);
630 if (y != node_min.Y - 1 && y >= water_level) {
631 ridge_heightmap[index] = y; //update ridgeheight
632 ntopnodes = biome->top_depth;
633 for (; y <= node_max.Y && ntopnodes; y++) {
635 vm->m_data[i] = MapNode(biome->c_top);
636 vm->m_area.add_y(em, i, 1);
638 // If dirt, grow grass on it.
639 if (y > water_level - 10 &&
640 vm->m_data[i].getContent() == CONTENT_AIR) {
641 vm->m_area.add_y(em, i, -1);
642 if (vm->m_data[i].getContent() == c_dirt)
643 vm->m_data[i] = MapNode(c_dirt_with_grass);
647 //////////////////// Now, add top nodes on top of the ridge
648 y = heightmap[index];
649 if (y > node_max.Y) {
650 y = node_max.Y; // Let's see if we can still go downward anyway
651 u32 vi = vm->m_area.index(x, y, z);
652 content_t c = vm->m_data[vi].getContent();
653 if (ndef->get(c).walkable)
657 i = vm->m_area.index(x, y, z);
658 for (; y >= node_min.Y; y--) {
659 content_t c = vm->m_data[i].getContent();
660 if (ndef->get(c).walkable)
662 vm->m_area.add_y(em, i, -1);
665 if (y != node_min.Y - 1) {
666 ntopnodes = biome->top_depth;
667 // Let's see if we've already added it...
668 if (y == ridge_heightmap[index] + ntopnodes - 1)
671 for (; y <= node_max.Y && ntopnodes; y++) {
673 vm->m_data[i] = MapNode(biome->c_top);
674 vm->m_area.add_y(em, i, 1);
676 // If dirt, grow grass on it.
677 if (y > water_level - 10 &&
678 vm->m_data[i].getContent() == CONTENT_AIR) {
679 vm->m_area.add_y(em, i, -1);
680 if (vm->m_data[i].getContent() == c_dirt)
681 vm->m_data[i] = MapNode(c_dirt_with_grass);