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);
65 this->heightmap = new s16[csize.X * csize.Z];
66 this->ridge_heightmap = new s16[csize.X * csize.Z];
68 MapgenV7Params *sp = (MapgenV7Params *)params->sparams;
70 this->spflags = sp->spflags;
71 this->cave_width = sp->cave_width;
74 noise_terrain_base = new Noise(&sp->np_terrain_base, seed, csize.X, csize.Z);
75 noise_terrain_alt = new Noise(&sp->np_terrain_alt, seed, csize.X, csize.Z);
76 noise_terrain_persist = new Noise(&sp->np_terrain_persist, seed, csize.X, csize.Z);
77 noise_height_select = new Noise(&sp->np_height_select, seed, csize.X, csize.Z);
78 noise_filler_depth = new Noise(&sp->np_filler_depth, seed, csize.X, csize.Z);
79 noise_mount_height = new Noise(&sp->np_mount_height, seed, csize.X, csize.Z);
80 noise_ridge_uwater = new Noise(&sp->np_ridge_uwater, seed, csize.X, csize.Z);
83 // 1-up 1-down overgeneration
84 noise_mountain = new Noise(&sp->np_mountain, seed, csize.X, csize.Y + 2, csize.Z);
85 noise_ridge = new Noise(&sp->np_ridge, seed, csize.X, csize.Y + 2, csize.Z);
87 MapgenBasic::np_cave1 = sp->np_cave1;
88 MapgenBasic::np_cave2 = sp->np_cave2;
90 // TODO(hmmmm): should we have a way to disable biomemanager biomes?
91 //// Initialize biome generator
92 biomegen = emerge->biomemgr->createBiomeGen(
93 BIOMEGEN_ORIGINAL, params->bparams, csize);
94 biomemap = biomegen->biomemap;
96 //// Resolve nodes to be used
97 c_stone = ndef->getId("mapgen_stone");
98 c_water_source = ndef->getId("mapgen_water_source");
99 c_lava_source = ndef->getId("mapgen_lava_source");
100 c_desert_stone = ndef->getId("mapgen_desert_stone");
101 c_ice = ndef->getId("mapgen_ice");
102 c_sandstone = ndef->getId("mapgen_sandstone");
104 c_cobble = ndef->getId("mapgen_cobble");
105 c_stair_cobble = ndef->getId("mapgen_stair_cobble");
106 c_mossycobble = ndef->getId("mapgen_mossycobble");
107 c_sandstonebrick = ndef->getId("mapgen_sandstonebrick");
108 c_stair_sandstonebrick = ndef->getId("mapgen_stair_sandstonebrick");
110 if (c_ice == CONTENT_IGNORE)
112 if (c_mossycobble == CONTENT_IGNORE)
113 c_mossycobble = c_cobble;
114 if (c_stair_cobble == CONTENT_IGNORE)
115 c_stair_cobble = c_cobble;
116 if (c_sandstonebrick == CONTENT_IGNORE)
117 c_sandstonebrick = c_sandstone;
118 if (c_stair_sandstonebrick == CONTENT_IGNORE)
119 c_stair_sandstonebrick = c_sandstone;
123 MapgenV7::~MapgenV7()
125 delete noise_terrain_base;
126 delete noise_terrain_persist;
127 delete noise_height_select;
128 delete noise_terrain_alt;
129 delete noise_filler_depth;
130 delete noise_mount_height;
131 delete noise_ridge_uwater;
132 delete noise_mountain;
137 delete[] ridge_heightmap;
142 MapgenV7Params::MapgenV7Params()
144 spflags = MGV7_MOUNTAINS | MGV7_RIDGES;
147 np_terrain_base = NoiseParams(4, 70, v3f(600, 600, 600), 82341, 5, 0.6, 2.0);
148 np_terrain_alt = NoiseParams(4, 25, v3f(600, 600, 600), 5934, 5, 0.6, 2.0);
149 np_terrain_persist = NoiseParams(0.6, 0.1, v3f(2000, 2000, 2000), 539, 3, 0.6, 2.0);
150 np_height_select = NoiseParams(-8, 16, v3f(500, 500, 500), 4213, 6, 0.7, 2.0);
151 np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0);
152 np_mount_height = NoiseParams(256, 112, v3f(1000, 1000, 1000), 72449, 3, 0.6, 2.0);
153 np_ridge_uwater = NoiseParams(0, 1, v3f(1000, 1000, 1000), 85039, 5, 0.6, 2.0);
154 np_mountain = NoiseParams(-0.6, 1, v3f(250, 350, 250), 5333, 5, 0.63, 2.0);
155 np_ridge = NoiseParams(0, 1, v3f(100, 100, 100), 6467, 4, 0.75, 2.0);
156 np_cave1 = NoiseParams(0, 12, v3f(96, 96, 96), 52534, 4, 0.5, 2.0);
157 np_cave2 = NoiseParams(0, 12, v3f(96, 96, 96), 10325, 4, 0.5, 2.0);
161 void MapgenV7Params::readParams(const Settings *settings)
163 settings->getFlagStrNoEx("mgv7_spflags", spflags, flagdesc_mapgen_v7);
164 settings->getFloatNoEx("mgv7_cave_width", cave_width);
166 settings->getNoiseParams("mgv7_np_terrain_base", np_terrain_base);
167 settings->getNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
168 settings->getNoiseParams("mgv7_np_terrain_persist", np_terrain_persist);
169 settings->getNoiseParams("mgv7_np_height_select", np_height_select);
170 settings->getNoiseParams("mgv7_np_filler_depth", np_filler_depth);
171 settings->getNoiseParams("mgv7_np_mount_height", np_mount_height);
172 settings->getNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater);
173 settings->getNoiseParams("mgv7_np_mountain", np_mountain);
174 settings->getNoiseParams("mgv7_np_ridge", np_ridge);
175 settings->getNoiseParams("mgv7_np_cave1", np_cave1);
176 settings->getNoiseParams("mgv7_np_cave2", np_cave2);
180 void MapgenV7Params::writeParams(Settings *settings) const
182 settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7, U32_MAX);
183 settings->setFloat("mgv7_cave_width", cave_width);
185 settings->setNoiseParams("mgv7_np_terrain_base", np_terrain_base);
186 settings->setNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
187 settings->setNoiseParams("mgv7_np_terrain_persist", np_terrain_persist);
188 settings->setNoiseParams("mgv7_np_height_select", np_height_select);
189 settings->setNoiseParams("mgv7_np_filler_depth", np_filler_depth);
190 settings->setNoiseParams("mgv7_np_mount_height", np_mount_height);
191 settings->setNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater);
192 settings->setNoiseParams("mgv7_np_mountain", np_mountain);
193 settings->setNoiseParams("mgv7_np_ridge", np_ridge);
194 settings->setNoiseParams("mgv7_np_cave1", np_cave1);
195 settings->setNoiseParams("mgv7_np_cave2", np_cave2);
199 ///////////////////////////////////////////////////////////////////////////////
202 int MapgenV7::getSpawnLevelAtPoint(v2s16 p)
204 // Base terrain calculation
205 s16 y = baseTerrainLevelAtPoint(p.X, p.Y);
207 // Ridge/river terrain calculation
209 float uwatern = NoisePerlin2D(&noise_ridge_uwater->np, p.X, p.Y, seed) * 2;
210 // if inside a river this is an unsuitable spawn point
211 if (fabs(uwatern) <= width)
212 return MAX_MAP_GENERATION_LIMIT;
214 // Mountain terrain calculation
217 if (!getMountainTerrainAtPoint(p.X, y + 1, p.Y)) { // Air, y is ground level
218 if (y <= water_level || y > water_level + 16)
219 return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
226 // Unsuitable spawn point, no ground surface found
227 return MAX_MAP_GENERATION_LIMIT;
231 void MapgenV7::makeChunk(BlockMakeData *data)
234 assert(data->vmanip);
235 assert(data->nodedef);
236 assert(data->blockpos_requested.X >= data->blockpos_min.X &&
237 data->blockpos_requested.Y >= data->blockpos_min.Y &&
238 data->blockpos_requested.Z >= data->blockpos_min.Z);
239 assert(data->blockpos_requested.X <= data->blockpos_max.X &&
240 data->blockpos_requested.Y <= data->blockpos_max.Y &&
241 data->blockpos_requested.Z <= data->blockpos_max.Z);
243 this->generating = true;
244 this->vm = data->vmanip;
245 this->ndef = data->nodedef;
246 //TimeTaker t("makeChunk");
248 v3s16 blockpos_min = data->blockpos_min;
249 v3s16 blockpos_max = data->blockpos_max;
250 node_min = blockpos_min * MAP_BLOCKSIZE;
251 node_max = (blockpos_max + v3s16(1, 1, 1)) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
252 full_node_min = (blockpos_min - 1) * MAP_BLOCKSIZE;
253 full_node_max = (blockpos_max + 2) * MAP_BLOCKSIZE - v3s16(1, 1, 1);
255 blockseed = getBlockSeed2(full_node_min, seed);
260 // Generate terrain and ridges with initial heightmaps
261 s16 stone_surface_max_y = generateTerrain();
263 if (spflags & MGV7_RIDGES)
264 generateRidgeTerrain();
266 // Update heightmap to include mountain terrain
267 updateHeightmap(node_min, node_max);
269 // Init biome generator, place biome-specific nodes, and build biomemap
270 biomegen->calcBiomeNoise(node_min);
271 biomegen->getBiomes(heightmap);
272 MgStoneType stone_type = generateBiomes();
274 if (flags & MG_CAVES)
275 generateCaves(stone_surface_max_y, water_level);
277 if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) {
280 dp.np_rarity = nparams_dungeon_rarity;
281 dp.np_density = nparams_dungeon_density;
282 dp.np_wetness = nparams_dungeon_wetness;
283 dp.c_water = c_water_source;
284 if (stone_type == MGSTONE_STONE) {
285 dp.c_cobble = c_cobble;
286 dp.c_moss = c_mossycobble;
287 dp.c_stair = c_stair_cobble;
289 dp.diagonal_dirs = false;
291 dp.holesize = v3s16(1, 2, 1);
292 dp.roomsize = v3s16(0, 0, 0);
293 dp.notifytype = GENNOTIFY_DUNGEON;
294 } else if (stone_type == MGSTONE_DESERT_STONE) {
295 dp.c_cobble = c_desert_stone;
296 dp.c_moss = c_desert_stone;
297 dp.c_stair = c_desert_stone;
299 dp.diagonal_dirs = true;
301 dp.holesize = v3s16(2, 3, 2);
302 dp.roomsize = v3s16(2, 5, 2);
303 dp.notifytype = GENNOTIFY_TEMPLE;
304 } else if (stone_type == MGSTONE_SANDSTONE) {
305 dp.c_cobble = c_sandstonebrick;
306 dp.c_moss = c_sandstonebrick;
307 dp.c_stair = c_sandstonebrick;
309 dp.diagonal_dirs = false;
311 dp.holesize = v3s16(2, 2, 2);
312 dp.roomsize = v3s16(2, 0, 2);
313 dp.notifytype = GENNOTIFY_DUNGEON;
316 DungeonGen dgen(this, &dp);
317 dgen.generate(blockseed, full_node_min, full_node_max);
320 // Generate the registered decorations
321 if (flags & MG_DECORATIONS)
322 m_emerge->decomgr->placeAllDecos(this, blockseed, node_min, node_max);
324 // Generate the registered ores
325 m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
327 // Sprinkle some dust on top after everything else was generated
330 //printf("makeChunk: %dms\n", t.stop());
332 updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
334 if (flags & MG_LIGHT)
335 calcLighting(node_min - v3s16(0, 1, 0), node_max + v3s16(0, 1, 0),
336 full_node_min, full_node_max);
338 //setLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
339 // node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE, 0xFF);
341 this->generating = false;
345 void MapgenV7::calculateNoise()
347 //TimeTaker t("calculateNoise", NULL, PRECISION_MICRO);
349 s16 y = node_min.Y - 1;
352 noise_terrain_persist->perlinMap2D(x, z);
353 float *persistmap = noise_terrain_persist->result;
355 noise_terrain_base->perlinMap2D(x, z, persistmap);
356 noise_terrain_alt->perlinMap2D(x, z, persistmap);
357 noise_height_select->perlinMap2D(x, z);
359 if (spflags & MGV7_MOUNTAINS) {
360 noise_mountain->perlinMap3D(x, y, z);
361 noise_mount_height->perlinMap2D(x, z);
364 if ((spflags & MGV7_RIDGES) && node_max.Y >= water_level) {
365 noise_ridge->perlinMap3D(x, y, z);
366 noise_ridge_uwater->perlinMap2D(x, z);
369 // Cave noises are calculated in generateCaves()
370 // only if solid terrain is present in mapchunk
372 //printf("calculateNoise: %dus\n", t.stop());
376 float MapgenV7::baseTerrainLevelAtPoint(s16 x, s16 z)
378 float hselect = NoisePerlin2D(&noise_height_select->np, x, z, seed);
379 hselect = rangelim(hselect, 0.0, 1.0);
381 float persist = NoisePerlin2D(&noise_terrain_persist->np, x, z, seed);
383 noise_terrain_base->np.persist = persist;
384 float height_base = NoisePerlin2D(&noise_terrain_base->np, x, z, seed);
386 noise_terrain_alt->np.persist = persist;
387 float height_alt = NoisePerlin2D(&noise_terrain_alt->np, x, z, seed);
389 if (height_alt > height_base)
392 return (height_base * hselect) + (height_alt * (1.0 - hselect));
396 float MapgenV7::baseTerrainLevelFromMap(int index)
398 float hselect = rangelim(noise_height_select->result[index], 0.0, 1.0);
399 float height_base = noise_terrain_base->result[index];
400 float height_alt = noise_terrain_alt->result[index];
402 if (height_alt > height_base)
405 return (height_base * hselect) + (height_alt * (1.0 - hselect));
409 bool MapgenV7::getMountainTerrainAtPoint(s16 x, s16 y, s16 z)
411 float mnt_h_n = NoisePerlin2D(&noise_mount_height->np, x, z, seed);
412 float density_gradient = -((float)y / mnt_h_n);
413 float mnt_n = NoisePerlin3D(&noise_mountain->np, x, y, z, seed);
415 return mnt_n + density_gradient >= 0.0;
419 bool MapgenV7::getMountainTerrainFromMap(int idx_xyz, int idx_xz, s16 y)
421 float mounthn = noise_mount_height->result[idx_xz];
422 float density_gradient = -((float)y / mounthn);
423 float mountn = noise_mountain->result[idx_xyz];
425 return mountn + density_gradient >= 0.0;
429 int MapgenV7::generateTerrain()
431 MapNode n_air(CONTENT_AIR);
432 MapNode n_stone(c_stone);
433 MapNode n_water(c_water_source);
435 v3s16 em = vm->m_area.getExtent();
436 s16 stone_surface_max_y = -MAX_MAP_GENERATION_LIMIT;
438 bool mountain_flag = spflags & MGV7_MOUNTAINS;
440 for (s16 z = node_min.Z; z <= node_max.Z; z++)
441 for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
442 s16 surface_y = baseTerrainLevelFromMap(index2d);
443 heightmap[index2d] = surface_y; // Create base terrain heightmap
444 ridge_heightmap[index2d] = surface_y;
446 if (surface_y > stone_surface_max_y)
447 stone_surface_max_y = surface_y;
449 u32 vi = vm->m_area.index(x, node_min.Y - 1, z);
450 u32 index3d = (z - node_min.Z) * zstride_1u1d + (x - node_min.X);
452 for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
453 if (vm->m_data[vi].getContent() == CONTENT_IGNORE) {
454 if (y <= surface_y) {
455 vm->m_data[vi] = n_stone; // Base terrain
456 } else if (mountain_flag &&
457 getMountainTerrainFromMap(index3d, index2d, y)) {
458 vm->m_data[vi] = n_stone; // Mountain terrain
459 if (y > stone_surface_max_y)
460 stone_surface_max_y = y;
461 } else if (y <= water_level) {
462 vm->m_data[vi] = n_water;
464 vm->m_data[vi] = n_air;
467 vm->m_area.add_y(em, vi, 1);
472 return stone_surface_max_y;
476 void MapgenV7::generateRidgeTerrain()
478 if (node_max.Y < water_level - 16)
481 MapNode n_water(c_water_source);
482 MapNode n_air(CONTENT_AIR);
486 for (s16 z = node_min.Z; z <= node_max.Z; z++)
487 for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
488 u32 vi = vm->m_area.index(node_min.X, y, z);
489 for (s16 x = node_min.X; x <= node_max.X; x++, index++, vi++) {
490 int j = (z - node_min.Z) * csize.X + (x - node_min.X);
492 if (heightmap[j] < water_level - 16) // Use base terrain heightmap
495 float uwatern = noise_ridge_uwater->result[j] * 2;
496 if (fabs(uwatern) > width)
499 float altitude = y - water_level;
500 float height_mod = (altitude + 17) / 2.5;
501 float width_mod = width - fabs(uwatern);
502 float nridge = noise_ridge->result[index] * MYMAX(altitude, 0) / 7.0;
504 if (nridge + width_mod * height_mod < 0.6)
507 if (y < ridge_heightmap[j])
508 ridge_heightmap[j] = y - 1;
510 vm->m_data[vi] = (y > water_level) ? n_air : n_water;
516 ////////////////////////////////////////////////////////////////////////////////
519 //// Much of the stuff here has potential to become useful again at some point
520 //// in the future, but we don't want it to get lost or forgotten in version
525 int MapgenV7::generateMountainTerrain(s16 ymax)
527 MapNode n_stone(c_stone);
530 for (s16 z = node_min.Z; z <= node_max.Z; z++)
531 for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
532 u32 vi = vm->m_area.index(node_min.X, y, z);
533 for (s16 x = node_min.X; x <= node_max.X; x++) {
534 int index = (z - node_min.Z) * csize.X + (x - node_min.X);
535 content_t c = vm->m_data[vi].getContent();
537 if (getMountainTerrainFromMap(j, index, y)
538 && (c == CONTENT_AIR || c == c_water_source)) {
539 vm->m_data[vi] = n_stone;
555 void MapgenV7::carveRivers() {
556 MapNode n_air(CONTENT_AIR), n_water_source(c_water_source);
557 MapNode n_stone(c_stone);
562 for (s16 z = node_min.Z; z <= node_max.Z; z++)
563 for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
564 float terrain_mod = noise_terrain_mod->result[index];
565 NoiseParams *np = noise_terrain_river->np;
566 np.persist = noise_terrain_persist->result[index];
567 float terrain_river = NoisePerlin2DNoTxfm(np, x, z, seed);
568 float height = terrain_river * (1 - abs(terrain_mod)) *
569 noise_terrain_river->np.scale;
570 height = log(height * height); //log(h^3) is pretty interesting for terrain
572 s16 y = heightmap[index];
573 if (height < 1.0 && y > river_depth &&
574 y - river_depth >= node_min.Y && y <= node_max.Y) {
576 for (s16 ry = y; ry != y - river_depth; ry--) {
577 u32 vi = vm->m_area.index(x, ry, z);
578 vm->m_data[vi] = n_air;
581 u32 vi = vm->m_area.index(x, y - river_depth, z);
582 vm->m_data[vi] = n_water_source;
590 void MapgenV7::addTopNodes()
592 v3s16 em = vm->m_area.getExtent();
596 for (s16 z = node_min.Z; z <= node_max.Z; z++)
597 for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
598 Biome *biome = bmgr->biomes[biomemap[index]];
600 //////////////////// First, add top nodes below the ridge
601 s16 y = ridge_heightmap[index];
603 // This cutoff is good enough, but not perfect.
604 // It will cut off potentially placed top nodes at chunk boundaries
607 if (y > node_max.Y) {
608 y = node_max.Y; // Let's see if we can still go downward anyway
609 u32 vi = vm->m_area.index(x, y, z);
610 content_t c = vm->m_data[vi].getContent();
611 if (ndef->get(c).walkable)
615 // N.B. It is necessary to search downward since ridge_heightmap[i]
616 // might not be the actual height, just the lowest part in the chunk
617 // where a ridge had been carved
618 u32 i = vm->m_area.index(x, y, z);
619 for (; y >= node_min.Y; y--) {
620 content_t c = vm->m_data[i].getContent();
621 if (ndef->get(c).walkable)
623 vm->m_area.add_y(em, i, -1);
626 if (y != node_min.Y - 1 && y >= water_level) {
627 ridge_heightmap[index] = y; //update ridgeheight
628 ntopnodes = biome->top_depth;
629 for (; y <= node_max.Y && ntopnodes; y++) {
631 vm->m_data[i] = MapNode(biome->c_top);
632 vm->m_area.add_y(em, i, 1);
634 // If dirt, grow grass on it.
635 if (y > water_level - 10 &&
636 vm->m_data[i].getContent() == CONTENT_AIR) {
637 vm->m_area.add_y(em, i, -1);
638 if (vm->m_data[i].getContent() == c_dirt)
639 vm->m_data[i] = MapNode(c_dirt_with_grass);
643 //////////////////// Now, add top nodes on top of the ridge
644 y = heightmap[index];
645 if (y > node_max.Y) {
646 y = node_max.Y; // Let's see if we can still go downward anyway
647 u32 vi = vm->m_area.index(x, y, z);
648 content_t c = vm->m_data[vi].getContent();
649 if (ndef->get(c).walkable)
653 i = vm->m_area.index(x, y, z);
654 for (; y >= node_min.Y; y--) {
655 content_t c = vm->m_data[i].getContent();
656 if (ndef->get(c).walkable)
658 vm->m_area.add_y(em, i, -1);
661 if (y != node_min.Y - 1) {
662 ntopnodes = biome->top_depth;
663 // Let's see if we've already added it...
664 if (y == ridge_heightmap[index] + ntopnodes - 1)
667 for (; y <= node_max.Y && ntopnodes; y++) {
669 vm->m_data[i] = MapNode(biome->c_top);
670 vm->m_area.add_y(em, i, 1);
672 // If dirt, grow grass on it.
673 if (y > water_level - 10 &&
674 vm->m_data[i].getContent() == CONTENT_AIR) {
675 vm->m_area.add_y(em, i, -1);
676 if (vm->m_data[i].getContent() == c_dirt)
677 vm->m_data[i] = MapNode(c_dirt_with_grass);