From cadf9ebe4ee6bb6a26e4357f14009ec9fd4f3d95 Mon Sep 17 00:00:00 2001 From: proller Date: Sat, 26 Oct 2024 04:29:51 +0200 Subject: [PATCH] wip --- src/client/content_mapblock.cpp | 4 ++-- src/client/fm_far_container.cpp | 13 +++++++------ src/client/mapblock_mesh.cpp | 4 ++-- src/mapgen/mapgen_v7.cpp | 3 +++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/client/content_mapblock.cpp b/src/client/content_mapblock.cpp index 343a3c262..42cd138cb 100644 --- a/src/client/content_mapblock.cpp +++ b/src/client/content_mapblock.cpp @@ -1750,8 +1750,8 @@ void MapblockMeshGenerator::drawNode() void MapblockMeshGenerator::generate() { - const auto lstep = data->lod_step ? data->fscale : 1; - const auto fstep = data->far_step ? data->fscale : 1; + const auto lstep = 1 << data->lod_step; + const auto fstep = 1 << data->far_step; for (cur_node.pf.Z = cur_node.pr.Z = 0; cur_node.pr.Z < data->side_length_data; cur_node.pr.Z+=lstep, cur_node.pf.Z+=fstep) for (cur_node.pf.Y = cur_node.pr.Y = 0; cur_node.pr.Y < data->side_length_data; cur_node.pr.Y+=lstep, cur_node.pf.Y+=fstep) for (cur_node.pf.X = cur_node.pr.X = 0; cur_node.pr.X < data->side_length_data; cur_node.pr.X+=lstep, cur_node.pf.X+=fstep) { diff --git a/src/client/fm_far_container.cpp b/src/client/fm_far_container.cpp index 164cfd62c..8d83266f1 100644 --- a/src/client/fm_far_container.cpp +++ b/src/client/fm_far_container.cpp @@ -16,7 +16,7 @@ FarContainer::FarContainer(Client *client) : m_client{client} namespace { thread_local MapBlockP block_cache{}; -thread_local v3bpos_t block_cache_p; +thread_local std::pair block_cache_p; } const MapNode &FarContainer::getNodeRefUnsafe(const v3pos_t &pos) @@ -26,12 +26,13 @@ const MapNode &FarContainer::getNodeRefUnsafe(const v3pos_t &pos) getNodeBlockPos(m_client->getEnv().getClientMap().far_blocks_last_cam_pos), bpos); const auto &shift = step; // + cell_size_pow; - const v3bpos_t bpos_aligned((bpos.X >> shift) << shift, (bpos.Y >> shift) << shift, - (bpos.Z >> shift) << shift); + const v3bpos_t bpos_aligned = getFarActual(bpos, + getNodeBlockPos(m_client->getEnv().getClientMap().far_blocks_last_cam_pos), + step, m_client->getEnv().getClientMap().getControl()); MapBlockP block; - - if (block_cache && bpos_aligned == block_cache_p) { + const auto step_block_pos = std::make_pair(step, bpos_aligned); + if (block_cache && step_block_pos == block_cache_p) { block = block_cache; } @@ -94,7 +95,7 @@ const MapNode &FarContainer::getNodeRefUnsafe(const v3pos_t &pos) return n; } - block_cache_p = bpos_aligned; + block_cache_p = step_block_pos; block_cache = block; } diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index 7b3d6d23e..8a8b1422b 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -48,7 +48,7 @@ MeshMakeData::MeshMakeData(Client *client, bool use_shaders, NodeContainer *nodecontainer) : m_mesh_grid(client->getMeshGrid()), - side_length((MAP_BLOCKSIZE * m_mesh_grid.cell_size) / (pow(2, lod_step))), + side_length((MAP_BLOCKSIZE * m_mesh_grid.cell_size) >> lod_step), m_client(client), m_use_shaders(use_shaders) , @@ -56,7 +56,7 @@ MeshMakeData::MeshMakeData(Client *client, bool use_shaders, side_length_data(MAP_BLOCKSIZE * m_mesh_grid.cell_size), lod_step{lod_step}, far_step{far_step}, - fscale(pow(2, far_step + lod_step)) + fscale(1<<(far_step + lod_step)) {} void MeshMakeData::fillBlockDataBegin(const v3s16 &blockpos) diff --git a/src/mapgen/mapgen_v7.cpp b/src/mapgen/mapgen_v7.cpp index 50a55d36e..7072f3cf4 100644 --- a/src/mapgen/mapgen_v7.cpp +++ b/src/mapgen/mapgen_v7.cpp @@ -193,6 +193,7 @@ MapgenV7Params::MapgenV7Params(): void MapgenV7Params::readParams(const Settings *settings) { + //freeminer: settings->getNoiseParamsFromGroup("mg_np_layers", np_layers); paramsj = settings->getJson("mg_params", paramsj); @@ -239,10 +240,12 @@ void MapgenV7Params::readParams(const Settings *settings) void MapgenV7Params::writeParams(Settings *settings) const { + //freeminer: settings->setNoiseParams("mg_np_layers", np_layers); settings->setJson("mg_params", paramsj); //---------- + settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7); settings->setS16("mgv7_mount_zero_level", mount_zero_level); settings->setS16("mgv7_floatland_ymin", floatland_ymin);