mirror of
https://github.com/bdnugget/freeminer.git
synced 2026-11-07 06:57:27 +00:00
far namespace
This commit is contained in:
1 parent
3134cf57ee
commit
30b1ab9eb0
10 files changed
+47
-37
No files matched your search
@@ -182,9 +182,9 @@ Client::Client(
|
||||
m_cache_save_interval = g_settings->getU16("server_map_save_interval");
|
||||
m_mesh_grid = { g_settings->getU16("client_mesh_chunk") };
|
||||
control.cell_size = m_mesh_grid.cell_size;
|
||||
control.cell_size_pow = rangeToStep(control.cell_size);
|
||||
control.cell_size_pow = farmesh::rangeToStep(control.cell_size);
|
||||
control.farmesh_quality = g_settings->getU16("farmesh_quality");
|
||||
control.farmesh_quality_pow = rangeToStep(control.farmesh_quality);
|
||||
control.farmesh_quality_pow = farmesh::rangeToStep(control.farmesh_quality);
|
||||
control.farmesh_stable = g_settings->getBool("farmesh_stable");
|
||||
control.farmesh_all_changed = g_settings->getPos("farmesh_all_changed");
|
||||
}
|
||||
|
||||
+11
-11
@@ -455,11 +455,11 @@ void ClientMap::updateDrawList(float dtime, unsigned int max_cycle_ms)
|
||||
|
||||
|
||||
for (auto & [block_coord, block] : m_blocks) {
|
||||
int mesh_step = getLodStep(
|
||||
int mesh_step = farmesh::getLodStep(
|
||||
m_control, getNodeBlockPos(cam_pos_nodes), block_coord, speedf);
|
||||
auto mesh = block ? block->getLodMesh(mesh_step, true) : nullptr;
|
||||
if (!mesh && block) {
|
||||
int fmesh_step = getFarStep(
|
||||
int fmesh_step = farmesh::getFarStep(
|
||||
m_control, getNodeBlockPos(far_blocks_last_cam_pos), block_coord);
|
||||
mesh = block->getFarMesh(fmesh_step);
|
||||
}
|
||||
@@ -594,10 +594,10 @@ void ClientMap::updateDrawList(float dtime, unsigned int max_cycle_ms)
|
||||
*/
|
||||
MapBlock *block = getBlockNoCreateNoEx(block_coord);
|
||||
int mesh_step =
|
||||
getLodStep(m_control, getNodeBlockPos(cam_pos_nodes), block_coord, speedf);
|
||||
farmesh::getLodStep(m_control, getNodeBlockPos(cam_pos_nodes), block_coord, speedf);
|
||||
auto mesh = block ? block->getLodMesh(mesh_step, true) : nullptr;
|
||||
if (!mesh && block) {
|
||||
int fmesh_step = getFarStep(
|
||||
int fmesh_step = farmesh::getFarStep(
|
||||
m_control, getNodeBlockPos(far_blocks_last_cam_pos), block_coord);
|
||||
mesh = block->getFarMesh(fmesh_step);
|
||||
}
|
||||
@@ -963,7 +963,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
|
||||
block->resetUsageTimer();
|
||||
|
||||
const auto mesh_step =
|
||||
getLodStep(m_control, getNodeBlockPos(m_camera_position_node), bp, speedf);
|
||||
farmesh::getLodStep(m_control, getNodeBlockPos(m_camera_position_node), bp, speedf);
|
||||
|
||||
|
||||
/*
|
||||
@@ -1138,7 +1138,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
|
||||
continue;
|
||||
|
||||
{
|
||||
blocks_skip_farmesh.emplace(getFarActualBlockPos(
|
||||
blocks_skip_farmesh.emplace(farmesh::getFarActualBlockPos(
|
||||
m_control, getNodeBlockPos(far_blocks_last_cam_pos), bp ));
|
||||
}
|
||||
|
||||
@@ -1469,7 +1469,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
||||
for (auto &i : m_drawlist) {
|
||||
const v3s16 block_pos = i.first;
|
||||
const auto & block = i.second;
|
||||
int mesh_step = getLodStep(
|
||||
int mesh_step = farmesh::getLodStep(
|
||||
m_control, getNodeBlockPos(m_camera_position_node), block->getPos(), speedf);
|
||||
|
||||
// If the mesh of the block happened to get deleted, ignore it
|
||||
@@ -1480,7 +1480,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
||||
if (!block_mesh) {
|
||||
int &fmesh_step = mesh_step;
|
||||
|
||||
fmesh_step = getFarStep(
|
||||
fmesh_step = farmesh::getFarStep(
|
||||
m_control, getNodeBlockPos(far_blocks_last_cam_pos), block->getPos());
|
||||
block_mesh = block->getFarMesh(fmesh_step);
|
||||
is_far = true;
|
||||
@@ -1914,7 +1914,7 @@ void ClientMap::renderMapShadows(video::IVideoDriver *driver,
|
||||
auto block = i.second;
|
||||
|
||||
// If the mesh of the block happened to get deleted, ignore it
|
||||
auto mapBlockMesh = block->getLodMesh(getLodStep(m_control, getNodeBlockPos(m_camera_position_node), block_pos, speedf), true);
|
||||
auto mapBlockMesh = block->getLodMesh(farmesh::getLodStep(m_control, getNodeBlockPos(m_camera_position_node), block_pos, speedf), true);
|
||||
|
||||
#if FARMESH_SHADOWS
|
||||
if (!mapBlockMesh) {
|
||||
@@ -2056,7 +2056,7 @@ void ClientMap::updateDrawListShadow(v3f shadow_light_pos, v3f shadow_light_dir,
|
||||
for (const auto & [key, block] : m_blocks) {
|
||||
++blocks_loaded;
|
||||
|
||||
const auto mesh = block->getLodMesh(getLodStep(m_control, getNodeBlockPos(m_camera_position_node), block->getPos(), speedf), true);
|
||||
const auto mesh = block->getLodMesh(farmesh::getLodStep(m_control, getNodeBlockPos(m_camera_position_node), block->getPos(), speedf), true);
|
||||
/*
|
||||
for (const auto &entry : sector->getBlocks()) {
|
||||
MapBlock *block = entry.second.get();
|
||||
@@ -2130,7 +2130,7 @@ void ClientMap::updateTransparentMeshBuffers()
|
||||
MapBlockMesh *blockmesh = block->mesh;
|
||||
*/
|
||||
auto block = it->second;
|
||||
auto blockmesh = block->getLodMesh(getLodStep(m_control, getNodeBlockPos(m_camera_position_node), block->getPos(), speedf));
|
||||
auto blockmesh = block->getLodMesh(farmesh::getLodStep(m_control, getNodeBlockPos(m_camera_position_node), block->getPos(), speedf));
|
||||
|
||||
#if FARMESH_SHADOWS
|
||||
if (!blockmesh) {
|
||||
|
||||
@@ -299,8 +299,9 @@ void Client::handleCommand_BlockDataFm(NetworkPacket *pkt)
|
||||
auto &client_map = getEnv().getClientMap();
|
||||
const auto &control = client_map.getControl();
|
||||
const auto bpos = block->getPos();
|
||||
if (!inFarGrid(control, getNodeBlockPos(client_map.far_blocks_last_cam_pos),
|
||||
bpos, step)) {
|
||||
if (!farmesh::inFarGrid(control,
|
||||
getNodeBlockPos(client_map.far_blocks_last_cam_pos), bpos,
|
||||
step)) {
|
||||
return;
|
||||
}
|
||||
createFarMesh(block);
|
||||
|
||||
@@ -26,7 +26,7 @@ const MapNode &FarContainer::getNodeRefUnsafe(const v3pos_t &pos)
|
||||
const auto player_block_pos = getNodeBlockPos(client_map.far_blocks_last_cam_pos);
|
||||
const auto &control = client_map.getControl();
|
||||
|
||||
const auto tree_result = getFarParams(control, player_block_pos, block_pos);
|
||||
const auto tree_result = farmesh::getFarParams(control, player_block_pos, block_pos);
|
||||
if (!tree_result) {
|
||||
return m_mg->visible_transparent;
|
||||
}
|
||||
|
||||
+12
-11
@@ -65,8 +65,8 @@ void FarMesh::makeFarBlock(const v3bpos_t &blockpos, block_step_t step, bool bne
|
||||
const auto blockpos_actual =
|
||||
blockpos_actual_optional.has_value() ? blockpos_actual_optional.value()
|
||||
: bnear ? blockpos
|
||||
: getFarActualBlockPos(draw_control,
|
||||
getNodeBlockPos(m_camera_pos_aligned), blockpos);
|
||||
: farmesh::getFarActualBlockPos(draw_control,
|
||||
getNodeBlockPos(m_camera_pos_aligned), blockpos);
|
||||
auto &far_blocks = //near ? m_client->getEnv().getClientMap().m_far_near_blocks :
|
||||
client_map.m_far_blocks;
|
||||
if (const auto it = client_map.far_blocks_storage[step].find(blockpos_actual);
|
||||
@@ -153,10 +153,10 @@ void FarMesh::makeFarBlocks(const v3bpos_t &blockpos, block_step_t step)
|
||||
const auto step_width = 1 << (step - 1 + control.cell_size_pow);
|
||||
for (const auto &dir : use_dirs) {
|
||||
const auto bpos_dir = blockpos + dir * step_width;
|
||||
const auto bpos = getFarActualBlockPos(
|
||||
const auto bpos = farmesh::getFarActualBlockPos(
|
||||
control, getNodeBlockPos(m_camera_pos_aligned), bpos_dir);
|
||||
const auto block_step_correct =
|
||||
getFarStep(control, getNodeBlockPos(m_camera_pos_aligned), bpos);
|
||||
farmesh::getFarStep(control, getNodeBlockPos(m_camera_pos_aligned), bpos);
|
||||
makeFarBlock(bpos, block_step_correct, {}, bpos);
|
||||
}
|
||||
}
|
||||
@@ -279,7 +279,7 @@ int FarMesh::go_container()
|
||||
thread_local static const s16 farmesh_all_changed =
|
||||
g_settings->getU32("farmesh_all_changed");
|
||||
|
||||
runFarAll(cbpos, draw_control.cell_size_pow, draw_control.farmesh,
|
||||
farmesh::runFarAll(cbpos, draw_control.cell_size_pow, draw_control.farmesh,
|
||||
draw_control.farmesh_quality_pow, 0, false,
|
||||
[this, &cbpos](const v3bpos_t &bpos, const bpos_t &size,
|
||||
const block_step_t &step) -> bool {
|
||||
@@ -323,7 +323,7 @@ int FarMesh::go_flat()
|
||||
|
||||
// todo: maybe save blocks while cam pos not changed
|
||||
std::array<std::unordered_set<v3bpos_t>, FARMESH_STEP_MAX> blocks;
|
||||
runFarAll(cbpos, draw_control.cell_size_pow, draw_control.farmesh,
|
||||
farmesh::runFarAll(cbpos, draw_control.cell_size_pow, draw_control.farmesh,
|
||||
draw_control.farmesh_quality_pow, cbpos.Y ?: 1, true,
|
||||
[this, &draw_control, &blocks](const v3bpos_t &bpos, const bpos_t &size,
|
||||
const block_step_t &step) -> bool {
|
||||
@@ -341,7 +341,7 @@ int FarMesh::go_flat()
|
||||
(bpos_new.Z << MAP_BLOCKP) - 1)) >>
|
||||
MAP_BLOCKP;
|
||||
|
||||
const auto step_new = getFarStep(draw_control,
|
||||
const auto step_new = farmesh::getFarStep(draw_control,
|
||||
getNodeBlockPos(m_camera_pos_aligned), bpos_new //, 0
|
||||
);
|
||||
|
||||
@@ -416,9 +416,9 @@ int FarMesh::go_direction(const size_t dir_n)
|
||||
g_profiler->avg("Client: Farmesh processed", 1);
|
||||
#endif
|
||||
//const auto dstep = ray_cache.step_num; // + 1;
|
||||
auto block_step_prev =
|
||||
getFarStepBad(draw_control, getNodeBlockPos(m_camera_pos_aligned),
|
||||
getNodeBlockPos(floatToInt(pos_last, BS)));
|
||||
auto block_step_prev = farmesh::getFarStepBad(draw_control,
|
||||
getNodeBlockPos(m_camera_pos_aligned),
|
||||
getNodeBlockPos(floatToInt(pos_last, BS)));
|
||||
|
||||
const auto step_width_shift = (block_step_prev - block_step_reduce);
|
||||
const auto step_width = MAP_BLOCKSIZE
|
||||
@@ -451,7 +451,8 @@ int FarMesh::go_direction(const size_t dir_n)
|
||||
break;
|
||||
}
|
||||
|
||||
const int step_aligned_pow = rangeToStep(step_width) - align_reduce; // ceil ?
|
||||
const int step_aligned_pow =
|
||||
farmesh::rangeToStep(step_width) - align_reduce; // ceil ?
|
||||
const auto pos_int = align_shift(
|
||||
floatToInt(pos, BS), step_aligned_pow > 0 ? step_aligned_pow : 0);
|
||||
|
||||
|
||||
+1
-1
@@ -964,7 +964,7 @@ const auto is_each_mode= m_block_bounds_mode == BLOCK_BOUNDS_FAR_DRAWN_EACH;
|
||||
const auto &mesh_step = block->far_step;
|
||||
int g = 0;
|
||||
|
||||
if (!inFarGrid(client_map.getControl(),
|
||||
if (!farmesh::inFarGrid(client_map.getControl(),
|
||||
getNodeBlockPos(client_map.far_blocks_last_cam_pos), blockPos,
|
||||
mesh_step, is_each_mode)) {
|
||||
// DUMP("Not in grid", blockPos, block->far_step, mesh_step, block->getTimestamp(), client->getEnv() .getClientMap() .m_far_blocks_last_cam_pos);
|
||||
|
||||
@@ -213,7 +213,7 @@ void MeshUpdateQueue::fillDataFromMapBlocks(QueuedMeshUpdate *q)
|
||||
{
|
||||
auto mesh_grid = m_client->getMeshGrid();
|
||||
|
||||
const auto lod_step = getLodStep(m_client->m_env.getClientMap().getControl(),
|
||||
const auto lod_step = farmesh::getLodStep(m_client->m_env.getClientMap().getControl(),
|
||||
getNodeBlockPos(
|
||||
floatToInt(m_client->m_env.getLocalPlayer()->getPosition(), BS)),
|
||||
q->p, m_client->getEnv().getLocalPlayer()->getSpeed().getLength());
|
||||
|
||||
@@ -626,13 +626,13 @@ uint32_t RemoteClient::SendFarBlocks(const int32_t uptime)
|
||||
const auto cbpos = floatToInt(playerpos, BS * MAP_BLOCKSIZE);
|
||||
|
||||
const auto cell_size = 1; // FMTODO from remoteclient
|
||||
const auto cell_size_pow = rangeToStep(cell_size);
|
||||
thread_local static const s16 setting_farmesh_all_changed =
|
||||
const auto cell_size_pow = farmesh::rangeToStep(cell_size);
|
||||
thread_local static const pos_t setting_farmesh_all_changed =
|
||||
g_settings->getU32("farmesh_all_changed");
|
||||
const auto &use_farmesh_all_changed =
|
||||
std::min(setting_farmesh_all_changed, farmesh_all_changed);
|
||||
runFarAll(cbpos, cell_size_pow, farmesh, rangeToStep(farmesh_quality), false,
|
||||
true,
|
||||
farmesh::runFarAll(cbpos, cell_size_pow, farmesh,
|
||||
farmesh::rangeToStep(farmesh_quality), false, true,
|
||||
[this, &ordered, &cbpos, &use_farmesh_all_changed](
|
||||
const v3bpos_t &bpos, const bpos_t &size,
|
||||
const block_step_t &step) -> bool {
|
||||
|
||||
+8
-4
@@ -28,6 +28,9 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "irr_v3d.h"
|
||||
#include "irrlichttypes.h"
|
||||
|
||||
namespace farmesh
|
||||
{
|
||||
|
||||
block_step_t getLodStep(const MapDrawControl &draw_control,
|
||||
const v3bpos_t &playerblockpos, const v3bpos_t &blockpos, const pos_t speedf)
|
||||
{
|
||||
@@ -228,7 +231,7 @@ std::optional<tree_result_t> find(const find_param_t ¶m,
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
/*
|
||||
const auto nearest_pow2 = [](const int v) -> int8_t {
|
||||
if (v == 0)
|
||||
return 0;
|
||||
@@ -240,7 +243,7 @@ const auto nearest_pow2 = [](const int v) -> int8_t {
|
||||
}
|
||||
return n;
|
||||
};
|
||||
|
||||
*/
|
||||
struct tree_params_t
|
||||
{
|
||||
const int16_t tree_pow;
|
||||
@@ -256,9 +259,9 @@ struct tree_params_t
|
||||
#endif
|
||||
};
|
||||
|
||||
const auto farmesh_to_tree_pow = [](const int farmesh) {
|
||||
const auto farmesh_to_tree_pow = [](const auto farmesh) {
|
||||
return std::min<int16_t>(tree_params_t::tree_pow_max,
|
||||
nearest_pow2(farmesh) - 1); // -2 ? TODO: test and tune
|
||||
rangeToStep(farmesh) - 1); // -2 ? TODO: test and tune
|
||||
};
|
||||
|
||||
child_t tree_params_to_child(
|
||||
@@ -445,3 +448,4 @@ void runFarAll(const v3bpos_t &ppos, uint8_t cell_size_pow, int farmesh,
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -27,6 +27,9 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
struct MapDrawControl;
|
||||
|
||||
namespace farmesh
|
||||
{
|
||||
|
||||
#if USE_POS32
|
||||
constexpr uint16_t tree_pow_default = FARMESH_STEP_MAX;
|
||||
#else
|
||||
@@ -79,3 +82,4 @@ void runFarAll(const v3bpos_t &player_block_pos, uint8_t cell_size_pow, int farm
|
||||
&func);
|
||||
|
||||
uint8_t rangeToStep(const int range);
|
||||
}
|
||||
Reference in new issue
Block a user