mgv7: Implement getGroundLevelAtPoint(), fix layer of topnodes at chunk Y boundaries, remove growGrass()
parent
daddd37706
commit
37e6d1356b
|
@ -115,7 +115,23 @@ MapgenV7::~MapgenV7() {
|
||||||
|
|
||||||
|
|
||||||
int MapgenV7::getGroundLevelAtPoint(v2s16 p) {
|
int MapgenV7::getGroundLevelAtPoint(v2s16 p) {
|
||||||
return 20;
|
s16 groundlevel = baseTerrainLevelAtPoint(p.X, p.Y);
|
||||||
|
float heat = NoisePerlin2D(bmgr->np_heat, p.X, p.Y, seed);
|
||||||
|
float humidity = NoisePerlin2D(bmgr->np_humidity, p.X, p.Y, seed);
|
||||||
|
Biome *b = bmgr->getBiome(heat, humidity, groundlevel);
|
||||||
|
|
||||||
|
s16 y = groundlevel;
|
||||||
|
if (y > water_level) {
|
||||||
|
int iters = 1024; // don't even bother iterating more than 1024 times..
|
||||||
|
while (iters--) {
|
||||||
|
float ridgenoise = NoisePerlin3D(noise_ridge->np, p.X, y, p.Y, seed);
|
||||||
|
if (ridgenoise * (float)(y * y) < 15.0)
|
||||||
|
break;
|
||||||
|
y--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return y + b->top_depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,12 +185,8 @@ void MapgenV7::makeChunk(BlockMakeData *data) {
|
||||||
generateTerrain();
|
generateTerrain();
|
||||||
carveRidges();
|
carveRidges();
|
||||||
|
|
||||||
//carveRivers();
|
|
||||||
|
|
||||||
|
|
||||||
generateCaves(stone_surface_max_y);
|
generateCaves(stone_surface_max_y);
|
||||||
addTopNodes();
|
addTopNodes();
|
||||||
growGrass();
|
|
||||||
//v3s16 central_area_size = node_max - node_min + v3s16(1,1,1);
|
//v3s16 central_area_size = node_max - node_min + v3s16(1,1,1);
|
||||||
|
|
||||||
if (flags & MG_DUNGEONS) {
|
if (flags & MG_DUNGEONS) {
|
||||||
|
@ -193,7 +205,8 @@ void MapgenV7::makeChunk(BlockMakeData *data) {
|
||||||
|
|
||||||
calcLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
|
calcLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
|
||||||
node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE);
|
node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE);
|
||||||
//setLighting(node_min, node_max, 0xFF);
|
//setLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
|
||||||
|
// node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE, 0xFF);
|
||||||
|
|
||||||
this->generating = false;
|
this->generating = false;
|
||||||
}
|
}
|
||||||
|
@ -404,7 +417,7 @@ void MapgenV7::addTopNodes() {
|
||||||
for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
|
for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
|
||||||
Biome *biome = bmgr->biomes[biomemap[index]];
|
Biome *biome = bmgr->biomes[biomemap[index]];
|
||||||
|
|
||||||
// First, add top nodes below the ridge
|
//////////////////// First, add top nodes below the ridge
|
||||||
s16 y = ridge_heightmap[index];
|
s16 y = ridge_heightmap[index];
|
||||||
|
|
||||||
// This cutoff is good enough, but not perfect.
|
// This cutoff is good enough, but not perfect.
|
||||||
|
@ -415,7 +428,7 @@ void MapgenV7::addTopNodes() {
|
||||||
y = node_max.Y; // Let's see if we can still go downward anyway
|
y = node_max.Y; // Let's see if we can still go downward anyway
|
||||||
u32 vi = vm->m_area.index(x, y, z);
|
u32 vi = vm->m_area.index(x, y, z);
|
||||||
content_t c = vm->m_data[vi].getContent();
|
content_t c = vm->m_data[vi].getContent();
|
||||||
if (c == biome->c_filler || c == c_stone)//c != CONTENT_AIR)
|
if (ndef->get(c).walkable)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,15 +438,12 @@ void MapgenV7::addTopNodes() {
|
||||||
u32 i = vm->m_area.index(x, y, z);
|
u32 i = vm->m_area.index(x, y, z);
|
||||||
for (; y >= node_min.Y; y--) {
|
for (; y >= node_min.Y; y--) {
|
||||||
content_t c = vm->m_data[i].getContent();
|
content_t c = vm->m_data[i].getContent();
|
||||||
if (c == biome->c_filler || c == c_stone)//c != CONTENT_AIR)
|
if (ndef->get(c).walkable)
|
||||||
//if (vm->m_data[i].getContent() != CONTENT_AIR)
|
|
||||||
break;
|
break;
|
||||||
vm->m_area.add_y(em, i, -1);
|
vm->m_area.add_y(em, i, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (y != node_min.Y - 1 && y >= water_level) {
|
||||||
|
|
||||||
if (y != node_min.Y - 1) {
|
|
||||||
ridge_heightmap[index] = y; //update ridgeheight
|
ridge_heightmap[index] = y; //update ridgeheight
|
||||||
ntopnodes = biome->top_depth;
|
ntopnodes = biome->top_depth;
|
||||||
for (; y <= node_max.Y && ntopnodes; y++) {
|
for (; y <= node_max.Y && ntopnodes; y++) {
|
||||||
|
@ -441,17 +451,28 @@ void MapgenV7::addTopNodes() {
|
||||||
vm->m_data[i] = MapNode(biome->c_top);
|
vm->m_data[i] = MapNode(biome->c_top);
|
||||||
vm->m_area.add_y(em, i, 1);
|
vm->m_area.add_y(em, i, 1);
|
||||||
}
|
}
|
||||||
//heightmap[index] = y;
|
// If dirt, grow grass on it.
|
||||||
|
if (vm->m_data[i].getContent() == CONTENT_AIR) {
|
||||||
|
vm->m_area.add_y(em, i, -1);
|
||||||
|
if (vm->m_data[i].getContent() == c_dirt)
|
||||||
|
vm->m_data[i] = MapNode(c_dirt_with_grass);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now, add top nodes on top of the ridge
|
//////////////////// Now, add top nodes on top of the ridge
|
||||||
y = heightmap[index];
|
y = heightmap[index];
|
||||||
|
if (y > node_max.Y) {
|
||||||
|
y = node_max.Y; // Let's see if we can still go downward anyway
|
||||||
|
u32 vi = vm->m_area.index(x, y, z);
|
||||||
|
content_t c = vm->m_data[vi].getContent();
|
||||||
|
if (ndef->get(c).walkable)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
i = vm->m_area.index(x, y, z);
|
i = vm->m_area.index(x, y, z);
|
||||||
for (; y >= node_min.Y; y--) {
|
for (; y >= node_min.Y; y--) {
|
||||||
content_t c = vm->m_data[i].getContent();
|
content_t c = vm->m_data[i].getContent();
|
||||||
if (c == biome->c_filler || c == c_stone)//c != CONTENT_AIR)
|
if (ndef->get(c).walkable)
|
||||||
//if (vm->m_data[i].getContent() != CONTENT_AIR)
|
|
||||||
break;
|
break;
|
||||||
vm->m_area.add_y(em, i, -1);
|
vm->m_area.add_y(em, i, -1);
|
||||||
}
|
}
|
||||||
|
@ -467,39 +488,17 @@ void MapgenV7::addTopNodes() {
|
||||||
vm->m_data[i] = MapNode(biome->c_top);
|
vm->m_data[i] = MapNode(biome->c_top);
|
||||||
vm->m_area.add_y(em, i, 1);
|
vm->m_area.add_y(em, i, 1);
|
||||||
}
|
}
|
||||||
}
|
// If dirt, grow grass on it.
|
||||||
}
|
if (vm->m_data[i].getContent() == CONTENT_AIR) {
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MapgenV7::growGrass() {
|
|
||||||
for (s16 z = node_min.Z; z <= node_max.Z; z++)
|
|
||||||
for (s16 x = node_min.X; x <= node_max.X; x++) {
|
|
||||||
// Find the lowest surface to which enough light ends up to make
|
|
||||||
// grass grow. Basically just wait until not air and not leaves.
|
|
||||||
s16 surface_y = 0;
|
|
||||||
{
|
|
||||||
v3s16 em = vm->m_area.getExtent();
|
|
||||||
u32 i = vm->m_area.index(x, node_max.Y, z);
|
|
||||||
s16 y;
|
|
||||||
// Go to ground level
|
|
||||||
for (y = node_max.Y; y >= node_min.Y; y--) {
|
|
||||||
MapNode &n = vm->m_data[i];
|
|
||||||
if (ndef->get(n).param_type != CPT_LIGHT ||
|
|
||||||
ndef->get(n).liquid_type != LIQUID_NONE)
|
|
||||||
break;
|
|
||||||
vm->m_area.add_y(em, i, -1);
|
vm->m_area.add_y(em, i, -1);
|
||||||
|
if (vm->m_data[i].getContent() == c_dirt)
|
||||||
|
vm->m_data[i] = MapNode(c_dirt_with_grass);
|
||||||
}
|
}
|
||||||
surface_y = (y >= node_min.Y) ? y : node_min.Y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 i = vm->m_area.index(x, surface_y, z);
|
|
||||||
MapNode *n = &vm->m_data[i];
|
|
||||||
if (n->getContent() == c_dirt && surface_y >= water_level - 20)
|
|
||||||
n->setContent(c_dirt_with_grass);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "mapgen_v6.h"
|
#include "mapgen_v6.h"
|
||||||
void MapgenV7::generateCaves(int max_stone_y) {
|
void MapgenV7::generateCaves(int max_stone_y) {
|
||||||
PseudoRandom ps(blockseed + 21343);
|
PseudoRandom ps(blockseed + 21343);
|
||||||
|
|
|
@ -109,7 +109,6 @@ public:
|
||||||
|
|
||||||
void testBiomes();
|
void testBiomes();
|
||||||
void addTopNodes();
|
void addTopNodes();
|
||||||
void growGrass();
|
|
||||||
|
|
||||||
void generateCaves(int max_stone_y);
|
void generateCaves(int max_stone_y);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue