Biome API: Add shore top and shore filler nodes, underwater node, water top node. Add water top depth and shore height parameters. Remove water dust node
parent
61dfa912f5
commit
570c2042b1
|
@ -421,6 +421,8 @@ void MapgenV5::generateBiomes() {
|
|||
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;
|
||||
|
||||
s16 nplaced = 0;
|
||||
u32 i = vm->m_area.index(x, node_max.Y, z);
|
||||
|
@ -439,14 +441,19 @@ void MapgenV5::generateBiomes() {
|
|||
|
||||
if (c_below != CONTENT_AIR) {
|
||||
if (nplaced < y0_top) {
|
||||
// A hack to prevent dirt_with_grass from being
|
||||
// placed below water. TODO: fix later
|
||||
content_t c_place = ((y < water_level) &&
|
||||
(biome->c_top == c_dirt_with_grass)) ?
|
||||
c_dirt : biome->c_top;
|
||||
vm->m_data[i] = MapNode(c_place);
|
||||
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);
|
||||
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);
|
||||
nplaced++;
|
||||
} else if (c == c_stone) {
|
||||
|
@ -469,6 +476,9 @@ void MapgenV5::generateBiomes() {
|
|||
} else if (c == c_water_source) {
|
||||
have_air = true;
|
||||
nplaced = 0;
|
||||
if(y > water_level - depth_water_top)
|
||||
vm->m_data[i] = MapNode(biome->c_water_top);
|
||||
else
|
||||
vm->m_data[i] = MapNode(biome->c_water);
|
||||
} else if (c == CONTENT_AIR) {
|
||||
have_air = true;
|
||||
|
@ -480,6 +490,7 @@ void MapgenV5::generateBiomes() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void MapgenV5::dustTopNodes() {
|
||||
v3s16 em = vm->m_area.getExtent();
|
||||
u32 index = 0;
|
||||
|
@ -504,12 +515,7 @@ void MapgenV5::dustTopNodes() {
|
|||
}
|
||||
|
||||
content_t c = vm->m_data[vi].getContent();
|
||||
if (c == biome->c_water && biome->c_dust_water != CONTENT_IGNORE) {
|
||||
if (y < node_min.Y - 1)
|
||||
continue;
|
||||
|
||||
vm->m_data[vi] = MapNode(biome->c_dust_water);
|
||||
} else if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE
|
||||
if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE
|
||||
&& c != biome->c_dust) {
|
||||
if (y == node_max.Y + 1)
|
||||
continue;
|
||||
|
|
|
@ -520,6 +520,8 @@ void MapgenV7::generateBiomes() {
|
|||
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;
|
||||
|
||||
s16 nplaced = 0;
|
||||
u32 i = vm->m_area.index(x, node_max.Y, z);
|
||||
|
@ -545,14 +547,19 @@ void MapgenV7::generateBiomes() {
|
|||
|
||||
if (c_below != CONTENT_AIR) {
|
||||
if (nplaced < y0_top) {
|
||||
// A hack to prevent dirt_with_grass from being
|
||||
// placed below water. TODO: fix later
|
||||
content_t c_place = ((y < water_level) &&
|
||||
(biome->c_top == c_dirt_with_grass)) ?
|
||||
c_dirt : biome->c_top;
|
||||
vm->m_data[i] = MapNode(c_place);
|
||||
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);
|
||||
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);
|
||||
nplaced++;
|
||||
} else if (c == c_stone) {
|
||||
|
@ -575,6 +582,9 @@ void MapgenV7::generateBiomes() {
|
|||
} else if (c == c_water_source) {
|
||||
have_air = true;
|
||||
nplaced = 0;
|
||||
if(y > water_level - depth_water_top)
|
||||
vm->m_data[i] = MapNode(biome->c_water_top);
|
||||
else
|
||||
vm->m_data[i] = MapNode(biome->c_water);
|
||||
} else if (c == CONTENT_AIR) {
|
||||
have_air = true;
|
||||
|
@ -611,12 +621,7 @@ void MapgenV7::dustTopNodes() {
|
|||
}
|
||||
|
||||
content_t c = vm->m_data[vi].getContent();
|
||||
if (c == biome->c_water && biome->c_dust_water != CONTENT_IGNORE) {
|
||||
if (y < node_min.Y)
|
||||
continue;
|
||||
|
||||
vm->m_data[vi] = MapNode(biome->c_dust_water);
|
||||
} else if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE) {
|
||||
if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE) {
|
||||
if (y == node_max.Y)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ BiomeManager::BiomeManager(IGameDef *gamedef) :
|
|||
b->flags = 0;
|
||||
b->depth_top = 0;
|
||||
b->depth_filler = 0;
|
||||
b->height_shore = 0;
|
||||
b->depth_water_top = 0;
|
||||
b->height_min = -MAP_GENERATION_LIMIT;
|
||||
b->height_max = MAP_GENERATION_LIMIT;
|
||||
b->heat_point = 0.0;
|
||||
|
@ -51,10 +53,13 @@ BiomeManager::BiomeManager(IGameDef *gamedef) :
|
|||
NodeResolveInfo *nri = new NodeResolveInfo(b);
|
||||
nri->nodenames.push_back("air");
|
||||
nri->nodenames.push_back("air");
|
||||
nri->nodenames.push_back("air");
|
||||
nri->nodenames.push_back("air");
|
||||
nri->nodenames.push_back("air");
|
||||
nri->nodenames.push_back("mapgen_stone");
|
||||
nri->nodenames.push_back("mapgen_water_source");
|
||||
nri->nodenames.push_back("air");
|
||||
nri->nodenames.push_back("mapgen_water_source");
|
||||
nri->nodenames.push_back("air");
|
||||
m_ndef->pendNodeResolve(nri);
|
||||
|
||||
add(b);
|
||||
|
@ -121,9 +126,12 @@ void Biome::resolveNodeNames(NodeResolveInfo *nri)
|
|||
{
|
||||
m_ndef->getIdFromResolveInfo(nri, "mapgen_dirt_with_grass", CONTENT_AIR, c_top);
|
||||
m_ndef->getIdFromResolveInfo(nri, "mapgen_dirt", CONTENT_AIR, c_filler);
|
||||
m_ndef->getIdFromResolveInfo(nri, "mapgen_sand", CONTENT_AIR, c_shore_top);
|
||||
m_ndef->getIdFromResolveInfo(nri, "mapgen_sand", CONTENT_AIR, c_shore_filler);
|
||||
m_ndef->getIdFromResolveInfo(nri, "mapgen_sand", CONTENT_AIR, c_underwater);
|
||||
m_ndef->getIdFromResolveInfo(nri, "mapgen_stone", CONTENT_AIR, c_stone);
|
||||
m_ndef->getIdFromResolveInfo(nri, "mapgen_water_source", CONTENT_AIR, c_water_top);
|
||||
m_ndef->getIdFromResolveInfo(nri, "mapgen_water_source", CONTENT_AIR, c_water);
|
||||
m_ndef->getIdFromResolveInfo(nri, "air", CONTENT_IGNORE, c_dust);
|
||||
m_ndef->getIdFromResolveInfo(nri, "mapgen_water_source", CONTENT_IGNORE, c_dust_water);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,13 +39,18 @@ public:
|
|||
|
||||
content_t c_top;
|
||||
content_t c_filler;
|
||||
content_t c_shore_top;
|
||||
content_t c_shore_filler;
|
||||
content_t c_underwater;
|
||||
content_t c_stone;
|
||||
content_t c_water_top;
|
||||
content_t c_water;
|
||||
content_t c_dust;
|
||||
content_t c_dust_water;
|
||||
|
||||
s16 depth_top;
|
||||
s16 depth_filler;
|
||||
s16 height_shore;
|
||||
s16 depth_water_top;
|
||||
|
||||
s16 height_min;
|
||||
s16 height_max;
|
||||
|
|
|
@ -425,6 +425,8 @@ int ModApiMapgen::l_register_biome(lua_State *L)
|
|||
b->name = getstringfield_default(L, index, "name", "");
|
||||
b->depth_top = getintfield_default(L, index, "depth_top", 1);
|
||||
b->depth_filler = getintfield_default(L, index, "depth_filler", 3);
|
||||
b->height_shore = getintfield_default(L, index, "height_shore", 3);
|
||||
b->depth_water_top = getintfield_default(L, index, "depth_water_top", 0);
|
||||
b->height_min = getintfield_default(L, index, "height_min", 0);
|
||||
b->height_max = getintfield_default(L, index, "height_max", 0);
|
||||
b->heat_point = getfloatfield_default(L, index, "heat_point", 0.);
|
||||
|
@ -441,10 +443,13 @@ int ModApiMapgen::l_register_biome(lua_State *L)
|
|||
std::list<std::string> &nnames = nri->nodenames;
|
||||
nnames.push_back(getstringfield_default(L, index, "node_top", ""));
|
||||
nnames.push_back(getstringfield_default(L, index, "node_filler", ""));
|
||||
nnames.push_back(getstringfield_default(L, index, "node_shore_top", ""));
|
||||
nnames.push_back(getstringfield_default(L, index, "node_shore_filler", ""));
|
||||
nnames.push_back(getstringfield_default(L, index, "node_underwater", ""));
|
||||
nnames.push_back(getstringfield_default(L, index, "node_stone", ""));
|
||||
nnames.push_back(getstringfield_default(L, index, "node_water_top", ""));
|
||||
nnames.push_back(getstringfield_default(L, index, "node_water", ""));
|
||||
nnames.push_back(getstringfield_default(L, index, "node_dust", ""));
|
||||
nnames.push_back(getstringfield_default(L, index, "node_dust_water", ""));
|
||||
ndef->pendNodeResolve(nri);
|
||||
|
||||
verbosestream << "register_biome: " << b->name << std::endl;
|
||||
|
|
Loading…
Reference in New Issue