mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Optimize liquid queue on generate map for liquid_finite
This commit is contained in:
parent
21a4adcd27
commit
848c3fe51a
@ -228,9 +228,12 @@ public:
|
||||
ServerMap *map = &env->getServerMap();
|
||||
if (map->transforming_liquid_size() > 500)
|
||||
return;
|
||||
//todo: look around except top
|
||||
MapNode n_below = map->getNodeNoEx(p - v3s16(0, 1, 0));
|
||||
if (n_below.getContent() != CONTENT_AIR)
|
||||
if ( map->getNodeNoEx(p - v3s16(0, 1, 0 )).getContent() != CONTENT_AIR // below
|
||||
&& map->getNodeNoEx(p - v3s16(1, 0, 0 )).getContent() != CONTENT_AIR // right
|
||||
&& map->getNodeNoEx(p - v3s16(-1, 0, 0 )).getContent() != CONTENT_AIR // left
|
||||
&& map->getNodeNoEx(p - v3s16(0, 0, 1 )).getContent() != CONTENT_AIR // back
|
||||
&& map->getNodeNoEx(p - v3s16(0, 0, -1)).getContent() != CONTENT_AIR // front
|
||||
)
|
||||
return;
|
||||
map->transforming_liquid_add(p);
|
||||
}
|
||||
|
@ -836,8 +836,10 @@ void Mapgen::updateHeightmap(v3s16 nmin, v3s16 nmax) {
|
||||
|
||||
|
||||
void Mapgen::updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax) {
|
||||
bool isliquid, wasliquid;
|
||||
bool isliquid, wasliquid, rare;
|
||||
v3s16 em = vm->m_area.getExtent();
|
||||
rare = g_settings->getBool("liquid_finite");
|
||||
int rarecnt = 0;
|
||||
|
||||
for (s16 z = nmin.Z; z <= nmax.Z; z++) {
|
||||
for (s16 x = nmin.X; x <= nmax.X; x++) {
|
||||
@ -847,8 +849,8 @@ void Mapgen::updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nm
|
||||
for (s16 y = nmax.Y; y >= nmin.Y; y--) {
|
||||
isliquid = ndef->get(vm->m_data[i]).isLiquid();
|
||||
|
||||
// there was a change between liquid and nonliquid, add to queue
|
||||
if (isliquid != wasliquid)
|
||||
// there was a change between liquid and nonliquid, add to queue. no need to add every with liquid_finite
|
||||
if (isliquid != wasliquid && (!rare || !(rarecnt++ % 36)))
|
||||
trans_liquid->push_back(v3s16(x, y, z));
|
||||
|
||||
wasliquid = isliquid;
|
||||
|
Loading…
Reference in New Issue
Block a user