aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParamat <paramat@users.noreply.github.com>2019-08-15 20:32:28 +0100
committerGitHub <noreply@github.com>2019-08-15 20:32:28 +0100
commitd7c10b66d39adb330612da0da6d9c8ed993fe588 (patch)
tree817db25f2f33d9c2a0dfe96e1afd2944518761b3
parent2db0e93f73a4b103bfec469b8ff02edce11399de (diff)
downloadminetest-d7c10b66d39adb330612da0da6d9c8ed993fe588.tar.gz
minetest-d7c10b66d39adb330612da0da6d9c8ed993fe588.tar.bz2
minetest-d7c10b66d39adb330612da0da6d9c8ed993fe588.zip
Mapgen v6: Fix mudflow iteration and iterate twice (#8795)
In MapgenV6::flowMud(), the previous implementation of coordinate inversion caused the 2 inverted mudflow iterations (out of the 3 iterations) to not loop over the area, so only 1 non-inverted iteration occurred. Fix this bug but only iterate mudflow twice, as mapgen v6 has only had 1 iteration for many years. There is now a good balance of 1 non-inverted iteration and 1 inverted iteration.
-rw-r--r--src/mapgen/mapgen_v6.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/mapgen/mapgen_v6.cpp b/src/mapgen/mapgen_v6.cpp
index ae87b094d..28ca8faa2 100644
--- a/src/mapgen/mapgen_v6.cpp
+++ b/src/mapgen/mapgen_v6.cpp
@@ -773,22 +773,22 @@ void MapgenV6::addMud()
void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos)
{
- // 340ms @cs=8
- //TimeTaker timer1("flow mud");
-
- // Iterate a few times
- for (s16 k = 0; k < 3; k++) {
+ // Iterate twice
+ for (s16 k = 0; k < 2; k++) {
for (s16 z = mudflow_minpos; z <= mudflow_maxpos; z++)
for (s16 x = mudflow_minpos; x <= mudflow_maxpos; x++) {
- // Invert coordinates every 2nd iteration
- if (k % 2 == 0) {
- x = mudflow_maxpos - (x - mudflow_minpos);
- z = mudflow_maxpos - (z - mudflow_minpos);
+ // Node column position
+ v2s16 p2d;
+ // Invert coordinates on second iteration to process columns in
+ // opposite order, to avoid a directional bias.
+ if (k == 1) {
+ p2d = v2s16(node_min.X, node_min.Z) + v2s16(
+ mudflow_maxpos - (x - mudflow_minpos),
+ mudflow_maxpos - (z - mudflow_minpos));
+ } else {
+ p2d = v2s16(node_min.X, node_min.Z) + v2s16(x, z);
}
- // Node position in 2d
- v2s16 p2d = v2s16(node_min.X, node_min.Z) + v2s16(x, z);
-
const v3s16 &em = vm->m_area.getExtent();
u32 i = vm->m_area.index(p2d.X, node_max.Y, p2d.Y);
s16 y = node_max.Y;