diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp
index 5a0a091d9..bb039be41 100644
--- a/src/client/clientmap.cpp
+++ b/src/client/clientmap.cpp
@@ -760,7 +760,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
drawlist.clear();
- auto is_frustum_culled = m_client->getCamera()->getFrustumCuller();
+ //auto is_frustum_culled = m_client->getCamera()->getFrustumCuller();
//v3f camera_position = m_camera_position;
//f32 camera_fov = m_camera_fov;
@@ -833,14 +833,14 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
continue;
f32 d = radius_box(bp*MAP_BLOCKSIZE, m_camera_position_node); //blockpos_relative.getLength();
- if (d > range_max) {
- if (d > range_max ) {
+ if (d > range_max + m_client->getMeshGrid().cell_size * MAP_BLOCKSIZE) {
+ if (d > range_max * 4) {
int mul = d / range_max;
block->usage_timer_multiplier = mul;
}
continue;
}
- int range = d / MAP_BLOCKSIZE;
+ int range_blocks = d / MAP_BLOCKSIZE;
block->resetUsageTimer();
@@ -855,7 +855,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
const auto mesh = block->getLodMesh(mesh_step, true);
{
- blocks_in_range++;
+ ++blocks_in_range;
const int smesh_size = !mesh ? -1 : mesh->getMesh()->getMeshBufferCount();
@@ -865,7 +865,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
{
if ((!mesh && smesh_size < 0) || mesh_step != mesh->lod_step) {
blocks_in_range_without_mesh++;
- if (m_mesh_queued < maxq || range <= 2) {
+ if (m_mesh_queued < maxq || range_blocks <= 2) {
const auto bts = block->getTimestamp();
if (block->mesh_requested_timestamp < bts) {
block->mesh_requested_timestamp = bts;
@@ -931,27 +931,29 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
}
*/
+ if (m_client->getMeshGrid().cell_size > 1) {
// Calculate the coordinates for range and frustum culling
v3opos_t mesh_sphere_center;
+
f32 mesh_sphere_radius;
v3pos_t block_pos_nodes = block->getPosRelative();
-
if (mesh) {
- mesh_sphere_center = intToFloat(block_pos_nodes, BS)
- + mesh->getBoundingSphereCenter();
+ mesh_sphere_center = intToFloat(block_pos_nodes, BS) +
+ mesh->getBoundingSphereCenter();
mesh_sphere_radius = mesh->getBoundingRadius();
} else {
- mesh_sphere_center = intToFloat(block_pos_nodes, BS)
- + v3opos_t((MAP_BLOCKSIZE * 0.5f - 0.5f) * BS);
+ mesh_sphere_center = intToFloat(block_pos_nodes, BS) +
+ v3opos_t((MAP_BLOCKSIZE * 0.5f - 0.5f) * BS);
mesh_sphere_radius = 0.0f;
}
// First, perform a simple distance check.
if (!m_control.range_all &&
- mesh_sphere_center.getDistanceFrom(m_camera_position) >
+ radius_box(mesh_sphere_center, m_camera_position) >
m_control.wanted_range * BS + mesh_sphere_radius)
continue; // Out of range, skip.
+ }
// Keep the block alive as long as it is in range.
//block->resetUsageTimer();
@@ -972,6 +974,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 (range_blocks>3)
if (!m_control.range_all && occlusion_culling_enabled && m_enable_raytraced_culling &&
mesh &&
isMeshOccluded(block, mesh_grid.cell_size, m_camera_position_node)) {
@@ -990,16 +993,16 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
*/
if (mesh_step != mesh->lod_step && smesh_size < 0 &&
- (m_mesh_queued < maxq * 1.2 || range <= 2)) {
+ (m_mesh_queued < maxq * 1.2 || range_blocks <= 2)) {
m_client->addUpdateMeshTask(bp);
++m_mesh_queued;
} else if (const auto bts = block->getTimestamp();
bts != BLOCK_TIMESTAMP_UNDEFINED &&
block->getTimestamp() > mesh->timestamp + (smesh_size ? 0
- : range >= 2
+ : range_blocks >= 2
? 60
: 0) &&
- (m_mesh_queued < maxq * 1.5 || range <= 2)) {
+ (m_mesh_queued < maxq * 1.5 || range_blocks <= 2)) {
if (mesh_step > 1)
m_client->addUpdateMeshTask(bp);
else
@@ -1025,8 +1028,8 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
//blocks_drawn++;
- if(range * MAP_BLOCKSIZE > farthest_drawn)
- farthest_drawn = range * MAP_BLOCKSIZE;
+ if(range_blocks * MAP_BLOCKSIZE > farthest_drawn)
+ farthest_drawn = range_blocks * MAP_BLOCKSIZE;
}
}
diff --git a/src/client/game.cpp b/src/client/game.cpp
index c6e11a335..07c7884a2 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -4609,7 +4609,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
runData.update_draw_list_timer += dtime;
runData.touch_blocks_timer += dtime;
- float update_draw_list_delta = 0.2f;
+ float update_draw_list_delta = 0.5f;
/* mt dir */
#if 0
@@ -4634,25 +4634,23 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
#if 1
const auto camera_position = camera->getPosition();
- if (!runData.headless_optimize) {
- if (client->m_new_meshes ||
- //runData.update_draw_list_timer >= update_draw_list_delta ||
+ if (!runData.headless_optimize)
+ if ((client->m_new_meshes &&
+ runData.update_draw_list_timer >= update_draw_list_delta) ||
runData.update_draw_list_last_cam_pos.getDistanceFrom(camera_position) >
MAP_BLOCKSIZE * BS * 1 ||
m_camera_offset_changed) {
- if (updateDrawList_async.step(
+ updateDrawList_async.step(
[&](const float dtime) {
- client->getEnv().getClientMap().updateDrawListFm(
- dtime, 10000);
+ client->m_new_meshes = 0;
+ runData.update_draw_list_timer = 0;
+ runData.update_draw_list_last_cam_pos = camera_position;
+ client->getEnv().getClientMap().updateDrawListFm(dtime, 10000);
},
- runData.update_draw_list_timer)) {
- client->m_new_meshes = 0;
- runData.update_draw_list_timer = 0;
- runData.update_draw_list_last_cam_pos = camera_position;
- }
+ runData.update_draw_list_timer);
+
}
- }
-#endif
+
if (!runData.headless_optimize)
if (RenderingEngine::get_shadow_renderer()) {
updateShadows();
diff --git a/src/fm_clientiface.cpp b/src/fm_clientiface.cpp
index 97439fafb..4e12bdfea 100644
--- a/src/fm_clientiface.cpp
+++ b/src/fm_clientiface.cpp
@@ -331,7 +331,7 @@ int RemoteClient::GetNextBlocks(ServerEnvironment *env, EmergeManager *emerge,
}
if (block_sent > 0 &&
- (/* (block_overflow && d>1) || */ block_sent + (d <= 2 ? 1 : d * d) >
+ (/* (block_overflow && d>1) || */ block_sent + (d <= 2 ? 1 : d * d * d) >
m_uptime)) {
// DUMP(p, block_sent, d, "ddd");
continue;
diff --git a/src/threading/async.h b/src/threading/async.h
index a876d0ac0..6272f2ce9 100644
--- a/src/threading/async.h
+++ b/src/threading/async.h
@@ -20,6 +20,7 @@ along with Freeminer. If not, see .
*/
#pragma once
+#include
#include
#include
@@ -27,7 +28,6 @@ along with Freeminer. If not, see .
#include "log.h"
#endif
-
class async_step_runner
{
std::future future;
@@ -57,8 +57,12 @@ class async_step_runner
inline bool valid() { return future.valid(); }
+ constexpr static uint8_t UNKNOWN = 2;
+ // 0 : started
+ // 1 : skipped
+ // 2 : unknown ?
template
- bool step(Func func, Args &&...args)
+ uint8_t step(Func func, Args &&...args)
{
if (future.valid()) {
auto res = future.wait_for(std::chrono::milliseconds(0));
@@ -66,7 +70,7 @@ class async_step_runner
#if defined(DUMP_STREAM)
++skips;
#endif
- return true;
+ return UNKNOWN;
}
}