np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 4, 0.7, 2.0);
np_mount_height = NoiseParams(100, 30, v3f(500, 500, 500), 72449, 4, 0.6, 2.0);
np_ridge_uwater = NoiseParams(0, 1, v3f(500, 500, 500), 85039, 4, 0.6, 2.0);
- np_mountain = NoiseParams(0, 1, v3f(250, 350, 250), 5333, 5, 0.68, 2.0);
+ np_mountain = NoiseParams(-0.6, 1, v3f(250, 350, 250), 5333, 5, 0.68, 2.0);
np_ridge = NoiseParams(0, 1, v3f(100, 100, 100), 6467, 4, 0.75, 2.0);
np_cave1 = NoiseParams(0, 12, v3f(100, 100, 100), 52534, 4, 0.5, 2.0);
np_cave2 = NoiseParams(0, 12, v3f(100, 100, 100), 10325, 4, 0.5, 2.0);
}
-void MapgenV7Params::readParams(Settings *settings)
+void MapgenV7Params::readParams(const Settings *settings)
{
settings->getFlagStrNoEx("mgv7_spflags", spflags, flagdesc_mapgen_v7);
}
-void MapgenV7Params::writeParams(Settings *settings)
+void MapgenV7Params::writeParams(Settings *settings) const
{
settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7, (u32)-1);
s16 y = baseTerrainLevelAtPoint(p.X, p.Y);
// Ridge/river terrain calculation
- float width = 0.3;
+ float width = 0.2;
float uwatern = NoisePerlin2D(&noise_ridge_uwater->np, p.X, p.Y, seed) * 2;
// actually computing the depth of the ridge is much more expensive;
// if inside a river, simply guess
- if (uwatern >= -width && uwatern <= width)
+ if (fabs(uwatern) <= width)
return water_level - 10;
// Mountain terrain calculation
void MapgenV7::makeChunk(BlockMakeData *data)
{
+ // Pre-conditions
assert(data->vmanip);
assert(data->nodedef);
assert(data->blockpos_requested.X >= data->blockpos_min.X &&
// Generate base terrain, mountains, and ridges with initial heightmaps
s16 stone_surface_max_y = generateTerrain();
+ // Create heightmap
updateHeightmap(node_min, node_max);
- // Calculate biomes
+ // Create biomemap at heightmap surface
bmgr->calcBiomes(csize.X, csize.Z, noise_heat->result,
noise_humidity->result, heightmap, biomemap);
- // Actually place the biome-specific nodes and what not
- generateBiomes();
+ // Actually place the biome-specific nodes
+ generateBiomes(noise_heat->result, noise_humidity->result);
if (flags & MG_CAVES)
generateCaves(stone_surface_max_y);
noise_cave2->perlinMap3D(x, y, z);
}
+ if ((spflags & MGV7_RIDGES) && node_max.Y >= water_level) {
+ noise_ridge->perlinMap3D(x, y, z);
+ noise_ridge_uwater->perlinMap2D(x, z);
+ }
+
+ if ((spflags & MGV7_MOUNTAINS) && node_max.Y >= 0) {
+ noise_mountain->perlinMap3D(x, y, z);
+ noise_mount_height->perlinMap2D(x, z);
+ }
+
if (node_max.Y >= water_level) {
noise_filler_depth->perlinMap2D(x, z);
noise_heat->perlinMap2D(x, z);
noise_humidity->perlinMap2D(x, z);
-
- if (spflags & MGV7_MOUNTAINS) {
- noise_mountain->perlinMap3D(x, y, z);
- noise_mount_height->perlinMap2D(x, z);
- }
-
- if (spflags & MGV7_RIDGES) {
- noise_ridge->perlinMap3D(x, y, z);
- noise_ridge_uwater->perlinMap2D(x, z);
- }
}
-
//printf("calculateNoise: %dus\n", t.stop());
}
hselect = rangelim(hselect, 0.0, 1.0);
float persist = NoisePerlin2D(&noise_terrain_persist->np, x, z, seed);
- persist = rangelim(persist, 0.4, 0.9);
noise_terrain_base->np.persist = persist;
float height_base = NoisePerlin2D(&noise_terrain_base->np, x, z, seed);
bool MapgenV7::getMountainTerrainAtPoint(int x, int y, int z)
{
float mnt_h_n = NoisePerlin2D(&noise_mount_height->np, x, z, seed);
- float height_modifier = -((float)y / mnt_h_n);
float mnt_n = NoisePerlin3D(&noise_mountain->np, x, y, z, seed);
-
- return mnt_n + height_modifier >= 0.6;
+ return mnt_n * mnt_h_n >= (float)y;
}
bool MapgenV7::getMountainTerrainFromMap(int idx_xyz, int idx_xz, int y)
{
float mounthn = noise_mount_height->result[idx_xz];
- float height_modifier = -((float)y / mounthn);
- return (noise_mountain->result[idx_xyz] + height_modifier >= 0.6);
+ float mountn = noise_mountain->result[idx_xyz];
+ return mountn * mounthn >= (float)y;
}
int MapgenV7::generateMountainTerrain(int ymax)
{
- if (node_max.Y < water_level)
+ if (node_max.Y < 0)
return ymax;
MapNode n_stone(c_stone);
MapNode n_water(c_water_source);
MapNode n_air(CONTENT_AIR);
u32 index = 0;
+ float width = 0.2; // TODO: figure out acceptable perlin noise values
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 y = node_min.Y; y <= node_max.Y; y++) {
if (heightmap[j] < water_level - 16)
continue;
- float width = 0.2; // TODO: figure out acceptable perlin noise values
float uwatern = noise_ridge_uwater->result[j] * 2;
if (fabs(uwatern) > width)
continue;
}
-void MapgenV7::generateBiomes()
+void MapgenV7::generateBiomes(float *heat_map, float *humidity_map)
{
if (node_max.Y < water_level)
return;
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
- Biome *biome = (Biome *)bmgr->get(biomemap[index]);
- s16 dfiller = biome->depth_filler + noise_filler_depth->result[index];
- s16 y0_top = biome->depth_top;
- s16 y0_filler = biome->depth_top + dfiller;
- s16 shore_max = water_level + biome->height_shore;
- s16 depth_water_top = biome->depth_water_top;
+ Biome *biome = NULL;
+ s16 dfiller = 0;
+ s16 y0_top = 0;
+ s16 y0_filler = 0;
+ s16 depth_water_top = 0;
s16 nplaced = 0;
u32 i = vm->m_area.index(x, node_max.Y, z);
have_air = !getMountainTerrainFromMap(j, index, y);
}
+ if (c != CONTENT_IGNORE && c != CONTENT_AIR && (y == node_max.Y || have_air)) {
+ biome = bmgr->getBiome(heat_map[index], humidity_map[index], y);
+ dfiller = biome->depth_filler + noise_filler_depth->result[index];
+ y0_top = biome->depth_top;
+ y0_filler = biome->depth_top + dfiller;
+ depth_water_top = biome->depth_water_top;
+ }
+
if (c == c_stone && have_air) {
content_t c_below = vm->m_data[i - em.X].getContent();
if (c_below != CONTENT_AIR) {
if (nplaced < y0_top) {
- if(y < water_level)
- vm->m_data[i] = MapNode(biome->c_underwater);
- else if(y <= shore_max)
- vm->m_data[i] = MapNode(biome->c_shore_top);
- else
- vm->m_data[i] = MapNode(biome->c_top);
+ vm->m_data[i] = MapNode(biome->c_top);
nplaced++;
} else if (nplaced < y0_filler && nplaced >= y0_top) {
- if(y < water_level)
- vm->m_data[i] = MapNode(biome->c_underwater);
- else if(y <= shore_max)
- vm->m_data[i] = MapNode(biome->c_shore_filler);
- else
- vm->m_data[i] = MapNode(biome->c_filler);
+ vm->m_data[i] = MapNode(biome->c_filler);
nplaced++;
} else if (c == c_stone) {
have_air = false;
}
PseudoRandom ps(blockseed + 21343);
- u32 bruises_count = (ps.range(1, 6) == 1) ? ps.range(1, 2) : 0;
+ u32 bruises_count = (ps.range(1, 5) == 1) ? ps.range(1, 2) : 0;
for (u32 i = 0; i < bruises_count; i++) {
- CaveV7 cave(this, &ps, true);
+ CaveV7 cave(this, &ps);
cave.makeCave(node_min, node_max, max_stone_y);
}
}