1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Move biome calculation to BiomeGen

BiomeGen defines an interface that, given a set of BiomeParams, computes biomes
for a given area using the algorithm implemented by that specific BiomeGen.
This abstracts away the old system where each mapgen supplied the noises
required for biome generation.
This commit is contained in:
kwolekr 2016-04-28 03:43:09 -04:00
parent fa6b21a15b
commit 76f4856479
16 changed files with 421 additions and 304 deletions

View file

@ -528,24 +528,26 @@ int ModApiMapgen::l_get_mapgen_object(lua_State *L)
return 1;
}
case MGOBJ_BIOMEMAP: {
if (!mg->biomemap)
if (!mg->biomegen)
return 0;
lua_newtable(L);
for (size_t i = 0; i != maplen; i++) {
lua_pushinteger(L, mg->biomemap[i]);
lua_pushinteger(L, mg->biomegen->biomemap[i]);
lua_rawseti(L, -2, i + 1);
}
return 1;
}
case MGOBJ_HEATMAP: {
if (!mg->heatmap)
if (!mg->biomegen || mg->biomegen->getType() != BIOMEGEN_ORIGINAL)
return 0;
BiomeGenOriginal *bg = (BiomeGenOriginal *)mg->biomegen;
lua_newtable(L);
for (size_t i = 0; i != maplen; i++) {
lua_pushnumber(L, mg->heatmap[i]);
lua_pushnumber(L, bg->heatmap[i]);
lua_rawseti(L, -2, i + 1);
}
@ -553,12 +555,14 @@ int ModApiMapgen::l_get_mapgen_object(lua_State *L)
}
case MGOBJ_HUMIDMAP: {
if (!mg->humidmap)
if (!mg->biomegen || mg->biomegen->getType() != BIOMEGEN_ORIGINAL)
return 0;
BiomeGenOriginal *bg = (BiomeGenOriginal *)mg->biomegen;
lua_newtable(L);
for (size_t i = 0; i != maplen; i++) {
lua_pushnumber(L, mg->humidmap[i]);
lua_pushnumber(L, bg->humidmap[i]);
lua_rawseti(L, -2, i + 1);
}