mirror of
https://github.com/minetest/minetest.git
synced 2024-12-28 08:57:30 +01:00
Optimize Mapgen::updateLiquid()
-55% runtime in singlenode usage, which is the best case
This commit is contained in:
parent
43c9c38a28
commit
bf36a90579
@ -370,8 +370,13 @@ inline bool Mapgen::isLiquidHorizontallyFlowable(u32 vi, v3s16 em)
|
||||
void Mapgen::updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax)
|
||||
{
|
||||
bool isignored, isliquid, wasignored, wasliquid, waschecked, waspushed;
|
||||
content_t was_n;
|
||||
const v3s16 &em = vm->m_area.getExtent();
|
||||
|
||||
isignored = true;
|
||||
isliquid = false;
|
||||
was_n = CONTENT_IGNORE;
|
||||
|
||||
for (s16 z = nmin.Z + 1; z <= nmax.Z - 1; z++)
|
||||
for (s16 x = nmin.X + 1; x <= nmax.X - 1; x++) {
|
||||
wasignored = true;
|
||||
@ -381,8 +386,11 @@ void Mapgen::updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nm
|
||||
|
||||
u32 vi = vm->m_area.index(x, nmax.Y, z);
|
||||
for (s16 y = nmax.Y; y >= nmin.Y; y--) {
|
||||
isignored = vm->m_data[vi].getContent() == CONTENT_IGNORE;
|
||||
isliquid = ndef->get(vm->m_data[vi]).isLiquid();
|
||||
const content_t is_n = vm->m_data[vi].getContent();
|
||||
if (is_n != was_n) {
|
||||
isignored = is_n == CONTENT_IGNORE;
|
||||
isliquid = ndef->get(is_n).isLiquid();
|
||||
}
|
||||
|
||||
if (isignored || wasignored || isliquid == wasliquid) {
|
||||
// Neither topmost node of liquid column nor topmost node below column
|
||||
@ -411,6 +419,7 @@ void Mapgen::updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nm
|
||||
}
|
||||
}
|
||||
|
||||
was_n = is_n;
|
||||
wasliquid = isliquid;
|
||||
wasignored = isignored;
|
||||
VoxelArea::add_y(em, vi, -1);
|
||||
|
Loading…
Reference in New Issue
Block a user