Skip to content

Commit 848c3fe

Browse files
committedJun 29, 2013
Optimize liquid queue on generate map for liquid_finite
1 parent 21a4adc commit 848c3fe

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed
 

‎src/content_abm.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,12 @@ class LiquidDropABM : public ActiveBlockModifier
228228
ServerMap *map = &env->getServerMap();
229229
if (map->transforming_liquid_size() > 500)
230230
return;
231-
//todo: look around except top
232-
MapNode n_below = map->getNodeNoEx(p - v3s16(0, 1, 0));
233-
if (n_below.getContent() != CONTENT_AIR)
231+
if ( map->getNodeNoEx(p - v3s16(0, 1, 0 )).getContent() != CONTENT_AIR // below
232+
&& map->getNodeNoEx(p - v3s16(1, 0, 0 )).getContent() != CONTENT_AIR // right
233+
&& map->getNodeNoEx(p - v3s16(-1, 0, 0 )).getContent() != CONTENT_AIR // left
234+
&& map->getNodeNoEx(p - v3s16(0, 0, 1 )).getContent() != CONTENT_AIR // back
235+
&& map->getNodeNoEx(p - v3s16(0, 0, -1)).getContent() != CONTENT_AIR // front
236+
)
234237
return;
235238
map->transforming_liquid_add(p);
236239
}

‎src/mapgen.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,10 @@ void Mapgen::updateHeightmap(v3s16 nmin, v3s16 nmax) {
836836

837837

838838
void Mapgen::updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax) {
839-
bool isliquid, wasliquid;
839+
bool isliquid, wasliquid, rare;
840840
v3s16 em = vm->m_area.getExtent();
841+
rare = g_settings->getBool("liquid_finite");
842+
int rarecnt = 0;
841843

842844
for (s16 z = nmin.Z; z <= nmax.Z; z++) {
843845
for (s16 x = nmin.X; x <= nmax.X; x++) {
@@ -847,8 +849,8 @@ void Mapgen::updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nm
847849
for (s16 y = nmax.Y; y >= nmin.Y; y--) {
848850
isliquid = ndef->get(vm->m_data[i]).isLiquid();
849851

850-
// there was a change between liquid and nonliquid, add to queue
851-
if (isliquid != wasliquid)
852+
// there was a change between liquid and nonliquid, add to queue. no need to add every with liquid_finite
853+
if (isliquid != wasliquid && (!rare || !(rarecnt++ % 36)))
852854
trans_liquid->push_back(v3s16(x, y, z));
853855

854856
wasliquid = isliquid;

0 commit comments

Comments
 (0)
Please sign in to comment.