Skip to content

Commit

Permalink
next era of..
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Nov 19, 2023
1 parent 8551551 commit 294bfc5
Show file tree
Hide file tree
Showing 22 changed files with 408 additions and 106 deletions.
2 changes: 2 additions & 0 deletions src/client/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ void Camera::updateViewingRange()

static int framecnt = 0;
m_draw_control.fps_wanted = wanted_fps;
#if FARMESH_OLD
if (farmesh) {
//infostream<<" m_draw_control.fps="<<m_draw_control.fps<< " wanted_fps="<< wanted_fps << " m_draw_control.fps_avg="<< m_draw_control.fps_avg <<" wanted_fps*1.4="<< wanted_fps*1.4 /*<<" block_draw_ratio="<<block_draw_ratio */<< " wanted_frametime="<< wanted_frametime <<" .blocks_would_have_drawn=" <<m_draw_control.blocks_would_have_drawn <<" .blocks_drawn=" <<m_draw_control.blocks_drawn <<std::endl;
if (m_draw_control.fps > wanted_fps && m_draw_control.fps_avg >= wanted_fps*1.3) {
Expand Down Expand Up @@ -713,6 +714,7 @@ void Camera::updateViewingRange()
return;
}
}
#endif

} // static_viewing_range

Expand Down
17 changes: 17 additions & 0 deletions src/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,10 @@ void Client::addNode(v3pos_t p, MapNode n, bool remove_metadata, int fast)
}
catch(InvalidPositionException &e) {
}

if (p.getDistanceFrom(floatToInt(m_env.getLocalPlayer()->getPosition(), BS)) > MAP_BLOCKSIZE*2)
return;

addUpdateMeshTaskForNode(p, true);

for (const auto &modified_block : modified_blocks) {
Expand Down Expand Up @@ -1973,6 +1977,19 @@ void Client::updateMeshTimestampWithEdge(v3bpos_t blockpos) {
continue;
block->setTimestampNoChangedFlag(m_uptime);
}

int to = FARMESH_STEP_MAX;
#if FARMESH_OLD
to = 1;
#endif
for (int step = 1; step <= to; ++step) {
v3pos_t actualpos = getFarmeshActual(blockpos, step);
auto *block = m_env.getMap().getBlockNoCreateNoEx(actualpos); // todo maybe update bp1 too if differ
if(!block)
continue;
block->setTimestampNoChangedFlag(m_uptime);
}

}

ClientEvent *Client::getClientEvent()
Expand Down
39 changes: 31 additions & 8 deletions src/client/clientmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void MeshBufListList::add(scene::IMeshBuffer *buf, v3s16 position, u8 layer)

void MapDrawControl::fm_init() {
farmesh = g_settings->getS32("farmesh");
farmesh_step = g_settings->getS32("farmesh_step");
//farmesh_step = g_settings->getS32("farmesh_step");
fov_want = fov = g_settings->getFloat("fov");
}

Expand Down Expand Up @@ -734,6 +734,10 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)

if (!m_drawlist_last) {
drawlist.clear();

for (const auto &b : m_far_blocks) {
drawlist.emplace(b.first, b.second.get());
}
}

if (!max_cycle_ms)
Expand All @@ -750,7 +754,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
//camera_fov *= 1.2;

//v3s16 cam_pos_nodes = floatToInt(camera_position, BS);
v3pos_t cam_pos_nodes = m_camera_position_node;
//v3pos_t cam_pos_nodes = m_camera_position_node;
/*
v3pos_t p_blocks_min;
v3pos_t p_blocks_max;
Expand Down Expand Up @@ -813,7 +817,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
);
*/

f32 d = radius_box(bp*MAP_BLOCKSIZE, cam_pos_nodes); //blockpos_relative.getLength();
f32 d = radius_box(bp*MAP_BLOCKSIZE, m_camera_position_node); //blockpos_relative.getLength();
if (d > range_max) {
if (d > range_max * 4 && ir.second) {
int mul = d / range_max;
Expand All @@ -839,7 +843,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
bool occlusion_culling_enabled = mesh_grid.cell_size < 4;

if (m_control.allow_noclip) {
MapNode n = getNode(cam_pos_nodes);
MapNode n = getNode(m_camera_position_node);
if (n.getContent() == CONTENT_IGNORE || m_nodedef->get(n).solidness == 2)
occlusion_culling_enabled = false;
}
Expand All @@ -863,17 +867,28 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
if (!block)
continue;

int mesh_step = getFarmeshStep(m_control, getNodeBlockPos(cam_pos_nodes), bp);
int mesh_step =
getFarmeshStep(m_control, getNodeBlockPos(m_camera_position_node), bp);
if (!inFarmeshGrid(bp, mesh_step)) {
verbosestream << "meshskip "
<< " s=" << mesh_step << " p=" << bp
<< " player=" << getNodeBlockPos(m_camera_position_node)
<< std::endl;
//DUMP("meshskip", mesh_step, bp, cam_pos_nodes);
continue;
}
/*
Compare block position to camera position, skip
if not seen on display
*/

auto mesh = block->getMesh(mesh_step);
auto mesh = block->getMesh(mesh_step);
{
blocks_in_range++;

const int smesh_size = block->getMeshSize(mesh_step);
//const int smesh_size = block->getMeshSize(mesh_step);
const int smesh_size = !mesh ? -1 : mesh->getMesh()->getMeshBufferCount();

/*
Ignore if mesh doesn't exist
*/
Expand Down Expand Up @@ -983,7 +998,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
// Raytraced occlusion culling - send rays from the camera to the block's corners
if (!m_control.range_all && occlusion_culling_enabled && m_enable_raytraced_culling &&
mesh &&
isMeshOccluded(block, mesh_grid.cell_size, cam_pos_nodes)) {
isMeshOccluded(block, mesh_grid.cell_size, m_camera_position_node)) {
blocks_occlusion_culled++;
continue;
}
Expand Down Expand Up @@ -1139,6 +1154,14 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
MapBlock *block = i.second;
//int mesh_step = getFarmeshStep(m_control, getNodeBlockPos(cam_pos_nodes), block->getPos());
int mesh_step = getFarmeshStep(m_control, getNodeBlockPos(m_camera_position_node), block->getPos());

if (!inFarmeshGrid(block_pos, mesh_step)) {
verbosestream << "Rmeshskip "
<< " s=" << mesh_step << " p=" << block_pos
<< " player=" << getNodeBlockPos(m_camera_position_node)
<< std::endl;
continue;
}

// If the mesh of the block happened to get deleted, ignore it
const auto block_mesh = block->getMesh(mesh_step);
Expand Down
2 changes: 1 addition & 1 deletion src/client/clientmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct MapDrawControl

// freeminer:
float farmesh = 0;
int farmesh_step = 1;
//int farmesh_step = 1;
int cell_size = 1;

float fps = 30;
Expand Down
6 changes: 4 additions & 2 deletions src/client/gameui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
;

if (draw_control->farmesh)
os << ", farmesh = " << draw_control->farmesh << ":"
<< draw_control->farmesh_step;
os << ", farmesh = " << draw_control->farmesh //<< ":"
//<< draw_control->farmesh_step
;

#if MINETEST_TRANSPORT
os

Expand Down
Loading

0 comments on commit 294bfc5

Please sign in to comment.