diff --git a/src/client/fm_far_calc.cpp b/src/client/fm_far_calc.cpp
index 41d6997c2..6478d033e 100644
--- a/src/client/fm_far_calc.cpp
+++ b/src/client/fm_far_calc.cpp
@@ -24,7 +24,6 @@ along with Freeminer. If not, see .
#include "client/clientmap.h"
#include "constants.h"
-#include "debug/iostream_debug_helpers.h"
#include "irr_v3d.h"
#include "irrlichttypes.h"
diff --git a/src/client/fm_farmesh.cpp b/src/client/fm_farmesh.cpp
index 58933f406..b7c36b684 100644
--- a/src/client/fm_farmesh.cpp
+++ b/src/client/fm_farmesh.cpp
@@ -18,7 +18,10 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Freeminer. If not, see .
*/
+#include
+#include
#include
+#include
#include
#include "fm_farmesh.h"
@@ -30,6 +33,7 @@ along with Freeminer. If not, see .
#include "constants.h"
#include "emerge.h"
#include "irr_v3d.h"
+#include "irrlichttypes.h"
#include "mapblock.h"
#include "mapgen/mapgen.h"
#include "mapnode.h"
@@ -274,14 +278,34 @@ int FarMesh::go_flat()
const auto cbpos = getNodeBlockPos(m_camera_pos_aligned);
+ std::array, FARMESH_STEP_MAX> blocks;
runFarAll(draw_control, cbpos, draw_control.cell_size_pow, 1,
- [this, &draw_control](const v3bpos_t &bpos, const bpos_t &size) -> bool {
- const auto stp = int(log(size) / log(2)) - draw_control.cell_size_pow;
- // DUMP(bpos, size, stp);
- makeFarBlocks(bpos, stp);
+ [this, &draw_control, &blocks](
+ const v3bpos_t &bpos, const bpos_t &size) -> bool {
+ for (const auto &add : {
+ v2bpos_t(0, 0), v2bpos_t(0, size - 1), v2bpos_t(size - 1, 0),
+ v2bpos_t(size - 1, size - 1), v2bpos_t(size >> 1, size >> 1),
+ }) {
+ v3bpos_t bpos_new(bpos.X + add.X, 0, bpos.Z + add.Y);
+
+ bpos_new.Y = mg->getGroundLevelAtPoint(
+ v2pos_t((bpos_new.X << MAP_BLOCKP) - 1,
+ (bpos_new.Z << MAP_BLOCKP) - 1)) >>
+ MAP_BLOCKP;
+
+ auto step_new = getFarStep(draw_control,
+ getNodeBlockPos(m_camera_pos_aligned), bpos_new);
+ blocks[step_new].emplace(bpos_new);
+ }
return false;
});
+ for (size_t step = 0; step < blocks.size(); ++step) {
+ for (const auto &bpos : blocks[step]) {
+ makeFarBlocks(bpos, step);
+ }
+ }
+
return last_range;
}
diff --git a/src/mapgen/mapgen_earth.cpp b/src/mapgen/mapgen_earth.cpp
index d67d9b283..ec8feb0c5 100644
--- a/src/mapgen/mapgen_earth.cpp
+++ b/src/mapgen/mapgen_earth.cpp
@@ -146,7 +146,7 @@ MapgenEarth::MapgenEarth(MapgenEarthParams *params_, EmergeParams *emerge) :
scale = {params["scale"]["x"].asDouble(), params["scale"]["y"].asDouble(),
params["scale"]["z"].asDouble()};
- /* todomake test
+ /* todomake test
static bool shown = 0;
if (!shown) {
shown = true;
@@ -168,7 +168,7 @@ MapgenEarth::MapgenEarth(MapgenEarthParams *params_, EmergeParams *emerge) :
}
}
*/
- /*
+ /*
hgt_reader.debug = 1;
std::vector> a{
{0, 0}, {-30000, -30000}, {-30000, 30000}, {30000, -30000}, {30000, 30000}};
@@ -270,6 +270,11 @@ int MapgenEarth::getSpawnLevelAtPoint(v2pos_t p)
return std::max(2, get_height(p.X, p.Y) + 2);
}
+int MapgenEarth::getGroundLevelAtPoint(v2pos_t p)
+{
+ return get_height(p.X, p.Y); // + MGV6_AVERAGE_MUD_AMOUNT;
+}
+
// https://www.roguebasin.com/index.php?title=Bresenham%27s_Line_Algorithm
void MapgenEarth::bresenham(pos_t x1, pos_t y1, const pos_t x2, const pos_t y2, pos_t y,
pos_t h, const MapNode &n)
@@ -371,5 +376,4 @@ void MapgenEarth::generateBuildings()
if (handler)
handler->apply();
-
}
diff --git a/src/mapgen/mapgen_earth.h b/src/mapgen/mapgen_earth.h
index a874ffd11..e7029e945 100644
--- a/src/mapgen/mapgen_earth.h
+++ b/src/mapgen/mapgen_earth.h
@@ -76,6 +76,7 @@ class MapgenEarth : public MapgenV7
int generateTerrain() override;
void generateBuildings() override;
int getSpawnLevelAtPoint(v2pos_t p) override;
+ int getGroundLevelAtPoint(v2pos_t p) override;
v3d scale{1, 1, 1};
v3d center{0, 0, 0};